@Override protected boolean goFurther(int nodeId) { if (isPolygon) return isInsideBBox(nodeId); return localShape.contains(na.getLatitude(nodeId), na.getLongitude(nodeId)); }
/** * @return true if the specified edgeState is part of this BlockArea */ public final boolean contains(EdgeIteratorState edgeState) { if (!blockedEdges.isEmpty() && blockedEdges.contains(edgeState.getEdge())) { return true; } if (!blockedShapes.isEmpty() && na != null) { for (Shape shape : blockedShapes) { if (shape.contains(na.getLatitude(edgeState.getAdjNode()), na.getLongitude(edgeState.getAdjNode()))) return true; } } return false; } }
@Override protected boolean checkAdjacent(EdgeIteratorState edge) { int adjNodeId = edge.getAdjNode(); if (localShape.contains(na.getLatitude(adjNodeId), na.getLongitude(adjNodeId))) { edgeIds.add(edge.getEdge()); return true; } return isPolygon && isInsideBBox(adjNodeId); }
throw new IllegalArgumentException("Shape " + shape + " does not cover graph"); if (shape.contains(qr.getSnappedPoint().lat, qr.getSnappedPoint().lon)) edgeIds.add(qr.getClosestEdge().getEdge());
@Override protected boolean goFurther(int nodeId) { return localShape.contains(na.getLatitude(nodeId), na.getLongitude(nodeId)); }
@Override protected boolean goFurther(int nodeId) { if (isPolygon) return isInsideBBox(nodeId); return localShape.contains(na.getLatitude(nodeId), na.getLongitude(nodeId)); }
@Override protected boolean checkAdjacent(EdgeIteratorState edge) { int adjNodeId = edge.getAdjNode(); if (localShape.contains(na.getLatitude(adjNodeId), na.getLongitude(adjNodeId))) { edgeIds.add(edge.getEdge()); return true; } return isPolygon && isInsideBBox(adjNodeId); }
/** * @return true if the specified edgeState is part of this BlockArea */ public final boolean contains(EdgeIteratorState edgeState) { if (!blockedEdges.isEmpty() && blockedEdges.contains(edgeState.getEdge())) { return true; } if (!blockedShapes.isEmpty() && na != null) { for (Shape shape : blockedShapes) { if (shape.contains(na.getLatitude(edgeState.getAdjNode()), na.getLongitude(edgeState.getAdjNode()))) return true; } } return false; } }
@Override protected boolean checkAdjacent(EdgeIteratorState edge) { if (localShape.contains(na.getLatitude(edge.getAdjNode()), na.getLongitude(edge.getAdjNode()))) { edgeIds.add(edge.getEdge()); return true; } return false; } };
/** * This method fills the edgeIds hash with edgeIds found inside the specified shape */ public void findEdgesInShape(final GHIntHashSet edgeIds, final Shape shape, EdgeFilter filter) { GHPoint center = shape.getCenter(); QueryResult qr = locationIndex.findClosest(center.getLat(), center.getLon(), filter); // TODO: if there is no street close to the center it'll fail although there are roads covered. Maybe we should check edge points or some random points in the Shape instead? if (!qr.isValid()) throw new IllegalArgumentException("Shape " + shape + " does not cover graph"); if (shape.contains(qr.getSnappedPoint().lat, qr.getSnappedPoint().lon)) edgeIds.add(qr.getClosestEdge().getEdge()); BreadthFirstSearch bfs = new BreadthFirstSearch() { final NodeAccess na = graph.getNodeAccess(); final Shape localShape = shape; @Override protected boolean goFurther(int nodeId) { return localShape.contains(na.getLatitude(nodeId), na.getLongitude(nodeId)); } @Override protected boolean checkAdjacent(EdgeIteratorState edge) { if (localShape.contains(na.getLatitude(edge.getAdjNode()), na.getLongitude(edge.getAdjNode()))) { edgeIds.add(edge.getEdge()); return true; } return false; } }; bfs.start(graph.createEdgeExplorer(filter), qr.getClosestNode()); }
throw new IllegalArgumentException("Shape " + shape + " does not cover graph"); if (shape.contains(qr.getSnappedPoint().lat, qr.getSnappedPoint().lon)) edgeIds.add(qr.getClosestEdge().getEdge());
if (shape.contains(na.getLatitude(edgeState.getAdjNode()), na.getLongitude(edgeState.getAdjNode()))) { return Double.POSITIVE_INFINITY;