Search in sources :

Example 21 with ParseException

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

the class NsiliFilterFactory method convertWktToBqs.

public String convertWktToBqs(String wkt) {
    WKTReader wktReader = new WKTReader(GEOMETRY_FACTORY);
    Geometry geometry;
    try {
        geometry = wktReader.read(wkt);
    } catch (ParseException e) {
        LOGGER.debug("Unable to parse WKT String {}", wkt, e);
        return NsiliFilterDelegate.EMPTY_STRING;
    }
    if (geometry.getCoordinates() == null || StringUtils.isBlank(geometry.getGeometryType())) {
        return NsiliFilterDelegate.EMPTY_STRING;
    }
    StringBuilder result = new StringBuilder(geometry.getGeometryType().toUpperCase() + LP);
    Coordinate[] coordinates = geometry.getCoordinates();
    for (Coordinate coordinate : coordinates) {
        result.append(coordinate.y + COMMA + coordinate.x + COMMA);
    }
    return result.toString().substring(0, result.toString().length() - 1) + RP;
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) Coordinate(com.vividsolutions.jts.geom.Coordinate) ParseException(com.vividsolutions.jts.io.ParseException) WKTReader(com.vividsolutions.jts.io.WKTReader)

Example 22 with ParseException

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

the class ImagingChipActionProvider method hasValidLocation.

private boolean hasValidLocation(String location) {
    if (StringUtils.isNotBlank(location)) {
        try {
            // parse the WKT location to determine if it has valid format
            final WKTReader wktReader = new WKTReader(geometryFactory);
            wktReader.read(location);
            return true;
        } catch (ParseException e) {
            LOGGER.debug("Location [{}] is invalid. Cannot chip this image", location);
        }
    }
    return false;
}
Also used : ParseException(com.vividsolutions.jts.io.ParseException) WKTReader(com.vividsolutions.jts.io.WKTReader)

Example 23 with ParseException

use of com.vividsolutions.jts.io.ParseException in project teiid by teiid.

the class GeometryUtils method getGeometry.

public static Geometry getGeometry(InputStream is1, Integer srid, boolean allowEwkb) throws FunctionExecutionException {
    try {
        WKBReader reader = new WKBReader();
        Geometry jtsGeom = reader.read(new InputStreamInStream(is1));
        if (!allowEwkb && (jtsGeom.getSRID() != GeometryType.UNKNOWN_SRID || (jtsGeom.getCoordinate() != null && !Double.isNaN(jtsGeom.getCoordinate().z)))) {
            // $NON-NLS-1$
            throw new FunctionExecutionException(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31160, "EWKB"));
        }
        if (srid != null) {
            jtsGeom.setSRID(srid);
        }
        return jtsGeom;
    } catch (ParseException e) {
        throw new FunctionExecutionException(e);
    } catch (IOException e) {
        throw new FunctionExecutionException(e);
    } finally {
        if (is1 != null) {
            try {
                is1.close();
            } catch (IOException e) {
            }
        }
    }
}
Also used : InputStreamInStream(com.vividsolutions.jts.io.InputStreamInStream) FunctionExecutionException(org.teiid.api.exception.query.FunctionExecutionException) ParseException(com.vividsolutions.jts.io.ParseException) IOException(java.io.IOException) WKBReader(com.vividsolutions.jts.io.WKBReader)

Example 24 with ParseException

use of com.vividsolutions.jts.io.ParseException in project hibernate-spatial-tutorials by maesenka.

the class EventManager method wktToGeometry.

private Geometry wktToGeometry(String wktPoint) {
    WKTReader fromText = new WKTReader();
    Geometry geom = null;
    try {
        geom = fromText.read(wktPoint);
    } catch (ParseException e) {
        throw new RuntimeException("Not a WKT string:" + wktPoint);
    }
    return geom;
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) ParseException(com.vividsolutions.jts.io.ParseException) WKTReader(com.vividsolutions.jts.io.WKTReader)

Example 25 with ParseException

use of com.vividsolutions.jts.io.ParseException in project ili2db by claeis.

the class PostgisColumnConverter method toIomMultiSurface.

@Override
public IomObject toIomMultiSurface(Object geomobj, String sqlAttrName, boolean is3D) throws SQLException, ConverterException {
    byte[] bv = (byte[]) geomobj;
    Wkb2iox conv = new Wkb2iox();
    try {
        return conv.read(bv);
    } catch (ParseException e) {
        throw new ConverterException(e);
    }
}
Also used : ConverterException(ch.ehi.ili2db.converter.ConverterException) ParseException(com.vividsolutions.jts.io.ParseException) Wkb2iox(ch.interlis.iox_j.wkb.Wkb2iox)

Aggregations

ParseException (com.vividsolutions.jts.io.ParseException)64 Geometry (com.vividsolutions.jts.geom.Geometry)28 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 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 Point (com.vividsolutions.jts.geom.Point)3 Polygon (com.vividsolutions.jts.geom.Polygon)3 WKTWriter (com.vividsolutions.jts.io.WKTWriter)3 SQLException (java.sql.SQLException)3