Search in sources :

Example 1 with CoordinatesType

use of org.geotoolkit.gml.xml.v321.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 org.geotoolkit.gml.xml.v321.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 org.geotoolkit.gml.xml.v321.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 org.geotoolkit.gml.xml.v321.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)

Example 5 with CoordinatesType

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

the class WfsFilterDelegate method createLineString.

private JAXBElement<LineStringType> createLineString(Geometry geometry) {
    LineStringType lineStringType = gmlObjectFactory.createLineStringType();
    String coordinatesValue = coordinateStrategy.toString(geometry.getCoordinates());
    CoordinatesType coordinatesType = gmlObjectFactory.createCoordinatesType();
    coordinatesType.setValue(coordinatesValue);
    coordinatesType.setDecimal(".");
    coordinatesType.setCs(",");
    coordinatesType.setTs(" ");
    lineStringType.setCoordinates(coordinatesType);
    return gmlObjectFactory.createLineString(lineStringType);
}
Also used : LineString(org.locationtech.jts.geom.LineString) LineStringType(net.opengis.gml.v_3_1_1.LineStringType) 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