use of org.locationtech.jts.util.UniqueCoordinateArrayFilter in project h2gis by orbisgis.
the class FullConvexHull method extractCoordinates.
private static Coordinate[] extractCoordinates(Geometry geom) {
UniqueCoordinateArrayFilter filter = new UniqueCoordinateArrayFilter();
geom.apply(filter);
return filter.getCoordinates();
}
use of org.locationtech.jts.util.UniqueCoordinateArrayFilter in project OpenTripPlanner by opentripplanner.
the class ConcaveHull method transformIntoPointGeometryCollection.
/**
* Transform into GeometryCollection.
*
* @param geom
* input geometry
* @return
* a geometry collection
*/
private static GeometryCollection transformIntoPointGeometryCollection(Geometry geom) {
UniqueCoordinateArrayFilter filter = new UniqueCoordinateArrayFilter();
geom.apply(filter);
Coordinate[] coord = filter.getCoordinates();
Geometry[] geometries = new Geometry[coord.length];
for (int i = 0; i < coord.length; i++) {
Coordinate[] c = new Coordinate[] { coord[i] };
CoordinateArraySequence cs = new CoordinateArraySequence(c);
geometries[i] = new Point(cs, geom.getFactory());
}
return new GeometryCollection(geometries, geom.getFactory());
}
use of org.locationtech.jts.util.UniqueCoordinateArrayFilter in project jts by locationtech.
the class ConvexHull method extractCoordinates.
private static Coordinate[] extractCoordinates(Geometry geom) {
UniqueCoordinateArrayFilter filter = new UniqueCoordinateArrayFilter();
geom.apply(filter);
return filter.getCoordinates();
}
use of org.locationtech.jts.util.UniqueCoordinateArrayFilter in project OpenTripPlanner by opentripplanner.
the class ConcaveHull method transformIntoPointGeometryCollection.
/**
* Transform into GeometryCollection.
*
* @param geom
* input geometry
* @return
* a geometry collection
*/
private static GeometryCollection transformIntoPointGeometryCollection(GeometryCollection gc) {
UniqueCoordinateArrayFilter filter = new UniqueCoordinateArrayFilter();
gc.apply(filter);
Coordinate[] coord = filter.getCoordinates();
Geometry[] geometries = new Geometry[coord.length];
for (int i = 0; i < coord.length; i++) {
Coordinate[] c = new Coordinate[] { coord[i] };
CoordinateArraySequence cs = new CoordinateArraySequence(c);
geometries[i] = new Point(cs, gc.getFactory());
}
return new GeometryCollection(geometries, gc.getFactory());
}
use of org.locationtech.jts.util.UniqueCoordinateArrayFilter in project geometry-ws by jericks.
the class CoordinatesController method coordinates.
private HttpResponse coordinates(String from, String to, String geometryString, boolean isUnique) throws Exception {
GeometryReader reader = GeometryReaders.find(from);
GeometryWriter writer = GeometryWriters.find(to);
Geometry geometry = reader.read(geometryString);
Coordinate[] coords = geometry.getCoordinates();
Geometry outputGeometry = geometry.getFactory().createMultiPointFromCoords(coords);
if (isUnique) {
UniqueCoordinateArrayFilter coordinateFilter = new UniqueCoordinateArrayFilter();
outputGeometry.apply(coordinateFilter);
outputGeometry = geometry.getFactory().createMultiPointFromCoords(coordinateFilter.getCoordinates());
}
String content = writer.write(outputGeometry);
return HttpResponse.ok(content).contentType(new MediaType(writer.getMediaType()));
}
Aggregations