yes/proposed logic for relations
This commit is contained in:
parent
6c90fb9a25
commit
7fc76ad8c4
3 changed files with 63 additions and 21 deletions
|
@ -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 );
|
||||
|
|
|
@ -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<r.ways.size();i++ )
|
||||
{
|
||||
long wid = r.ways.get(i);
|
||||
|
|
|
@ -66,29 +66,32 @@ public class RelationMerger extends MapCreatorBase
|
|||
long rid = readId( dis );
|
||||
String route = 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;
|
||||
|
||||
CompactLongSet routeset = null;
|
||||
if ( expctxCheck.getLookupNameIdx(tagname) >= 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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue