Search in sources :

Example 1 with UniqueCoordinateArrayFilter

use of com.vividsolutions.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(com.vividsolutions.jts.geom.Geometry) GeometryCollection(com.vividsolutions.jts.geom.GeometryCollection) UniqueCoordinateArrayFilter(com.vividsolutions.jts.util.UniqueCoordinateArrayFilter) Coordinate(com.vividsolutions.jts.geom.Coordinate) Point(com.vividsolutions.jts.geom.Point) Point(com.vividsolutions.jts.geom.Point) CoordinateArraySequence(com.vividsolutions.jts.geom.impl.CoordinateArraySequence)

Example 2 with UniqueCoordinateArrayFilter

use of com.vividsolutions.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(com.vividsolutions.jts.geom.Geometry) GeometryCollection(com.vividsolutions.jts.geom.GeometryCollection) UniqueCoordinateArrayFilter(com.vividsolutions.jts.util.UniqueCoordinateArrayFilter) Coordinate(com.vividsolutions.jts.geom.Coordinate) Point(com.vividsolutions.jts.geom.Point) Point(com.vividsolutions.jts.geom.Point) CoordinateArraySequence(com.vividsolutions.jts.geom.impl.CoordinateArraySequence)

Aggregations

Coordinate (com.vividsolutions.jts.geom.Coordinate)2 Geometry (com.vividsolutions.jts.geom.Geometry)2 GeometryCollection (com.vividsolutions.jts.geom.GeometryCollection)2 Point (com.vividsolutions.jts.geom.Point)2 CoordinateArraySequence (com.vividsolutions.jts.geom.impl.CoordinateArraySequence)2 UniqueCoordinateArrayFilter (com.vividsolutions.jts.util.UniqueCoordinateArrayFilter)2