Search in sources :

Example 1 with ParseException

use of com.vividsolutions.jts.io.ParseException in project ddf by codice.

the class WfsFilterDelegate method createGeometryOperand.

private JAXBElement<? extends AbstractGeometryType> createGeometryOperand(String wkt) {
    String convertedWkt = wkt;
    Geometry wktGeometry = null;
    try {
        wktGeometry = getGeometryFromWkt(convertedWkt);
    } catch (ParseException e) {
        throw new IllegalArgumentException("Unable to parse WKT Geometry [" + convertedWkt + "]", e);
    }
    if (wktGeometry instanceof Polygon) {
        if (isGeometryOperandSupported(Wfs10Constants.POLYGON)) {
            return createPolygon(convertedWkt);
        } else {
            throw new IllegalArgumentException("The Polygon operand is not supported.");
        }
    } else if (wktGeometry instanceof Point) {
        if (isGeometryOperandSupported(Wfs10Constants.POINT)) {
            return createPoint(convertedWkt);
        } else {
            throw new IllegalArgumentException("The Point operand is not supported.");
        }
    } else if (wktGeometry instanceof LineString) {
        if (isGeometryOperandSupported(Wfs10Constants.LINESTRING)) {
            return createLineString(wktGeometry);
        } else {
            throw new IllegalArgumentException("The LineString operand is not supported.");
        }
    } else if (wktGeometry instanceof MultiPoint) {
        if (isGeometryOperandSupported(Wfs10Constants.MULTI_POINT)) {
            return createMultiPoint(wktGeometry);
        } else {
            throw new IllegalArgumentException("The MultiPoint operand is not supported.");
        }
    } else if (wktGeometry instanceof MultiLineString) {
        if (isGeometryOperandSupported(Wfs10Constants.MULTI_LINESTRING)) {
            return createMultiLineString(wktGeometry);
        } else {
            throw new IllegalArgumentException("The MultiLineString operand is not supported.");
        }
    } else if (wktGeometry instanceof MultiPolygon) {
        if (isGeometryOperandSupported(Wfs10Constants.MULTI_POLYGON)) {
            return createMultiPolygon(wktGeometry);
        } else {
            throw new IllegalArgumentException("The MultiPolygon operand is not supported.");
        }
    } else if (wktGeometry instanceof GeometryCollection) {
        if (isGeometryOperandSupported(Wfs10Constants.GEOMETRY_COLLECTION)) {
            return createGeometryCollection(wktGeometry);
        } else {
            throw new IllegalArgumentException("The GeometryCollection operand is not supported.");
        }
    }
    throw new IllegalArgumentException("Unable to create Geometry from WKT String");
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) MultiPoint(com.vividsolutions.jts.geom.MultiPoint) GeometryCollection(com.vividsolutions.jts.geom.GeometryCollection) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) LineString(com.vividsolutions.jts.geom.LineString) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) MultiPolygon(com.vividsolutions.jts.geom.MultiPolygon) LineString(com.vividsolutions.jts.geom.LineString) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) ParseException(com.vividsolutions.jts.io.ParseException) Point(com.vividsolutions.jts.geom.Point) MultiPoint(com.vividsolutions.jts.geom.MultiPoint) MultiPolygon(com.vividsolutions.jts.geom.MultiPolygon) Polygon(com.vividsolutions.jts.geom.Polygon)

Example 2 with ParseException

use of com.vividsolutions.jts.io.ParseException in project ddf by codice.

the class WfsFilterDelegate method createEnvelopeFromWkt.

private Envelope createEnvelopeFromWkt(String wkt) {
    Envelope envelope = null;
    try {
        Geometry geo = getGeometryFromWkt(wkt);
        envelope = geo.getEnvelopeInternal();
    } catch (ParseException e) {
        throw new IllegalArgumentException("Unable to parse WKT String", e);
    }
    return envelope;
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) ParseException(com.vividsolutions.jts.io.ParseException) Envelope(com.vividsolutions.jts.geom.Envelope)

Example 3 with ParseException

use of com.vividsolutions.jts.io.ParseException in project ddf by codice.

the class WfsFilterDelegate method bufferGeometry.

private String bufferGeometry(String wkt, double distance) {
    LOGGER.debug("Buffering WKT {} by distance {} meter(s).", wkt, distance);
    String bufferedWkt = null;
    try {
        Geometry geometry = getGeometryFromWkt(wkt);
        double bufferInDegrees = metersToDegrees(distance);
        LOGGER.debug("Buffering {} by {} degree(s).", geometry.getClass().getSimpleName(), bufferInDegrees);
        Geometry bufferedGeometry = geometry.buffer(bufferInDegrees);
        bufferedWkt = new WKTWriter().write(bufferedGeometry);
        LOGGER.debug("Buffered WKT: {}.", bufferedWkt);
    } catch (ParseException e) {
        throw new IllegalArgumentException("Unable to parse WKT String", e);
    }
    return bufferedWkt;
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) WKTWriter(com.vividsolutions.jts.io.WKTWriter) LineString(com.vividsolutions.jts.geom.LineString) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) ParseException(com.vividsolutions.jts.io.ParseException)

Example 4 with ParseException

use of com.vividsolutions.jts.io.ParseException in project ddf by codice.

the class WfsFilterDelegate method getCoordinatesFromWkt.

private Coordinate[] getCoordinatesFromWkt(String wkt) {
    Coordinate[] coordinates = null;
    try {
        Geometry geo = getGeometryFromWkt(wkt);
        coordinates = geo.getCoordinates();
    } catch (ParseException e) {
        throw new IllegalArgumentException("Unable to parse WKT String", e);
    }
    return coordinates;
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) Coordinate(com.vividsolutions.jts.geom.Coordinate) ParseException(com.vividsolutions.jts.io.ParseException)

Example 5 with ParseException

use of com.vividsolutions.jts.io.ParseException in project GeoGig by boundlessgeo.

the class WriteTree2Test method feature.

private Node feature(ObjectDatabase db, String idPrefix, int index) {
    final String id = idPrefix + "." + index;
    final Feature feature;
    try {
        feature = super.feature(pointsType, id, id, index, point(index));
    } catch (ParseException e) {
        throw Throwables.propagate(e);
    }
    RevFeature revFeature = RevFeatureBuilder.build(feature);
    db.put(revFeature);
    Envelope bounds = (Envelope) feature.getBounds();
    return Node.create(id, revFeature.getId(), ObjectId.NULL, TYPE.FEATURE, bounds);
}
Also used : RevFeature(org.locationtech.geogig.api.RevFeature) ParseException(com.vividsolutions.jts.io.ParseException) Envelope(com.vividsolutions.jts.geom.Envelope) RevFeature(org.locationtech.geogig.api.RevFeature) Feature(org.opengis.feature.Feature)

Aggregations

ParseException (com.vividsolutions.jts.io.ParseException)65 Geometry (com.vividsolutions.jts.geom.Geometry)29 WKTReader (com.vividsolutions.jts.io.WKTReader)21 ConverterException (ch.ehi.ili2db.converter.ConverterException)17 RyaStatement (org.apache.rya.api.domain.RyaStatement)7 SimpleFeature (org.opengis.feature.simple.SimpleFeature)7 Statement (org.openrdf.model.Statement)7 Wkb2iox (ch.interlis.iox_j.wkb.Wkb2iox)6 IsValidOp (com.vividsolutions.jts.operation.valid.IsValidOp)6 ServiceException (eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException)6 IoxException (ch.interlis.iox.IoxException)5 MapLayer (au.org.emii.portal.menu.MapLayer)4 Point (com.vividsolutions.jts.geom.Point)4 WKBReader (com.vividsolutions.jts.io.WKBReader)4 IOException (java.io.IOException)4 Literal (org.openrdf.model.Literal)4 Coordinate (com.vividsolutions.jts.geom.Coordinate)3 LineString (com.vividsolutions.jts.geom.LineString)3 Polygon (com.vividsolutions.jts.geom.Polygon)3 WKTWriter (com.vividsolutions.jts.io.WKTWriter)3