Search in sources :

Example 1 with DirectPositionType

use of net.opengis.gml.DirectPositionType in project arctic-sea by 52North.

the class GmlDecoderv311 method parsePointType.

private Object 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 = JTSHelper.createWKTPointFromCoordinateString(directPosition);
    } else if (xbPointType.getCoordinates() != null) {
        CoordinatesType xbCoords = xbPointType.getCoordinates();
        String directPosition = getString4Coordinates(xbCoords);
        geomWKT = JTSHelper.createWKTPointFromCoordinateString(directPosition);
    } else {
        throw new DecodingException("For geometry type 'gml:Point' only elements 'gml:pos' and 'gml:coordinates' are allowed");
    }
    checkSrid(srid);
    if (srid == -1) {
        throw new DecodingException("No SrsName ist specified for geometry!");
    }
    try {
        return JTSHelper.createGeometryFromWKT(geomWKT, srid);
    } catch (ParseException ex) {
        throw new DecodingException(ex);
    }
}
Also used : DirectPositionType(net.opengis.gml.DirectPositionType) DecodingException(org.n52.svalbard.decode.exception.DecodingException) DateTimeParseException(org.n52.shetland.util.DateTimeParseException) ParseException(org.locationtech.jts.io.ParseException) CoordinatesType(net.opengis.gml.CoordinatesType)

Example 2 with DirectPositionType

use of net.opengis.gml.DirectPositionType in project arctic-sea by 52North.

the class GmlEncoderv311 method createPointFromJtsGeometry.

/**
 * Creates a XML Point from a SOS Point.
 *
 * @param jtsPoint
 *            SOS Point
 * @param xbPoint
 *            XML Point
 */
private void createPointFromJtsGeometry(Point jtsPoint, PointType xbPoint) {
    DirectPositionType xbPos = xbPoint.addNewPos();
    xbPos.setSrsName(getSrsName(jtsPoint));
    xbPos.setStringValue(JTSHelper.getCoordinatesString(jtsPoint));
}
Also used : DirectPositionType(net.opengis.gml.DirectPositionType)

Aggregations

DirectPositionType (net.opengis.gml.DirectPositionType)2 CoordinatesType (net.opengis.gml.CoordinatesType)1 ParseException (org.locationtech.jts.io.ParseException)1 DateTimeParseException (org.n52.shetland.util.DateTimeParseException)1 DecodingException (org.n52.svalbard.decode.exception.DecodingException)1