Search in sources :

Example 1 with CurvePropertyType

use of org.geotoolkit.gml.xml.v311.CurvePropertyType in project ddf by codice.

the class Wfs20JTStoGML321Converter method convertToRingType.

public static RingType convertToRingType(LinearRing line, String srsName) {
    RingType ringType = GML320_OBJECT_FACTORY.createRingType();
    CurvePropertyType curvePropertyType = GML320_OBJECT_FACTORY.createCurvePropertyType();
    LineStringType curve = convertToLineStringType(line, srsName);
    JAXBElement<LineStringType> lineStringTypeJAXBElement = GML320_OBJECT_FACTORY.createLineString(curve);
    curvePropertyType.setAbstractCurve(lineStringTypeJAXBElement);
    ringType.getCurveMember().add(curvePropertyType);
    return ringType;
}
Also used : CurvePropertyType(net.opengis.gml.v_3_2_1.CurvePropertyType) LineStringType(net.opengis.gml.v_3_2_1.LineStringType) RingType(net.opengis.gml.v_3_2_1.RingType)

Example 2 with CurvePropertyType

use of org.geotoolkit.gml.xml.v311.CurvePropertyType in project arctic-sea by 52North.

the class GmlEncoderv321 method createPosition.

private XmlObject createPosition(Geometry geom, EncodingContext ctx) throws EncodingException {
    String foiId = ctx.<String>get(XmlBeansEncodingFlags.GMLID).orElse(null);
    if (geom instanceof Point) {
        PointType xbPoint = PointType.Factory.newInstance(getXmlOptions());
        xbPoint.setId(getGmlID(geom, foiId));
        createPointFromJtsGeometry((Point) geom, xbPoint);
        if (ctx.has(XmlBeansEncodingFlags.DOCUMENT)) {
            PointDocument xbPointDoc = PointDocument.Factory.newInstance(getXmlOptions());
            xbPointDoc.setPoint(xbPoint);
            return xbPointDoc;
        } else if (ctx.has(XmlBeansEncodingFlags.PROPERTY_TYPE)) {
            GeometryPropertyType geometryPropertyType = GeometryPropertyType.Factory.newInstance(getXmlOptions());
            geometryPropertyType.setAbstractGeometry(xbPoint);
            geometryPropertyType.getAbstractGeometry().substitute(GmlConstants.QN_POINT_32, PointType.type);
            return geometryPropertyType;
        }
        return xbPoint;
    } else if (geom instanceof LineString) {
        LineStringType xbLineString = LineStringType.Factory.newInstance(getXmlOptions());
        xbLineString.setId(getGmlID(geom, foiId));
        createLineStringFromJtsGeometry((LineString) geom, xbLineString);
        if (ctx.has(XmlBeansEncodingFlags.DOCUMENT)) {
            LineStringDocument xbLineStringDoc = LineStringDocument.Factory.newInstance(getXmlOptions());
            xbLineStringDoc.setLineString(xbLineString);
            return xbLineStringDoc;
        } else if (ctx.has(XmlBeansEncodingFlags.PROPERTY_TYPE)) {
            GeometryPropertyType geometryPropertyType = GeometryPropertyType.Factory.newInstance(getXmlOptions());
            geometryPropertyType.setAbstractGeometry(xbLineString);
            geometryPropertyType.getAbstractGeometry().substitute(GmlConstants.QN_LINESTRING_32, LineStringType.type);
            return geometryPropertyType;
        }
        return xbLineString;
    } else if (geom instanceof MultiLineString) {
        MultiCurveType xbMultiCurve = MultiCurveType.Factory.newInstance(getXmlOptions());
        xbMultiCurve.setId(getGmlID(geom, foiId));
        xbMultiCurve.setSrsName(getSrsName(geom));
        for (int i = 0; i < geom.getNumGeometries(); ++i) {
            Geometry lineString = geom.getGeometryN(i);
            LineStringType xbLineString = LineStringType.Factory.newInstance(getXmlOptions());
            xbLineString.setId(getGmlID(geom, foiId));
            xbLineString.addNewPosList().setStringValue(JTSHelper.getCoordinatesString(lineString));
            CurvePropertyType xbCurveMember = xbMultiCurve.addNewCurveMember();
            xbCurveMember.addNewAbstractCurve().set(xbLineString);
            XmlHelper.substituteElement(xbCurveMember.getAbstractCurve(), xbLineString);
        }
        if (ctx.has(XmlBeansEncodingFlags.DOCUMENT)) {
            MultiCurveDocument xbMultiCurveDoc = MultiCurveDocument.Factory.newInstance(getXmlOptions());
            xbMultiCurveDoc.setMultiCurve(xbMultiCurve);
            return xbMultiCurveDoc;
        } else if (ctx.has(XmlBeansEncodingFlags.PROPERTY_TYPE)) {
            GeometryPropertyType xbGeometryProperty = GeometryPropertyType.Factory.newInstance(getXmlOptions());
            xbGeometryProperty.addNewAbstractGeometry().set(xbMultiCurve);
            XmlHelper.substituteElement(xbGeometryProperty.getAbstractGeometry(), xbMultiCurve);
            return xbGeometryProperty;
        } else {
            return xbMultiCurve;
        }
    } else if (geom instanceof Polygon) {
        PolygonType xbPolygon = PolygonType.Factory.newInstance(getXmlOptions());
        xbPolygon.setId(getGmlID(geom, foiId));
        createPolygonFromJtsGeometry((Polygon) geom, xbPolygon);
        if (ctx.has(XmlBeansEncodingFlags.DOCUMENT)) {
            PolygonDocument xbPolygonDoc = PolygonDocument.Factory.newInstance(getXmlOptions());
            xbPolygonDoc.setPolygon(xbPolygon);
            return xbPolygonDoc;
        } else if (ctx.has(XmlBeansEncodingFlags.PROPERTY_TYPE)) {
            GeometryPropertyType geometryPropertyType = GeometryPropertyType.Factory.newInstance(getXmlOptions());
            geometryPropertyType.setAbstractGeometry(xbPolygon);
            geometryPropertyType.getAbstractGeometry().substitute(GmlConstants.QN_POLYGON_32, PolygonType.type);
            return geometryPropertyType;
        }
        return xbPolygon;
    } else if (geom instanceof MultiPoint) {
        MultiPointType xbMultiPoint = MultiPointType.Factory.newInstance(getXmlOptions());
        String id = getGmlID(geom, foiId);
        xbMultiPoint.setId(id);
        createMultiPointFromJtsGeometry((MultiPoint) geom, xbMultiPoint, id);
        if (ctx.has(XmlBeansEncodingFlags.DOCUMENT)) {
            MultiPointDocument xbMultiPointDoc = MultiPointDocument.Factory.newInstance(getXmlOptions());
            xbMultiPointDoc.setMultiPoint(xbMultiPoint);
            return xbMultiPointDoc;
        } else if (ctx.has(XmlBeansEncodingFlags.PROPERTY_TYPE)) {
            GeometryPropertyType geometryPropertyType = GeometryPropertyType.Factory.newInstance(getXmlOptions());
            geometryPropertyType.setAbstractGeometry(xbMultiPoint);
            geometryPropertyType.getAbstractGeometry().substitute(GmlConstants.QN_MULTI_POINT_32, PolygonType.type);
            return geometryPropertyType;
        }
        return xbMultiPoint;
    } else {
        throw new UnsupportedEncoderInputException(this, geom);
    }
}
Also used : MultiPoint(org.locationtech.jts.geom.MultiPoint) MultiLineString(org.locationtech.jts.geom.MultiLineString) PolygonDocument(net.opengis.gml.x32.PolygonDocument) MultiPointDocument(net.opengis.gml.x32.MultiPointDocument) PointDocument(net.opengis.gml.x32.PointDocument) MultiCurveType(net.opengis.gml.x32.MultiCurveType) MultiCurveDocument(net.opengis.gml.x32.MultiCurveDocument) PolygonType(net.opengis.gml.x32.PolygonType) MultiLineString(org.locationtech.jts.geom.MultiLineString) LineString(org.locationtech.jts.geom.LineString) MultiPoint(org.locationtech.jts.geom.MultiPoint) Point(org.locationtech.jts.geom.Point) LineStringType(net.opengis.gml.x32.LineStringType) MultiPointType(net.opengis.gml.x32.MultiPointType) MultiPointDocument(net.opengis.gml.x32.MultiPointDocument) MultiPoint(org.locationtech.jts.geom.MultiPoint) Point(org.locationtech.jts.geom.Point) UnsupportedEncoderInputException(org.n52.svalbard.encode.exception.UnsupportedEncoderInputException) EnvelopeOrGeometry(org.n52.shetland.util.EnvelopeOrGeometry) Geometry(org.locationtech.jts.geom.Geometry) AbstractGeometry(org.n52.shetland.ogc.gml.AbstractGeometry) MultiLineString(org.locationtech.jts.geom.MultiLineString) LineString(org.locationtech.jts.geom.LineString) LineStringDocument(net.opengis.gml.x32.LineStringDocument) MultiPointType(net.opengis.gml.x32.MultiPointType) PointType(net.opengis.gml.x32.PointType) CurvePropertyType(net.opengis.gml.x32.CurvePropertyType) Polygon(org.locationtech.jts.geom.Polygon) GeometryPropertyType(net.opengis.gml.x32.GeometryPropertyType)

Example 3 with CurvePropertyType

use of org.geotoolkit.gml.xml.v311.CurvePropertyType in project geotoolkit by Geomatys.

the class GMLUtilities method getGMLFromISO.

/**
 * @param geometry The ISO geometry to convert.
 * @return A GML 3.1.1 geometry matching given geometry definition.
 * @deprecated This method should not be used for multiple reasons:
 * <ol>
 * <li>OpenGIS definition is based on an obsolete ISO-19107 draft</li>
 * <li>The GML version is fixed and obsolete</li>
 * <li>Only partial management of geometries</li>
 * </ol>
 */
public static AbstractGeometryType getGMLFromISO(final org.opengis.geometry.Geometry geometry) {
    if (geometry instanceof Point) {
        Point point = (Point) geometry;
        PointType gmlPoint = new PointType(null, point.getDirectPosition());
        return gmlPoint;
    } else if (geometry instanceof OrientableSurface) {
        OrientableSurface surface = (OrientableSurface) geometry;
        SurfaceBoundary boundary = surface.getBoundary();
        Ring exterior = boundary.getExterior();
        List<CurvePropertyType> curves = new ArrayList<CurvePropertyType>();
        for (Primitive p : exterior.getElements()) {
            curves.add(new CurvePropertyType((CurveType) getGMLFromISO(p)));
        }
        RingType gmlExterior = new RingType();
        gmlExterior.getCurveMember().addAll(curves);
        List<Ring> interiors = boundary.getInteriors();
        List<RingType> gmlInteriors = new ArrayList<RingType>();
        for (Ring interior : interiors) {
            List<CurvePropertyType> intcurves = new ArrayList<CurvePropertyType>();
            for (Primitive p : interior.getElements()) {
                intcurves.add(new CurvePropertyType((CurveType) getGMLFromISO(p)));
            }
            RingType gmlinterior = new RingType();
            gmlinterior.getCurveMember().addAll(intcurves);
            gmlInteriors.add(gmlinterior);
        }
        PolygonType poly = new PolygonType(gmlExterior, gmlInteriors);
        return poly;
    } else if (geometry instanceof MultiSurface) {
        MultiSurface multiPrim = (MultiSurface) geometry;
        List<PolygonPropertyType> geometries = new ArrayList<PolygonPropertyType>();
        for (Geometry prim : multiPrim.getElements()) {
            PolygonType element = (PolygonType) getGMLFromISO(prim);
            PolygonPropertyType gp = new PolygonPropertyType((PolygonType) element);
            geometries.add(gp);
        }
        MultiPolygonType gmlMulti = new MultiPolygonType(null, geometries);
        return gmlMulti;
    } else if (geometry instanceof MultiCurve) {
        MultiCurve multiPrim = (MultiCurve) geometry;
        List<CurvePropertyType> geometries = new ArrayList<CurvePropertyType>();
        for (OrientableCurve prim : multiPrim.getElements()) {
            AbstractCurveType element = (AbstractCurveType) getGMLFromISO(prim);
            CurvePropertyType gp = new CurvePropertyType((AbstractCurveType) element);
            geometries.add(gp);
        }
        MultiCurveType gmlMulti = new MultiCurveType(geometries);
        return gmlMulti;
    } else if (geometry instanceof MultiPoint) {
        MultiPoint multiPrim = (MultiPoint) geometry;
        List<PointPropertyType> geometries = new ArrayList<PointPropertyType>();
        for (Point prim : multiPrim.getElements()) {
            PointType element = (PointType) getGMLFromISO(prim);
            PointPropertyType gp = new PointPropertyType((PointType) element);
            geometries.add(gp);
        }
        MultiPointType gmlMulti = new MultiPointType(null, geometries);
        return gmlMulti;
    } else if (geometry instanceof MultiPrimitive) {
        MultiPrimitive multiPrim = (MultiPrimitive) geometry;
        List<GeometryPropertyType> geometries = new ArrayList<GeometryPropertyType>();
        for (Primitive prim : multiPrim.getElements()) {
            AbstractGMLType element = getGMLFromISO(prim);
            GeometryPropertyType gp = new GeometryPropertyType((AbstractGeometryType) element);
            geometries.add(gp);
        }
        MultiGeometryType gmlMulti = new MultiGeometryType(geometries);
        return gmlMulti;
    } else if (geometry instanceof Curve) {
        Curve curve = (Curve) geometry;
        List<? extends CurveSegment> segments = curve.getSegments();
        List<LineStringSegmentType> gmlSegments = new ArrayList<LineStringSegmentType>();
        for (CurveSegment segment : segments) {
            CurveInterpolationType interpolation = CurveInterpolationType.fromValue(segment.getInterpolation().identifier());
            PointArray array = GeometricUtilities.getSamplePoints(segment);
            List<DirectPosition> positions = new ArrayList<DirectPosition>();
            for (int i = 0; i < array.size(); i++) {
                positions.add(array.getDirectPosition(i, null));
            }
            LineStringSegmentType gmlSegment = new LineStringSegmentType(segment.getNumDerivativesAtStart(), segment.getNumDerivativesAtEnd(), segment.getNumDerivativesInterior(), interpolation, positions);
            gmlSegments.add(gmlSegment);
        }
        CurveType gmlCurve = new CurveType(gmlSegments);
        return gmlCurve;
    } else if (geometry instanceof LineString) {
        LineString line = (LineString) geometry;
        PointArray array = GeometricUtilities.getSamplePoints(line);
        List<DirectPosition> positions = new ArrayList<DirectPosition>();
        for (int i = 0; i < array.size(); i++) {
            positions.add(array.getDirectPosition(i, null));
        }
        LineStringType gmlLine = new LineStringType(positions);
        return gmlLine;
    } else if (geometry instanceof Polygon) {
        Polygon polygon = (Polygon) geometry;
        SurfaceBoundary boundary = polygon.getBoundary();
        Ring exterior = boundary.getExterior();
        List<CurvePropertyType> curves = new ArrayList<CurvePropertyType>();
        for (Primitive p : exterior.getElements()) {
            curves.add(new CurvePropertyType((CurveType) getGMLFromISO(p)));
        }
        RingType gmlExterior = new RingType();
        gmlExterior.getCurveMember().addAll(curves);
        List<Ring> interiors = boundary.getInteriors();
        List<RingType> gmlInteriors = new ArrayList<RingType>();
        for (Ring interior : interiors) {
            List<CurvePropertyType> intcurves = new ArrayList<CurvePropertyType>();
            for (Primitive p : interior.getElements()) {
                intcurves.add(new CurvePropertyType((CurveType) getGMLFromISO(p)));
            }
            RingType gmlinterior = new RingType();
            gmlinterior.getCurveMember().addAll(intcurves);
            gmlInteriors.add(gmlinterior);
        }
        PolygonType gmlPolygon = new PolygonType(gmlExterior, gmlInteriors);
        return gmlPolygon;
    } else if (geometry instanceof PolyhedralSurface) {
        PolyhedralSurface polySurface = (PolyhedralSurface) geometry;
        List<PolygonPatchType> gmlPatches = new ArrayList<PolygonPatchType>();
        List<? extends Polygon> patches = polySurface.getPatches();
        for (Polygon polygon : patches) {
            SurfaceInterpolationType interpolation = SurfaceInterpolationType.fromValue(polygon.getInterpolation().identifier());
            SurfaceBoundary boundary = polygon.getBoundary();
            Ring exterior = boundary.getExterior();
            List<CurvePropertyType> curves = new ArrayList<CurvePropertyType>();
            for (Primitive p : exterior.getElements()) {
                curves.add(new CurvePropertyType((CurveType) getGMLFromISO(p)));
            }
            RingType gmlExterior = new RingType();
            gmlExterior.getCurveMember().addAll(curves);
            List<Ring> interiors = boundary.getInteriors();
            List<RingType> gmlInteriors = new ArrayList<RingType>();
            for (Ring interior : interiors) {
                List<CurvePropertyType> intcurves = new ArrayList<CurvePropertyType>();
                for (Primitive p : interior.getElements()) {
                    intcurves.add(new CurvePropertyType((CurveType) getGMLFromISO(p)));
                }
                RingType gmlinterior = new RingType();
                gmlinterior.getCurveMember().addAll(intcurves);
                gmlInteriors.add(gmlinterior);
            }
            PolygonPatchType patche = new PolygonPatchType(interpolation, gmlExterior, gmlInteriors);
            gmlPatches.add(patche);
        }
        PolygonPatchArrayPropertyType pathArray = new PolygonPatchArrayPropertyType(gmlPatches);
        PolyhedralSurfaceType gmlPolySurface = new PolyhedralSurfaceType(pathArray);
        return gmlPolySurface;
    } else {
        System.out.println("unexpected iso geometry type:" + geometry.getClass().getName());
    }
    return null;
}
Also used : MultiPoint(org.opengis.geometry.aggregate.MultiPoint) DirectPosition(org.opengis.geometry.DirectPosition) MultiCurveType(org.geotoolkit.gml.xml.v311.MultiCurveType) OrientableSurface(org.opengis.geometry.primitive.OrientableSurface) ArrayList(java.util.ArrayList) MultiGeometryType(org.geotoolkit.gml.xml.v311.MultiGeometryType) MultiPrimitive(org.opengis.geometry.aggregate.MultiPrimitive) CurveSegment(org.opengis.geometry.primitive.CurveSegment) MultiCurve(org.opengis.geometry.aggregate.MultiCurve) ArrayList(java.util.ArrayList) List(java.util.List) CurvePropertyType(org.geotoolkit.gml.xml.v311.CurvePropertyType) Polygon(org.opengis.geometry.coordinate.Polygon) SurfaceBoundary(org.opengis.geometry.primitive.SurfaceBoundary) AbstractGeometryType(org.geotoolkit.gml.xml.v311.AbstractGeometryType) Curve(org.opengis.geometry.primitive.Curve) MultiCurve(org.opengis.geometry.aggregate.MultiCurve) OrientableCurve(org.opengis.geometry.primitive.OrientableCurve) PolygonType(org.geotoolkit.gml.xml.v311.PolygonType) MultiPolygonType(org.geotoolkit.gml.xml.v311.MultiPolygonType) OrientableCurve(org.opengis.geometry.primitive.OrientableCurve) LineStringType(org.geotoolkit.gml.xml.v311.LineStringType) MultiPointType(org.geotoolkit.gml.xml.v311.MultiPointType) CurveInterpolationType(org.geotoolkit.gml.xml.v311.CurveInterpolationType) RingType(org.geotoolkit.gml.xml.v311.RingType) PolyhedralSurfaceType(org.geotoolkit.gml.xml.v311.PolyhedralSurfaceType) LineStringSegmentType(org.geotoolkit.gml.xml.v311.LineStringSegmentType) MultiSurface(org.opengis.geometry.aggregate.MultiSurface) SurfaceInterpolationType(org.geotoolkit.gml.xml.v311.SurfaceInterpolationType) AbstractCurveType(org.geotoolkit.gml.xml.v311.AbstractCurveType) MultiCurveType(org.geotoolkit.gml.xml.v311.MultiCurveType) CurveType(org.geotoolkit.gml.xml.v311.CurveType) AbstractGMLType(org.geotoolkit.gml.xml.v311.AbstractGMLType) PolygonPatchArrayPropertyType(org.geotoolkit.gml.xml.v311.PolygonPatchArrayPropertyType) MultiPrimitive(org.opengis.geometry.aggregate.MultiPrimitive) Primitive(org.opengis.geometry.primitive.Primitive) MultiPolygonType(org.geotoolkit.gml.xml.v311.MultiPolygonType) PolygonPatchType(org.geotoolkit.gml.xml.v311.PolygonPatchType) Point(org.opengis.geometry.primitive.Point) MultiPoint(org.opengis.geometry.aggregate.MultiPoint) PointArray(org.opengis.geometry.coordinate.PointArray) Point(org.opengis.geometry.primitive.Point) MultiPoint(org.opengis.geometry.aggregate.MultiPoint) PolyhedralSurface(org.opengis.geometry.coordinate.PolyhedralSurface) Geometry(org.opengis.geometry.Geometry) AbstractCurveType(org.geotoolkit.gml.xml.v311.AbstractCurveType) LineString(org.opengis.geometry.coordinate.LineString) Ring(org.opengis.geometry.primitive.Ring) PolygonPropertyType(org.geotoolkit.gml.xml.v311.PolygonPropertyType) PointType(org.geotoolkit.gml.xml.v311.PointType) MultiPointType(org.geotoolkit.gml.xml.v311.MultiPointType) PointPropertyType(org.geotoolkit.gml.xml.v311.PointPropertyType) GeometryPropertyType(org.geotoolkit.gml.xml.v311.GeometryPropertyType)

Example 4 with CurvePropertyType

use of org.geotoolkit.gml.xml.v311.CurvePropertyType in project ddf by codice.

the class Wfs20JTStoGML321Converter method createCurvePropertyType.

private static CurvePropertyType createCurvePropertyType(LineString lineString) {
    final CurvePropertyType curvePropertyType = GML320_OBJECT_FACTORY.createCurvePropertyType();
    curvePropertyType.setAbstractCurve(createElementJAXB(lineString));
    return curvePropertyType;
}
Also used : CurvePropertyType(net.opengis.gml.v_3_2_1.CurvePropertyType)

Aggregations

CurvePropertyType (net.opengis.gml.v_3_2_1.CurvePropertyType)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 LineStringType (net.opengis.gml.v_3_2_1.LineStringType)1 RingType (net.opengis.gml.v_3_2_1.RingType)1 CurvePropertyType (net.opengis.gml.x32.CurvePropertyType)1 GeometryPropertyType (net.opengis.gml.x32.GeometryPropertyType)1 LineStringDocument (net.opengis.gml.x32.LineStringDocument)1 LineStringType (net.opengis.gml.x32.LineStringType)1 MultiCurveDocument (net.opengis.gml.x32.MultiCurveDocument)1 MultiCurveType (net.opengis.gml.x32.MultiCurveType)1 MultiPointDocument (net.opengis.gml.x32.MultiPointDocument)1 MultiPointType (net.opengis.gml.x32.MultiPointType)1 PointDocument (net.opengis.gml.x32.PointDocument)1 PointType (net.opengis.gml.x32.PointType)1 PolygonDocument (net.opengis.gml.x32.PolygonDocument)1 PolygonType (net.opengis.gml.x32.PolygonType)1 AbstractCurveType (org.geotoolkit.gml.xml.v311.AbstractCurveType)1 AbstractGMLType (org.geotoolkit.gml.xml.v311.AbstractGMLType)1 AbstractGeometryType (org.geotoolkit.gml.xml.v311.AbstractGeometryType)1