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,7 +17,11 @@ public class OsmNodeNamed extends OsmNode
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
return ilon + "," + ilat + "," + name + "," + nogoWeight;
|
if ( Double.isNaN(nogoWeight ) ) {
|
||||||
|
return ilon + "," + ilat + "," + name;
|
||||||
|
} else {
|
||||||
|
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,7 +427,11 @@ abstract class OsmPath implements OsmLinkHolder
|
||||||
}
|
}
|
||||||
if ( rc.nogomatch != null )
|
if ( rc.nogomatch != null )
|
||||||
{
|
{
|
||||||
cost += rc.nogomatch.nogoWeight;
|
if ( Double.isNaN(rc.nogomatch.nogoWeight) ) {
|
||||||
|
cost = -1;
|
||||||
|
} else {
|
||||||
|
cost += rc.nogomatch.nogoWeight;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -462,7 +466,12 @@ 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 )
|
||||||
{
|
{
|
||||||
cost += rc.nogomatch.nogoWeight;
|
if ( Double.isNaN(rc.nogomatch.nogoWeight) ) {
|
||||||
|
cost = -1;
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
cost += rc.nogomatch.nogoWeight;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// add target-node costs
|
// add target-node costs
|
||||||
|
|
|
@ -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 )
|
||||||
{
|
{
|
||||||
|
|
|
@ -45,7 +45,7 @@ final class ScheduledRouter
|
||||||
|
|
||||||
private static List<Iternity> trips = new ArrayList<Iternity>();
|
private static List<Iternity> trips = new ArrayList<Iternity>();
|
||||||
private static long oldChecksum = 0;
|
private static long oldChecksum = 0;
|
||||||
|
|
||||||
private String startEndText()
|
private String startEndText()
|
||||||
{
|
{
|
||||||
return (start == null ? "unmatched" : start.getName() ) + "->" + (end == null ? "unmatched" : end.getName() );
|
return (start == null ? "unmatched" : start.getName() ) + "->" + (end == null ? "unmatched" : end.getName() );
|
||||||
|
@ -69,11 +69,11 @@ final class ScheduledRouter
|
||||||
|
|
||||||
// check for identical params
|
// check for identical params
|
||||||
long[] nogocheck = rc.getNogoChecksums();
|
long[] nogocheck = rc.getNogoChecksums();
|
||||||
|
|
||||||
long checksum = nogocheck[0] + nogocheck[1] + nogocheck[2];
|
long checksum = nogocheck[0] + nogocheck[1] + nogocheck[2];
|
||||||
checksum += startPos.getILat() + startPos.getILon() + endPos.getILat() + endPos.getILon();
|
checksum += startPos.getILat() + startPos.getILon() + endPos.getILat() + endPos.getILon();
|
||||||
checksum += rc.localFunction.hashCode();
|
checksum += rc.localFunction.hashCode();
|
||||||
|
|
||||||
if ( checksum != oldChecksum )
|
if ( checksum != oldChecksum )
|
||||||
{
|
{
|
||||||
trips = _findRoute( startPos, endPos, false );
|
trips = _findRoute( startPos, endPos, false );
|
||||||
|
@ -86,7 +86,7 @@ final class ScheduledRouter
|
||||||
if ( linksProcessed + linksReProcessed > 5000000 ) throw new RuntimeException( "5 million links limit reached" );
|
if ( linksProcessed + linksReProcessed > 5000000 ) throw new RuntimeException( "5 million links limit reached" );
|
||||||
else throw new RuntimeException( "no track found! (" + startEndText() + ")" );
|
else throw new RuntimeException( "no track found! (" + startEndText() + ")" );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( alternativeIdx == 0 ) // = result overview
|
if ( alternativeIdx == 0 ) // = result overview
|
||||||
{
|
{
|
||||||
List<String> details = new ArrayList<String>();
|
List<String> details = new ArrayList<String>();
|
||||||
|
@ -101,15 +101,15 @@ final class ScheduledRouter
|
||||||
t.iternity = details;
|
t.iternity = details;
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
int idx = alternativeIdx > trips.size() ? trips.size()-1 : alternativeIdx-1;
|
int idx = alternativeIdx > trips.size() ? trips.size()-1 : alternativeIdx-1;
|
||||||
Iternity iternity = trips.get( idx );
|
Iternity iternity = trips.get( idx );
|
||||||
OsmTrack t = iternity.track;
|
OsmTrack t = iternity.track;
|
||||||
t.iternity = iternity.details;
|
t.iternity = iternity.details;
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private List<Iternity> _findRoute( OsmPos startPos, OsmPos endPos, boolean fastStop ) throws Exception
|
private List<Iternity> _findRoute( OsmPos startPos, OsmPos endPos, boolean fastStop ) throws Exception
|
||||||
{
|
{
|
||||||
List<Iternity> iternities = new ArrayList<Iternity>();
|
List<Iternity> iternities = new ArrayList<Iternity>();
|
||||||
|
@ -120,7 +120,7 @@ final class ScheduledRouter
|
||||||
end = graph.matchNodeForPosition( endPos, rc.expctxWay, rc.transitonly );
|
end = graph.matchNodeForPosition( endPos, rc.expctxWay, rc.transitonly );
|
||||||
if ( end == null )
|
if ( end == null )
|
||||||
throw new IllegalArgumentException( "unmatched end: " + endPos );
|
throw new IllegalArgumentException( "unmatched end: " + endPos );
|
||||||
|
|
||||||
time0 = System.currentTimeMillis() + (long) ( rc.starttimeoffset * 60000L );
|
time0 = System.currentTimeMillis() + (long) ( rc.starttimeoffset * 60000L );
|
||||||
long minutes0 = ( time0 + 59999L ) / 60000L;
|
long minutes0 = ( time0 + 59999L ) / 60000L;
|
||||||
time0 = minutes0 * 60000L;
|
time0 = minutes0 * 60000L;
|
||||||
|
@ -170,8 +170,8 @@ final class ScheduledRouter
|
||||||
OffsetSet offsets = trip.offsets.ensureMaxOffset( maxOffset );
|
OffsetSet offsets = trip.offsets.ensureMaxOffset( maxOffset );
|
||||||
if ( offsets == null )
|
if ( offsets == null )
|
||||||
continue;
|
continue;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
OffsetSet offsets = trip.offsets;
|
OffsetSet offsets = trip.offsets;
|
||||||
|
|
||||||
// check global closure
|
// check global closure
|
||||||
|
@ -240,7 +240,7 @@ System.out.println( "*** added track to result list !**** ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
System.out.println( "*** finishedOffsets = " + finishedOffsets );
|
System.out.println( "*** finishedOffsets = " + finishedOffsets );
|
||||||
|
|
||||||
}
|
}
|
||||||
for ( OsmLinkP link = currentNode.getFirstLink(); link != null; link = link.getNext( currentNode ) )
|
for ( OsmLinkP link = currentNode.getFirstLink(); link != null; link = link.getNext( currentNode ) )
|
||||||
{
|
{
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -483,7 +483,7 @@ System.out.println( "*** finishedOffsets = " + finishedOffsets );
|
||||||
|
|
||||||
int distance = 0;
|
int distance = 0;
|
||||||
long departure = 0;
|
long departure = 0;
|
||||||
|
|
||||||
ScheduledTrip itrip = null;
|
ScheduledTrip itrip = null;
|
||||||
|
|
||||||
String profile = extractProfile( rc.localFunction );
|
String profile = extractProfile( rc.localFunction );
|
||||||
|
@ -496,7 +496,7 @@ System.out.println( "*** finishedOffsets = " + finishedOffsets );
|
||||||
while (current != null)
|
while (current != null)
|
||||||
{
|
{
|
||||||
departure = current.departure;
|
departure = current.departure;
|
||||||
|
|
||||||
// System.out.println( "trip=" + current );
|
// System.out.println( "trip=" + current );
|
||||||
OsmNodeP node = current.getTargetNode();
|
OsmNodeP node = current.getTargetNode();
|
||||||
OsmPathElement pe = OsmPathElement.create( node.ilon, node.ilat, node.selev, null, false );
|
OsmPathElement pe = OsmPathElement.create( node.ilon, node.ilat, node.selev, null, false );
|
||||||
|
@ -569,18 +569,18 @@ System.out.println( "*** finishedOffsets = " + finishedOffsets );
|
||||||
iternity.details.add( "depart: " + df.format( d0 ) + " " + stationName );
|
iternity.details.add( "depart: " + df.format( d0 ) + " " + stationName );
|
||||||
iternity.details.add( " --- " + lineName + " ---" );
|
iternity.details.add( " --- " + lineName + " ---" );
|
||||||
iternity.details.add( "arrive: " + df.format( d1 ) + " " + nextStationName );
|
iternity.details.add( "arrive: " + df.format( d1 ) + " " + nextStationName );
|
||||||
|
|
||||||
if ( !iternity.lines.contains( lineName ) )
|
if ( !iternity.lines.contains( lineName ) )
|
||||||
{
|
{
|
||||||
iternity.lines.add( lineName );
|
iternity.lines.add( lineName );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
iternity.track = track;
|
iternity.track = track;
|
||||||
iternity.arrivaltime = time0 + 60000L * offset + trip.arrival;
|
iternity.arrivaltime = time0 + 60000L * offset + trip.arrival;
|
||||||
iternity.departtime = time0 + 60000L * offset + departure;
|
iternity.departtime = time0 + 60000L * offset + departure;
|
||||||
|
|
||||||
return iternity;
|
return iternity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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