org.opentripplanner.common.geometry.GraphUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of otp Show documentation
Show all versions of otp Show documentation
The OpenTripPlanner multimodal journey planning system
package org.opentripplanner.common.geometry;
import java.util.Collection;
import org.locationtech.jts.algorithm.ConvexHull;
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.geom.GeometryCollection;
import org.locationtech.jts.geom.GeometryFactory;
import org.opentripplanner.routing.graph.Graph;
import org.opentripplanner.routing.graph.Vertex;
import org.opentripplanner.util.geometry.GeometryUtils;
public class GraphUtils {
public static Geometry makeConvexHull(Graph graph) {
return new ConvexHull(geometryCollectionFromVertices(graph)).getConvexHull();
}
private static GeometryCollection geometryCollectionFromVertices(Graph graph) {
GeometryFactory gf = GeometryUtils.getGeometryFactory();
Collection vertices = graph.getVertices();
Geometry[] points = new Geometry[vertices.size()];
int i = 0;
for (Vertex v : vertices) {
points[i++] = gf.createPoint(v.getCoordinate());
}
return new GeometryCollection(points, gf);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy