User:Kannix/brouter

From OpenStreetMap Wiki
Jump to navigation Jump to search

aim

draft

  • fetch navigable waterways in terms of vessel's dimensions
    • maxhight
    • maxdraft
    • maxwidth
    • maxlength
  • add waiting times (locks, opening bridges) to ETA
  • assign maxspeed to waterway categories (solved)
  • assign different forward/backward speeds to free flowing rivers (solved)
  • implemnt vector-tiles layer @ brouter-web

setup

prerequisites

nginx

  • additional nginx directives
location /brouter/ {
	proxy_pass http://127.0.0.1:17777/;
}

brouter.grade.de

  • config.js
    if (hostname.endsWith('grade.de')) {
        // online service (brouter.grade.de) configuration

        BR.conf.host = origin + '/brouter';
        BR.conf.profilesUrl = origin + '/brouter-server/profiles2/';
    } else {

brouter-server

NAME="brouter-server"
PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
APPDIR="/var/www/vhosts/grade.de/brouter.grade.de/brouter-server"
APPBIN="/usr/bin/java"
APPARGS="-Xmx128M -Xms128M -Xmn8M -DmaxRunningTime=300 -cp brouter.jar btools.server.RouteServer ./segments4 ./profiles2 ./customprofiles 17777 1 localhost"
USER="www-data"
GROUP="psaserv"
  • update-rc.d brouter-server defaults
  • service brouter-server start
  • service brouter-server status
  • service brouter-server stop

map creation

issues

map data

  • CEMT (incl. bridges)
    • overpass sample query: https://overpass-turbo.eu/
    • overpass API query: ways CEMT=* OR ship=yes OR motorboat=yes and fetch all tagged nodes of these ways (Nordholland ~9mb):
<osm-script>
 <union>
 <union>
  <query type="way">
    <has-kv k="CEMT"/>
    <bbox-query s="51.90" n="53.50" w="4.00" e="7.25"/>
  </query>
  <query type="way">
    <has-kv k="ship" v="yes"/>
    <bbox-query s="51.90" n="53.50" w="4.00" e="7.25"/>
  </query>
  <query type="way">
    <has-kv k="motorboat" v="yes"/>
    <bbox-query s="51.90" n="53.50" w="4.00" e="7.25"/>
  </query>
 </union>
  <recurse type="way-node"/>
 </union>
 <print  mode="meta"/>
</osm-script>

formatting map data

./osmosis --read-xml file="test.osm" --write-xml file="test-2.osm"

all.brf

---context:global   # following code refers to global config

# the elevation parameters

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

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

assign turncost 0
assign initialcost 0

assign costfactor
  switch not or waterway= waterway=unknown  1
  100000

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

assign initialcost 0

river.brf

---context:global   # following code refers to global config

# the elevation parameters

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

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

assign turncost 0
assign initialcost 0

assign costfactor
  switch or waterway=canal or waterway=river waterway=fairway  1
  100000

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

assign initialcost 0

lookups.dat

---lookupversion:10
---minorversion:13

---context:way

bicycle;0001245560 yes

maxspeed;0000000001 none
maxspeed;0000000001 4.5
maxspeed;0000000001 5
maxspeed;0000000001 6 4_mph
maxspeed;0000000001 7
maxspeed;0000000001 8
maxspeed;0000000001 9
maxspeed;0000025232 10
maxspeed;0000000001 12
maxspeed;0000000001 13
maxspeed;0000000001 13.5
maxspeed;0000000001 15
maxspeed;0000000001 16
maxspeed;0000000001 20
maxspeed;0000000001 25

seamark:type;0000000001 lock_basin
seamark:type;0000000001 bridge
seamark:type;0000000001 fairway
seamark:type;0000000001 recommended_track
seamark:bridge:category;0000000001 fixed viaduct aqueduct suspension footbridge
seamark:bridge:category;0000000001 opening swing bascule pontoon drawbridge
seamark:bridge:category;0000000001 lifting transporter

waterway;0000016046 river
waterway;0000009496 canal
waterway;0000000071 fairway
waterway;0000000001 riverbank

waterway;0000002202 weir
waterway;0000001364 dam
waterway;0000000386 lock
waterway;0000000321 tidal_flat_slough
waterway;0000000179 wadi
waterway;0000000126 dock
waterway;0000000113 fish_pass
waterway;0000000086 boatyard
waterway;0000000059 lock_gate
waterway;0000000001 safe_water
waterway;0000000001 stream
waterway;0000000001 narrow

draft;0000000001 *
maxdraft;0000000001 *
depth;0000000001 *
maxdraught;0000000001 *

passage_time;0000000001 *

lock;0000000001 yes               

boat;0000019888 no private
boat;0000002718 yes permissive

motorboat;0000001077 yes
motorboat;0000000808 no private privat

Ship;0000000001 yes
ship;0000000001 no

CEMT;0000000001 0
CEMT;0000000001 I
CEMT;0000000001 II
CEMT;0000000001 III
CEMT;0000000001 IV
CEMT;0000000001 V
CEMT;0000000001 Va
CEMT;0000000001 Vb
CEMT;0000000001 VI
CEMT;0000000001 VIa
CEMT;0000000001 VIb
CEMT;0000000001 VIc
CEMT;0000000001 VII

brouter_route_placeholder_dummy_01;0000000001 dummy
brouter_route_placeholder_dummy_02;0000000001 dummy
brouter_route_placeholder_dummy_03;0000000001 dummy
brouter_route_placeholder_dummy_04;0000000001 dummy
brouter_route_placeholder_dummy_05;0000000001 dummy
brouter_route_placeholder_dummy_06;0000000001 dummy
brouter_route_placeholder_dummy_07;0000000001 dummy
brouter_route_placeholder_dummy_08;0000000001 dummy
brouter_route_placeholder_dummy_09;0000000001 dummy
brouter_route_placeholder_dummy_10;0000000001 dummy
brouter_route_placeholder_dummy_11;0000000001 dummy
brouter_route_placeholder_dummy_12;0000000001 dummy
brouter_route_placeholder_dummy_13;0000000001 dummy
brouter_route_placeholder_dummy_14;0000000001 dummy
brouter_route_placeholder_dummy_15;0000000001 dummy
brouter_route_placeholder_dummy_16;0000000001 dummy
brouter_route_placeholder_dummy_17;0000000001 dummy
brouter_route_placeholder_dummy_18;0000000001 dummy
brouter_route_placeholder_dummy_19;0000000001 dummy
brouter_route_placeholder_dummy_20;0000000001 dummy
brouter_route_placeholder_dummy_21;0000000001 dummy

---context:node
disused;0000000001 yes

waterway;0000050000 dam
waterway;0000035000 waterfall
waterway;0000000020 fish_pass
waterway;0000015000 rapids
waterway;0000040000 weir
waterway;0000015000 lock_gate

maxdraft;0000000001 *
depth;0000000001 *
water:depth;0000000001 *

seamark:type;000007500 bridge
seamark:bridge:category;0000000001 fixed viaduct aqueduct suspension footbridge
seamark:bridge:category;0000000001 opening swing bascule pontoon drawbridge
seamark:bridge:category;0000000001 lifting transporter
seamark:bridge:clearance_width;0000000001 *
seamark:bridge:clearance_height;0000000001 *
seamark:bridge:clearance_height_safe;0000000001 *
seamark:bridge:clearance_height_closed;0000000001 *
seamark:bridge:clearance_height_open;0000000001 *

seamark:type;0000002700 gate
seamark:gate:clearance_width;0000000001 *
seamark:gate:clearance_height;0000000001 *

seamark:type;000000820 cable_overhead
seamark:cable_overhead:clearance_height;0000000001 *
seamark:cable_overhead:clearance_height_safe;0000000001 *

creating segment files

  • make dir
mkdir tmp
cd tmp
mkdir srtm3_bef
mkdir nodetiles
mkdir waytiles
mkdir waytiles55
mkdir nodes55
mkdir unodes55
mkdir segments
  • OsmFastCutter <lookup-file> <node-dir> <way-dir> <node55-dir> <way55-dir> <border-file> <out-rel-file> <out-res-file> <filter-profile> <report-profile> <check-profile> <inputfile>
java -Xmx2600m -Xms2600m -Xmn32m -cp ../brouter-server-test.jar -Ddeletetmpfiles=true -DuseDenseMaps=true btools.util.StackSampler btools.mapcreator.OsmFastCutter ../profiles2/lookups.dat nodetiles waytiles nodes55 waytiles55  bordernids.dat  relations.dat  restrictions.dat  ../profiles2/all.brf ../profiles2/river.brf ../profiles2/softaccess.brf test-2.osm
  • PosUnifier <node-tiles-in> <node-tiles-out> <bordernids-in> <bordernodes-out> <srtm-data-dir>
java -Xmx2600m -Xms2600m -Xmn32m -cp ../brouter-server-test.jar -Ddeletetmpfiles=true -DuseDenseMaps=true btools.util.StackSampler btools.mapcreator.PosUnifier nodes55 unodes55 bordernids.dat bordernodes.dat ./srtm3_bef
  • WayLinker <node-tiles-in> <way-tiles-in> <bordernodes> <restrictions> <lookup-file> <profile-file> <data-tiles-out> <data-tiles-suffix>
java -Xmx2600m -Xms2600m -Xmn32m -cp ../brouter-server-test.jar -DuseDenseMaps=true -DskipEncodingCheck=true btools.util.StackSampler btools.mapcreator.WayLinker unodes55 waytiles55 bordernodes.dat restrictions.dat ../profiles2/lookups.dat ../profiles2/all.brf segments rd5

custom profile

issues

waterway.brf

---model:btools.router.WaterwayModel
---context:global   # following code refers to global config

# user values

# my boat in meter
assign boat_height	1.5     # %boat_height% | Boat height in Meter | number
assign boat_width	2.2     # %boat_width% | Boat width in Meter | number
assign boat_length	10.0	# Boat height in Meter | (not used now)
assign boat_draft	1.2		# %boat_draft% | Boat draft in Meter | number
assign literHour    1.5		# %literHour% | liter per hour | number

# my boat is CEMT class (decimal)
assign boat_class   1

# my boat has max speed
assign  maxSpeed             18  # km/h (Caution: this is case sensitive internal parameter and different to maxspeed)
                                 # handle with care, this belongs to your local area and your boat
assign  speed_normal         10  # %speed_normal% | Speed in kmh | number
assign  flow_rate            0   # %flow_rate% | Flow in kmh | number

# global values

assign   validForBikes            0
assign   validForCars             0
assign   validForFoot             0
assign   validForVessels          1

#assign totalMass  = 1000     # unused at the moment xtotalMass% | Mass (in kg) of the bike + biker, for travel time computation | number
#assign bikerPower = 15000    # unused at the moment xbikerPower% | Average power (in W) provided by the biker, for travel time computation | number

assign   shortest_way             1   # 0 as default

#assign   vmax 		              20

assign   turnInstructionMode      1   # 0=none, 1=auto-choose, 2=locus-style, 3=osmand-style, 4=comment-style, 5=gpsies
assign   processUnusedTags        0   # lists all (incl. unused) key/value pairs in geojson

assign   cost1speed               20  # kmh
assign   inverseRouting           1
assign   showspeed                1   # show speed instead of elevation (geojson)

assign   waiting_lock 			  900    # in seconds, for one lock_gate
assign   waiting_bridge			  900    # in seconds
assign   around_time			  900    # in seconds, avoid obstacles

assign   notdefined               10000


# https://wiki.openstreetmap.org/wiki/Key:CEMT
# https://wiki.openstreetmap.org/wiki/Inland_navigation

# CEMT is available in this region
assign can_use_CEMT               true



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

assign control_draft
#	switch  and CEMT=0 not maxdraft=          true 
	switch  and CEMT=0 not draft=             true 
#	switch  and CEMT=0 not depth=             true
#	switch  and CEMT=0 not maxdraught=        true
#    switch and not waterway= not maxdraft=   true 
#    switch and not waterway= not draft=      true 
#    switch and not waterway= not depth=      true 
#    switch and not waterway= not maxdraught= true 
	false

	
assign pass_lock 
	if seamark:type=lock_basin then (
		true
		)
	else false

assign this_class                       # len       width 	draught 	height
    if      CEMT=0       then 1         # used in NL for recreational boating fairways 
    else if CEMT=I       then 2         # 38,50 	5,05 	1,8-2,2 	4
    else if CEMT=II      then 3         # 50-55 	6,6 	2,5 	    4-5
    else if CEMT=III     then 4         # 67-80 	8,2 	2,5 	    4-5
    else if CEMT=IV      then 5         # 80-85 	9,5 	2,5 	    5,25-7
    else if CEMT=V       then 6         # 95-110 	11,4 	2,5-4,5 	5,25-7
    else if CEMT=Va      then 6         # 95-110 	11,4 	2,5-4,5 	5,25-7
    else if CEMT=Vb      then 7         # 172-185 	11,4 	2,5-4,5 	5,25-9,1
    else if CEMT=VI      then 8         # 95-110 	22,8 	2,5-4,5 	7-9,1
    else if CEMT=VIa     then 8         # 95-110 	22,8 	2,5-4,5 	7-9,1
    else if CEMT=VIb     then 9         # 185-195 	22,8 	2,5-4,5 	7-9,1
    else if CEMT=VIc     then 10        # 193-200 	34,2 	2,5-4,5 	9,1
    else if CEMT=VII     then 11        # 195/285 	34,2 	2,5-4,5 	9,1
    else
        0
	
assign	use_CEMT 
    if not CEMT= then (
        # if motorboat=no then false
        # else if greater this_class boat_class then true
        # else
		switch motorboat=no false
		switch ship=no false
		switch CEMT=0|I|II|III|IV|V|Va|Vb|VI|VIa|VIb|VIc|VII true	# make sure to drop classes you can't use
        false
    )
    else 
	    false
		
		  
assign boat_maxspeed =
  if ( and waterway=river reversedirection=yes ) then add speed_normal flow_rate 
  else if ( and waterway=river reversedirection= ) then sub speed_normal flow_rate
  else speed_normal


assign maxspeed_impl =
  switch CEMT=0                     10 # 6
  switch CEMT=I|II|III|IV           10
  switch CEMT=V|Va|Vb               10 # 12
  switch CEMT=VI|VIa|VIb|VIc|VII    15
  20
  
assign maxspeed_expl =
  switch maxspeed=  notdefined
  switch maxspeed=6 6
  switch maxspeed=9 9
  switch maxspeed=4.5 4.5
  switch maxspeed=5 5
  switch maxspeed=7 7
  switch maxspeed=8 8
  switch maxspeed=10 10
  switch maxspeed=12 12
  switch maxspeed=13 13
  switch maxspeed=13.5 13.5
  switch maxspeed=15 15
  switch maxspeed=16 16
  switch maxspeed=20 20
  switch maxspeed=25 25
  notdefined

assign maxspeed_defined 
  switch lesser maxspeed_expl notdefined maxspeed_expl maxspeed_impl 
  
assign maxspeed =
  min maxspeed_defined boat_maxspeed

assign turncost 0


assign initialcost 
    if waterway=weir                then around_time
    else if waterway=dam            then around_time
    else if waterway=fish_pass      then around_time
    else
    0



assign costfactor
    if  use_CEMT then (
      	1
    )
    else (
        if      waterway=               then 10000
        else if seamark:type=fairway    then 1
		else if waterway=canal 			then 1
		else if waterway=river 			then 1
		else if waterway=safe_water		then 1
	  	else if waterway=fairway        then 1
	  	else if waterway=narrow         then 1
		else if seamark:type=recommended_track	then 1
		else if motorboat=yes           then 1
	  	else   
    		15000
    )


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

assign control_node_draft
	switch not maxdraft=    true
	switch not depth=       true
	switch not water:depth= true
	false

assign control_bridge_fixed_height
    if seamark:bridge:category=fixed then  true 
	else false

assign control_bridge_opening_height
    if seamark:bridge:category=opening then  true 
	else false

assign control_node_bridge_width
    if not seamark:bridge:clearance_width= then true
	else false
	
assign initialcost 
	switch waterway=lock_gate  waiting_lock
	switch seamark:bridge:category=opening waiting_bridge
    switch waterway=waterfall  around_time
	0

waterway_fast.brf

  • assign costfactor to waterway-classes

waterway_short.brf

  • do not assign costfactor to waterway-classes

brouter-web

issues

see also