Search in sources :

Example 6 with CoordinatesType

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

the class AbstractCoverageEncoder method encodeValueList.

/**
 * Encode value list of {@link RangeSetType} from {@link DiscreteCoverage}
 *
 * @param rst
 *            The {@link RangeSetType} to encode value list for
 * @param discreteCoverage
 *            The {@link DiscreteCoverage} with the value list
 * @throws EncodingException
 *             If an error occurs
 */
protected void encodeValueList(RangeSetType rst, DiscreteCoverage<?> discreteCoverage) throws EncodingException {
    List<?> list = getList(discreteCoverage);
    Value<?> value = discreteCoverage.getRangeSet().iterator().next();
    if (value instanceof BooleanValue) {
        BooleanListDocument bld = BooleanListDocument.Factory.newInstance(getXmlOptions());
        bld.setBooleanList(list);
        rst.set(bld);
    } else if (value instanceof CategoryValue || value instanceof TextValue) {
        DataBlockType dbt = rst.addNewDataBlock();
        dbt.addNewRangeParameters().setHref(discreteCoverage.getRangeParameters());
        CoordinatesType ct = dbt.addNewTupleList();
        ct.setCs(",");
        ct.setStringValue(Joiner.on(",").join(list));
    } else if (value instanceof CountValue) {
        CountListDocument cld = CountListDocument.Factory.newInstance(getXmlOptions());
        cld.setCountList(list);
        rst.set(cld);
    } else if (value instanceof QuantityValue) {
        QuantityListDocument qld = QuantityListDocument.Factory.newInstance(getXmlOptions());
        MeasureOrNilReasonListType monrlt = qld.addNewQuantityList();
        if (discreteCoverage.isSetUnit()) {
            monrlt.setUom(discreteCoverage.getUnit());
        } else if (value.isSetUnit()) {
            monrlt.setUom(value.getUnit());
        }
        monrlt.setListValue(list);
        rst.set(qld);
    }
}
Also used : CountListDocument(net.opengis.gml.x32.CountListDocument) MeasureOrNilReasonListType(net.opengis.gml.x32.MeasureOrNilReasonListType) BooleanListDocument(net.opengis.gml.x32.BooleanListDocument) CoordinatesType(net.opengis.gml.x32.CoordinatesType) CountValue(org.n52.shetland.ogc.om.values.CountValue) TextValue(org.n52.shetland.ogc.om.values.TextValue) QuantityValue(org.n52.shetland.ogc.om.values.QuantityValue) BooleanValue(org.n52.shetland.ogc.om.values.BooleanValue) DataBlockType(net.opengis.gml.x32.DataBlockType) CategoryValue(org.n52.shetland.ogc.om.values.CategoryValue) QuantityListDocument(net.opengis.gml.x32.QuantityListDocument)

Example 7 with CoordinatesType

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

the class WfsFilterDelegate method createPoint.

private JAXBElement<PointType> createPoint(Geometry geometry) {
    Coordinate[] coordinates = geometry.getCoordinates();
    if (coordinates != null && coordinates.length > 0) {
        StringBuilder coordString = new StringBuilder();
        coordString.append(coordinates[0].x).append(",").append(coordinates[0].y);
        CoordinatesType coordinatesType = new CoordinatesType();
        coordinatesType.setValue(coordString.toString());
        PointType point = new PointType();
        point.setSrsName(srsName);
        point.setCoordinates(coordinatesType);
        return gml320ObjectFactory.createPoint(point);
    } else {
        throw new IllegalArgumentException("Unable to parse Point coordinates from WKT String");
    }
}
Also used : Coordinate(com.vividsolutions.jts.geom.Coordinate) PointType(net.opengis.gml.v_3_2_1.PointType) CoordinatesType(net.opengis.gml.v_3_2_1.CoordinatesType)

Example 8 with CoordinatesType

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

Example 9 with CoordinatesType

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

the class GmlDecoderv321 method parsePointType.

private Geometry parsePointType(PointType xbPointType) throws DecodingException {
    String geomWKT = null;
    int srid = -1;
    if (xbPointType.getSrsName() != null) {
        srid = CRSHelper.parseSrsName(xbPointType.getSrsName());
    }
    if (xbPointType.getPos() != null) {
        DirectPositionType xbPos = xbPointType.getPos();
        if (srid == -1 && xbPos.getSrsName() != null) {
            srid = CRSHelper.parseSrsName(xbPos.getSrsName());
        }
        String directPosition = getString4Pos(xbPos);
        geomWKT = "POINT(" + directPosition + ")";
    } else if (xbPointType.getCoordinates() != null) {
        CoordinatesType xbCoords = xbPointType.getCoordinates();
        String directPosition = getString4Coordinates(xbCoords);
        geomWKT = "POINT" + directPosition;
    } else {
        throw new DecodingException("For geometry type 'gml:Point' only element " + "'gml:pos' and 'gml:coordinates' are allowed " + "in the feature of interest parameter!");
    }
    srid = setDefaultForUnsetSrid(srid);
    try {
        return JTSHelper.createGeometryFromWKT(geomWKT, srid);
    } catch (ParseException ex) {
        throw new DecodingException(ex);
    }
}
Also used : DirectPositionType(net.opengis.gml.x32.DirectPositionType) DecodingException(org.n52.svalbard.decode.exception.DecodingException) DateTimeParseException(org.n52.shetland.util.DateTimeParseException) ParseException(org.locationtech.jts.io.ParseException) CoordinatesType(net.opengis.gml.x32.CoordinatesType)

Aggregations

Coordinate (com.vividsolutions.jts.geom.Coordinate)5 CoordinatesType (net.opengis.gml.v_3_2_1.CoordinatesType)3 CoordinatesType (net.opengis.gml.x32.CoordinatesType)3 CoordinatesType (ogc.schema.opengis.gml.v_2_1_2.CoordinatesType)3 DirectPositionType (net.opengis.gml.x32.DirectPositionType)2 DecodingException (org.n52.svalbard.decode.exception.DecodingException)2 Envelope (com.vividsolutions.jts.geom.Envelope)1 LineString (com.vividsolutions.jts.geom.LineString)1 MultiLineString (com.vividsolutions.jts.geom.MultiLineString)1 MultiPoint (com.vividsolutions.jts.geom.MultiPoint)1 Point (com.vividsolutions.jts.geom.Point)1 LineStringType (net.opengis.gml.v_3_2_1.LineStringType)1 PointType (net.opengis.gml.v_3_2_1.PointType)1 BooleanListDocument (net.opengis.gml.x32.BooleanListDocument)1 CountListDocument (net.opengis.gml.x32.CountListDocument)1 DataBlockType (net.opengis.gml.x32.DataBlockType)1 DirectPositionListType (net.opengis.gml.x32.DirectPositionListType)1 MeasureOrNilReasonListType (net.opengis.gml.x32.MeasureOrNilReasonListType)1 QuantityListDocument (net.opengis.gml.x32.QuantityListDocument)1 LinearRingMemberType (ogc.schema.opengis.gml.v_2_1_2.LinearRingMemberType)1