network and access checks on cycle relations
This commit is contained in:
parent
2b70d8a862
commit
1b8c3ccea8
10 changed files with 409 additions and 10 deletions
|
|
@ -174,11 +174,16 @@ public class OsmCutter extends MapCreatorBase
|
|||
return;
|
||||
}
|
||||
|
||||
String network = r.getTag( "network" );
|
||||
if ( network == null ) network = "";
|
||||
writeId( cyclewayDos, r.rid );
|
||||
cyclewayDos.writeUTF( network );
|
||||
for ( int i=0; i<r.ways.size();i++ )
|
||||
{
|
||||
long wid = r.ways.get(i);
|
||||
writeId( cyclewayDos, wid );
|
||||
}
|
||||
writeId( cyclewayDos, -1 );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,74 @@
|
|||
package btools.mapcreator;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.EOFException;
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
|
||||
import btools.util.DenseLongMap;
|
||||
import btools.util.TinyDenseLongMap;
|
||||
|
||||
/**
|
||||
* WayCutter does 2 step in map-processing:
|
||||
*
|
||||
* - cut the way file into 45*30 - pieces
|
||||
* - enrich ways with relation information
|
||||
*
|
||||
* @author ab
|
||||
*/
|
||||
public class RelationStatistics extends MapCreatorBase
|
||||
{
|
||||
public static void main(String[] args) throws Exception
|
||||
{
|
||||
System.out.println("*** RelationStatistics: count relation networks");
|
||||
if (args.length != 1)
|
||||
{
|
||||
System.out.println("usage: java WayCutter <relation-file>" );
|
||||
|
||||
return;
|
||||
}
|
||||
new RelationStatistics().process( new File( args[0] ) );
|
||||
}
|
||||
|
||||
public void process( File relationFileIn ) throws Exception
|
||||
{
|
||||
HashMap<String,long[]> relstats = new HashMap<String,long[]>();
|
||||
|
||||
DataInputStream dis = createInStream( relationFileIn );
|
||||
try
|
||||
{
|
||||
for(;;)
|
||||
{
|
||||
long rid = readId( dis );
|
||||
String network = dis.readUTF();
|
||||
int waycount = 0;
|
||||
for(;;)
|
||||
{
|
||||
long wid = readId( dis );
|
||||
if ( wid == -1 ) break;
|
||||
waycount++;
|
||||
}
|
||||
|
||||
long[] stat = relstats.get( network );
|
||||
if ( stat == null )
|
||||
{
|
||||
stat = new long[2];
|
||||
relstats.put( network, stat );
|
||||
}
|
||||
stat[0]++;
|
||||
stat[1] += waycount;
|
||||
}
|
||||
}
|
||||
catch( EOFException eof )
|
||||
{
|
||||
dis.close();
|
||||
}
|
||||
for( String network : relstats.keySet() )
|
||||
{
|
||||
long[] stat = relstats.get( network );
|
||||
System.out.println( "network: " + network + " has " + stat[0] + " relations with " + stat[1] + " ways" );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -4,8 +4,10 @@ import java.io.DataInputStream;
|
|||
import java.io.EOFException;
|
||||
import java.io.File;
|
||||
|
||||
import btools.expressions.BExpressionContext;
|
||||
import btools.util.CompactLongSet;
|
||||
import btools.util.DenseLongMap;
|
||||
import btools.util.FrozenLongSet;
|
||||
import btools.util.TinyDenseLongMap;
|
||||
|
||||
/**
|
||||
|
|
@ -20,23 +22,33 @@ public class WayCutter extends MapCreatorBase
|
|||
{
|
||||
private CompactLongSet cyclewayset;
|
||||
private DenseLongMap tileIndexMap;
|
||||
private BExpressionContext expctxReport;
|
||||
private BExpressionContext expctxCheck;
|
||||
|
||||
public static void main(String[] args) throws Exception
|
||||
{
|
||||
System.out.println("*** WayCutter: Soft-Cut way-data into tiles");
|
||||
if (args.length != 4)
|
||||
if (args.length != 7)
|
||||
{
|
||||
System.out.println("usage: java WayCutter <node-tiles-in> <way-file-in> <way-tiles-out> <relation-file>" );
|
||||
System.out.println("usage: java WayCutter <node-tiles-in> <way-file-in> <way-tiles-out> <relation-file> <lookup-file> <report-profile> <check-profile>" );
|
||||
|
||||
return;
|
||||
}
|
||||
new WayCutter().process( new File( args[0] ), new File( args[1] ), new File( args[2] ), new File( args[3] ) );
|
||||
new WayCutter().process( new File( args[0] ), new File( args[1] ), new File( args[2] ), new File( args[3] ), new File( args[4] ), new File( args[5] ), new File( args[6] ) );
|
||||
}
|
||||
|
||||
public void process( File nodeTilesIn, File wayFileIn, File wayTilesOut, File relationFileIn ) throws Exception
|
||||
public void process( File nodeTilesIn, File wayFileIn, File wayTilesOut, File relationFileIn, File lookupFile, File reportProfile, File checkProfile ) throws Exception
|
||||
{
|
||||
this.outTileDir = wayTilesOut;
|
||||
|
||||
// read lookup + profile for relation access-check
|
||||
expctxReport = new BExpressionContext("way");
|
||||
expctxReport.readMetaData( lookupFile );
|
||||
expctxReport.parseFile( reportProfile, "global" );
|
||||
expctxCheck = new BExpressionContext("way");
|
||||
expctxCheck.readMetaData( lookupFile );
|
||||
expctxCheck.parseFile( checkProfile, "global" );
|
||||
|
||||
// *** read the relation file into a set (currently cycleway processing only)
|
||||
cyclewayset = new CompactLongSet();
|
||||
DataInputStream dis = createInStream( relationFileIn );
|
||||
|
|
@ -44,14 +56,24 @@ public class WayCutter extends MapCreatorBase
|
|||
{
|
||||
for(;;)
|
||||
{
|
||||
long wid = readId( dis );
|
||||
if ( !cyclewayset.contains( wid ) ) cyclewayset.add( wid );
|
||||
long rid = readId( dis );
|
||||
String network = dis.readUTF();
|
||||
boolean goodNetwork = "lcn".equals( network ) || "rcn".equals( network ) || "ncn".equals( network ) || "icn".equals( network );
|
||||
|
||||
for(;;)
|
||||
{
|
||||
long wid = readId( dis );
|
||||
if ( wid == -1 ) break;
|
||||
if ( goodNetwork && !cyclewayset.contains( wid ) ) cyclewayset.add( wid );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( EOFException eof )
|
||||
{
|
||||
dis.close();
|
||||
}
|
||||
|
||||
cyclewayset = new FrozenLongSet( cyclewayset );
|
||||
System.out.println( "marked cycleways: " + cyclewayset.size() );
|
||||
|
||||
|
||||
|
|
@ -76,7 +98,20 @@ public class WayCutter extends MapCreatorBase
|
|||
// propagate the cycleway-bit
|
||||
if ( cyclewayset.contains( data.wid ) )
|
||||
{
|
||||
data.description |= 2;
|
||||
// check access and log a warning for conflicts
|
||||
expctxCheck.evaluate( data.description, null );
|
||||
boolean ok = expctxCheck.getCostfactor() < 10000.;
|
||||
expctxReport.evaluate( data.description, null );
|
||||
boolean warn = expctxReport.getCostfactor() >= 10000.;
|
||||
if ( warn )
|
||||
{
|
||||
System.out.println( "** relation access conflict for wid = " + data.wid + " tags:" + expctxReport.getKeyValueDescription( data.description ) + " (ok=" + ok + ")" );
|
||||
}
|
||||
|
||||
if ( ok )
|
||||
{
|
||||
data.description |= 2;
|
||||
}
|
||||
}
|
||||
|
||||
long waytileset = 0;
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ public class WayLinker extends MapCreatorBase
|
|||
this.borderFileIn = borderFileIn;
|
||||
this.dataTilesSuffix = dataTilesSuffix;
|
||||
|
||||
// read lookup file to get the lookup-version
|
||||
// read lookup + profile for lookup-version + access-filter
|
||||
expctxWay = new BExpressionContext("way");
|
||||
expctxWay.readMetaData( lookupFile );
|
||||
lookupVersion = expctxWay.lookupVersion;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue