tr details, ele interpolation
This commit is contained in:
parent
0641a17b9c
commit
de5f70b9d9
3 changed files with 41 additions and 31 deletions
|
@ -96,17 +96,12 @@ public final class MicroCache2 extends MicroCache
|
|||
|
||||
if ( featureId == 1 ) // turn-restriction
|
||||
{
|
||||
if ( bitsize != 1 + 4*29 )
|
||||
{
|
||||
throw new RuntimeException( "turn-restriction of unexpected bit-size: " + bitsize );
|
||||
}
|
||||
writeBoolean( true );
|
||||
writeBoolean( bc.decodeBit() ); // isPositive
|
||||
int max = (1 << 29) - 1;
|
||||
writeInt( bc.decodeBounded( max ) ); // fromLon, ...
|
||||
writeInt( bc.decodeBounded( max ) );
|
||||
writeInt( bc.decodeBounded( max ) );
|
||||
writeInt( bc.decodeBounded( max ) );
|
||||
writeInt( ilon + bc.decodeNoisyDiff( 10 ) ); // fromLon
|
||||
writeInt( ilat + bc.decodeNoisyDiff( 10 ) ); // fromLat
|
||||
writeInt( ilon + bc.decodeNoisyDiff( 10 ) ); // toLon
|
||||
writeInt( ilat + bc.decodeNoisyDiff( 10 ) ); // toLat
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -312,6 +307,7 @@ public final class MicroCache2 extends MicroCache
|
|||
|
||||
IntegerFifo3Pass linkCounts = new IntegerFifo3Pass( 256 );
|
||||
IntegerFifo3Pass transCounts = new IntegerFifo3Pass( 256 );
|
||||
IntegerFifo3Pass restrictionBits = new IntegerFifo3Pass( 16 );
|
||||
|
||||
TagValueCoder wayTagCoder = new TagValueCoder();
|
||||
TagValueCoder nodeTagCoder = new TagValueCoder();
|
||||
|
@ -334,6 +330,7 @@ public final class MicroCache2 extends MicroCache
|
|||
|
||||
linkCounts.init();
|
||||
transCounts.init();
|
||||
restrictionBits.init();
|
||||
|
||||
wayTagCoder.encodeDictionary( bc );
|
||||
if ( dostats ) bc.assignBits( "wayTagDictionary" );
|
||||
|
@ -360,18 +357,22 @@ public final class MicroCache2 extends MicroCache
|
|||
aboffsetEnd = fapos[n];
|
||||
if ( dodebug ) System.out.println( "*** encoding node " + n + " from " + aboffset + " to " + aboffsetEnd );
|
||||
|
||||
long id64 = expandId( faid[n] );
|
||||
int ilon = (int)(id64 >> 32);
|
||||
int ilat = (int)(id64 & 0xffffffff);
|
||||
|
||||
// write turn restrictions
|
||||
while( readBoolean() )
|
||||
{
|
||||
bc.encodeVarBits( 1 ); // 1 = extra-data type : turn-restriction
|
||||
bc.encodeNoisyNumber( 1 + 4*29, 5 );
|
||||
|
||||
bc.encodeNoisyNumber( restrictionBits.getNext(), 5 ); // bit-count using looku-ahead fifo
|
||||
long b0 = bc.getWritingBitPosition();
|
||||
bc.encodeBit( readBoolean() ); // isPositive
|
||||
int max = (1 << 29) - 1;
|
||||
bc.encodeBounded( max, readInt() ); // fromLon
|
||||
bc.encodeBounded( max, readInt() ); // fromLat
|
||||
bc.encodeBounded( max, readInt() ); // toLon
|
||||
bc.encodeBounded( max, readInt() ); // toLat
|
||||
bc.encodeNoisyDiff( readInt() - ilon, 10 ); // fromLon
|
||||
bc.encodeNoisyDiff( readInt() - ilat, 10 ); // fromLat
|
||||
bc.encodeNoisyDiff( readInt() - ilon, 10 ); // toLon
|
||||
bc.encodeNoisyDiff( readInt() - ilat, 10 ); // toLat
|
||||
restrictionBits.add( (int)( bc.getWritingBitPosition() - b0 ) );
|
||||
}
|
||||
bc.encodeVarBits( 0 ); // end of extra data
|
||||
|
||||
|
@ -387,11 +388,7 @@ public final class MicroCache2 extends MicroCache
|
|||
if ( dodebug ) System.out.println( "*** nlinks=" + nlinks );
|
||||
bc.encodeNoisyNumber( nlinks, 1 );
|
||||
if ( dostats ) bc.assignBits( "link-counts" );
|
||||
|
||||
long id64 = expandId( faid[n] );
|
||||
int ilon = (int)(id64 >> 32);
|
||||
int ilat = (int)(id64 & 0xffffffff);
|
||||
|
||||
|
||||
nlinks = 0;
|
||||
while( hasMoreData() ) // loop over links
|
||||
{
|
||||
|
|
|
@ -170,8 +170,6 @@ final class OsmPath implements OsmLinkHolder
|
|||
cost += iicost;
|
||||
}
|
||||
|
||||
// OsmTransferNode transferNode = link.decodeGeometry( p1, rc.byteDataReaderGeometry, rc.transferNodeCache );
|
||||
|
||||
OsmTransferNode transferNode = link.geometry == null ? null
|
||||
: rc.geometryDecoder.decodeGeometry( link.geometry, p1, targetNode, isReverse );
|
||||
|
||||
|
@ -200,9 +198,18 @@ final class OsmPath implements OsmLinkHolder
|
|||
}
|
||||
|
||||
// check turn restrictions: do we have one with that origin?
|
||||
if ( isFirstSection && rc.considerTurnRestrictions )
|
||||
boolean checkTRs = false;
|
||||
if ( isFirstSection )
|
||||
{
|
||||
isFirstSection = false;
|
||||
|
||||
// TODO: TRs for inverse routing would need inverse TR logic,
|
||||
// inverse routing for now just for target island check, so don't care (?)
|
||||
checkTRs = rc.considerTurnRestrictions && !rc.inverseDirection;
|
||||
}
|
||||
|
||||
if ( checkTRs )
|
||||
{
|
||||
boolean hasAnyPositive = false;
|
||||
boolean hasPositive = false;
|
||||
boolean hasNegative = false;
|
||||
|
@ -244,15 +251,13 @@ final class OsmPath implements OsmLinkHolder
|
|||
}
|
||||
|
||||
int dist = rc.calcDistance( lon1, lat1, lon2, lat2 );
|
||||
int elefactor = 250000;
|
||||
boolean stopAtEndpoint = false;
|
||||
if ( rc.shortestmatch )
|
||||
{
|
||||
elefactor = (int)(elefactor*rc.wayfraction);
|
||||
|
||||
if ( rc.isEndpoint )
|
||||
{
|
||||
stopAtEndpoint = true;
|
||||
ele2 = interpolateEle( ele1, ele2, rc.wayfraction );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -267,7 +272,8 @@ final class OsmPath implements OsmLinkHolder
|
|||
{
|
||||
if ( rc.wayfraction > 0. )
|
||||
{
|
||||
originElement = OsmPathElement.create( rc.ilonshortest, rc.ilatshortest, ele2, null, rc.countTraffic );
|
||||
ele1 = interpolateEle( ele1, ele2, 1. - rc.wayfraction );
|
||||
originElement = OsmPathElement.create( rc.ilonshortest, rc.ilatshortest, ele1, null, rc.countTraffic );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -313,6 +319,7 @@ final class OsmPath implements OsmLinkHolder
|
|||
// only the part of the descend that does not fit into the elevation-hysteresis-buffer
|
||||
// leads to an immediate penalty
|
||||
|
||||
int elefactor = 250000;
|
||||
if ( ele2 == Short.MIN_VALUE ) ele2 = ele1;
|
||||
if ( ele1 != Short.MIN_VALUE )
|
||||
{
|
||||
|
@ -502,6 +509,15 @@ final class OsmPath implements OsmLinkHolder
|
|||
|
||||
}
|
||||
|
||||
public short interpolateEle( short e1, short e2, double fraction )
|
||||
{
|
||||
if ( e1 == Short.MIN_VALUE || e2 == Short.MIN_VALUE )
|
||||
{
|
||||
return Short.MIN_VALUE;
|
||||
}
|
||||
return (short)( e1*(1.-fraction) + e2*fraction );
|
||||
}
|
||||
|
||||
public int elevationCorrection( RoutingContext rc )
|
||||
{
|
||||
return ( rc.downhillcostdiv > 0 ? ehbd/rc.downhillcostdiv : 0 )
|
||||
|
|
|
@ -143,9 +143,6 @@ public class OsmNode extends OsmLink implements OsmPos
|
|||
tr.toLat = mc.readInt();
|
||||
tr.next = firstRestriction;
|
||||
firstRestriction = tr;
|
||||
|
||||
System.out.println( "decoded tr: " + tr );
|
||||
|
||||
}
|
||||
|
||||
selev = mc.readShort();
|
||||
|
|
Loading…
Reference in a new issue