Search in sources :

Example 1 with LinearRingType

use of net.opengis.gml.x32.LinearRingType in project ddf by codice.

the class TestWfs10JTStoGML200Converter method extractPolygonMemberCoordinates.

private String extractPolygonMemberCoordinates(PolygonMemberType polygonMemberType1) throws JAXBException, SAXException, IOException, ParseException, NullPointerException {
    JAXBElement<? extends AbstractGeometryType> polygonGeometry1 = polygonMemberType1.getGeometry();
    assertThat(Wfs10Constants.POLYGON.getLocalPart().equals(polygonGeometry1.getName().getLocalPart()), is(Boolean.TRUE));
    PolygonType polygonType1 = (PolygonType) polygonGeometry1.getValue();
    LinearRingMemberType linearRingMemberType1 = polygonType1.getOuterBoundaryIs();
    JAXBElement<? extends AbstractGeometryType> linearRingGeometry1 = linearRingMemberType1.getGeometry();
    LinearRingType linearRingType1 = (LinearRingType) linearRingGeometry1.getValue();
    return linearRingType1.getCoordinates().getValue().replaceAll("\n", "").trim();
}
Also used : LinearRingType(ogc.schema.opengis.gml.v_2_1_2.LinearRingType) LinearRingMemberType(ogc.schema.opengis.gml.v_2_1_2.LinearRingMemberType) PolygonType(ogc.schema.opengis.gml.v_2_1_2.PolygonType) MultiPolygonType(ogc.schema.opengis.gml.v_2_1_2.MultiPolygonType)

Example 2 with LinearRingType

use of net.opengis.gml.x32.LinearRingType 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 LinearRingType

use of net.opengis.gml.x32.LinearRingType in project ddf by codice.

the class WfsFilterDelegate method createPolygon.

private JAXBElement<PolygonType> createPolygon(String wkt) {
    PolygonType polygon = new PolygonType();
    LinearRingType linearRing = new LinearRingType();
    Coordinate[] coordinates = getCoordinatesFromWkt(wkt);
    if (coordinates != null && coordinates.length > 0) {
        StringBuffer coordString = new StringBuffer();
        for (Coordinate coordinate : coordinates) {
            coordString.append(coordinate.x).append(",").append(coordinate.y).append(" ");
        }
        CoordinatesType coordinatesType = new CoordinatesType();
        coordinatesType.setValue(coordString.toString());
        coordinatesType.setDecimal(".");
        coordinatesType.setCs(",");
        coordinatesType.setTs(" ");
        linearRing.setCoordinates(coordinatesType);
        LinearRingMemberType member = new LinearRingMemberType();
        member.setGeometry(gmlObjectFactory.createLinearRing(linearRing));
        polygon.setOuterBoundaryIs(member);
        polygon.setSrsName(srsName);
        return gmlObjectFactory.createPolygon(polygon);
    } else {
        throw new IllegalArgumentException("Unable to parse Polygon coordinates from WKT String");
    }
}
Also used : Coordinate(com.vividsolutions.jts.geom.Coordinate) LinearRingType(ogc.schema.opengis.gml.v_2_1_2.LinearRingType) LinearRingMemberType(ogc.schema.opengis.gml.v_2_1_2.LinearRingMemberType) MultiPolygonType(ogc.schema.opengis.gml.v_2_1_2.MultiPolygonType) PolygonType(ogc.schema.opengis.gml.v_2_1_2.PolygonType) CoordinatesType(ogc.schema.opengis.gml.v_2_1_2.CoordinatesType)

Example 4 with LinearRingType

use of net.opengis.gml.x32.LinearRingType 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 5 with LinearRingType

use of net.opengis.gml.x32.LinearRingType 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)

Aggregations

Coordinate (com.vividsolutions.jts.geom.Coordinate)3 LinearRingMemberType (ogc.schema.opengis.gml.v_2_1_2.LinearRingMemberType)3 LinearRingType (ogc.schema.opengis.gml.v_2_1_2.LinearRingType)3 MultiPolygonType (ogc.schema.opengis.gml.v_2_1_2.MultiPolygonType)3 PolygonType (ogc.schema.opengis.gml.v_2_1_2.PolygonType)3 LinearRingType (net.opengis.gml.v_3_1_1.LinearRingType)2 AbstractRingPropertyType (net.opengis.gml.x32.AbstractRingPropertyType)2 AbstractRingType (net.opengis.gml.x32.AbstractRingType)2 DirectPositionListType (net.opengis.gml.x32.DirectPositionListType)2 LinearRingType (net.opengis.gml.x32.LinearRingType)2 DecodingException (org.n52.svalbard.decode.exception.DecodingException)2 LineString (com.vividsolutions.jts.geom.LineString)1 MultiLineString (com.vividsolutions.jts.geom.MultiLineString)1 MultiPolygon (com.vividsolutions.jts.geom.MultiPolygon)1 Polygon (com.vividsolutions.jts.geom.Polygon)1 ArrayList (java.util.ArrayList)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