Search in sources :

Example 6 with CoordinateSequence

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);
}
Also used : CoordinateSequence(org.locationtech.jts.geom.CoordinateSequence) Point(org.locationtech.jts.geom.Point) MultiPoint(org.locationtech.jts.geom.MultiPoint)

Example 7 with CoordinateSequence

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);
}
Also used : CoordinateSequence(org.locationtech.jts.geom.CoordinateSequence) Point(org.locationtech.jts.geom.Point) MultiPoint(org.locationtech.jts.geom.MultiPoint)

Example 8 with CoordinateSequence

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;
}
Also used : CoordinateSequence(org.locationtech.jts.geom.CoordinateSequence) Point(org.locationtech.jts.geom.Point) MultiPoint(org.locationtech.jts.geom.MultiPoint)

Example 9 with CoordinateSequence

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);
}
Also used : CoordinateSequence(org.locationtech.jts.geom.CoordinateSequence) GeometryFactory(org.locationtech.jts.geom.GeometryFactory) Point(org.locationtech.jts.geom.Point) MultiPoint(org.locationtech.jts.geom.MultiPoint)

Example 10 with CoordinateSequence

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));
}
Also used : CoordinateSequence(org.locationtech.jts.geom.CoordinateSequence) GeometryWrapper(org.apache.sis.internal.feature.GeometryWrapper) MultiLineString(org.locationtech.jts.geom.MultiLineString) LineString(org.locationtech.jts.geom.LineString) Polygon(org.locationtech.jts.geom.Polygon) MultiPolygon(org.locationtech.jts.geom.MultiPolygon) LinearRing(org.locationtech.jts.geom.LinearRing) Point(org.locationtech.jts.geom.Point) MultiPoint(org.locationtech.jts.geom.MultiPoint)

Aggregations

CoordinateSequence (org.locationtech.jts.geom.CoordinateSequence)10 MultiPoint (org.locationtech.jts.geom.MultiPoint)5 Point (org.locationtech.jts.geom.Point)5 GeometryFactory (org.locationtech.jts.geom.GeometryFactory)3 Coordinate (org.locationtech.jts.geom.Coordinate)2 LineString (org.locationtech.jts.geom.LineString)2 LinearRing (org.locationtech.jts.geom.LinearRing)2 MultiLineString (org.locationtech.jts.geom.MultiLineString)2 GeometryWrapper (org.apache.sis.internal.feature.GeometryWrapper)1 CoordinateSequenceFactory (org.locationtech.jts.geom.CoordinateSequenceFactory)1 MultiPolygon (org.locationtech.jts.geom.MultiPolygon)1 Polygon (org.locationtech.jts.geom.Polygon)1