Search in sources :

Example 1 with InputStreamInStream

use of com.vividsolutions.jts.io.InputStreamInStream 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)

Aggregations

InputStreamInStream (com.vividsolutions.jts.io.InputStreamInStream)1 ParseException (com.vividsolutions.jts.io.ParseException)1 WKBReader (com.vividsolutions.jts.io.WKBReader)1 IOException (java.io.IOException)1 FunctionExecutionException (org.teiid.api.exception.query.FunctionExecutionException)1