Instead of continuing with the old samples I created a new one in a
systematical way.
1)Create a polygon z with OpenJUMP
POLYGON (( 340 580 1, 560 580 2, 560 420 3, 340 580 1 ))
2)Save as jml
3)Convert with ogr2ogr
ogr2ogr -f gpkg polygonz.gpkg polygonz.jml
4)Check with ogrinfo
ogrinfo polygonz.gpkg -al
INFO: Open of `polygonz.gpkg'
using driver `GPKG' successful.
Layer name: polygonz
Geometry: Unknown (any)
Feature Count: 1
Extent: (340.000000, 420.000000) - (560.000000, 580.000000)
Layer SRS WKT:
(unknown)
FID Column = fid
Geometry Column = geom
OGRFeature(polygonz):1
POLYGON ((340 580 1,560 580 2,560 420 3,340 580 1))
Good so far, GDAL can round trip and GeoPackage contains the same XYZ
geometry which I made with OpenJUMP
5)Open polygonz.gpkg with Spatialite-gui v. 1.8.0-devel
Spatialite-gui creates an virtual table vgpkg_polygonz that converts
GeoPackege blobs into Spatialite blobs on-the-fly. Geometry preview
shows that Spatialite does understand the blob.
6)Study the GeoPackage blob from the original “polygonz” table with
the BLOB explore tool. Use the Export BLOB option and save into a file.
Trying to analyze the first bytes:
-47 50 00 = It is GeoPackage blob, version 1
-05 = flags, 48 bytes reserved for the envelope
-00 00 00 00 = srid, not defined
-after srid bytes skip 48 bytes and read from byte 57
-Now I think that byte 57 is not yet WKB but perhaps some binary flag
byte; the value is “40”
-WKB starts: 01 EB 03 00 00 …
This seems to be the same as last time. You say that EB 03 00 00 is
not correct but still GDAL writes it so and it seems that both GDAL
and Spatialite-gui can read it right. But what if it is not a 4-byte
integer but a 2-byte integer? Wouldn’t little endian EB 03 be correct
then?
GeoPackage and BLOB attached.
-Jukka-
*Lähettäjä:*Michaël Michaud [mailto:[email protected]]
*Lähetetty:* 10. helmikuuta 2016 22:36
*Vastaanottaja:*[email protected]
*Aihe:* Re: [JPP-Devel] Parsing XYZ geometries from Geopackage
Hi,
I suspect your geometry is malformed. Do you intend something like the
following ?
- I am not encline to suspect JTS parser because I have used it to
parse PostGIS 2D and 3D WKB for a long time.
- When I saw your example on stackoverflow, I suspected EB 03 is not a
valid geometry type.
- When I swapp byte 2 and 3 of the wkb (what I would have done to
write 1003 geometry type with little endian convention), I can read it
and get the above geometry.
More about endianess
The wkb first byte is an endianess flag. It says the geometry type is
coded using little endian convention (01)
But actual int value EB 03 00 00 is neither 1003 in little endian
convention nor in big endian convention
little endian (less significant bit first) : 1003 (as a 4 bytes
integer) = 03 EB 00 00
big endian (most significant bit first) : 1003 (as a 4 bytes
integer) = 00 00 EB 03
Also, I made a quick test with Spatialite, and when I tried to read
geometry (ST_AsText(geom)), it returned null.
Could you read this table with spatialite ?
Do you know how this gpkg file has been produced ?
Michaël
Le 10/02/2016 10:24, [email protected] <mailto:[email protected]>
a écrit :
hehe :)),
it was probably less a lack of interest and more a lack of directly usable
test data ;).. anyway,
Mike: afair WKB blob parsing is done via JTS, or? so the bug is probably in
there and must be fixed there as well. maybe i makes sense if you forward the
testdata to them.
..ede
On 09.02.2016 23:40, Rahkonen Jukka (MML) wrote:
Hi,
Sorry, I was thinking that you programmers are interested in the deep
details. That file can't be read directly with OJ because it is just the
geometry BLOB from the database. Perhaps somebody who knows the source code
could feed the blob into the Spatialite code in the debug environment and see
what happens.
Here is a small GeoPackage that shows the problem with parsing XYZ
geometrieshttp://latuviitta.org/downloads/mtk.gpkg.
Make a spatialite connection to the database file and try to read some layer. My
example was from the "kunta" layer which is POLYGON Z.
-Jukka-
Michaël Michaud wrote:
Jukka,
Can you give me some some hints to test the file with OpenJUMP ?
I tried to open the file with datastore / spatialite driver, but it
does not seem to recognize the file as a sqlite database.
Is it supposed to be recognized as is.
With
Le 09/02/2016 11:09, Rahkonen Jukka (MML) a écrit :
Hi Michaël,
Please find attached one GeoPackage blob that OpenJUMP does not
convert. It is of type POLYGON Z, thus 1003 and 03ea as hexadecimal.
I am not good in reading bits and bytes but I have tried.
Bytes 1-3:
47 50 00
"GP" and "0" Means that file is Geopackage, version 1
Byte 4: 05
This is a lag byte with bit values 0 0 0 0 0 1 0 1
Of those flags bits 5-7 "010" makes number "2", which means that
envelope is [minx, maxx, miny, maxy, minz, maxz] and it takes 48 bytes. Remember this.
Bytes 5-8:
fb 0b 00 00
SRID, value as decimal number "3067"
Bytes 9-56
48 bytes used for the envelope
Bytes 57 ->
WKB
starts 00 01 eb 03 ...
In reversed order "03 eb" is 1003 as decimal, which means "wkbPolygonZ"
which is correct.
Regards,
-Jukka-
Lähettäjä: Michaël Michaud [mailto:[email protected]]
Lähetetty: 9. helmikuuta 2016 10:13
Vastaanottaja:[email protected]
<mailto:[email protected]><mailto:[email protected]>
<mailto:[email protected]>
Aihe: Re: [JPP-Devel] Parsing XYZ geometries from Geopackage
Hi Jukka,
GeoPackage geometry is read with JTS WKBReader which is supposed to
handle 3D geometries.
I think it cannot read ZM though.
The WKB type returned in the error message is the geometry type
truncated to the 2 last bytes,
z information is held in a separate boolean variable for every type >
128.
Maybe the reading of the wkb part does not start exactly where it
should. Or maybe there is an
endianness problem.
In the example of stackoverflow, I would say that the input wkb is
actually not valid (I would write
wkb type as 03ea0000, not ea030000), but I may be wrong.
Michaël
Le 08/02/2016 23:40, Rahkonen Jukka (MML) a écrit :
Hi,
I tried to open a GeoPackage file through the new Spatialite datastore but got
just JTS errors like "unknown wkb type 235". I discovered soon that my data had
also Z-coordinates and this Stackoverflow
questionhttp://stackoverflow.com/questions/29142663/parse-wkb-string-using-jts-topology-suite
handles the same issue. But don't we have some support for 3d geometries in WKB range
1001-1007 in other places of OpenJUMP?
The full list of WKB types from page 66 of "OpenGIS® Implementation Standard
for Geographic information - Simple feature access - Part 1: Common architecture" is
as follows:
enum WKBGeometryType {
wkbPoint = 1,
wkbLineString = 2,
wkbPolygon = 3,
wkbTriangle = 17
wkbMultiPoint = 4,
wkbMultiLineString = 5,
wkbMultiPolygon = 6,
wkbGeometryCollection = 7,
wkbPolyhedralSurface = 15,
wkbTIN = 16
wkbPointZ = 1001,
wkbLineStringZ = 1002,
wkbPolygonZ = 1003,
wkbTrianglez = 1017
wkbMultiPointZ = 1004,
wkbMultiLineStringZ = 1005,
wkbMultiPolygonZ = 1006,
wkbGeometryCollectionZ = 1007,
wkbPolyhedralSurfaceZ = 1015,
wkbTINZ = 1016
wkbPointM = 2001,
wkbLineStringM = 2002,
wkbPolygonM = 2003,
wkbTriangleM = 2017
wkbMultiPointM = 2004,
wkbMultiLineStringM = 2005,
wkbMultiPolygonM = 2006,
wkbGeometryCollectionM = 2007,
wkbPolyhedralSurfaceM = 2015,
wkbTINM = 2016
wkbPointZM = 3001,
wkbLineStringZM = 3002,
wkbPolygonZM = 3003,
wkbTriangleZM = 3017
wkbMultiPointZM = 3004,
wkbMultiLineStringZM = 3005,
wkbMultiPolygonZM = 3006,
wkbGeometryCollectionZM = 3007,
wkbPolyhedralSurfaceZM = 3015,
wkbTinZM = 3016,
}
-Jukka Rahkonen-
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
Jump-pilot-devel mailing list
[email protected]
<mailto:[email protected]><mailto:[email protected]>
<mailto:[email protected]>
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
Jump-pilot-devel mailing list
[email protected]
<mailto:[email protected]><mailto:[email protected]>
<mailto:[email protected]>
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
Jump-pilot-devel mailing list
[email protected]
<mailto:[email protected]>
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
Jump-pilot-devel mailing list
[email protected]
<mailto:[email protected]>
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
Jump-pilot-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel