ngageoint / simple-features-wkb-java Goto Github PK
View Code? Open in Web Editor NEWSimple Features Well-Known Binary Java Library
Home Page: http://ngageoint.github.io/simple-features-wkb-java
License: MIT License
Simple Features Well-Known Binary Java Library
Home Page: http://ngageoint.github.io/simple-features-wkb-java
License: MIT License
Although the geometries are tested in the GeoPackage Java and Android projects, we need some stand alone library tests.
Please fill out as much known and relevant information as possible.
I am currently exploring how can I convert data from GeoJson formats to WKB and then store it but getting Magic value errors. From debugging it seems there is no place Converter would create magic value using POINT type.
mil.nga.geopackage.GeoPackageException: Unexpected GeoPackage Geometry magic number: ����, Expected: GP
mil.nga.geopackage.GeoPackageException: Unexpected GeoPackage Geometry magic number: ����, Expected: GP at mil.nga.geopackage.geom.GeoPackageGeometryData.fromBytes(GeoPackageGeometryData.java:111) at mil.nga.geopackage.geom.GeoPackageGeometryData.<init>(GeoPackageGeometryData.java:86) at land.meridia.collect.ngageo.poc.NGAGeo.onMapReady(NGAGeo.kt:150) at com.google.android.gms.maps.zzak.zza(Unknown Source:2) at com.google.android.gms.maps.internal.zzaq.dispatchTransaction(Unknown Source:12) at com.google.android.gms.internal.maps.zzb.onTransact(Unknown Source:12) at android.os.Binder.transact(Binder.java:667) at fv.b(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (040700-239467275):14) at com.google.android.gms.maps.internal.bd.a(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (040700-239467275):4) at com.google.maps.api.android.lib6.impl.bk.run(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (040700-239467275):4) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6669) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
val geometryGeoJson: mil.nga.sf.geojson.Geometry = FeatureConverter.toGeometry(geometryString)
val geometry:Geometry = geometryGeoJson.geometry
val writer = ByteWriter()
writer.byteOrder = ByteOrder.BIG_ENDIAN
GeometryWriter.writeGeometry(writer, geometry)
val bytes: ByteArray = writer.bytes
writer.close()
val geoPackageData = GeoPackageGeometryData(bytes)
{ "type": "Point", "coordinates": [ 102.0, 0.5 ] }
I am just starting to use this interesting library, and I followed the example on reading a WKB as stated in the readme, here: https://github.com/ngageoint/geopackage-wkb-java/blob/master/README.md
Basically, the code translated to Kotlin is as follows:
//wkb_geometry is the wkb as String
var reader = ByteReader(wkb_geometry.toByteArray())
reader.byteOrder= ByteOrder.BIG_ENDIAN
var geometry: Geometry = WkbGeometryReader.readGeometry(reader)
However, I obtained a NullPointerException
that traces to the Geometry instantiation line (the last one). This WKB I originally saved on a PostGIS database, and I have checked it is saved correctly (as I can display the geometries on my GeoServer as well as on the GIS I use)
Full (relevant) stack trace:
java.lang.NullPointerException: Attempt to invoke virtual method 'int mil.nga.wkb.geom.GeometryType.ordinal()' on a null object reference
at mil.nga.wkb.io.WkbGeometryReader.readGeometry(WkbGeometryReader.java:94)
at mil.nga.wkb.io.WkbGeometryReader.readGeometry(WkbGeometryReader.java:37)
at gt.aerobots.aegis.util.JsonHelper$Companion.toGeometry(JsonHelper.kt:31)
Run the code above mentioned, to instantiate a Geometry from a wkb
Here is the wkb of the geometry that gave me this error, I tried with others but get the same error. Worth mentioning that this is a MultiPolygon object:
0106000080010000000103000080010000000F0000007835454789C456C0DFDB63124D3F2C4000000000000000004CE4512E89C456C060BF20D13F3F2C400000000000000000A42EC6388CC456C0E0A50400423F2C400000000000000000B4E3B1608CC456C060034E67433F2C400000000000000000F82138508DC456C09FD015C5473F2C400000000000000000ECD6591B8CC456C000C305BC5B3F2C4000000000000000001002AD0F8CC456C060DB367D5C3F2C40000000000000000010996DEF8AC456C0BF01756A6C3F2C4000000000000000007054A08B8AC456C0806A0C1F733F2C4000000000000000009422D81D8AC456C041CA3C5B8A3F2C4000000000000000003CCB05C489C456C03FC4FC52AA3F2C400000000000000000740315A689C456C0BFC8635EB33F2C400000000000000000E4A5630B89C456C0DFE726D6B33F2C400000000000000000F45A4F3389C456C000B07950703F2C4000000000000000007835454789C456C0DFDB63124D3F2C400000000000000000
I am coding this app in Kotlin
I am able to verify that the wkb is OK, as it opens on my GeoServer and QGis
Further tracing the error I see it happens on line 94 of WkbGeometryReader, on the switch(geometryType)
part. It seems that geometryType
is null
, which suggests that GeometryType.fromCode()
is returning null
. This means that somehow it was unable to determine the Geometry Type on the switch/case.
I'll try other approaches to see if I screwed up with something. Thank you for your assistance :)
Hello, as we migrated data from Oracle (Spatial) to Postgres/Postgis (from WKT to WKB) we use your library to read the geometry from Postgres/Postgis.
We ran into problem with MULTICURVE/COMPOUND geometry, where in the specs of OGC there is the standard like non-instance class and you have it right.
But the implementation is different little bit and postgis is able to save the data like this:
st_geomfromtext('MULTICURVE(COMPOUNDCURVE(LINESTRING(3451418.006 5481808.951,3451417.787 5481809.927,3451409.995 5481806.744),LINESTRING(3451409.995 5481806.744,3451418.006 5481808.951)))')
And the software like QGIS and so on accept this, can read it from db.
So we want to know, if it is possible your parser (is the best for us) could accept and read also this geometry.
Thank you.
Hi,
I tried to use it to export geometry point as binary and use COPY command to copy it to PostGIS, but reports "ERROR: Geometry SRID (0) does not match column SRID (4326)". So my question is where can I set SRID to geometry types and then write them to binary? Thanks.
State your question
A clear and concise question.
Additional context
Add any other context or screenshots related to your question.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.