Search in sources :

Example 1 with LineStringType

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

the class GmlEncoderv311 method createPosition.

private XmlObject createPosition(Geometry geom, Optional<Object> optional) throws UnsupportedEncoderInputException {
    String gmlId = (optional != null && optional.isPresent() && optional.get() instanceof String) ? (String) optional.get() : null;
    if (geom instanceof Point) {
        PointType xbPoint = PointType.Factory.newInstance(getXmlOptions());
        if (gmlId != null) {
            xbPoint.setId(geom.getGeometryType() + "_" + gmlId);
        }
        createPointFromJtsGeometry((Point) geom, xbPoint);
        return xbPoint;
    } else if (geom instanceof LineString) {
        LineStringType xbLineString = LineStringType.Factory.newInstance(getXmlOptions());
        if (gmlId != null) {
            xbLineString.setId(geom.getGeometryType() + "_" + gmlId);
        }
        createLineStringFromJtsGeometry((LineString) geom, xbLineString);
        return xbLineString;
    } else if (geom instanceof Polygon) {
        PolygonType xbPolygon = PolygonType.Factory.newInstance(getXmlOptions());
        if (gmlId != null) {
            xbPolygon.setId(geom.getGeometryType() + "_" + gmlId);
        }
        createPolygonFromJtsGeometry((Polygon) geom, xbPolygon);
        return xbPolygon;
    } else {
        throw new UnsupportedEncoderInputException(this, geom);
    }
}
Also used : LineString(org.locationtech.jts.geom.LineString) PointType(net.opengis.gml.PointType) PolygonType(net.opengis.gml.PolygonType) LineString(org.locationtech.jts.geom.LineString) Point(org.locationtech.jts.geom.Point) LineStringType(net.opengis.gml.LineStringType) Polygon(org.locationtech.jts.geom.Polygon) UnsupportedEncoderInputException(org.n52.svalbard.encode.exception.UnsupportedEncoderInputException)

Aggregations

LineStringType (net.opengis.gml.LineStringType)1 PointType (net.opengis.gml.PointType)1 PolygonType (net.opengis.gml.PolygonType)1 LineString (org.locationtech.jts.geom.LineString)1 Point (org.locationtech.jts.geom.Point)1 Polygon (org.locationtech.jts.geom.Polygon)1 UnsupportedEncoderInputException (org.n52.svalbard.encode.exception.UnsupportedEncoderInputException)1