use of org.locationtech.jts.geom.CoordinateSequence in project hale by halestudio.
the class ExtendedWKBReader method readLineString.
private LineString readLineString() throws IOException {
int size = dis.readInt();
CoordinateSequence pts = readCoordinateSequence(size);
return factory.createLineString(pts);
}
use of org.locationtech.jts.geom.CoordinateSequence in project hale by halestudio.
the class ExtendedWKBReader method readLinearRing.
private LinearRing readLinearRing() throws IOException {
int size = dis.readInt();
CoordinateSequence pts = readCoordinateSequenceRing(size);
return factory.createLinearRing(pts);
}
use of org.locationtech.jts.geom.CoordinateSequence in project hale by halestudio.
the class ExtendedWKBReader method readCoordinateSequence.
private CoordinateSequence readCoordinateSequence(int size) throws IOException {
CoordinateSequence seq = csFactory.create(size, inputDimension);
int targetDim = seq.getDimension();
if (targetDim > inputDimension)
targetDim = inputDimension;
for (int i = 0; i < size; i++) {
readCoordinate();
for (int j = 0; j < targetDim; j++) {
seq.setOrdinate(i, j, ordValues[j]);
}
}
return seq;
}
use of org.locationtech.jts.geom.CoordinateSequence in project jena by apache.
the class GeometryTransformation method transformPoint.
private static Point transformPoint(Geometry sourceGeometry, MathTransform transform) throws TransformException {
GeometryFactory geometryFactory = sourceGeometry.getFactory();
Point point = (Point) sourceGeometry;
CoordinateSequence coordSeq = point.getCoordinateSequence();
CoordinateSequence transformCoordSeq = transformCoordSeq(coordSeq, transform);
return geometryFactory.createPoint(transformCoordSeq);
}
use of org.locationtech.jts.geom.CoordinateSequence in project sis by apache.
the class Factory method createMultiPolygon.
/**
* Creates a multi-polygon from an array of JTS {@link Polygon} or {@link LinearRing}.
* If some geometries are actually linear rings, they will be converted to polygons.
*
* @param geometries the polygons or linear rings to put in a multi-polygons.
* @throws ClassCastException if an element in the array is not a JTS geometry.
* @throws IllegalArgumentException if an element is a non-closed linear string.
*/
@Override
public GeometryWrapper<Geometry> createMultiPolygon(final Object[] geometries) {
final Polygon[] polygons = new Polygon[geometries.length];
boolean isFloat = true;
for (int i = 0; i < geometries.length; i++) {
final Object polyline = unwrap(geometries[i]);
final Polygon polygon;
if (polyline instanceof Polygon) {
polygon = (Polygon) polyline;
} else {
final boolean fs;
final CoordinateSequence cs;
if (polyline instanceof LinearRing) {
final LinearRing ring = (LinearRing) polyline;
cs = ring.getCoordinateSequence();
fs = isFloat(cs);
polygon = factory(fs).createPolygon(ring);
} else if (polyline instanceof LineString) {
// Let JTS throws an exception with its own error message if the ring is not valid.
cs = ((LineString) polyline).getCoordinateSequence();
fs = isFloat(cs);
polygon = factory(fs).createPolygon(cs);
} else {
throw new ClassCastException(Errors.format(Errors.Keys.IllegalArgumentClass_3, Strings.bracket("geometries", i), Polygon.class, Classes.getClass(polyline)));
}
JTS.copyMetadata((Geometry) polyline, polygon);
isFloat &= fs;
}
polygons[i] = polygon;
}
return new Wrapper(factory(isFloat).createMultiPolygon(polygons));
}
Aggregations