Search in sources :

Example 6 with JTSGeometry

use of org.geotoolkit.geometry.isoonjts.spatialschema.geometry.JTSGeometry in project geotoolkit by Geomatys.

the class JTSCurve method computeJTSPeer.

/**
 * {@inheritDoc }
 */
@Override
protected org.locationtech.jts.geom.Geometry computeJTSPeer() {
    // For each segment that comprises us, get the JTS peer.
    int n = curveSegments.size();
    ArrayList allCoords = new ArrayList();
    for (int i = 0; i < n; i++) {
        JTSGeometry g = (JTSGeometry) curveSegments.get(i);
        org.locationtech.jts.geom.LineString jts = (org.locationtech.jts.geom.LineString) g.getJTSGeometry();
        int m = jts.getNumPoints();
        for (int j = 0; j < m; j++) {
            allCoords.add(jts.getCoordinateN(j));
        }
        if (i != (n - 1))
            allCoords.remove(allCoords.size() - 1);
    }
    org.locationtech.jts.geom.Coordinate[] coords = new org.locationtech.jts.geom.Coordinate[allCoords.size()];
    allCoords.toArray(coords);
    return JTSUtils.GEOMETRY_FACTORY.createLineString(coords);
}
Also used : JTSLineString(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.geometry.JTSLineString) LineString(org.opengis.geometry.coordinate.LineString) NotifyingArrayList(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.NotifyingArrayList) JTSGeometry(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.JTSGeometry) AbstractJTSGeometry(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.AbstractJTSGeometry) ParamForPoint(org.opengis.geometry.coordinate.ParamForPoint)

Example 7 with JTSGeometry

use of org.geotoolkit.geometry.isoonjts.spatialschema.geometry.JTSGeometry in project geotoolkit by Geomatys.

the class JTSMultiPolygon method computeJTSPeer.

/**
 * {@inheritDoc }
 */
@Override
protected org.locationtech.jts.geom.Geometry computeJTSPeer() {
    List<org.locationtech.jts.geom.Geometry> childParts = new ArrayList<org.locationtech.jts.geom.Geometry>();
    for (Polygon prim : elements) {
        if (prim instanceof JTSGeometry) {
            JTSGeometry jtsGeom = (JTSGeometry) prim;
            childParts.add(jtsGeom.getJTSGeometry());
        } else {
            throw new IllegalStateException("Only JTSGeometries are allowed in the JTSMultiPolygon class.");
        }
    }
    // we want a multi geometry event if there is only one geometry
    if (childParts.size() == 1) {
        org.locationtech.jts.geom.Geometry geom = childParts.get(0);
        if (geom instanceof org.locationtech.jts.geom.Polygon) {
            return JTSUtils.GEOMETRY_FACTORY.createMultiPolygon(new org.locationtech.jts.geom.Polygon[] { (org.locationtech.jts.geom.Polygon) geom });
        }
    }
    return JTSUtils.GEOMETRY_FACTORY.buildGeometry(childParts);
}
Also used : JTSGeometry(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.JTSGeometry) AbstractJTSGeometry(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.AbstractJTSGeometry) JTSPolygon(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.geometry.JTSPolygon) Polygon(org.opengis.geometry.coordinate.Polygon) JTSGeometry(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.JTSGeometry) AbstractJTSGeometry(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.AbstractJTSGeometry)

Example 8 with JTSGeometry

use of org.geotoolkit.geometry.isoonjts.spatialschema.geometry.JTSGeometry in project geotoolkit by Geomatys.

the class JTSSurface method computeJTSPeer.

/**
 * {@inheritDoc }
 */
@Override
protected org.locationtech.jts.geom.Geometry computeJTSPeer() {
    if (patches.size() > 1) {
        // throw new UnsupportedOperationException("This implementation does not support surfaces with multiple patches.");
        final org.locationtech.jts.geom.Polygon[] polygons = new org.locationtech.jts.geom.Polygon[patches.size()];
        for (int i = 0; i < patches.size(); i++) {
            final JTSGeometry jtsGeometry = (JTSGeometry) patches.get(i);
            polygons[i] = (org.locationtech.jts.geom.Polygon) jtsGeometry.getJTSGeometry();
        }
        return JTSUtils.GEOMETRY_FACTORY.createMultiPolygon(polygons);
    }
    return ((JTSGeometry) patches.get(0)).getJTSGeometry();
}
Also used : JTSGeometry(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.JTSGeometry) AbstractJTSGeometry(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.AbstractJTSGeometry)

Aggregations

JTSGeometry (org.geotoolkit.geometry.isoonjts.spatialschema.geometry.JTSGeometry)8 AbstractJTSGeometry (org.geotoolkit.geometry.isoonjts.spatialschema.geometry.AbstractJTSGeometry)6 JTSLineString (org.geotoolkit.geometry.isoonjts.spatialschema.geometry.geometry.JTSLineString)2 JTSPolygon (org.geotoolkit.geometry.isoonjts.spatialschema.geometry.geometry.JTSPolygon)2 LineString (org.locationtech.jts.geom.LineString)2 Point (org.locationtech.jts.geom.Point)2 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)2 List (java.util.List)1 JAXBElement (javax.xml.bind.JAXBElement)1 JAXBException (javax.xml.bind.JAXBException)1 Unmarshaller (javax.xml.bind.Unmarshaller)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 NotifyingArrayList (org.geotoolkit.geometry.isoonjts.spatialschema.geometry.NotifyingArrayList)1 JTSMultiCurve (org.geotoolkit.geometry.isoonjts.spatialschema.geometry.aggregate.JTSMultiCurve)1 AbstractGeometry (org.geotoolkit.gml.xml.AbstractGeometry)1 LineStringPosListType (org.geotoolkit.internal.jaxb.LineStringPosListType)1 PolygonType (org.geotoolkit.internal.jaxb.PolygonType)1 Geometry (org.locationtech.jts.geom.Geometry)1 MultiLineString (org.locationtech.jts.geom.MultiLineString)1 MultiPoint (org.locationtech.jts.geom.MultiPoint)1