Search in sources :

Example 1 with DirectPositionListType

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

use of net.opengis.gml.x32.DirectPositionListType in project arctic-sea by 52North.

the class GmlEncoderv321 method createLineStringFromJtsGeometry.

/**
 * Creates a XML LineString from a SOS LineString.
 *
 * @param jtsLineString
 *            SOS LineString
 * @param xbLst
 *            XML LinetSring
 */
private void createLineStringFromJtsGeometry(LineString jtsLineString, LineStringType xbLst) {
    String srsName = getSrsName(jtsLineString);
    xbLst.setSrsName(srsName);
    DirectPositionListType xbPosList = xbLst.addNewPosList();
    xbPosList.setSrsName(srsName);
    xbPosList.setStringValue(JTSHelper.getCoordinatesString(jtsLineString));
}
Also used : DirectPositionListType(net.opengis.gml.x32.DirectPositionListType) MultiLineString(org.locationtech.jts.geom.MultiLineString) LineString(org.locationtech.jts.geom.LineString)

Example 3 with DirectPositionListType

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

the class CswJTSToGML311LinearRingConverter method doCreateGeometryType.

/**
 * @see {@code JTSToGML311LinearRingConverter#doCreateGeometryType}
 */
@Override
protected LinearRingType doCreateGeometryType(LinearRing linearRing) {
    final LinearRingType resultLinearRing;
    if (usePosList) {
        resultLinearRing = getObjectFactory().createLinearRingType();
        List<Double> posDoubleList = new ArrayList<Double>();
        for (Coordinate coordinate : linearRing.getCoordinates()) {
            posDoubleList.add(coordinate.x);
            posDoubleList.add(coordinate.y);
        }
        DirectPositionListType directPosListType = new DirectPositionListType();
        directPosListType.setValue(posDoubleList);
        resultLinearRing.setPosList(directPosListType);
    } else {
        resultLinearRing = super.doCreateGeometryType(linearRing);
    }
    return resultLinearRing;
}
Also used : Coordinate(org.locationtech.jts.geom.Coordinate) LinearRingType(net.opengis.gml.v_3_1_1.LinearRingType) ArrayList(java.util.ArrayList) DirectPositionListType(net.opengis.gml.v_3_1_1.DirectPositionListType)

Example 4 with DirectPositionListType

use of net.opengis.gml.x32.DirectPositionListType in project arctic-sea by 52North.

the class AbstractRectifiedGridCoverageTypeEncoder method encodeDomainSet.

private XmlObject encodeDomainSet(RectifiedGridCoverage rectifiedGridCoverage) {
    List<ComparableValue<?, ?>> domainSet = rectifiedGridCoverage.getDomainSet();
    if (!checkForRange(domainSet)) {
        SimpleMultiPointDocument smpd = SimpleMultiPointDocument.Factory.newInstance();
        SimpleMultiPointType smpt = smpd.addNewSimpleMultiPoint();
        smpt.setId("smp_" + rectifiedGridCoverage.getGmlId());
        DirectPositionListType dplt = smpt.addNewPosList();
        List<String> uoms = getUoms(domainSet);
        if (!uoms.isEmpty()) {
            dplt.setUomLabels(Lists.newArrayList(uoms));
        }
        dplt.setListValue(getList(rectifiedGridCoverage.getDomainSet()));
        return smpd;
    } else {
        LineStringDocument lsd = LineStringDocument.Factory.newInstance();
        LineStringType lst = lsd.addNewLineString();
        lst.setId("ls_" + rectifiedGridCoverage.getGmlId());
        lst.setUomLabels(getUoms(domainSet));
        for (ComparableValue<?, ?> quantityValued : domainSet) {
            Object value = quantityValued.getValue();
            if (value instanceof Double) {
                lst.addNewPos().setListValue(Lists.newArrayList((Double) value));
            } else if (value instanceof RangeValue) {
                lst.addNewPos().setListValue(((RangeValue) value).getRangeAsList());
            }
        }
        return lsd;
    }
}
Also used : SimpleMultiPointType(net.opengis.gml.x33.ce.SimpleMultiPointType) DirectPositionListType(net.opengis.gml.x32.DirectPositionListType) LineStringType(net.opengis.gml.x32.LineStringType) ComparableValue(org.n52.shetland.ogc.om.values.ComparableValue) RangeValue(org.n52.shetland.ogc.swe.RangeValue) SimpleMultiPointDocument(net.opengis.gml.x33.ce.SimpleMultiPointDocument) LineStringDocument(net.opengis.gml.x32.LineStringDocument) XmlObject(org.apache.xmlbeans.XmlObject)

Example 5 with DirectPositionListType

use of net.opengis.gml.x32.DirectPositionListType in project arctic-sea by 52North.

the class GmlDecoderv321 method getCoordString4LinearRing.

/**
 * method parses the passed linearRing(generated thru XmlBEans) and returns a string containing the coordinate
 * values of the passed ring
 *
 * @param xbLinearRing linearRing(generated thru XmlBEans)
 *
 * @return Returns a string containing the coordinate values of the passed ring
 *
 * @throws DecodingException * if parsing the linear Ring failed
 */
private String getCoordString4LinearRing(LinearRingType xbLinearRing) throws DecodingException {
    String result = "";
    DirectPositionListType xbPosList = xbLinearRing.getPosList();
    CoordinatesType xbCoordinates = xbLinearRing.getCoordinates();
    DirectPositionType[] xbPosArray = xbLinearRing.getPosArray();
    if (xbPosList != null && !(xbPosList.getStringValue().isEmpty())) {
        result = getString4PosList(xbPosList);
    } else if (xbCoordinates != null && !(xbCoordinates.getStringValue().isEmpty())) {
        result = getString4Coordinates(xbCoordinates);
    } else if (xbPosArray != null && xbPosArray.length > 0) {
        result = getString4PosArray(xbPosArray, true);
    } else {
        throw new DecodingException("The Polygon must contain the following elements " + "<gml:exterior><gml:LinearRing><gml:posList>, " + "<gml:exterior><gml:LinearRing><gml:coordinates> " + "or <gml:exterior><gml:LinearRing><gml:pos>{<gml:pos>}!");
    }
    return result;
}
Also used : DirectPositionType(net.opengis.gml.x32.DirectPositionType) DirectPositionListType(net.opengis.gml.x32.DirectPositionListType) DecodingException(org.n52.svalbard.decode.exception.DecodingException) CoordinatesType(net.opengis.gml.x32.CoordinatesType)

Aggregations

DirectPositionListType (net.opengis.gml.x32.DirectPositionListType)5 DirectPositionType (net.opengis.gml.x32.DirectPositionType)2 LineString (org.locationtech.jts.geom.LineString)2 MultiLineString (org.locationtech.jts.geom.MultiLineString)2 DecodingException (org.n52.svalbard.decode.exception.DecodingException)2 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 DirectPositionListType (net.opengis.gml.v_3_1_1.DirectPositionListType)1 LinearRingType (net.opengis.gml.v_3_1_1.LinearRingType)1 AbstractRingPropertyType (net.opengis.gml.x32.AbstractRingPropertyType)1 AbstractRingType (net.opengis.gml.x32.AbstractRingType)1 CoordinatesType (net.opengis.gml.x32.CoordinatesType)1 LineStringDocument (net.opengis.gml.x32.LineStringDocument)1 LineStringType (net.opengis.gml.x32.LineStringType)1 LinearRingType (net.opengis.gml.x32.LinearRingType)1 SimpleMultiPointDocument (net.opengis.gml.x33.ce.SimpleMultiPointDocument)1 SimpleMultiPointType (net.opengis.gml.x33.ce.SimpleMultiPointType)1 XmlCursor (org.apache.xmlbeans.XmlCursor)1 XmlObject (org.apache.xmlbeans.XmlObject)1 Coordinate (org.locationtech.jts.geom.Coordinate)1