yes/proposed logic for relations

This commit is contained in:
Arndt 2014-09-27 13:28:29 +02:00
parent 6c90fb9a25
commit 7fc76ad8c4
3 changed files with 63 additions and 21 deletions

View file

@ -593,6 +593,36 @@ public final class BExpressionContext
lookupData[inum] = valueIndex; 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 ) public boolean getBooleanLookupValue( String name )
{ {
Integer num = lookupNumbers.get( name ); Integer num = lookupNumbers.get( name );

View file

@ -178,9 +178,12 @@ public class OsmCutter extends MapCreatorBase
String network = r.getTag( "network" ); String network = r.getTag( "network" );
if ( network == null ) network = ""; if ( network == null ) network = "";
String state = r.getTag( "state" );
if ( state == null ) state = "";
writeId( cyclewayDos, r.rid ); writeId( cyclewayDos, r.rid );
cyclewayDos.writeUTF( route ); cyclewayDos.writeUTF( route );
cyclewayDos.writeUTF( network ); cyclewayDos.writeUTF( network );
cyclewayDos.writeUTF( state );
for ( int i=0; i<r.ways.size();i++ ) for ( int i=0; i<r.ways.size();i++ )
{ {
long wid = r.ways.get(i); long wid = r.ways.get(i);

View file

@ -66,17 +66,20 @@ public class RelationMerger extends MapCreatorBase
long rid = readId( dis ); long rid = readId( dis );
String route = dis.readUTF(); String route = dis.readUTF();
String network = dis.readUTF(); String network = dis.readUTF();
String state = dis.readUTF();
int value = "proposed".equals( state ) ? 3 : 2; // 2=yes, 3=proposed
String tagname = "route_" + route + "_" + network; String tagname = "route_" + route + "_" + network;
CompactLongSet routeset = null; CompactLongSet routeset = null;
if ( expctxCheck.getLookupNameIdx(tagname) >= 0 ) if ( expctxCheck.getLookupNameIdx(tagname) >= 0 )
{ {
routeset = routesets.get( tagname ); String key = tagname + "_" + value;
routeset = routesets.get( key );
if ( routeset == null ) if ( routeset == null )
{ {
routeset = new CompactLongSet(); routeset = new CompactLongSet();
routesets.put( tagname, routeset ); routesets.put( key, routeset );
} }
} }
@ -97,11 +100,11 @@ public class RelationMerger extends MapCreatorBase
{ {
dis.close(); dis.close();
} }
for( String tagname : routesets.keySet() ) for( String key : routesets.keySet() )
{ {
CompactLongSet routeset = new FrozenLongSet( routesets.get( tagname ) ); CompactLongSet routeset = new FrozenLongSet( routesets.get( key ) );
routesets.put( tagname, routeset ); routesets.put( key, routeset );
System.out.println( "marked " + routeset.size() + " routes for tag: " + tagname ); System.out.println( "marked " + routeset.size() + " routes for key: " + key );
} }
// *** finally process the way-file // *** finally process the way-file
@ -134,10 +137,16 @@ public class RelationMerger extends MapCreatorBase
if ( ok ) if ( ok )
{ {
expctxReport.decode( data.description ); expctxReport.decode( data.description );
for( String tagname : routesets.keySet() ) for( String key : routesets.keySet() )
{ {
CompactLongSet routeset = routesets.get( tagname ); CompactLongSet routeset = routesets.get( key );
if ( routeset.contains( data.wid ) ) expctxReport.addLookupValue( tagname, 2 ); 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(); data.description = expctxReport.encode();
} }