#
# Car-Routing is experimantal !!!
#
# DO NOT USE FOR ACTUAL NAVIGATION
#
# Turn restrictions are missing, leading to wrong routes
#

---context:global

assign downhillcost 0
assign downhillcutoff 0
assign uphillcost 0
assign uphillcutoff 0

assign validForCars 1
assign considerTurnRestrictions = false

assign pass1coefficient 0.
assign pass2coefficient -1

---context:way   # following code refers to way-tags


assign turncost = 0

assign initialcost switch route=ferry 20000 0


#
# calculate logical car access
#
assign isresidentialorliving = or highway=residential|living_street living_street=yes

assign caraccess
       switch motorcar=
              switch motor_vehicle=
                     switch vehicle=
                            switch access=
                                   switch or highway=motorway highway=motorway_link    1
                                   switch or highway=trunk highway=trunk_link          1
                                   switch or highway=primary highway=primary_link      1
                                   switch or highway=secondary highway=secondary_link  1
                                   switch or highway=tertiary highway=tertiary_link    1
                                   switch    highway=unclassified                      1
                                   switch    route=ferry                               1
                                   switch    isresidentialorliving                     1
                                   switch    highway=service                           1
                                   0
                                   or access=yes or access=permissive or access=designated access=destination
                            or vehicle=yes or vehicle=designated vehicle=destination
                     or motor_vehicle=yes or motor_vehicle=permissive or motor_vehicle=designated motor_vehicle=destination
              or motorcar=yes or motorcar=permissive or motorcar=designated motorcar=destination

assign accesspenalty
       switch caraccess
              0
              10000

assign onewaypenalty
       switch switch reversedirection=yes
                     switch oneway=
                            junction=roundabout
                            or oneway=yes or oneway=true oneway=1
                     oneway=-1
              10000
              0.0


assign ispaved or surface=paved or surface=asphalt or surface=concrete surface=paving_stones


assign costfactor

 add max onewaypenalty accesspenalty

 switch and highway= not route=ferry  10000

 switch or highway=motorway highway=motorway_link    1
 switch or highway=trunk highway=trunk_link          1
 switch or highway=primary highway=primary_link      1.2
 switch or highway=secondary highway=secondary_link  1.6
 switch or highway=tertiary highway=tertiary_link    2.0
 switch    highway=unclassified                      2.5
 switch    route=ferry                               5.67
 switch    highway=bridleway                         5
 switch    isresidentialorliving 3.5
 switch    highway=service                           3.5
 switch or highway=track or highway=road highway=path
  switch tracktype=grade1 5
  switch ispaved 5
  30
 10000

assign trafficsourcedensity =
   if isresidentialorliving then 1
   else if and maxspeed=30|50 highway=tertiary|secondary|primary then 1
   else 0

assign istrafficbackbone
  if greater costfactor 9999 then false
  else if highway=motorway|motorway_link then true
  else false

---context:node  # following code refers to node tags

#
# calculate logical car access to nodes
#
assign caraccess
       switch motorcar=
              switch motor_vehicle=
                     switch vehicle=
                            switch access=
                                   switch barrier=gate 0
                                   switch barrier=bollard 0
                                   switch barrier=lift_gate 0
                                   switch barrier=cycle_barrier 0
                                   1
                                   or access=yes or access=permissive or access=designated access=destination
                            or vehicle=yes or vehicle=permissive or vehicle=designated vehicle=destination
                     or motor_vehicle=yes or motor_vehicle=permissive or motor_vehicle=designated motor_vehicle=destination
              or motorcar=yes or motorcar=permissive or motorcar=designated motorcar=destination

assign initialcost
       switch caraccess
              0
              1000000
