rburhum/arcgis-ogr

Geometry fails to be converted in KML files

Closed this issue · 5 comments

KML files fail to process geometry properly. I tested with this file https://developers.google.com/kml/documentation/KML_Samples.kml, document "Placemarks".

The problem lies in OGRCursor.QueryGeometry. When IWkb.ImportFromWkb is called, it throws an exception "expected wkbPoint type in wkb stream". The original OGR geometry seems to be okay, though (checked by converting to WKT).

It may be related to the fact that the geometry type is PointZ (the KML file contains elevation information).

Can you open witg the libkml driver and then with the built-in kml driver and see if there is a difference? I am in Machu Picchu now and dont have anything better than a smartphone :)

I might do that, but just found that after flattening the geometry with Geometry.FlattenTo2D(), IWkb.ImportFromWkb imports the geometry just fine.

Looks like Esri WKB implementation does not support Z values, using a different KML driver probably won't help since it should produce the same WKB.

You are completely correct. The Import to WKB is failing. I have added #11 to add Z support. In the meantime, I will fix this bug by calling FlattenTo2D() as you suggested.

Interestingly enough, too, I noticed very different number of fields between the libkml trunk driver and the built-in KML driver. I think I will bundle the libkml driver.

#11 will track the Z support and this commit f10d97b will take care of at least being able to read the geometries in 2D. Thank you ptr-k!