if (bytes != null) {
byte[] wkb = new byte[bytes.length - 4];
System.arraycopy(bytes, 4, wkb, 0, wkb.length);
int srid = bytes[3] << 24 | (bytes[2] & 0xff) << 16 | (bytes[1] & 0xff) << 8 | (bytes[0] & 0xff);
// TODO make sure srid is set
WkbDecoder decoder = Wkb.newDecoder(Wkb.Dialect.POSTGIS_EWKB_1);
return decoder.decode(ByteBuffer.from(wkb));
} else {
return null;
}
}