Fix an incorrect handling of default nogo behavior for lines or polygons.
Fix #154
This commit is contained in:
parent
fc97754c90
commit
c8e8b9d421
1 changed files with 19 additions and 11 deletions
|
@ -347,22 +347,30 @@ public final class RoutingContext
|
||||||
}
|
}
|
||||||
if ( nogo.isNogo )
|
if ( nogo.isNogo )
|
||||||
{
|
{
|
||||||
if (Double.isNaN(nogo.nogoWeight))
|
if (!(nogo instanceof OsmNogoPolygon)) { // nogo is a circle
|
||||||
{
|
if (Double.isNaN(nogo.nogoWeight)) {
|
||||||
// Nogo is default nogo (ignore completely)
|
// default nogo behaviour (ignore completely)
|
||||||
nogoCost = -1;
|
nogoCost = -1;
|
||||||
}
|
} else {
|
||||||
else if (!(nogo instanceof OsmNogoPolygon)) {
|
// nogo weight, compute distance within the circle
|
||||||
// nogo is a circle, compute distance within the circle
|
nogoCost = nogo.distanceWithinRadius(lon1, lat1, lon2, lat2, d) * nogo.nogoWeight;
|
||||||
nogoCost = nogo.distanceWithinRadius(lon1, lat1, lon2, lat2, d) * nogo.nogoWeight;
|
}
|
||||||
}
|
}
|
||||||
else if (((OsmNogoPolygon)nogo).intersects(lon1, lat1, lon2, lat2))
|
else if (((OsmNogoPolygon)nogo).intersects(lon1, lat1, lon2, lat2))
|
||||||
{
|
{
|
||||||
// nogo is a polygon, compute distance within the polygon
|
// nogo is a polyline/polygon, we have to check there is indeed
|
||||||
if (((OsmNogoPolygon)nogo).isClosed) {
|
// an intersection in this case (radius check is not enough).
|
||||||
nogoCost = ((OsmNogoPolygon)nogo).distanceWithinPolygon(lon1, lat1, lon2, lat2) * nogo.nogoWeight;
|
if (Double.isNaN(nogo.nogoWeight)) {
|
||||||
|
// default nogo behaviour (ignore completely)
|
||||||
|
nogoCost = -1;
|
||||||
} else {
|
} else {
|
||||||
nogoCost = nogo.nogoWeight;
|
if (((OsmNogoPolygon)nogo).isClosed) {
|
||||||
|
// compute distance within the polygon
|
||||||
|
nogoCost = ((OsmNogoPolygon)nogo).distanceWithinPolygon(lon1, lat1, lon2, lat2) * nogo.nogoWeight;
|
||||||
|
} else {
|
||||||
|
// for a polyline, just add a constant penalty
|
||||||
|
nogoCost = nogo.nogoWeight;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue