diff --git a/brouter-core/src/main/java/btools/router/RoutingContext.java b/brouter-core/src/main/java/btools/router/RoutingContext.java index 1e0b27d..be0fe55 100644 --- a/brouter-core/src/main/java/btools/router/RoutingContext.java +++ b/brouter-core/src/main/java/btools/router/RoutingContext.java @@ -347,22 +347,30 @@ public final class RoutingContext } if ( nogo.isNogo ) { - if (Double.isNaN(nogo.nogoWeight)) - { - // Nogo is default nogo (ignore completely) + if (!(nogo instanceof OsmNogoPolygon)) { // nogo is a circle + if (Double.isNaN(nogo.nogoWeight)) { + // default nogo behaviour (ignore completely) nogoCost = -1; - } - else if (!(nogo instanceof OsmNogoPolygon)) { - // nogo is a circle, compute distance within the circle - nogoCost = nogo.distanceWithinRadius(lon1, lat1, lon2, lat2, d) * nogo.nogoWeight; + } else { + // nogo weight, compute distance within the circle + nogoCost = nogo.distanceWithinRadius(lon1, lat1, lon2, lat2, d) * nogo.nogoWeight; + } } else if (((OsmNogoPolygon)nogo).intersects(lon1, lat1, lon2, lat2)) { - // nogo is a polygon, compute distance within the polygon - if (((OsmNogoPolygon)nogo).isClosed) { - nogoCost = ((OsmNogoPolygon)nogo).distanceWithinPolygon(lon1, lat1, lon2, lat2) * nogo.nogoWeight; + // nogo is a polyline/polygon, we have to check there is indeed + // an intersection in this case (radius check is not enough). + if (Double.isNaN(nogo.nogoWeight)) { + // default nogo behaviour (ignore completely) + nogoCost = -1; } 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; + } } } }