Search in sources :

Example 6 with CoordinatesType

use of org.geotoolkit.gml.xml.v311.CoordinatesType in project ddf by codice.

the class WfsFilterDelegate method createCoordinates.

private CoordinatesType createCoordinates(Geometry geometry) {
    CoordinatesType coords = gml320ObjectFactory.createCoordinatesType();
    Coordinate[] coordinates = geometry.getCoordinates();
    if (coordinates != null && coordinates.length > 0) {
        StringBuffer coordString = new StringBuffer();
        for (Coordinate coordinate : coordinates) {
            coordString.append(coordinate.x).append(",").append(coordinate.y).append(" ");
        }
        coords.setValue(coordString.toString());
        coords.setDecimal(".");
        coords.setCs(",");
        coords.setTs(" ");
        coords.setValue(coordString.toString());
        return coords;
    } else {
        throw new IllegalArgumentException("Unable to parse Geometry coordinates from WKT String");
    }
}
Also used : Coordinate(org.locationtech.jts.geom.Coordinate) CoordinatesType(net.opengis.gml.v_3_2_1.CoordinatesType)

Example 7 with CoordinatesType

use of org.geotoolkit.gml.xml.v311.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 8 with CoordinatesType

use of org.geotoolkit.gml.xml.v311.CoordinatesType in project geotoolkit by Geomatys.

the class JsonBindingTest method testMarshallingExecuteV2.

@Test
public void testMarshallingExecuteV2() throws JAXBException, IOException, URISyntaxException {
    PointType pt = new PointType(new CoordinatesType());
    Format format = new Format().encoding("UTF8").mimeType("text/xml").schema("http://kk.com");
    final Execute executeRoot = new Execute();
    ComplexInput ci = new ComplexInput(format, new ValueType("not a point", null));
    Input dataInput = new Input("input1", ci);
    executeRoot.addInputsItem(dataInput);
    Output output = new Output();
    output.setId("out-1");
    output.setTransmissionMode(DataTransmissionMode.REFERENCE);
    executeRoot.setOutputs(Arrays.asList(output));
    executeRoot.setMode(org.geotoolkit.wps.xml.v200.Execute.Mode.async);
    executeRoot.setResponse(org.geotoolkit.wps.xml.v200.Execute.Response.document);
    ObjectMapper m = getMapper();
    StringWriter sw = new StringWriter();
    m.writeValue(sw, executeRoot);
    String expResult = IOUtilities.toString(IOUtilities.getResourceAsPath("json/executeRequest6.json"));
    expResult = expResult.replace(" ", "");
    expResult = expResult.replace("\n", "");
    String result = sw.toString().replace(" ", "");
    assertEquals(expResult, result);
}
Also used : StringWriter(java.io.StringWriter) PointType(org.geotoolkit.gml.xml.v321.PointType) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) CoordinatesType(org.geotoolkit.gml.xml.v321.CoordinatesType) Test(org.junit.Test)

Example 9 with CoordinatesType

use of org.geotoolkit.gml.xml.v311.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(org.locationtech.jts.geom.Coordinate) PointType(net.opengis.gml.v_3_2_1.PointType) CoordinatesType(net.opengis.gml.v_3_2_1.CoordinatesType)

Example 10 with CoordinatesType

use of org.geotoolkit.gml.xml.v311.CoordinatesType in project ddf by codice.

the class WfsFilterDelegate method createPoint.

private JAXBElement<AbstractGeometryType> createPoint(String wkt) {
    Coordinate[] coordinates = getCoordinatesFromWkt(wkt);
    if (coordinates != null && coordinates.length > 0) {
        CoordinatesType coordinatesType = new CoordinatesType();
        String coordinateString = coordinateStrategy.toString(coordinates[0]);
        coordinatesType.setValue(coordinateString);
        PointType point = new PointType();
        point.setCoordinates(coordinatesType);
        return gmlObjectFactory.createGeometry(point);
    } else {
        throw new IllegalArgumentException("Unable to parse Point coordinates from WKT String");
    }
}
Also used : Coordinate(org.locationtech.jts.geom.Coordinate) PointType(net.opengis.gml.v_3_1_1.PointType) LineString(org.locationtech.jts.geom.LineString) CoordinatesType(net.opengis.gml.v_3_1_1.CoordinatesType)

Aggregations

Coordinate (org.locationtech.jts.geom.Coordinate)5 LineString (org.locationtech.jts.geom.LineString)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 Coordinate (com.vividsolutions.jts.geom.Coordinate)2 DirectPositionType (net.opengis.gml.x32.DirectPositionType)2 Point (org.locationtech.jts.geom.Point)2 DecodingException (org.n52.svalbard.decode.exception.DecodingException)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Envelope (com.vividsolutions.jts.geom.Envelope)1 LineString (com.vividsolutions.jts.geom.LineString)1 MultiLineString (com.vividsolutions.jts.geom.MultiLineString)1 StringWriter (java.io.StringWriter)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