@Override public boolean intersect(Shape o) { if (o instanceof Circle) { return intersect((Circle) o); } else if (o instanceof BBox) { return intersect((BBox) o); } return o.intersect(this); }
GHPoint center = shape.getCenter(); QueryResult qr = locationIndex.findClosest(center.getLat(), center.getLon(), filter); throw new IllegalArgumentException("Shape " + shape + " does not cover graph"); if (shape.contains(qr.getSnappedPoint().lat, qr.getSnappedPoint().lon)) edgeIds.add(qr.getClosestEdge().getEdge());
private boolean isInsideBBox(int nodeId) { BBox bbox = localShape.getBounds(); double lat = na.getLatitude(nodeId); double lon = na.getLongitude(nodeId); return lat <= bbox.maxLat && lat >= bbox.minLat && lon <= bbox.maxLon && lon >= bbox.minLon; } };
@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); }
/** * 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()); }
/** * @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 public boolean intersect(Shape o) { if (o instanceof Circle) { return intersect((Circle) o); } else if (o instanceof BBox) { return intersect((BBox) o); } return o.intersect(this); }
private boolean isInsideBBox(int nodeId) { BBox bbox = localShape.getBounds(); double lat = na.getLatitude(nodeId); double lon = na.getLongitude(nodeId); return lat <= bbox.maxLat && lat >= bbox.minLat && lon <= bbox.maxLon && lon >= bbox.minLon; } };
GHPoint center = shape.getCenter(); QueryResult qr = locationIndex.findClosest(center.getLat(), center.getLon(), filter); 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 public boolean intersect( Shape o ) { if (o instanceof Circle) { return intersect((Circle) o); } else if (o instanceof BBox) { return intersect((BBox) o); } return o.intersect(this); }
@Override protected boolean goFurther(int nodeId) { if (isPolygon) return isInsideBBox(nodeId); return localShape.contains(na.getLatitude(nodeId), na.getLongitude(nodeId)); }
@Override public boolean intersect(Shape o) { if (o instanceof Circle) { return intersect((Circle) o); } else if (o instanceof BBox) { return intersect((BBox) o); } return o.intersect(this); }
@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; } };
if (shape.contains(na.getLatitude(edgeState.getAdjNode()), na.getLongitude(edgeState.getAdjNode()))) { return Double.POSITIVE_INFINITY;