Search in sources :

Example 16 with GeometryCollection

use of org.locationtech.jts.geom.GeometryCollection in project hale by halestudio.

the class StyledInstanceMarker method getPathIterator.

/**
 * Returns a path iterator.
 *
 * @param shape a shape to determine the iterator
 * @return the path iterator
 */
private PathIterator getPathIterator(final LiteShape2 shape) {
    // DJB: changed this to handle multi* geometries and line and
    // polygon geometries better
    GeometryCollection gc;
    if (shape.getGeometry() instanceof GeometryCollection)
        gc = (GeometryCollection) shape.getGeometry();
    else {
        Geometry[] gs = new Geometry[1];
        gs[0] = shape.getGeometry();
        // make a Point,Line, or Poly into a GC
        gc = shape.getGeometry().getFactory().createGeometryCollection(gs);
    }
    AffineTransform IDENTITY_TRANSFORM = new AffineTransform();
    GeomCollectionIterator citer = new GeomCollectionIterator(gc, IDENTITY_TRANSFORM, false, 1.0);
    return citer;
}
Also used : GeometryCollection(org.locationtech.jts.geom.GeometryCollection) Geometry(org.locationtech.jts.geom.Geometry) AffineTransform(java.awt.geom.AffineTransform) GeomCollectionIterator(org.geotools.geometry.jts.GeomCollectionIterator)

Example 17 with GeometryCollection

use of org.locationtech.jts.geom.GeometryCollection in project hale by halestudio.

the class WindingOrderTest method testUnifyGeometryCollection.

/**
 * Test winding order of GeometryCollection
 */
@Test
public void testUnifyGeometryCollection() {
    Geometry result = WindingOrder.unifyWindingOrder(clockWise4, true, null);
    assertTrue(result instanceof GeometryCollection);
    assertFalse(clockWise4.equalsExact(result));
    assertTrue(((GeometryCollection) result).getNumGeometries() == clockWise4.getNumGeometries());
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) GeometryCollection(org.locationtech.jts.geom.GeometryCollection) Test(org.junit.Test)

Example 18 with GeometryCollection

use of org.locationtech.jts.geom.GeometryCollection in project series-rest-api by 52North.

the class GeoJSONTest method testCrs.

private void testCrs(int parent, int child) throws GeoJSONException {
    final GeometryCollection col = geometryFactory.createGeometryCollection(new Geometry[] { randomPoint(child) });
    col.setSRID(parent);
    readWriteTest(col);
}
Also used : GeometryCollection(org.locationtech.jts.geom.GeometryCollection)

Example 19 with GeometryCollection

use of org.locationtech.jts.geom.GeometryCollection in project ddf by codice.

the class DynamicSchemaResolver method createCenterPoint.

private String createCenterPoint(List<Serializable> values) {
    WKTReader reader = new WKTReader(GEOMETRY_FACTORY);
    List<Geometry> geometries = new ArrayList<>();
    for (Serializable serializable : values) {
        String wkt = serializable.toString();
        try {
            geometries.add(reader.read(wkt));
        } catch (ParseException e) {
            LOGGER.debug("Failed to read WKT, skipping: {}", wkt, e);
        }
    }
    if (geometries.isEmpty()) {
        return null;
    }
    Point centerPoint;
    if (geometries.size() > 1) {
        GeometryCollection geoCollection = GEOMETRY_FACTORY.createGeometryCollection(geometries.toArray(new Geometry[0]));
        centerPoint = geoCollection.getCentroid();
    } else {
        centerPoint = geometries.get(0).getCentroid();
    }
    if (centerPoint == null || centerPoint.isEmpty()) {
        return null;
    }
    return normalize(centerPoint);
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) GeometryCollection(org.locationtech.jts.geom.GeometryCollection) Serializable(java.io.Serializable) ArrayList(java.util.ArrayList) ParseException(org.locationtech.jts.io.ParseException) Point(org.locationtech.jts.geom.Point) WKTReader(org.locationtech.jts.io.WKTReader)

Example 20 with GeometryCollection

use of org.locationtech.jts.geom.GeometryCollection in project jena by apache.

the class GeometryTransformation method transformGeometryCollection.

private static GeometryCollection transformGeometryCollection(Geometry sourceGeometry, MathTransform transform) throws TransformException {
    GeometryFactory geometryFactory = sourceGeometry.getFactory();
    GeometryCollection geometryCollection = (GeometryCollection) sourceGeometry;
    int geometryNumber = geometryCollection.getNumGeometries();
    ArrayList<Geometry> geometries = new ArrayList<>();
    for (int i = 0; i < geometryNumber; i++) {
        Geometry geometry = transform(geometryCollection.getGeometryN(i), transform);
        geometries.add(geometry);
    }
    return geometryFactory.createGeometryCollection(geometries.toArray(new Geometry[geometries.size()]));
}
Also used : GeometryCollection(org.locationtech.jts.geom.GeometryCollection) Geometry(org.locationtech.jts.geom.Geometry) GeometryFactory(org.locationtech.jts.geom.GeometryFactory) ArrayList(java.util.ArrayList) Point(org.locationtech.jts.geom.Point) MultiPoint(org.locationtech.jts.geom.MultiPoint)

Aggregations

GeometryCollection (org.locationtech.jts.geom.GeometryCollection)23 Geometry (org.locationtech.jts.geom.Geometry)13 Point (org.locationtech.jts.geom.Point)7 LineString (org.locationtech.jts.geom.LineString)6 Polygon (org.locationtech.jts.geom.Polygon)6 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)3 MultiLineString (org.locationtech.jts.geom.MultiLineString)3 MultiPoint (org.locationtech.jts.geom.MultiPoint)3 MultiPolygon (org.locationtech.jts.geom.MultiPolygon)3 OGCConcreteGeometryCollection (com.esri.core.geometry.ogc.OGCConcreteGeometryCollection)2 OGCGeometry (com.esri.core.geometry.ogc.OGCGeometry)2 OGCGeometry.createFromEsriGeometry (com.esri.core.geometry.ogc.OGCGeometry.createFromEsriGeometry)2 GeometryType (com.facebook.presto.geospatial.GeometryType)2 GeometryUtils.jsonFromJtsGeometry (com.facebook.presto.geospatial.GeometryUtils.jsonFromJtsGeometry)2 GeometryUtils.wktFromJtsGeometry (com.facebook.presto.geospatial.GeometryUtils.wktFromJtsGeometry)2 Description (com.facebook.presto.spi.function.Description)2 ScalarFunction (com.facebook.presto.spi.function.ScalarFunction)2 SqlNullable (com.facebook.presto.spi.function.SqlNullable)2 SqlType (com.facebook.presto.spi.function.SqlType)2