Search in sources :

Example 1 with AbstractRingPropertyType

use of net.opengis.gml.v_3_2_1.AbstractRingPropertyType in project ddf by codice.

the class Wfs20JTStoGML321Converter method convertToPolygonType.

public static PolygonType convertToPolygonType(Polygon polygon, String srsName) {
    PolygonType polygonType = GML320_OBJECT_FACTORY.createPolygonType();
    //exterior
    LineString lineString = polygon.getExteriorRing();
    LinearRing linearRing = lineString.getFactory().createLinearRing(lineString.getCoordinateSequence());
    RingType ringType = convertToRingType(linearRing, srsName);
    JAXBElement<RingType> ringTypeJAXBElement = GML320_OBJECT_FACTORY.createRing(ringType);
    AbstractRingPropertyType abstractRingPropertyType = GML320_OBJECT_FACTORY.createAbstractRingPropertyType();
    abstractRingPropertyType.setAbstractRing(ringTypeJAXBElement);
    polygonType.setExterior(abstractRingPropertyType);
    //interiors
    for (int i = 0; i < polygon.getNumInteriorRing(); i++) {
        LineString interiorRingN = polygon.getInteriorRingN(i);
        LinearRing linearRing1 = interiorRingN.getFactory().createLinearRing(interiorRingN.getCoordinateSequence());
        RingType ringType1 = convertToRingType(linearRing1, srsName);
        JAXBElement<RingType> ringTypeJAXBElement1 = GML320_OBJECT_FACTORY.createRing(ringType1);
        AbstractRingPropertyType abstractRingPropertyType1 = GML320_OBJECT_FACTORY.createAbstractRingPropertyType();
        abstractRingPropertyType1.setAbstractRing(ringTypeJAXBElement1);
        polygonType.getInterior().add(abstractRingPropertyType1);
    }
    polygonType.setSrsName(srsName);
    return polygonType;
}
Also used : LineString(com.vividsolutions.jts.geom.LineString) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) AbstractRingPropertyType(net.opengis.gml.v_3_2_1.AbstractRingPropertyType) PolygonType(net.opengis.gml.v_3_2_1.PolygonType) LinearRing(com.vividsolutions.jts.geom.LinearRing) RingType(net.opengis.gml.v_3_2_1.RingType) Point(com.vividsolutions.jts.geom.Point) MultiPoint(com.vividsolutions.jts.geom.MultiPoint)

Example 2 with AbstractRingPropertyType

use of net.opengis.gml.v_3_2_1.AbstractRingPropertyType in project ddf by codice.

the class CswQueryFactoryTest method createPolygon.

private JAXBElement<AbstractGeometryType> createPolygon() {
    PolygonType localPolygon = new PolygonType();
    LinearRingType ring = new LinearRingType();
    for (Coordinate coordinate : polygon.getCoordinates()) {
        CoordType coord = new CoordType();
        coord.setX(BigDecimal.valueOf(coordinate.x));
        coord.setY(BigDecimal.valueOf(coordinate.y));
        if (!Double.isNaN(coordinate.z)) {
            coord.setZ(BigDecimal.valueOf(coordinate.z));
        }
        ring.getCoord().add(coord);
    }
    AbstractRingPropertyType abstractRing = new AbstractRingPropertyType();
    abstractRing.setRing(gmlObjectFactory.createLinearRing(ring));
    localPolygon.setExterior(gmlObjectFactory.createExterior(abstractRing));
    JAXBElement<AbstractGeometryType> agt = new JAXBElement<>(new QName("http://www.opengis.net/gml", "Polygon"), AbstractGeometryType.class, null, localPolygon);
    return agt;
}
Also used : Coordinate(com.vividsolutions.jts.geom.Coordinate) AbstractGeometryType(net.opengis.gml.v_3_1_1.AbstractGeometryType) LinearRingType(net.opengis.gml.v_3_1_1.LinearRingType) AbstractRingPropertyType(net.opengis.gml.v_3_1_1.AbstractRingPropertyType) QName(javax.xml.namespace.QName) PolygonType(net.opengis.gml.v_3_1_1.PolygonType) JAXBElement(javax.xml.bind.JAXBElement) CoordType(net.opengis.gml.v_3_1_1.CoordType)

Example 3 with AbstractRingPropertyType

use of net.opengis.gml.v_3_2_1.AbstractRingPropertyType in project arctic-sea by 52North.

the class GmlEncoderv321 method createPolygonFromJtsGeometry.

/**
 * Creates a XML Polygon from a SOS Polygon.
 *
 * @param jtsPolygon
 *            SOS Polygon
 * @param xbPolType
 *            XML Polygon
 */
private void createPolygonFromJtsGeometry(Polygon jtsPolygon, PolygonType xbPolType) {
    List<?> jtsPolygons = PolygonExtracter.getPolygons(jtsPolygon);
    String srsName = getSrsName(jtsPolygon);
    for (int i = 0; i < jtsPolygons.size(); i++) {
        Polygon pol = (Polygon) jtsPolygons.get(i);
        AbstractRingPropertyType xbArpt = xbPolType.addNewExterior();
        AbstractRingType xbArt = xbArpt.addNewAbstractRing();
        LinearRingType xbLrt = LinearRingType.Factory.newInstance();
        // Exterior ring
        LineString ring = pol.getExteriorRing();
        DirectPositionListType xbPosList = xbLrt.addNewPosList();
        xbPosList.setSrsName(srsName);
        xbPosList.setStringValue(JTSHelper.getCoordinatesString(ring));
        xbArt.set(xbLrt);
        // Rename element name for output
        XmlCursor cursor = xbArpt.newCursor();
        if (cursor.toChild(GmlConstants.QN_ABSTRACT_RING_32)) {
            cursor.setName(GmlConstants.QN_LINEAR_RING_32);
        }
        // Interior ring
        int numberOfInteriorRings = pol.getNumInteriorRing();
        for (int ringNumber = 0; ringNumber < numberOfInteriorRings; ringNumber++) {
            xbArpt = xbPolType.addNewInterior();
            xbArt = xbArpt.addNewAbstractRing();
            xbLrt = LinearRingType.Factory.newInstance();
            ring = pol.getInteriorRingN(ringNumber);
            xbPosList = xbLrt.addNewPosList();
            xbPosList.setSrsName(srsName);
            xbPosList.setStringValue(JTSHelper.getCoordinatesString(ring));
            xbArt.set(xbLrt);
            // Rename element name for output
            cursor = xbArpt.newCursor();
            if (cursor.toChild(GmlConstants.QN_ABSTRACT_RING_32)) {
                cursor.setName(GmlConstants.QN_LINEAR_RING_32);
            }
        }
    }
}
Also used : AbstractRingType(net.opengis.gml.x32.AbstractRingType) MultiLineString(org.locationtech.jts.geom.MultiLineString) LineString(org.locationtech.jts.geom.LineString) AbstractRingPropertyType(net.opengis.gml.x32.AbstractRingPropertyType) LinearRingType(net.opengis.gml.x32.LinearRingType) DirectPositionListType(net.opengis.gml.x32.DirectPositionListType) MultiLineString(org.locationtech.jts.geom.MultiLineString) LineString(org.locationtech.jts.geom.LineString) Polygon(org.locationtech.jts.geom.Polygon) MultiPoint(org.locationtech.jts.geom.MultiPoint) Point(org.locationtech.jts.geom.Point) XmlCursor(org.apache.xmlbeans.XmlCursor)

Example 4 with AbstractRingPropertyType

use of net.opengis.gml.v_3_2_1.AbstractRingPropertyType in project ddf by codice.

the class WfsFilterDelegate method createPolygon.

private JAXBElement<PolygonType> createPolygon(Geometry geometry) {
    PolygonType polygonType = gml320ObjectFactory.createPolygonType();
    polygonType.setSrsName(GeospatialUtil.EPSG_4326_URN);
    LinearRingType ring = gml320ObjectFactory.createLinearRingType();
    ring.setCoordinates(createCoordinates(geometry));
    AbstractRingPropertyType abstractRing = gml320ObjectFactory.createAbstractRingPropertyType();
    abstractRing.setAbstractRing(gml320ObjectFactory.createLinearRing(ring));
    polygonType.setExterior(abstractRing);
    return gml320ObjectFactory.createPolygon(polygonType);
}
Also used : LinearRingType(net.opengis.gml.v_3_2_1.LinearRingType) AbstractRingPropertyType(net.opengis.gml.v_3_2_1.AbstractRingPropertyType) PolygonType(net.opengis.gml.v_3_2_1.PolygonType)

Example 5 with AbstractRingPropertyType

use of net.opengis.gml.v_3_2_1.AbstractRingPropertyType in project arctic-sea by 52North.

the class GmlDecoderv321 method parsePolygonType.

private Geometry parsePolygonType(PolygonType xbPolygonType) throws DecodingException {
    int srid = -1;
    if (xbPolygonType.getSrsName() != null) {
        srid = CRSHelper.parseSrsName(xbPolygonType.getSrsName());
    }
    String exteriorCoordString = null;
    StringBuilder geomWKT = new StringBuilder();
    StringBuilder interiorCoordString = new StringBuilder();
    AbstractRingPropertyType xbExterior = xbPolygonType.getExterior();
    if (xbExterior != null) {
        AbstractRingType xbExteriorRing = xbExterior.getAbstractRing();
        if (xbExteriorRing instanceof LinearRingType) {
            LinearRingType xbLinearRing = (LinearRingType) xbExteriorRing;
            exteriorCoordString = getCoordString4LinearRing(xbLinearRing);
        } else {
            throw new DecodingException("The Polygon must contain the following elements <gml:exterior><gml:LinearRing><gml:posList>!");
        }
    }
    AbstractRingPropertyType[] xbInterior = xbPolygonType.getInteriorArray();
    if (xbInterior != null && xbInterior.length != 0) {
        for (AbstractRingPropertyType xbInteriorRing : xbInterior) {
            if (xbInteriorRing.getAbstractRing() instanceof LinearRingType) {
                interiorCoordString.append(", ").append(getCoordString4LinearRing((LinearRingType) xbInteriorRing.getAbstractRing()));
            }
        }
    }
    geomWKT.append("POLYGON(");
    geomWKT.append(exteriorCoordString);
    geomWKT.append(interiorCoordString);
    geomWKT.append(")");
    srid = setDefaultForUnsetSrid(srid);
    try {
        return JTSHelper.createGeometryFromWKT(geomWKT.toString(), srid);
    } catch (ParseException ex) {
        throw new DecodingException(ex);
    }
}
Also used : AbstractRingType(net.opengis.gml.x32.AbstractRingType) AbstractRingPropertyType(net.opengis.gml.x32.AbstractRingPropertyType) LinearRingType(net.opengis.gml.x32.LinearRingType) DecodingException(org.n52.svalbard.decode.exception.DecodingException) DateTimeParseException(org.n52.shetland.util.DateTimeParseException) ParseException(org.locationtech.jts.io.ParseException)

Aggregations

AbstractRingPropertyType (net.opengis.gml.v_3_2_1.AbstractRingPropertyType)2 PolygonType (net.opengis.gml.v_3_2_1.PolygonType)2 AbstractRingPropertyType (net.opengis.gml.x32.AbstractRingPropertyType)2 AbstractRingType (net.opengis.gml.x32.AbstractRingType)2 LinearRingType (net.opengis.gml.x32.LinearRingType)2 Coordinate (com.vividsolutions.jts.geom.Coordinate)1 LineString (com.vividsolutions.jts.geom.LineString)1 LinearRing (com.vividsolutions.jts.geom.LinearRing)1 MultiLineString (com.vividsolutions.jts.geom.MultiLineString)1 MultiPoint (com.vividsolutions.jts.geom.MultiPoint)1 Point (com.vividsolutions.jts.geom.Point)1 JAXBElement (javax.xml.bind.JAXBElement)1 QName (javax.xml.namespace.QName)1 AbstractGeometryType (net.opengis.gml.v_3_1_1.AbstractGeometryType)1 AbstractRingPropertyType (net.opengis.gml.v_3_1_1.AbstractRingPropertyType)1 CoordType (net.opengis.gml.v_3_1_1.CoordType)1 LinearRingType (net.opengis.gml.v_3_1_1.LinearRingType)1 PolygonType (net.opengis.gml.v_3_1_1.PolygonType)1 LinearRingType (net.opengis.gml.v_3_2_1.LinearRingType)1 RingType (net.opengis.gml.v_3_2_1.RingType)1