variable length tag descriptions (downwards compatibility)

This commit is contained in:
Arndt 2014-05-29 16:47:43 +02:00
parent c16c242a65
commit afa498637a
14 changed files with 195 additions and 58 deletions

View file

@ -46,6 +46,9 @@ public class OsmCutter extends MapCreatorBase
private BExpressionContext _expctxWay;
private BExpressionContext _expctxNode;
private BExpressionContext _expctxWayStat;
private BExpressionContext _expctxNodeStat;
public void process (File lookupFile, File outTileDir, File wayFile, File relFile, File mapFile) throws Exception
{
if ( !lookupFile.exists() )
@ -55,9 +58,11 @@ public class OsmCutter extends MapCreatorBase
_expctxWay = new BExpressionContext("way");
_expctxWay.readMetaData( lookupFile );
_expctxWayStat = new BExpressionContext("way");
_expctxNode = new BExpressionContext("node");
_expctxNode.readMetaData( lookupFile );
_expctxNodeStat = new BExpressionContext("node");
this.outTileDir = outTileDir;
if ( !outTileDir.isDirectory() ) throw new RuntimeException( "out tile directory " + outTileDir + " does not exist" );
@ -77,11 +82,11 @@ public class OsmCutter extends MapCreatorBase
wayDos.close();
cyclewayDos.close();
/* System.out.println( "-------- way-statistics -------- " );
_expctxWay.dumpStatistics();
System.out.println( "-------- way-statistics -------- " );
_expctxWayStat.dumpStatistics();
System.out.println( "-------- node-statistics -------- " );
_expctxNode.dumpStatistics();
*/
_expctxNodeStat.dumpStatistics();
System.out.println( statsLine() );
}
@ -109,6 +114,7 @@ public class OsmCutter extends MapCreatorBase
{
String value = n.getTag( key );
_expctxNode.addLookupValue( key, value, lookupData );
_expctxNodeStat.addLookupValue( key, value, null );
}
n.description = _expctxNode.encode(lookupData);
}
@ -155,6 +161,7 @@ public class OsmCutter extends MapCreatorBase
{
String value = w.getTag( key );
_expctxWay.addLookupValue( key, value, lookupData );
_expctxWayStat.addLookupValue( key, value, null );
}
w.description = _expctxWay.encode(lookupData);
}

View file

@ -12,7 +12,7 @@ import java.io.IOException;
public class OsmNodeP implements Comparable<OsmNodeP>
{
public static final int EXTERNAL_BITMASK = 0x80;
public static final int FIRSTFORWAY_BITMASK = 0x40;
public static final int VARIABLEDESC_BITMASK = 0x40;
public static final int TRANSFERNODE_BITMASK = 0x20;
public static final int WRITEDESC_BITMASK = 0x10;
public static final int SKIPDETAILS_BITMASK = 0x08;
@ -144,14 +144,14 @@ public class OsmNodeP implements Comparable<OsmNodeP>
if ( targetLonIdx == lonIdx && targetLatIdx == latIdx )
{
// reduced position for internal target
os2.writeByte( tranferbit | writedescbit | nodedescbit | skipDetailBit );
os2.writeByte( tranferbit | writedescbit | nodedescbit | skipDetailBit | VARIABLEDESC_BITMASK );
os2.writeShort( (short)(target.ilon - lonIdx*62500 - 31250) );
os2.writeShort( (short)(target.ilat - latIdx*62500 - 31250) );
}
else
{
// full position for external target
os2.writeByte( tranferbit | writedescbit | nodedescbit | skipDetailBit | EXTERNAL_BITMASK );
os2.writeByte( tranferbit | writedescbit | nodedescbit | skipDetailBit | EXTERNAL_BITMASK | VARIABLEDESC_BITMASK );
os2.writeInt( target.ilon );
os2.writeInt( target.ilat );
}

View file

@ -23,6 +23,7 @@ public class RelationMerger extends MapCreatorBase
private CompactLongSet routesetall;
private BExpressionContext expctxReport;
private BExpressionContext expctxCheck;
private BExpressionContext expctxStat;
private DataOutputStream wayOutStream;
@ -47,6 +48,7 @@ public class RelationMerger extends MapCreatorBase
expctxCheck = new BExpressionContext("way");
expctxCheck.readMetaData( lookupFile );
expctxCheck.parseFile( checkProfile, "global" );
expctxStat = new BExpressionContext("way");
// *** read the relation file into sets for each processed tag
routesets = new HashMap<String,CompactLongSet>();
@ -76,6 +78,7 @@ public class RelationMerger extends MapCreatorBase
{
long wid = readId( dis );
if ( wid == -1 ) break;
expctxStat.addLookupValue( tagname, "yes", null );
if ( routeset != null && !routeset.contains( wid ) )
{
routeset.add( wid );
@ -92,14 +95,17 @@ public class RelationMerger extends MapCreatorBase
{
CompactLongSet routeset = new FrozenLongSet( routesets.get( tagname ) );
routesets.put( tagname, routeset );
System.out.println( "marked " + routeset.size() + " ways for tag: " + tagname );
System.out.println( "marked " + routeset.size() + " routes for tag: " + tagname );
}
// *** finally process the way-file
wayOutStream = createOutStream( wayFileOut );
new WayIterator( this, true ).processFile( wayFileIn );
wayOutStream.close();
}
System.out.println( "-------- route-statistics -------- " );
expctxStat.dumpStatistics();
}
@Override
public void nextWay( WayData data ) throws Exception

View file

@ -20,16 +20,16 @@ public class WayCutter extends MapCreatorBase
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 != 3)
{
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>" );
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] ) );
}
public void process( File nodeTilesIn, File wayFileIn, File wayTilesOut, File relationFileIn ) throws Exception
public void process( File nodeTilesIn, File wayFileIn, File wayTilesOut ) throws Exception
{
this.outTileDir = wayTilesOut;

View file

@ -8,6 +8,7 @@ import java.util.Collections;
import java.util.List;
import btools.expressions.BExpressionContext;
import btools.util.ByteArrayUnifier;
import btools.util.CompactLongMap;
import btools.util.CompactLongSet;
import btools.util.Crc32;
@ -43,6 +44,8 @@ public class WayLinker extends MapCreatorBase
private BExpressionContext expctxWay;
private ByteArrayUnifier abUnifier;
private int minLon;
private int minLat;
@ -80,6 +83,8 @@ public class WayLinker extends MapCreatorBase
creationTimeStamp = System.currentTimeMillis();
abUnifier = new ByteArrayUnifier( 16384 );
// then process all segments
new WayIterator( this, true ).processDir( wayTilesIn, ".wt5" );
}
@ -140,7 +145,7 @@ public class WayLinker extends MapCreatorBase
@Override
public void nextWay( WayData way ) throws Exception
{
byte[] description = way.description;
byte[] description = abUnifier.unify( way.description );
// filter according to profile
expctxWay.evaluate( false, description, null );

View file

@ -43,7 +43,7 @@ public class MapcreatorTest
// run WayCutter
File waytiles = new File( tmpdir, "waytiles" );
waytiles.mkdir();
new WayCutter().process( ftiles, wayFile2, waytiles, relFile );
new WayCutter().process( ftiles, wayFile2, waytiles );
// run WayCutter5
File waytiles55 = new File( tmpdir, "waytiles55" );