Search in sources :

Example 1 with CoordinatesType

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

the class WfsFilterDelegate method createPoint.

private JAXBElement<PointType> createPoint(String wkt) {
    Coordinate[] coordinates = getCoordinatesFromWkt(wkt);
    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 gmlObjectFactory.createPoint(point);
    } else {
        throw new IllegalArgumentException("Unable to parse Point coordinates from WKT String");
    }
}
Also used : Coordinate(com.vividsolutions.jts.geom.Coordinate) PointType(ogc.schema.opengis.gml.v_2_1_2.PointType) MultiPointType(ogc.schema.opengis.gml.v_2_1_2.MultiPointType) CoordinatesType(ogc.schema.opengis.gml.v_2_1_2.CoordinatesType)

Example 2 with CoordinatesType

use of net.opengis.gml.v_3_2_1.CoordinatesType 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 3 with CoordinatesType

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

the class WfsFilterDelegate method createCoordinatesTypeFromWkt.

private JAXBElement<CoordinatesType> createCoordinatesTypeFromWkt(String wkt) {
    Envelope envelope = createEnvelopeFromWkt(wkt);
    String coords = buildCoordinateString(envelope);
    CoordinatesType coordinatesType = new CoordinatesType();
    coordinatesType.setValue(coords);
    return gmlObjectFactory.createCoordinates(coordinatesType);
}
Also used : LineString(com.vividsolutions.jts.geom.LineString) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) Envelope(com.vividsolutions.jts.geom.Envelope) CoordinatesType(ogc.schema.opengis.gml.v_2_1_2.CoordinatesType)

Example 4 with CoordinatesType

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

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

the class Wfs20JTStoGML321Converter method convertToLineStringType.

public static LineStringType convertToLineStringType(LineString line, String srsName) {
    LineStringType lineStringType = GML320_OBJECT_FACTORY.createLineStringType();
    CoordinatesType coordinatesType = GML320_OBJECT_FACTORY.createCoordinatesType();
    StringBuilder stringBuffer = new StringBuilder();
    for (int i = 0; i < line.getCoordinateSequence().size(); i++) {
        Coordinate coordinate = line.getCoordinateSequence().getCoordinate(i);
        if (i != 0) {
            stringBuffer.append(" ");
        }
        stringBuffer.append(coordinate.x).append(",").append(coordinate.y);
        if (!Double.isNaN(coordinate.z)) {
            stringBuffer.append(",").append(coordinate.z);
        }
    }
    coordinatesType.setValue(stringBuffer.toString());
    lineStringType.setCoordinates(coordinatesType);
    lineStringType.setSrsName(srsName);
    return lineStringType;
}
Also used : Coordinate(org.locationtech.jts.geom.Coordinate) LineStringType(net.opengis.gml.v_3_2_1.LineStringType) Point(org.locationtech.jts.geom.Point) MultiPoint(org.locationtech.jts.geom.MultiPoint) CoordinatesType(net.opengis.gml.v_3_2_1.CoordinatesType)

Aggregations

Coordinate (org.locationtech.jts.geom.Coordinate)4 CoordinatesType (net.opengis.gml.v_3_1_1.CoordinatesType)3 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 LineString (org.locationtech.jts.geom.LineString)3 Coordinate (com.vividsolutions.jts.geom.Coordinate)2 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 AbstractRingPropertyType (net.opengis.gml.v_3_1_1.AbstractRingPropertyType)1 LineStringType (net.opengis.gml.v_3_1_1.LineStringType)1 LinearRingType (net.opengis.gml.v_3_1_1.LinearRingType)1 MultiPolygonType (net.opengis.gml.v_3_1_1.MultiPolygonType)1 PointType (net.opengis.gml.v_3_1_1.PointType)1 PolygonType (net.opengis.gml.v_3_1_1.PolygonType)1 LineStringType (net.opengis.gml.v_3_2_1.LineStringType)1 PointType (net.opengis.gml.v_3_2_1.PointType)1