Search in sources :

Example 1 with CoordinatesType

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

Aggregations

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