tr bike exceptions
This commit is contained in:
parent
e629a2b2b2
commit
f15c5b923e
8 changed files with 55 additions and 5 deletions
|
@ -88,15 +88,23 @@ public final class MicroCache2 extends MicroCache
|
|||
int ilat = alat[n];
|
||||
|
||||
// future escapes (turn restrictions?)
|
||||
short trExceptions = 0;
|
||||
for(;;)
|
||||
{
|
||||
int featureId = bc.decodeVarBits();
|
||||
if ( featureId == 0 ) break;
|
||||
int bitsize = bc.decodeNoisyNumber( 5 );
|
||||
|
||||
if ( featureId == 1 ) // turn-restriction
|
||||
if ( featureId == 2 ) // exceptions to turn-restriction
|
||||
{
|
||||
trExceptions = (short)bc.decodeBounded( 1023 );
|
||||
}
|
||||
else if ( featureId == 1 ) // turn-restriction
|
||||
{
|
||||
writeBoolean( true );
|
||||
writeShort( trExceptions ); // exceptions from previous feature
|
||||
trExceptions = 0;
|
||||
|
||||
writeBoolean( bc.decodeBit() ); // isPositive
|
||||
writeInt( ilon + bc.decodeNoisyDiff( 10 ) ); // fromLon
|
||||
writeInt( ilat + bc.decodeNoisyDiff( 10 ) ); // fromLat
|
||||
|
@ -364,8 +372,15 @@ public final class MicroCache2 extends MicroCache
|
|||
// write turn restrictions
|
||||
while( readBoolean() )
|
||||
{
|
||||
bc.encodeVarBits( 1 ); // 1 = extra-data type : turn-restriction
|
||||
bc.encodeNoisyNumber( restrictionBits.getNext(), 5 ); // bit-count using looku-ahead fifo
|
||||
short exceptions = readShort(); // except bikes, psv, ...
|
||||
if ( exceptions != 0 )
|
||||
{
|
||||
bc.encodeVarBits( 2 ); // 2 = tr exceptions
|
||||
bc.encodeNoisyNumber( 10 , 5 ); // bit-count
|
||||
bc.encodeBounded( 1023 , exceptions & 1023 );
|
||||
}
|
||||
bc.encodeVarBits( 1 ); // 1 = turn restriction
|
||||
bc.encodeNoisyNumber( restrictionBits.getNext(), 5 ); // bit-count using look-ahead fifo
|
||||
long b0 = bc.getWritingBitPosition();
|
||||
bc.encodeBit( readBoolean() ); // isPositive
|
||||
bc.encodeNoisyDiff( readInt() - ilon, 10 ); // fromLon
|
||||
|
|
|
@ -216,7 +216,8 @@ final class OsmPath implements OsmLinkHolder
|
|||
TurnRestriction tr = sourceNode.firstRestriction;
|
||||
while( tr != null )
|
||||
{
|
||||
if ( tr.fromLon == lon0 && tr.fromLat == lat0 )
|
||||
boolean trValid = ! (tr.exceptBikes() && rc.bikeMode);
|
||||
if ( trValid && tr.fromLon == lon0 && tr.fromLat == lat0 )
|
||||
{
|
||||
if ( tr.isPositive )
|
||||
{
|
||||
|
|
|
@ -224,9 +224,23 @@ public class OsmCutter extends MapCreatorBase
|
|||
{
|
||||
return;
|
||||
}
|
||||
|
||||
short exceptions = 0;
|
||||
String except = r.getTag( "except" );
|
||||
if ( except != null )
|
||||
{
|
||||
exceptions |= toBit( "bicycle" , 0, except );
|
||||
exceptions |= toBit( "motorcar" , 1, except );
|
||||
exceptions |= toBit( "agricultural" , 2, except );
|
||||
exceptions |= toBit( "forestry" , 2, except );
|
||||
exceptions |= toBit( "psv" , 3, except );
|
||||
exceptions |= toBit( "hgv" , 4, except );
|
||||
}
|
||||
|
||||
// System.out.println( "restriction id = " + r.rid + " isPositive=" + isPositive + " fromWid = " + fromWid + " toWid = " + toWid+ " viaNid = " + viaNid );
|
||||
RestrictionData res = new RestrictionData();
|
||||
res.isPositive = isPositive;
|
||||
res.exceptions = exceptions;
|
||||
res.fromWid = fromWid;
|
||||
res.toWid = toWid;
|
||||
res.viaNid = viaNid;
|
||||
|
@ -234,6 +248,11 @@ public class OsmCutter extends MapCreatorBase
|
|||
|
||||
}
|
||||
|
||||
private static short toBit( String tag, int bitpos, String s )
|
||||
{
|
||||
return (short) ( s.indexOf( tag ) < 0 ? 0 : 1 << bitpos );
|
||||
}
|
||||
|
||||
private int getTileIndex( int ilon, int ilat )
|
||||
{
|
||||
int lon = ilon / 45000000;
|
||||
|
|
|
@ -175,6 +175,7 @@ public class OsmNodeP extends OsmLinkP
|
|||
while( r != null )
|
||||
{
|
||||
mc.writeBoolean( true ); // restriction follows
|
||||
mc.writeShort( r.exceptions );
|
||||
mc.writeBoolean( r.isPositive );
|
||||
mc.writeInt( r.fromLon );
|
||||
mc.writeInt( r.fromLat );
|
||||
|
|
|
@ -13,6 +13,7 @@ import btools.util.LongList;
|
|||
public class RestrictionData extends MapCreatorBase
|
||||
{
|
||||
public boolean isPositive;
|
||||
public short exceptions;
|
||||
public long fromWid;
|
||||
public long toWid;
|
||||
public long viaNid;
|
||||
|
@ -31,6 +32,7 @@ public class RestrictionData extends MapCreatorBase
|
|||
public RestrictionData( DataInputStream di ) throws Exception
|
||||
{
|
||||
isPositive = di.readBoolean();
|
||||
exceptions = di.readShort();
|
||||
fromWid = readId( di );
|
||||
toWid = readId( di );
|
||||
viaNid = readId( di );
|
||||
|
@ -39,6 +41,7 @@ public class RestrictionData extends MapCreatorBase
|
|||
public void writeTo( DataOutputStream dos ) throws Exception
|
||||
{
|
||||
dos.writeBoolean( isPositive );
|
||||
dos.writeShort( exceptions );
|
||||
writeId( dos, fromWid );
|
||||
writeId( dos, toWid );
|
||||
writeId( dos, viaNid );
|
||||
|
|
|
@ -149,7 +149,11 @@ final class OsmFile
|
|||
|
||||
int crcData = Crc32.crc( ab, 0, asize - 4 );
|
||||
int crcFooter = new ByteDataReader( ab, asize - 4 ).readInt();
|
||||
if ( ( crcData ^ 2 ) == crcFooter )
|
||||
if ( crcData == crcFooter )
|
||||
{
|
||||
throw new IOException( "old, unsupported data-format" );
|
||||
}
|
||||
else if ( ( crcData ^ 2 ) == crcFooter )
|
||||
{
|
||||
return reallyDecode ? new MicroCache2( dataBuffers, lonIdx, latIdx, divisor, wayValidator, waypointMatcher ) : null;
|
||||
}
|
||||
|
|
|
@ -136,6 +136,7 @@ public class OsmNode extends OsmLink implements OsmPos
|
|||
while( mc.readBoolean() )
|
||||
{
|
||||
TurnRestriction tr = new TurnRestriction();
|
||||
tr.exceptions = mc.readShort();
|
||||
tr.isPositive = mc.readBoolean();
|
||||
tr.fromLon = mc.readInt();
|
||||
tr.fromLat = mc.readInt();
|
||||
|
|
|
@ -8,6 +8,7 @@ package btools.mapaccess;
|
|||
public final class TurnRestriction
|
||||
{
|
||||
public boolean isPositive;
|
||||
public short exceptions;
|
||||
|
||||
public int fromLon;
|
||||
public int fromLat;
|
||||
|
@ -17,6 +18,11 @@ public final class TurnRestriction
|
|||
|
||||
public TurnRestriction next;
|
||||
|
||||
public boolean exceptBikes()
|
||||
{
|
||||
return ( exceptions & 1 ) != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue