public GeoPkgGeomReader(InputStream input) throws IOException { this.input = new InputStreamInStream(input); }
@Override public Geometry loadFootprint(String pathNoExtension) throws Exception { File file = new File(pathNoExtension + ".wkb"); if (file.exists()) { FileInputStream is = null; try { is = new FileInputStream(file); return reader.read(new InputStreamInStream(is)); } finally { IOUtils.closeQuietly(is); } } return null; }
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 GeoPkgGeomReader(InputStream input) throws IOException { this.input = new InputStreamInStream(input); }
private Geometry createGeometry(ByteArrayInputStream stream) { InputStreamInStream inputStreamInStream = new InputStreamInStream(stream); Geometry geometry = null; try { geometry = new WKBReader().read(inputStreamInStream); } catch (IOException e) { throw new IllegalArgumentException("given geometry can not be found", e); } catch (ParseException e) { throw new IllegalArgumentException("given geometry is not valid", e); } return geometry; }
private Geometry createGeometry(ByteArrayInputStream stream) { InputStreamInStream inputStreamInStream = new InputStreamInStream(stream); Geometry geometry = null; try { geometry = new WKBReader().read(inputStreamInStream); } catch (IOException e) { throw new IllegalArgumentException("given geometry can not be found", e); } catch (ParseException e) { throw new IllegalArgumentException("given geometry is not valid", e); } return geometry; }
public static Geometry gFromEWKB( byte[] wkb, WKBReader wkbreader ) { try { //just read back everything after the first 32 bytes normally return wkbreader.read( new InputStreamInStream(new ByteArrayInputStream(wkb,32,wkb.length-32)) ); } catch( Exception e ) { // try the old format /*try { return fromWKB( wkb ); } catch( Exception e2 ) { //fail below }*/ throw new RuntimeException( e ); } }
public static Geometry gFromEWKB( byte[] wkb, WKBReader wkbreader ) { try { //just read back everything after the first 32 bytes normally return wkbreader.read( new InputStreamInStream(new ByteArrayInputStream(wkb,32,wkb.length-32)) ); } catch( Exception e ) { // try the old format /*try { return fromWKB( wkb ); } catch( Exception e2 ) { //fail below }*/ throw new RuntimeException( e ); } }
/** * @deprecated use {@link #gFromWKB(byte[])} */ 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 ); } }
/** * @deprecated use {@link #gFromWKB(byte[])} */ 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 ); } }