destination access logic

This commit is contained in:
Arndt Brenschede 2018-05-31 23:08:24 +02:00
parent 7881952682
commit 10931da3a7
4 changed files with 92 additions and 7 deletions

View file

@ -46,9 +46,34 @@ abstract class OsmPath implements OsmLinkHolder
// the classifier of the segment just before this paths position // the classifier of the segment just before this paths position
protected float lastClassifier; protected float lastClassifier;
protected float lastInitialCost;
protected int priorityclassifier; protected int priorityclassifier;
private static final int PATH_START_BIT = 1;
private static final int CAN_LEAVE_DESTINATION_BIT = 2;
private static final int IS_ON_DESTINATION_BIT = 4;
private static final int HAD_DESTINATION_START_BIT = 8;
protected int bitfield = PATH_START_BIT;
private boolean getBit( int mask )
{
return (bitfield & mask ) != 0;
}
private void setBit( int mask, boolean bit )
{
if ( getBit( mask ) != bit )
{
bitfield ^= mask;
}
}
public boolean didEnterDestinationArea()
{
return !getBit( HAD_DESTINATION_START_BIT ) && getBit( IS_ON_DESTINATION_BIT );
}
public MessageData message; public MessageData message;
public void unregisterUpTree( RoutingContext rc ) public void unregisterUpTree( RoutingContext rc )
@ -99,6 +124,8 @@ abstract class OsmPath implements OsmLinkHolder
this.targetNode = link.getTarget( sourceNode ); this.targetNode = link.getTarget( sourceNode );
this.cost = origin.cost; this.cost = origin.cost;
this.lastClassifier = origin.lastClassifier; this.lastClassifier = origin.lastClassifier;
this.lastInitialCost = origin.lastInitialCost;
this.bitfield = origin.bitfield;
init( origin ); init( origin );
addAddionalPenalty(refTrack, detailMode, origin, link, rc ); addAddionalPenalty(refTrack, detailMode, origin, link, rc );
} }
@ -140,15 +167,20 @@ abstract class OsmPath implements OsmLinkHolder
boolean isTrafficBackbone = cost == 0 && rc.expctxWay.getIsTrafficBackbone() > 0.f; boolean isTrafficBackbone = cost == 0 && rc.expctxWay.getIsTrafficBackbone() > 0.f;
int lastpriorityclassifier = priorityclassifier; int lastpriorityclassifier = priorityclassifier;
priorityclassifier = (int)rc.expctxWay.getPriorityClassifier(); priorityclassifier = (int)rc.expctxWay.getPriorityClassifier();
int classifiermask = (int)rc.expctxWay.getClassifierMask();
// *** add initial cost if the classifier changed // *** add initial cost if the classifier changed
float newClassifier = rc.expctxWay.getInitialClassifier(); float newClassifier = rc.expctxWay.getInitialClassifier();
float newInitialCost = rc.expctxWay.getInitialcost();
float classifierDiff = newClassifier - lastClassifier; float classifierDiff = newClassifier - lastClassifier;
if ( classifierDiff > 0.0005 || classifierDiff < -0.0005 ) if ( newClassifier != 0. && lastClassifier != 0. && ( classifierDiff > 0.0005 || classifierDiff < -0.0005 ) )
{ {
lastClassifier = newClassifier; float initialcost = rc.inverseDirection ? lastInitialCost : newInitialCost;
float initialcost = rc.expctxWay.getInitialcost(); if ( initialcost >= 1000000. )
{
cost = -1;
return;
}
int iicost = (int)initialcost; int iicost = (int)initialcost;
if ( message != null ) if ( message != null )
{ {
@ -156,6 +188,36 @@ abstract class OsmPath implements OsmLinkHolder
} }
cost += iicost; cost += iicost;
} }
lastClassifier = newClassifier;
lastInitialCost = newInitialCost;
// *** destination logic: no destination access in between
int classifiermask = (int)rc.expctxWay.getClassifierMask();
boolean newDestination = (classifiermask & 64) != 0;
boolean oldDestination = getBit( IS_ON_DESTINATION_BIT );
if ( getBit( PATH_START_BIT ) )
{
setBit( PATH_START_BIT, false );
setBit( CAN_LEAVE_DESTINATION_BIT, newDestination );
setBit( HAD_DESTINATION_START_BIT, newDestination );
}
else
{
if ( oldDestination && !newDestination )
{
if ( getBit( CAN_LEAVE_DESTINATION_BIT ) )
{
setBit( CAN_LEAVE_DESTINATION_BIT, false );
}
else
{
cost = -1;
return;
}
}
}
setBit( IS_ON_DESTINATION_BIT, newDestination );
OsmTransferNode transferNode = link.geometry == null ? null OsmTransferNode transferNode = link.geometry == null ? null
: rc.geometryDecoder.decodeGeometry( link.geometry, sourceNode, targetNode, isReverse ); : rc.geometryDecoder.decodeGeometry( link.geometry, sourceNode, targetNode, isReverse );

View file

@ -903,7 +903,10 @@ public class RoutingEngine extends Thread
long currentNodeId = currentNode.getIdFromPos(); long currentNodeId = currentNode.getIdFromPos();
long sourceNodeId = sourceNode.getIdFromPos(); long sourceNodeId = sourceNode.getIdFromPos();
islandNodePairs.addTempPair( sourceNodeId, currentNodeId ); if ( !path.didEnterDestinationArea() )
{
islandNodePairs.addTempPair( sourceNodeId, currentNodeId );
}
if ( path.treedepth != 1 ) if ( path.treedepth != 1 )
{ {

View file

@ -52,6 +52,15 @@ assign caraccess
motor_vehicle=yes|permissive|designated|destination motor_vehicle=yes|permissive|designated|destination
motorcar=yes|permissive|designated|destination motorcar=yes|permissive|designated|destination
assign caraccess_destination
switch motorcar=
switch motor_vehicle=
switch vehicle=
access=destination
vehicle=destination
motor_vehicle=destination
motorcar=destination
assign accessspeedlimit = if caraccess then 999 else 0 assign accessspeedlimit = if caraccess then 999 else 0
assign isbadoneway = if reversedirection=yes then ( if oneway= then junction=roundabout else oneway=yes|true|1 ) else oneway=-1 assign isbadoneway = if reversedirection=yes then ( if oneway= then junction=roundabout else oneway=yes|true|1 ) else oneway=-1
@ -150,7 +159,8 @@ assign classifiermask add isbadoneway
add multiply isroundabout 4 add multiply isroundabout 4
add multiply islinktype 8 add multiply islinktype 8
add multiply isgoodforcars 16 add multiply isgoodforcars 16
multiply highway=residential|living_street 32 add multiply highway=residential|living_street 32
multiply caraccess_destination 64
---context:node # following code refers to node tags ---context:node # following code refers to node tags

View file

@ -52,6 +52,15 @@ assign caraccess
motor_vehicle=yes|permissive|designated|destination motor_vehicle=yes|permissive|designated|destination
motorcar=yes|permissive|designated|destination motorcar=yes|permissive|designated|destination
assign caraccess_destination
switch motorcar=
switch motor_vehicle=
switch vehicle=
access=destination
vehicle=destination
motor_vehicle=destination
motorcar=destination
assign accessspeedlimit = if caraccess then 999 else 0 assign accessspeedlimit = if caraccess then 999 else 0
assign isbadoneway = if reversedirection=yes then ( if oneway= then junction=roundabout else oneway=yes|true|1 ) else oneway=-1 assign isbadoneway = if reversedirection=yes then ( if oneway= then junction=roundabout else oneway=yes|true|1 ) else oneway=-1
@ -150,7 +159,8 @@ assign classifiermask add isbadoneway
add multiply isroundabout 4 add multiply isroundabout 4
add multiply islinktype 8 add multiply islinktype 8
add multiply isgoodforcars 16 add multiply isgoodforcars 16
multiply highway=residential|living_street 32 add multiply highway=residential|living_street 32
multiply caraccess_destination 64
---context:node # following code refers to node tags ---context:node # following code refers to node tags