variable length tag descriptions (first shot)
This commit is contained in:
parent
6768a197ba
commit
a145230e0f
23 changed files with 860 additions and 124 deletions
|
|
@ -13,7 +13,7 @@ public class NodeData extends MapCreatorBase
|
|||
public long nid;
|
||||
public int ilon;
|
||||
public int ilat;
|
||||
public long description;
|
||||
public byte[] description;
|
||||
public short selev = Short.MIN_VALUE;
|
||||
|
||||
public NodeData( long id, double lon, double lat )
|
||||
|
|
@ -29,18 +29,18 @@ public class NodeData extends MapCreatorBase
|
|||
ilon = dis.readInt();
|
||||
ilat = dis.readInt();
|
||||
int mode = dis.readByte();
|
||||
if ( ( mode & 1 ) != 0 ) description = dis.readLong();
|
||||
if ( ( mode & 1 ) != 0 ) { int dlen = dis.readByte(); description = new byte[dlen]; dis.readFully( description ); }
|
||||
if ( ( mode & 2 ) != 0 ) selev = dis.readShort();
|
||||
}
|
||||
}
|
||||
|
||||
public void writeTo( DataOutputStream dos ) throws Exception
|
||||
{
|
||||
writeId( dos, nid );
|
||||
dos.writeInt( ilon );
|
||||
dos.writeInt( ilat );
|
||||
int mode = ( description == 0L ? 0 : 1 ) | ( selev == Short.MIN_VALUE ? 0 : 2 );
|
||||
int mode = ( description == null ? 0 : 1 ) | ( selev == Short.MIN_VALUE ? 0 : 2 );
|
||||
dos.writeByte( (byte)mode );
|
||||
if ( ( mode & 1 ) != 0 ) dos.writeLong( description );
|
||||
if ( ( mode & 1 ) != 0 ) { dos.writeByte( description.length ); dos.write( description ); }
|
||||
if ( ( mode & 2 ) != 0 ) dos.writeShort( selev );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,13 +6,13 @@
|
|||
package btools.mapcreator;
|
||||
|
||||
|
||||
public final class OsmLinkP
|
||||
public class OsmLinkP
|
||||
{
|
||||
/**
|
||||
* The description bitmap is mainly the way description
|
||||
* used to calculate the costfactor
|
||||
*/
|
||||
public long descriptionBitmap;
|
||||
public byte[] descriptionBitmap;
|
||||
|
||||
/**
|
||||
* The target is either the next link or the target node
|
||||
|
|
@ -22,8 +22,8 @@ public final class OsmLinkP
|
|||
public OsmLinkP next;
|
||||
|
||||
|
||||
public boolean counterLinkWritten( )
|
||||
public final boolean counterLinkWritten( )
|
||||
{
|
||||
return descriptionBitmap == 0L;
|
||||
return descriptionBitmap == null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
/**
|
||||
* Dummy child of OsmLinkP just to encode the reverse bit
|
||||
*
|
||||
* @author ab
|
||||
*/
|
||||
package btools.mapcreator;
|
||||
|
||||
|
||||
public class OsmLinkPReverse extends OsmLinkP
|
||||
{
|
||||
}
|
||||
|
|
@ -75,9 +75,9 @@ public class OsmNodeP implements Comparable<OsmNodeP>
|
|||
firstlink = link;
|
||||
}
|
||||
|
||||
public long getNodeDecsription()
|
||||
public byte[] getNodeDecsription()
|
||||
{
|
||||
return 0L;
|
||||
return null;
|
||||
}
|
||||
|
||||
public void writeNodeData( DataOutputStream os ) throws IOException
|
||||
|
|
@ -92,7 +92,7 @@ public class OsmNodeP implements Comparable<OsmNodeP>
|
|||
os2.writeShort( getSElev() );
|
||||
|
||||
// hack: write node-desc as link tag (copy cycleway-bits)
|
||||
long nodeDescription = getNodeDecsription();
|
||||
byte[] nodeDescription = getNodeDecsription();
|
||||
|
||||
for( OsmLinkP link0 = firstlink; link0 != null; link0 = link0.next )
|
||||
{
|
||||
|
|
@ -122,13 +122,15 @@ public class OsmNodeP implements Comparable<OsmNodeP>
|
|||
link = link0;
|
||||
}
|
||||
origin = this;
|
||||
long lastDescription = 0;
|
||||
byte[] lastDescription = null;
|
||||
while( link != null )
|
||||
{
|
||||
if ( link.descriptionBitmap == null && skipDetailBit == 0 ) throw new IllegalArgumentException( "missing way description...");
|
||||
|
||||
OsmNodeP target = link.targetNode;
|
||||
int tranferbit = target.isTransferNode() ? TRANSFERNODE_BITMASK : 0;
|
||||
int writedescbit = link.descriptionBitmap != lastDescription ? WRITEDESC_BITMASK : 0;
|
||||
int nodedescbit = nodeDescription != 0L ? NODEDESC_BITMASK : 0;
|
||||
int nodedescbit = nodeDescription != null ? NODEDESC_BITMASK : 0;
|
||||
|
||||
if ( skipDetailBit != 0 )
|
||||
{
|
||||
|
|
@ -153,12 +155,17 @@ public class OsmNodeP implements Comparable<OsmNodeP>
|
|||
}
|
||||
if ( writedescbit != 0 )
|
||||
{
|
||||
os2.writeLong( link.descriptionBitmap );
|
||||
// write the way description, code direction into the first bit
|
||||
byte[] dbytes = link.descriptionBitmap;
|
||||
int len = dbytes.length;
|
||||
os2.writeByte( len );
|
||||
os2.writeByte( link instanceof OsmLinkPReverse ? dbytes[0] | 1 : dbytes[0] );
|
||||
if ( len > 1 ) os2.write( dbytes, 1, len-1 );
|
||||
}
|
||||
if ( nodedescbit != 0 )
|
||||
{
|
||||
os2.writeLong( nodeDescription );
|
||||
nodeDescription = 0L;
|
||||
os2.writeByte( nodeDescription.length ); os2.write( nodeDescription );
|
||||
nodeDescription = null;
|
||||
}
|
||||
lastDescription = link.descriptionBitmap;
|
||||
|
||||
|
|
@ -220,7 +227,7 @@ public class OsmNodeP implements Comparable<OsmNodeP>
|
|||
{
|
||||
for( OsmLinkP link = firstlink; link != null; link = link.next )
|
||||
{
|
||||
if ( link.targetNode == t) link.descriptionBitmap = 0L;
|
||||
if ( link.targetNode == t) link.descriptionBitmap = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ package btools.mapcreator;
|
|||
|
||||
public class OsmNodePT extends OsmNodeP
|
||||
{
|
||||
public long descriptionBits;
|
||||
public byte[] descriptionBits;
|
||||
|
||||
public byte wayOrBits = 0; // used to propagate bike networks to nodes
|
||||
|
||||
|
|
@ -16,15 +16,16 @@ public class OsmNodePT extends OsmNodeP
|
|||
{
|
||||
}
|
||||
|
||||
public OsmNodePT( long descriptionBits )
|
||||
public OsmNodePT( byte[] descriptionBits )
|
||||
{
|
||||
this.descriptionBits = descriptionBits;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getNodeDecsription()
|
||||
public final byte[] getNodeDecsription()
|
||||
{
|
||||
return descriptionBits | (long)( (wayOrBits & 6) >> 1 );
|
||||
return descriptionBits;
|
||||
// return descriptionBits | (long)( (wayOrBits & 6) >> 1 ); TODO !!!!!!!!!!1
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -100,11 +100,11 @@ public class WayCutter extends MapCreatorBase
|
|||
{
|
||||
boolean ok = true;
|
||||
// check access and log a warning for conflicts
|
||||
expctxReport.evaluate( data.description, null );
|
||||
expctxReport.evaluate( false, data.description, null );
|
||||
boolean warn = expctxReport.getCostfactor() >= 10000.;
|
||||
if ( warn )
|
||||
{
|
||||
expctxCheck.evaluate( data.description, null );
|
||||
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 + ")" );
|
||||
|
|
@ -112,7 +112,8 @@ public class WayCutter extends MapCreatorBase
|
|||
|
||||
if ( ok )
|
||||
{
|
||||
data.description |= 2;
|
||||
expctxReport.addLookupValue( "longdistancecycleway", 2 );
|
||||
data.description = expctxReport.encode();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import btools.util.LongList;
|
|||
public class WayData extends MapCreatorBase
|
||||
{
|
||||
public long wid;
|
||||
public long description;
|
||||
public byte[] description;
|
||||
public LongList nodes;
|
||||
|
||||
public WayData( long id )
|
||||
|
|
@ -32,7 +32,7 @@ public class WayData extends MapCreatorBase
|
|||
{
|
||||
nodes = new LongList( 16 );
|
||||
wid = readId( di) ;
|
||||
description = di.readLong();
|
||||
int dlen = di.readByte(); description = new byte[dlen]; di.readFully( description );
|
||||
for (;;)
|
||||
{
|
||||
long nid = readId( di );
|
||||
|
|
@ -44,7 +44,7 @@ public class WayData extends MapCreatorBase
|
|||
public void writeTo( DataOutputStream dos ) throws Exception
|
||||
{
|
||||
writeId( dos, wid );
|
||||
dos.writeLong( description );
|
||||
dos.writeByte( description.length ); dos.write( description );
|
||||
int size = nodes.size();
|
||||
for( int i=0; i < size; i++ )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ public class WayLinker extends MapCreatorBase
|
|||
@Override
|
||||
public void nextNode( NodeData data ) throws Exception
|
||||
{
|
||||
OsmNodeP n = data.description == 0L ? new OsmNodeP() : new OsmNodePT(data.description);
|
||||
OsmNodeP n = data.description == null ? new OsmNodeP() : new OsmNodePT(data.description);
|
||||
n.ilon = data.ilon;
|
||||
n.ilat = data.ilat;
|
||||
n.selev = data.selev;
|
||||
|
|
@ -132,18 +132,17 @@ public class WayLinker extends MapCreatorBase
|
|||
@Override
|
||||
public void nextWay( WayData way ) throws Exception
|
||||
{
|
||||
long description = way.description;
|
||||
long reverseDescription = description | 1L; // (add reverse bit)
|
||||
byte[] description = way.description;
|
||||
|
||||
// filter according to profile
|
||||
expctxWay.evaluate( description, null );
|
||||
expctxWay.evaluate( false, description, null );
|
||||
boolean ok = expctxWay.getCostfactor() < 10000.;
|
||||
expctxWay.evaluate( reverseDescription, null );
|
||||
expctxWay.evaluate( true, description, null );
|
||||
ok |= expctxWay.getCostfactor() < 10000.;
|
||||
|
||||
if ( !ok ) return;
|
||||
|
||||
byte lowbyte = (byte)description;
|
||||
// byte lowbyte = (byte)description;
|
||||
|
||||
OsmNodeP n1 = null;
|
||||
OsmNodeP n2 = null;
|
||||
|
|
@ -159,16 +158,16 @@ public class WayLinker extends MapCreatorBase
|
|||
l1.descriptionBitmap = description;
|
||||
n1.addLink( l1 );
|
||||
|
||||
OsmLinkP l2 = new OsmLinkP();
|
||||
OsmLinkP l2 = new OsmLinkPReverse();
|
||||
l2.targetNode = n1;
|
||||
l2.descriptionBitmap = reverseDescription;
|
||||
l2.descriptionBitmap = description;
|
||||
|
||||
n2.addLink( l2 );
|
||||
}
|
||||
if ( n2 != null )
|
||||
{
|
||||
n2.wayAndBits &= lowbyte;
|
||||
if ( n2 instanceof OsmNodePT ) ((OsmNodePT)n2).wayOrBits |= lowbyte;
|
||||
// n2.wayAndBits &= lowbyte;
|
||||
// if ( n2 instanceof OsmNodePT ) ((OsmNodePT)n2).wayOrBits |= lowbyte;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue