Search in sources :

Example 1 with CoordinatesType

use of net.opengis.gml.x32.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(com.vividsolutions.jts.geom.Coordinate) CoordinatesType(net.opengis.gml.v_3_2_1.CoordinatesType)

Example 2 with CoordinatesType

use of net.opengis.gml.x32.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();
    StringBuffer stringBuffer = new StringBuffer();
    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(com.vividsolutions.jts.geom.Coordinate) LineStringType(net.opengis.gml.v_3_2_1.LineStringType) Point(com.vividsolutions.jts.geom.Point) MultiPoint(com.vividsolutions.jts.geom.MultiPoint) CoordinatesType(net.opengis.gml.v_3_2_1.CoordinatesType)

Example 3 with CoordinatesType

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

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

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

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