Search in sources :

Example 1 with UniqueCoordinateArrayFilter

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();
}
Also used : UniqueCoordinateArrayFilter(org.locationtech.jts.util.UniqueCoordinateArrayFilter)

Example 2 with UniqueCoordinateArrayFilter

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());
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) GeometryCollection(org.locationtech.jts.geom.GeometryCollection) UniqueCoordinateArrayFilter(org.locationtech.jts.util.UniqueCoordinateArrayFilter) Coordinate(org.locationtech.jts.geom.Coordinate) Point(org.locationtech.jts.geom.Point) Point(org.locationtech.jts.geom.Point) CoordinateArraySequence(org.locationtech.jts.geom.impl.CoordinateArraySequence)

Example 3 with UniqueCoordinateArrayFilter

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();
}
Also used : UniqueCoordinateArrayFilter(org.locationtech.jts.util.UniqueCoordinateArrayFilter)

Example 4 with UniqueCoordinateArrayFilter

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());
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) GeometryCollection(org.locationtech.jts.geom.GeometryCollection) UniqueCoordinateArrayFilter(org.locationtech.jts.util.UniqueCoordinateArrayFilter) Coordinate(org.locationtech.jts.geom.Coordinate) Point(org.locationtech.jts.geom.Point) Point(org.locationtech.jts.geom.Point) CoordinateArraySequence(org.locationtech.jts.geom.impl.CoordinateArraySequence)

Example 5 with UniqueCoordinateArrayFilter

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()));
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) UniqueCoordinateArrayFilter(org.locationtech.jts.util.UniqueCoordinateArrayFilter) Coordinate(org.locationtech.jts.geom.Coordinate) MediaType(io.micronaut.http.MediaType)

Aggregations

UniqueCoordinateArrayFilter (org.locationtech.jts.util.UniqueCoordinateArrayFilter)5 Coordinate (org.locationtech.jts.geom.Coordinate)3 Geometry (org.locationtech.jts.geom.Geometry)3 GeometryCollection (org.locationtech.jts.geom.GeometryCollection)2 Point (org.locationtech.jts.geom.Point)2 CoordinateArraySequence (org.locationtech.jts.geom.impl.CoordinateArraySequence)2 MediaType (io.micronaut.http.MediaType)1