diff --git a/brouter-expressions/src/main/java/btools/expressions/BExpressionContext.java b/brouter-expressions/src/main/java/btools/expressions/BExpressionContext.java index 4eb2716..bd1b2b5 100644 --- a/brouter-expressions/src/main/java/btools/expressions/BExpressionContext.java +++ b/brouter-expressions/src/main/java/btools/expressions/BExpressionContext.java @@ -593,6 +593,36 @@ public final class BExpressionContext lookupData[inum] = valueIndex; } + /** + * special hack for yes/proposed relations: + * add a lookup value if not yet a smaller, >1 value was added + * add a 2=yes if the provided value is out of range + * value-index means here 0=unknown, 1=other, 2=yes, 3=proposed + */ + public void addSmallestLookupValue( String name, int valueIndex ) + { + Integer num = lookupNumbers.get( name ); + if ( num == null ) + { + return; + } + + // look for that value + int inum = num.intValue(); + int nvalues = lookupValues.get( inum ).length; + int oldValueIndex = lookupData[inum]; + if ( oldValueIndex > 1 && oldValueIndex < valueIndex ) + { + return; + } + if ( valueIndex >= nvalues ) + { + valueIndex = nvalues-1; + } + if ( valueIndex < 0 ) throw new IllegalArgumentException( "value index out of range for name " + name + ": " + valueIndex ); + lookupData[inum] = valueIndex; + } + public boolean getBooleanLookupValue( String name ) { Integer num = lookupNumbers.get( name ); diff --git a/brouter-map-creator/src/main/java/btools/mapcreator/OsmCutter.java b/brouter-map-creator/src/main/java/btools/mapcreator/OsmCutter.java index 16eb333..8d08b11 100644 --- a/brouter-map-creator/src/main/java/btools/mapcreator/OsmCutter.java +++ b/brouter-map-creator/src/main/java/btools/mapcreator/OsmCutter.java @@ -178,9 +178,12 @@ public class OsmCutter extends MapCreatorBase String network = r.getTag( "network" ); if ( network == null ) network = ""; + String state = r.getTag( "state" ); + if ( state == null ) state = ""; writeId( cyclewayDos, r.rid ); cyclewayDos.writeUTF( route ); cyclewayDos.writeUTF( network ); + cyclewayDos.writeUTF( state ); for ( int i=0; i= 0 ) { - routeset = routesets.get( tagname ); - if ( routeset == null ) - { - routeset = new CompactLongSet(); - routesets.put( tagname, routeset ); - } + String key = tagname + "_" + value; + routeset = routesets.get( key ); + if ( routeset == null ) + { + routeset = new CompactLongSet(); + routesets.put( key, routeset ); + } } - + for(;;) { long wid = readId( dis ); if ( wid == -1 ) break; - // expctxStat.addLookupValue( tagname, "yes", null ); + // expctxStat.addLookupValue( tagname, "yes", null ); if ( routeset != null && !routeset.contains( wid ) ) { - routeset.add( wid ); - routesetall.add( wid ); + routeset.add( wid ); + routesetall.add( wid ); } } } @@ -97,11 +100,11 @@ public class RelationMerger extends MapCreatorBase { dis.close(); } - for( String tagname : routesets.keySet() ) + for( String key : routesets.keySet() ) { - CompactLongSet routeset = new FrozenLongSet( routesets.get( tagname ) ); - routesets.put( tagname, routeset ); - System.out.println( "marked " + routeset.size() + " routes for tag: " + tagname ); + CompactLongSet routeset = new FrozenLongSet( routesets.get( key ) ); + routesets.put( key, routeset ); + System.out.println( "marked " + routeset.size() + " routes for key: " + key ); } // *** finally process the way-file @@ -125,20 +128,26 @@ public class RelationMerger extends MapCreatorBase boolean warn = expctxReport.getCostfactor() >= 10000.; if ( warn ) { - expctxCheck.evaluate( false, data.description, null ); - ok = expctxCheck.getCostfactor() < 10000.; + expctxCheck.evaluate( false, data.description, null ); + ok = expctxCheck.getCostfactor() < 10000.; - System.out.println( "** relation access conflict for wid = " + data.wid + " tags:" + expctxReport.getKeyValueDescription( data.description ) + " (ok=" + ok + ")" ); + System.out.println( "** relation access conflict for wid = " + data.wid + " tags:" + expctxReport.getKeyValueDescription( data.description ) + " (ok=" + ok + ")" ); } if ( ok ) { expctxReport.decode( data.description ); - for( String tagname : routesets.keySet() ) + for( String key : routesets.keySet() ) { - CompactLongSet routeset = routesets.get( tagname ); - if ( routeset.contains( data.wid ) ) expctxReport.addLookupValue( tagname, 2 ); - } + CompactLongSet routeset = routesets.get( key ); + if ( routeset.contains( data.wid ) ) + { + int sepIdx = key.lastIndexOf( '_' ); + String tagname = key.substring( 0, sepIdx ); + int val = Integer.valueOf( key.substring( sepIdx+1 ) ); + expctxReport.addSmallestLookupValue( tagname, val ); + } + } data.description = expctxReport.encode(); } }