Search in sources :

Example 11 with CoordinatesType

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

the class WfsFilterDelegate method createPolygon.

private PolygonType createPolygon(Coordinate[] coordinates) {
    if (coordinates != null && coordinates.length > 0) {
        PolygonType polygon = new PolygonType();
        LinearRingType linearRing = new LinearRingType();
        String coordinateString = coordinateStrategy.toString(coordinates);
        CoordinatesType coordinatesType = new CoordinatesType();
        coordinatesType.setValue(coordinateString);
        coordinatesType.setDecimal(".");
        coordinatesType.setCs(",");
        coordinatesType.setTs(" ");
        linearRing.setCoordinates(coordinatesType);
        AbstractRingPropertyType abstractRingPropertyType = gmlObjectFactory.createAbstractRingPropertyType();
        abstractRingPropertyType.setRing(gmlObjectFactory.createLinearRing(linearRing));
        polygon.setExterior(gmlObjectFactory.createExterior(abstractRingPropertyType));
        return polygon;
    } else {
        throw new IllegalArgumentException("Unable to parse Polygon coordinates from WKT String");
    }
}
Also used : LinearRingType(net.opengis.gml.v_3_1_1.LinearRingType) AbstractRingPropertyType(net.opengis.gml.v_3_1_1.AbstractRingPropertyType) PolygonType(net.opengis.gml.v_3_1_1.PolygonType) MultiPolygonType(net.opengis.gml.v_3_1_1.MultiPolygonType) LineString(org.locationtech.jts.geom.LineString) CoordinatesType(net.opengis.gml.v_3_1_1.CoordinatesType)

Example 12 with CoordinatesType

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

Example 13 with CoordinatesType

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

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

the class FilterFactoryImpl method GeometryToGML.

/**
 * Transform a JTS geometric object into a GML marshallable object
 */
public Object GeometryToGML(final Object geom) {
    Object result = null;
    if (geom instanceof Polygon) {
        final Polygon p = (Polygon) geom;
        final Coordinate[] coord = p.getCoordinates();
        // an envelope
        if (coord.length == 5) {
            final DirectPositionType lowerCorner = new DirectPositionType(coord[0].y, coord[0].x);
            final DirectPositionType upperCorner = new DirectPositionType(coord[2].y, coord[2].x);
            result = new EnvelopeType(null, lowerCorner, upperCorner, "EPSG:4326");
        }
    } else if (geom instanceof Point) {
        final Point p = (Point) geom;
        final Coordinate[] coord = p.getCoordinates();
        result = new PointType(null, new DirectPositionType(coord[0].x, coord[0].y, coord[0].z));
        ((PointType) result).setSrsName("EPSG:4326");
    } else if (geom instanceof LineString) {
        final LineString ls = (LineString) geom;
        final Coordinate[] coord = ls.getCoordinates();
        result = new LineStringType(new CoordinatesType(coord[0].x + "," + coord[0].y + " " + coord[1].x + "," + coord[1].y));
        ((LineStringType) result).setSrsName("EPSG:4326");
    } else {
        LOGGER.severe("unable to create GML geometry with: " + geom.getClass().getSimpleName());
    }
    return result;
}
Also used : EnvelopeType(org.geotoolkit.gml.xml.v311.EnvelopeType) DirectPositionType(org.geotoolkit.gml.xml.v311.DirectPositionType) Coordinate(org.locationtech.jts.geom.Coordinate) LineString(org.locationtech.jts.geom.LineString) PointType(org.geotoolkit.gml.xml.v311.PointType) Point(org.locationtech.jts.geom.Point) Polygon(org.locationtech.jts.geom.Polygon) LineStringType(org.geotoolkit.gml.xml.v311.LineStringType) CoordinatesType(org.geotoolkit.gml.xml.v311.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