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;
}
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());
}
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);
}
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);
}
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()]));
}
Aggregations