Keep a cost of -1 for nogos which should never been entered to prevent them from being fed in the priority queue
This commit is contained in:
parent
910d6a0870
commit
3479fd7323
5 changed files with 37 additions and 25 deletions
|
@ -17,8 +17,12 @@ public class OsmNodeNamed extends OsmNode
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
|
if ( Double.isNaN(nogoWeight ) ) {
|
||||||
|
return ilon + "," + ilat + "," + name;
|
||||||
|
} else {
|
||||||
return ilon + "," + ilat + "," + name + "," + nogoWeight;
|
return ilon + "," + ilat + "," + name + "," + nogoWeight;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static OsmNodeNamed decodeNogo( String s )
|
public static OsmNodeNamed decodeNogo( String s )
|
||||||
{
|
{
|
||||||
|
@ -30,7 +34,7 @@ public class OsmNodeNamed extends OsmNode
|
||||||
int idx3 = s.indexOf( ',', idx2+1 );
|
int idx3 = s.indexOf( ',', idx2+1 );
|
||||||
if ( idx3 == -1) {
|
if ( idx3 == -1) {
|
||||||
n.name = s.substring( idx2 + 1 );
|
n.name = s.substring( idx2 + 1 );
|
||||||
n.nogoWeight = 100000;
|
n.nogoWeight = Double.NaN;
|
||||||
} else {
|
} else {
|
||||||
n.name = s.substring( idx2+1, idx3 );
|
n.name = s.substring( idx2+1, idx3 );
|
||||||
n.nogoWeight = Double.parseDouble( s.substring( idx3 + 1 ) );
|
n.nogoWeight = Double.parseDouble( s.substring( idx3 + 1 ) );
|
||||||
|
|
|
@ -427,8 +427,12 @@ abstract class OsmPath implements OsmLinkHolder
|
||||||
}
|
}
|
||||||
if ( rc.nogomatch != null )
|
if ( rc.nogomatch != null )
|
||||||
{
|
{
|
||||||
|
if ( Double.isNaN(rc.nogomatch.nogoWeight) ) {
|
||||||
|
cost = -1;
|
||||||
|
} else {
|
||||||
cost += rc.nogomatch.nogoWeight;
|
cost += rc.nogomatch.nogoWeight;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -462,8 +466,13 @@ abstract class OsmPath implements OsmLinkHolder
|
||||||
// check for nogo-matches (after the *actual* start of segment)
|
// check for nogo-matches (after the *actual* start of segment)
|
||||||
if ( rc.nogomatch != null )
|
if ( rc.nogomatch != null )
|
||||||
{
|
{
|
||||||
|
if ( Double.isNaN(rc.nogomatch.nogoWeight) ) {
|
||||||
|
cost = -1;
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
cost += rc.nogomatch.nogoWeight;
|
cost += rc.nogomatch.nogoWeight;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// add target-node costs
|
// add target-node costs
|
||||||
double targetCost = processTargetNode( rc );
|
double targetCost = processTargetNode( rc );
|
||||||
|
|
|
@ -180,7 +180,6 @@ final class StdPath extends OsmPath
|
||||||
return 0.;
|
return 0.;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int elevationCorrection( RoutingContext rc )
|
public int elevationCorrection( RoutingContext rc )
|
||||||
{
|
{
|
||||||
|
|
|
@ -305,9 +305,9 @@ System.out.println( "*** finishedOffsets = " + finishedOffsets );
|
||||||
}
|
}
|
||||||
|
|
||||||
// calc distance and check nogos
|
// calc distance and check nogos
|
||||||
rc.nogomatch = false;
|
rc.nogomatch = null;
|
||||||
int distance = rc.calcDistance( currentNode.ilon, currentNode.ilat, node.ilon, node.ilat );
|
int distance = rc.calcDistance( currentNode.ilon, currentNode.ilat, node.ilon, node.ilat );
|
||||||
if ( rc.nogomatch )
|
if ( rc.nogomatch != null )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -222,7 +222,7 @@ public class ServerHandler extends RequestHandler {
|
||||||
for (int i = 0; i < lonLatRadList.length; i++)
|
for (int i = 0; i < lonLatRadList.length; i++)
|
||||||
{
|
{
|
||||||
String[] lonLatRad = lonLatRadList[i].split(",");
|
String[] lonLatRad = lonLatRadList[i].split(",");
|
||||||
String nogoWeight = "100000";
|
String nogoWeight = "NaN";
|
||||||
if (lonLatRad.length > 3) {
|
if (lonLatRad.length > 3) {
|
||||||
nogoWeight = lonLatRad[3];
|
nogoWeight = lonLatRad[3];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue