private static Geometry fromWKB( byte[] wkb ) { try { ByteArrayInputStream bytes = new ByteArrayInputStream( wkb, 0, wkb.length-4 ); //read the geometry Geometry g = new WKBReader().read( new InputStreamInStream( bytes ) ); //read the srid int srid = 0; srid |= wkb[wkb.length-4] & 0xFF; srid <<= 8; srid |= wkb[wkb.length-3] & 0xFF; srid <<= 8; srid |= wkb[wkb.length-2] & 0xFF; srid <<= 8; srid |= wkb[wkb.length-1] & 0xFF; g.setSRID(srid); return g; } catch( Exception e ) { throw new RuntimeException( e ); } }
public static Geometry read( InputStream is, ICRS crs ) throws IOException, ParseException { // com.vividsolutions.jts.io.WKBReader() is not thread safe return defaultGeom.createFromJTS( new com.vividsolutions.jts.io.WKBReader().read( new InputStreamInStream( is ) ), crs ); } }
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)))) { //don't allow ewkb - that needs an explicit function throw new FunctionExecutionException(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31160, "EWKB")); //$NON-NLS-1$ } 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) { } } } }
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)))) { //don't allow ewkb - that needs an explicit function throw new FunctionExecutionException(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31160, "EWKB")); //$NON-NLS-1$ } 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) { } } } }
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)))) { //don't allow ewkb - that needs an explicit function throw new FunctionExecutionException(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31160, "EWKB")); //$NON-NLS-1$ } 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) { } } } }