Search in sources :

Example 1 with SurfaceProperty

use of org.geotoolkit.gml.xml.SurfaceProperty in project geotoolkit by Geomatys.

the class JAXPStreamFeatureWriter method setId.

/**
 * @param inc auto increment value, ids must be unique
 */
private void setId(AbstractGeometry gmlGeometry, String id) {
    if (gmlGeometry.getId() == null || gmlGeometry.getId().isEmpty()) {
        // do not override ids if they exist
        gmlGeometry.setId(id + (gidInc));
        gidInc++;
    }
    if (gmlGeometry instanceof MultiCurve) {
        for (CurveProperty po : ((MultiCurve) gmlGeometry).getCurveMember()) {
            final AbstractCurve child = po.getAbstractCurve();
            if (child instanceof AbstractGeometry) {
                setId((AbstractGeometry) child, id);
            }
        }
    } else if (gmlGeometry instanceof MultiSurface) {
        for (SurfaceProperty po : ((MultiSurface) gmlGeometry).getSurfaceMember()) {
            final AbstractSurface child = po.getAbstractSurface();
            if (child instanceof AbstractGeometry) {
                setId((AbstractGeometry) child, id);
            }
        }
    } else if (gmlGeometry instanceof MultiGeometryType) {
        for (GeometryPropertyType po : ((MultiGeometryType) gmlGeometry).getGeometryMember()) {
            final AbstractGeometryType child = po.getAbstractGeometry();
            if (child instanceof AbstractGeometry) {
                setId((AbstractGeometry) child, id);
            }
        }
    } else if (gmlGeometry instanceof MultiSolidType) {
        for (SolidPropertyType po : ((MultiSolidType) gmlGeometry).getSolidMember()) {
            final AbstractSolidType child = po.getAbstractSolid().getValue();
            if (child instanceof AbstractGeometry) {
                setId((AbstractGeometry) child, id);
            }
        }
    } else if (gmlGeometry instanceof MultiPointType) {
        for (PointPropertyType po : ((MultiPointType) gmlGeometry).getPointMember()) {
            final PointType child = po.getPoint();
            if (child instanceof AbstractGeometry) {
                setId((AbstractGeometry) child, id);
            }
        }
    }
}
Also used : AbstractGeometry(org.geotoolkit.gml.xml.AbstractGeometry) MultiSurface(org.geotoolkit.gml.xml.MultiSurface) AbstractGeometryType(org.geotoolkit.gml.xml.v321.AbstractGeometryType) MultiGeometryType(org.geotoolkit.gml.xml.v321.MultiGeometryType) MultiPointType(org.geotoolkit.gml.xml.v321.MultiPointType) AbstractSurface(org.geotoolkit.gml.xml.AbstractSurface) CurveProperty(org.geotoolkit.gml.xml.CurveProperty) AbstractSolidType(org.geotoolkit.gml.xml.v321.AbstractSolidType) MultiCurve(org.geotoolkit.gml.xml.MultiCurve) SurfaceProperty(org.geotoolkit.gml.xml.SurfaceProperty) SolidPropertyType(org.geotoolkit.gml.xml.v321.SolidPropertyType) PointType(org.geotoolkit.gml.xml.v321.PointType) MultiPointType(org.geotoolkit.gml.xml.v321.MultiPointType) AbstractCurve(org.geotoolkit.gml.xml.AbstractCurve) PointPropertyType(org.geotoolkit.gml.xml.v321.PointPropertyType) GeometryPropertyType(org.geotoolkit.gml.xml.v321.GeometryPropertyType) MultiSolidType(org.geotoolkit.gml.xml.v321.MultiSolidType)

Example 2 with SurfaceProperty

use of org.geotoolkit.gml.xml.SurfaceProperty in project geotoolkit by Geomatys.

the class GeometryTransformer method convertMultiSurface.

private MultiPolygon convertMultiSurface(final MultiSurface mp) {
    Polygon[] polys;
    try {
        polys = mp.getSurfaceMember().stream().map(SurfaceProperty::getAbstractSurface).map(surface -> {
            if (surface instanceof AbstractGeometry) {
                return (AbstractGeometry) surface;
            }
            throw new UnconvertibleObjectException("We cannot convert a non-geometric object: " + surface.getClass());
        }).map(p -> new GeometryTransformer(p, this).get()).map(Polygon.class::cast).toArray(size -> new Polygon[size]);
    } catch (ClassCastException e) {
        throw new UnconvertibleObjectException("Cannot create a multi-surface, because some of its components are not polygons", e);
    }
    final MultiPolygon result = GF.createMultiPolygon(polys);
    applyCRS(result);
    return result;
}
Also used : Measure(org.apache.sis.internal.jaxb.gml.Measure) Unit(javax.measure.Unit) CRS(org.apache.sis.referencing.CRS) GeodeticCalculator(org.apache.sis.referencing.GeodeticCalculator) Spliterators(java.util.Spliterators) NoSuchAuthorityCodeException(org.opengis.referencing.NoSuchAuthorityCodeException) Coordinate(org.locationtech.jts.geom.Coordinate) MeasureType(org.geotoolkit.gml.xml.v321.MeasureType) PolygonPatchType(org.geotoolkit.gml.xml.v321.PolygonPatchType) Envelope(org.geotoolkit.gml.xml.Envelope) Matcher(java.util.regex.Matcher) SingleCRS(org.opengis.referencing.crs.SingleCRS) GeometryProperty(org.geotoolkit.gml.xml.GeometryProperty) Map(java.util.Map) Ring(org.geotoolkit.gml.xml.Ring) TransformException(org.opengis.referencing.operation.TransformException) MultiLineString(org.locationtech.jts.geom.MultiLineString) AxesConvention(org.apache.sis.referencing.cs.AxesConvention) AbstractCRS(org.apache.sis.referencing.crs.AbstractCRS) Logger(java.util.logging.Logger) MultiSurface(org.geotoolkit.gml.xml.MultiSurface) Objects(java.util.Objects) Cache(org.apache.sis.util.collection.Cache) List(java.util.List) Stream(java.util.stream.Stream) UnconvertibleObjectException(org.apache.sis.util.UnconvertibleObjectException) Polygon(org.locationtech.jts.geom.Polygon) Optional(java.util.Optional) Geometry(org.locationtech.jts.geom.Geometry) SurfaceType(org.geotoolkit.gml.xml.v321.SurfaceType) Pattern(java.util.regex.Pattern) Spliterator(java.util.Spliterator) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) FactoryException(org.opengis.util.FactoryException) MultiPolygon(org.locationtech.jts.geom.MultiPolygon) Coordinates(org.geotoolkit.gml.xml.Coordinates) PointProperty(org.geotoolkit.gml.xml.PointProperty) ArgumentChecks(org.apache.sis.util.ArgumentChecks) DoubleFunction(java.util.function.DoubleFunction) LinearRing(org.locationtech.jts.geom.LinearRing) HashMap(java.util.HashMap) DirectPositionList(org.geotoolkit.gml.xml.DirectPositionList) Function(java.util.function.Function) Supplier(java.util.function.Supplier) CurveProperty(org.geotoolkit.gml.xml.CurveProperty) MultiGeometry(org.geotoolkit.gml.xml.MultiGeometry) ArrayList(java.util.ArrayList) Angle(javax.measure.quantity.Angle) AbstractGeometry(org.geotoolkit.gml.xml.AbstractGeometry) Length(javax.measure.quantity.Length) GeneralDirectPosition(org.apache.sis.geometry.GeneralDirectPosition) AbstractCurveSegment(org.geotoolkit.gml.xml.AbstractCurveSegment) WithCoordinates(org.geotoolkit.gml.xml.WithCoordinates) AxisDirections(org.apache.sis.internal.referencing.AxisDirections) PointPropertyType(org.geotoolkit.gml.xml.v321.PointPropertyType) CurveSegmentArrayProperty(org.geotoolkit.gml.xml.CurveSegmentArrayProperty) StreamSupport(java.util.stream.StreamSupport) Point(org.geotoolkit.gml.xml.Point) NoSuchElementException(java.util.NoSuchElementException) DirectPosition(org.opengis.geometry.DirectPosition) Units(org.apache.sis.measure.Units) GeometryFactory(org.locationtech.jts.geom.GeometryFactory) Iterator(java.util.Iterator) PolygonProperty(org.geotoolkit.gml.xml.PolygonProperty) JTS(org.geotoolkit.geometry.jts.JTS) AbstractSurface(org.geotoolkit.gml.xml.AbstractSurface) Consumer(java.util.function.Consumer) MultiCurve(org.geotoolkit.gml.xml.MultiCurve) GeometryCollection(org.locationtech.jts.geom.GeometryCollection) LineString(org.locationtech.jts.geom.LineString) AbstractMap(java.util.AbstractMap) ArcByCenterPointType(org.geotoolkit.gml.xml.v321.ArcByCenterPointType) Curve(org.geotoolkit.gml.xml.Curve) AbstractRingProperty(org.geotoolkit.gml.xml.AbstractRingProperty) MultiPoint(org.locationtech.jts.geom.MultiPoint) SurfaceProperty(org.geotoolkit.gml.xml.SurfaceProperty) Collections(java.util.Collections) LineStringProperty(org.geotoolkit.gml.xml.LineStringProperty) AbstractRing(org.geotoolkit.gml.xml.AbstractRing) UnconvertibleObjectException(org.apache.sis.util.UnconvertibleObjectException) AbstractGeometry(org.geotoolkit.gml.xml.AbstractGeometry) MultiPolygon(org.locationtech.jts.geom.MultiPolygon) Polygon(org.locationtech.jts.geom.Polygon) MultiPolygon(org.locationtech.jts.geom.MultiPolygon)

Aggregations

AbstractGeometry (org.geotoolkit.gml.xml.AbstractGeometry)2 AbstractSurface (org.geotoolkit.gml.xml.AbstractSurface)2 CurveProperty (org.geotoolkit.gml.xml.CurveProperty)2 MultiCurve (org.geotoolkit.gml.xml.MultiCurve)2 MultiSurface (org.geotoolkit.gml.xml.MultiSurface)2 SurfaceProperty (org.geotoolkit.gml.xml.SurfaceProperty)2 PointPropertyType (org.geotoolkit.gml.xml.v321.PointPropertyType)2 AbstractMap (java.util.AbstractMap)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 NoSuchElementException (java.util.NoSuchElementException)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 Spliterator (java.util.Spliterator)1 Spliterators (java.util.Spliterators)1 Consumer (java.util.function.Consumer)1