use of org.opentripplanner.graph_builder.annotation.BogusEdgeGeometry in project OpenTripPlanner by opentripplanner.
the class CheckGeometryModule method buildGraph.
@Override
public void buildGraph(Graph graph, HashMap<Class<?>, Object> extra) {
for (Vertex gv : graph.getVertices()) {
if (Double.isNaN(gv.getCoordinate().x) || Double.isNaN(gv.getCoordinate().y)) {
LOG.warn("Vertex " + gv + " has NaN location; this will cause doom.");
LOG.warn(graph.addBuilderAnnotation(new BogusVertexGeometry(gv)));
}
// TODO: This was filtered to EdgeNarratives before EdgeNarrative removal
for (Edge e : gv.getOutgoing()) {
Geometry g = e.getGeometry();
if (g == null) {
continue;
}
for (Coordinate c : g.getCoordinates()) {
if (Double.isNaN(c.x) || Double.isNaN(c.y)) {
LOG.warn(graph.addBuilderAnnotation(new BogusEdgeGeometry(e)));
}
}
if (e instanceof HopEdge) {
Coordinate edgeStartCoord = e.getFromVertex().getCoordinate();
Coordinate edgeEndCoord = e.getToVertex().getCoordinate();
Coordinate[] geometryCoordinates = g.getCoordinates();
if (geometryCoordinates.length < 2) {
LOG.warn(graph.addBuilderAnnotation(new BogusEdgeGeometry(e)));
continue;
}
Coordinate geometryStartCoord = geometryCoordinates[0];
Coordinate geometryEndCoord = geometryCoordinates[geometryCoordinates.length - 1];
if (SphericalDistanceLibrary.distance(edgeStartCoord, geometryStartCoord) > MAX_VERTEX_SHAPE_ERROR) {
LOG.warn(graph.addBuilderAnnotation(new VertexShapeError(e)));
} else if (SphericalDistanceLibrary.distance(edgeEndCoord, geometryEndCoord) > MAX_VERTEX_SHAPE_ERROR) {
LOG.warn(graph.addBuilderAnnotation(new VertexShapeError(e)));
}
}
}
}
}
Aggregations