more lookup changes

This commit is contained in:
Arndt 2014-06-19 18:44:10 +02:00
parent 8fa82633d4
commit e13d1ad468
12 changed files with 192 additions and 76 deletions

View file

@ -75,7 +75,7 @@ public final class RoutingContext implements DistanceChecker
public int ilatshortest;
public int ilonshortest;
public void prepareNogoPoints( List<OsmNodeNamed> nogos )
public static void prepareNogoPoints( List<OsmNodeNamed> nogos )
{
for( OsmNodeNamed nogo : nogos )
{

View file

@ -94,7 +94,7 @@ public final class BExpressionContext
this.context = context;
this.meta = meta;
meta.registerListener(context, this );
if ( meta != null ) meta.registerListener(context, this );
if ( Boolean.getBoolean( "disableExpressionCache" ) ) hashSize = 1;

View file

@ -29,10 +29,10 @@ public class OsmCutter extends MapCreatorBase
public static void main(String[] args) throws Exception
{
System.out.println("*** OsmCutter: cut an osm map in node-tiles + a way file");
if (args.length != 4 && args.length != 5)
if (args.length != 5 && args.length != 6)
{
System.out.println("usage: bzip2 -dc <map> | java OsmCutter <lookup-file> <out-tile-dir> <out-way-file> <out-rel-file>");
System.out.println("or : java OsmCutter <lookup-file> <out-tile-dir> <out-way-file> <out-rel-file> <inputfile>");
System.out.println("usage: bzip2 -dc <map> | java OsmCutter <lookup-file> <out-tile-dir> <out-way-file> <out-rel-file> <filter-profile>");
System.out.println("or : java OsmCutter <lookup-file> <out-tile-dir> <out-way-file> <out-rel-file> <filter-profile> <inputfile> ");
return;
}
@ -41,16 +41,18 @@ public class OsmCutter extends MapCreatorBase
, new File( args[1] )
, new File( args[2] )
, new File( args[3] )
, args.length > 4 ? new File( args[4] ) : null );
, new File( args[4] )
, args.length > 5 ? new File( args[5] ) : null
);
}
private BExpressionContext _expctxWay;
private BExpressionContext _expctxNode;
private BExpressionContext _expctxWayStat;
// private BExpressionContext _expctxNodeStat;
private BExpressionContext _expctxNodeStat;
public void process (File lookupFile, File outTileDir, File wayFile, File relFile, File mapFile) throws Exception
public void process (File lookupFile, File outTileDir, File wayFile, File relFile, File profileFile, File mapFile ) throws Exception
{
if ( !lookupFile.exists() )
{
@ -62,8 +64,11 @@ public class OsmCutter extends MapCreatorBase
_expctxWay = new BExpressionContext("way", meta );
_expctxNode = new BExpressionContext("node", meta );
meta.readMetaData( lookupFile );
// _expctxWayStat = new BExpressionContext("way", null );
// _expctxNodeStat = new BExpressionContext("node", null );
_expctxWay.parseFile( profileFile, "global" );
_expctxWayStat = new BExpressionContext("way", null );
_expctxNodeStat = new BExpressionContext("node", null );
this.outTileDir = outTileDir;
if ( !outTileDir.isDirectory() ) throw new RuntimeException( "out tile directory " + outTileDir + " does not exist" );
@ -83,10 +88,10 @@ public class OsmCutter extends MapCreatorBase
wayDos.close();
cyclewayDos.close();
// System.out.println( "-------- way-statistics -------- " );
// _expctxWayStat.dumpStatistics();
// System.out.println( "-------- node-statistics -------- " );
// _expctxNodeStat.dumpStatistics();
System.out.println( "-------- way-statistics -------- " );
_expctxWayStat.dumpStatistics();
System.out.println( "-------- node-statistics -------- " );
_expctxNodeStat.dumpStatistics();
System.out.println( statsLine() );
}
@ -115,7 +120,7 @@ public class OsmCutter extends MapCreatorBase
{
String value = n.getTag( key );
_expctxNode.addLookupValue( key, value, lookupData );
// _expctxNodeStat.addLookupValue( key, value, null );
_expctxNodeStat.addLookupValue( key, value, null );
}
n.description = _expctxNode.encode(lookupData);
}
@ -134,37 +139,26 @@ public class OsmCutter extends MapCreatorBase
waysParsed++;
checkStats();
// filter out non-highway ways
if ( w.getTag( "highway" ) == null )
{
// ... but eventually fake a ferry tag
if ( "ferry".equals( w.getTag( "route" ) ) )
{
w.putTag( "highway", "ferry" );
}
else
{
return;
}
}
if ( "no".equals( w.getTag( "oneway:bicycle" ) ) && w.getTag( "cycleway" ) == null )
{
w.putTag( "cycleway", "opposite" ); // fake that (no more bits available for oneway:bicycle..
}
// encode tags
if ( w.getTagsOrNull() != null )
{
if ( w.getTagsOrNull() == null ) return;
int[] lookupData = _expctxWay.createNewLookupData();
for( String key : w.getTagsOrNull().keySet() )
{
String value = w.getTag( key );
_expctxWay.addLookupValue( key, value, lookupData );
// _expctxWayStat.addLookupValue( key, value, null );
_expctxWayStat.addLookupValue( key, value, null );
}
w.description = _expctxWay.encode(lookupData);
}
if ( w.description == null ) return;
// filter according to profile
_expctxWay.evaluate( false, w.description, null );
boolean ok = _expctxWay.getCostfactor() < 10000.;
_expctxWay.evaluate( true, w.description, null );
ok |= _expctxWay.getCostfactor() < 10000.;
if ( !ok ) return;
w.writeTo( wayDos );
}

View file

@ -27,7 +27,8 @@ public class MapcreatorTest
File lookupFile = new File( profileDir, "lookups.dat" );
File wayFile = new File( tmpdir, "ways.dat" );
File relFile = new File( tmpdir, "cycleways.dat" );
new OsmCutter().process( lookupFile, nodetiles, wayFile, relFile, mapfile );
File profileAllFile = new File( profileDir, "all.brf" );
new OsmCutter().process( lookupFile, nodetiles, wayFile, relFile, profileAllFile, mapfile );
// run NodeFilter
File ftiles = new File( tmpdir, "ftiles" );
@ -65,7 +66,6 @@ public class MapcreatorTest
// run WayLinker
File segments = new File( tmpdir, "segments" );
segments.mkdir();
File profileAllFile = new File( profileDir, "all.brf" );
new WayLinker().process( unodes55, waytiles55, bordernodes, lookupFile, profileAllFile, segments, "rd5" );
// run WayLinker, car subset

View file

@ -112,22 +112,33 @@ public class BRouterView extends View
}
public void startSetup( String baseDir, boolean storeBasedir )
{
cor = null;
try
{
File fbd = new File( baseDir );
if ( !fbd.isDirectory() )
{
throw new IllegalArgumentException( "Base-directory " + baseDir + " is not a directory " );
}
String basedir = fbd.getAbsolutePath();
if ( storeBasedir )
{
ConfigHelper.writeBaseDir( getContext(), baseDir );
// Android 4.4 patch: try extend the basedir if not valid
File td = new File( fbd, "brouter" );
try { td.mkdir(); } catch ( Exception e ) {};
if ( !td.isDirectory() )
{
File td1 = new File( fbd, "Android/data/btools/routingapp" );
try { td1.mkdirs(); } catch ( Exception e ) {};
td = new File( td1, "brouter" );
try { td.mkdir(); } catch ( Exception e ) {};
if ( td.isDirectory() ) fbd = td1;
}
cor = null;
try
{
ConfigHelper.writeBaseDir( getContext(), baseDir );
}
String basedir = fbd.getAbsolutePath();
// create missing directories
assertDirectoryExists( "project directory", basedir + "/brouter", null );
segmentDir = basedir + "/brouter/segments2";

View file

@ -11,7 +11,13 @@ assign uphillcutoff 1.5
assign turncost 0
assign initialcost 0
assign costfactor 1
assign costfactor
switch not highway= 1
switch not railway= 1
switch not or waterway= waterway=unknown 1
switch not route= 1
100000
---context:node # following code refers to node tags

View file

@ -19,7 +19,7 @@ assign pass1coefficient 1.3
---context:way # following code refers to way-tags
assign turncost 200
assign initialcost switch highway=ferry 20000 0
assign initialcost switch route=ferry 20000 0
#
@ -36,7 +36,7 @@ assign caraccess
switch or highway=secondary highway=secondary_link 1
switch or highway=tertiary highway=tertiary_link 1
switch highway=unclassified 1
switch highway=ferry 1
switch route=ferry 1
switch or highway=residential highway=living_street 1
switch highway=service 1
0
@ -66,13 +66,15 @@ assign costfactor
add max onewaypenalty accesspenalty
switch and highway= not route=ferry 100000
switch or highway=motorway highway=motorway_link 1
switch or highway=trunk highway=trunk_link 1
switch or highway=primary highway=primary_link switch maxspeed=30 2.0 switch maxspeed=50 1.5 1.2
switch or highway=secondary highway=secondary_link 1.3
switch or highway=tertiary highway=tertiary_link 1.4
switch highway=unclassified 1.5
switch highway=ferry 5.67
switch route=ferry 5.67
switch highway=bridleway 5
switch or highway=residential highway=living_street 2
switch highway=service 2

View file

@ -37,7 +37,7 @@ assign isunpaved not or surface= or ispaved or surface=fine_gravel surface=cobbl
assign turncost 90
assign initialcost switch highway=ferry 10000 0
assign initialcost switch route=ferry 10000 0
#
# implicit access here just from the motorroad tag
@ -96,7 +96,7 @@ assign oneway
or oneway=yes or oneway=true oneway=1
assign onewaypenalty
switch switch reversedirection=yes oneway oneway=-1
switch or cycleway=opposite or cycleway=opposite_lane cycleway=opposite_track 0
switch or cycleway=opposite or cycleway=opposite_lane or cycleway=opposite_track oneway:bicycle=no 0
switch or highway=primary highway=primary_link 50
switch or highway=secondary highway=secondary_link 30
switch or highway=tertiary highway=tertiary_link 20
@ -107,6 +107,8 @@ assign costfactor
add max onewaypenalty accesspenalty
switch and highway= not route=ferry 100000
switch or highway=motorway highway=motorway_link 100000
switch or highway=proposed highway=abandoned 100000
switch or highway=trunk highway=trunk_link 10
@ -116,7 +118,7 @@ assign costfactor
switch highway=unclassified 1.1
switch highway=pedestrian 10
switch highway=steps 1000
switch highway=ferry 5.67
switch route=ferry 5.67
switch highway=bridleway 5
switch highway=cycleway 1.3
switch or highway=residential highway=living_street switch isunpaved 10 1.2

View file

@ -30,7 +30,6 @@ highway;0000058257 bridleway
highway;0000039003 platform
highway;0000037192 proposed
highway;0000010307 raceway
highway;0000008949 ferry
highway;0000003152 rest_area
highway;0000002942 abandoned
highway;0000002631 services
@ -213,9 +212,27 @@ cycleway;0000000224 cyclestreet
cycleway;0000000172 path
cycleway;0000000154 sidewalk
footway;0000104998 sidewalk
footway;0000065943 crossing
footway;0000012342 both
footway;0000008363 none
footway;0000005903 right
footway;0000004159 left
footway;0000003966 no
footway;0000001093 yes
footway;0000000558 separate
segregated;0000224960 no
segregated;0000051124 yes
sidewalk;0000194579 none
sidewalk;0000111468 both
sidewalk;0000052950 right
sidewalk;0000024489 left
sidewalk;0000012916 no
sidewalk;0000005725 separate
sidewalk;0000001950 yes
mtb:scale;0000114272 0
mtb:scale;0000068284 1
mtb:scale;0000027311 2
@ -272,6 +289,28 @@ oneway:bicycle;0000012034 no
oneway:bicycle;0000005217 yes
oneway:bicycle;0000000161 opposite
cycleway:right;0000012522 lane Lane
cycleway:right;0000006644 track
cycleway:right;0000000971 share_busway
cycleway:right;0000000686 sidepath
cycleway:right;0000000410 shared_lane
cycleway:right;0000000104 opposite_lane
cycleway:right;0000000058 opposite_track
cycleway:right;0000000045 no none
cycleway:right;0000000037 yes
cycleway:right;0000000004 opposite
cycleway:left;0000005134 lane Lane
cycleway:left;0000003169 track
cycleway:left;0000000656 share_busway
cycleway:left;0000000608 opposite_lane
cycleway:left;0000000475 sidepath
cycleway:left;0000000257 shared_lane
cycleway:left;0000000246 no none
cycleway:left;0000000130 opposite_track
cycleway:left;0000000053 opposite
cycleway:left;0000000014 yes
incline;0000052784 up
incline;0000035413 down
incline;0000001628 yes
@ -295,7 +334,53 @@ incline;0000000172 -30% -30 -40 -50 -40% -50%
toll;0000090536 yes true
brouter_placeholder_dummy_01;0000000001 dummy
railway;0000157547 rail
railway;0000019316 abandoned
railway;0000016982 tram
railway;0000014387 platform
railway;0000011143 disused
railway;0000004623 light_rail
railway;0000002982 subway
railway;0000002422 narrow_gauge
railway;0000001960 razed
railway;0000001859 preserved
seamark:type;0001564 recommended_track
seamark:type;0000522 fairway
waterway;0000016046 river
waterway;0000009496 canal
waterway;0000007876 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;0000000071 fairway
waterway;0000000059 lock_gate
boat;0000019888 no
boat;0000002718 yes
boat;0000000232 private
boat;0000000064 permissive
boat;0000000045 designated
motorboat;0000001077 yes
motorboat;0000000808 no
motorboat;0000000025 private privat
route;0000000850 ferry
route;0000000539 hiking
route;0000000505 bicycle
route;0000000454 ski
route;0000000413 mtb
route;0000000194 canoe
route;0000000151 road
route;0000000104 bus
brouter_placeholder_dummy_02;0000000001 dummy
brouter_placeholder_dummy_03;0000000001 dummy
brouter_placeholder_dummy_04;0000000001 dummy
@ -532,6 +617,15 @@ railway;0000024038 halt
railway;0000014285 subway_entrance
railway;0000010890 signal
waterway;0000004698 weir
waterway;0000001647 lock_gate
waterway;0000000425 waterfall
waterway;0000000337 take_right_side
waterway;0000000332 take_left_side
waterway;0000000219 milestone
waterway;0000000187 depth
waterway;0000000170 lock
noexit;0000195286 yes
entrance;0000301732 yes

View file

@ -19,7 +19,7 @@ assign validForCars 1
---context:way # following code refers to way-tags
assign turncost 90
assign initialcost switch highway=ferry 20000 0
assign initialcost switch route=ferry 20000 0
#
@ -34,7 +34,7 @@ assign motorverhicleaccess
switch or highway=secondary highway=secondary_link 1
switch or highway=tertiary highway=tertiary_link 1
switch highway=unclassified 1
switch highway=ferry 1
switch route=ferry 1
switch or highway=residential highway=living_street 1
switch highway=service 1
0
@ -73,12 +73,14 @@ assign costfactor
add max onewaypenalty accesspenalty
switch and highway= not route=ferry 100000
switch or highway=trunk highway=trunk_link 1.5
switch or highway=primary highway=primary_link switch maxspeed=30 2.0 switch maxspeed=50 1.5 1.2
switch or highway=secondary highway=secondary_link 1.4
switch or highway=tertiary highway=tertiary_link 1.3
switch highway=unclassified 1.2
switch highway=ferry 5.67
switch route=ferry 5.67
switch highway=bridleway 5
switch or highway=residential highway=living_street 2
switch highway=service 2

View file

@ -16,7 +16,7 @@ assign nodeaccessgranted or any_cycleroute lcn=yes
assign turncost 0
assign initialcost switch highway=ferry 10000 0
assign initialcost switch route=ferry 10000 0
#
# implicit access here just from the motorroad tag
@ -57,7 +57,9 @@ assign accesspenalty switch or bikeaccess footaccess 0 100000
assign costfactor
add accesspenalty
switch highway=ferry 5.67
switch and highway= not route=ferry 100000
switch route=ferry 5.67
switch or highway=motorway highway=motorway_link 100000
switch or highway=proposed highway=abandoned 100000
1

View file

@ -53,7 +53,7 @@ assign turncost switch is_ldcr 0 90
# this is added to the total cost each time the costfactor
# changed
#
assign initialcost switch highway=ferry 10000 0
assign initialcost switch route=ferry 10000 0
#
# implicit access here just from the motorroad tag
@ -110,9 +110,10 @@ assign oneway
switch oneway=
junction=roundabout
or oneway=yes or oneway=true oneway=1
assign onewaypenalty
switch switch reversedirection=yes oneway oneway=-1
switch or cycleway=opposite or cycleway=opposite_lane cycleway=opposite_track 0
switch or cycleway=opposite or cycleway=opposite_lane or cycleway=opposite_track oneway:bicycle=no 0
switch or highway=primary highway=primary_link 50
switch or highway=secondary highway=secondary_link 30
switch or highway=tertiary highway=tertiary_link 20
@ -130,13 +131,15 @@ assign costfactor
add max onewaypenalty accesspenalty
switch and highway= not route=ferry 100000
#
# steps and ferries are special. Note this is handled
# before the cycleroute-switch, to be able
# to really exlude them be setting cost to infinity
#
switch highway=steps switch allow_steps 40 100000
switch highway=ferry switch allow_ferries 5.67 100000
switch route=ferry switch allow_ferries 5.67 100000
#
# handle long-distance cycle-routes.