ThinkGeo.com    |     Documentation    |     Premium Support

Z-geometries from PostGIS and SQLite: The format of the known binary is incorrect (Parameter 'wkb')

Hi,

We are currently evaluating ThinkGeo for WPF and Blazor, but are having some problems opening our data sources. We have data tables in SQLite and PostGIS, both with Z-enabled geometries. We write the tables with “Microsoft.EntityFrameworkCore.Sqlite.NetTopologySuite” and “Npgsql.EntityFrameworkCore.PostgreSQL.NetTopologySuite” respectively.
For both data sources we get the message “the format of the known binary is incorrect (Parameter ‘wkb’)” when we try to draw the map.

If we create a custom layer, read the geometry with NTS and create the features with “new Feature(geometry.ToBinary())” from the NTS-geometry, the features will be created and drawn.

Note: For SQLite geometries we use “NetTopologySuite.IO.GaiaGeoReader.Read(byte[] reader.GetFieldValue<byte[]>([n]))”, for PostGIS “reader.GetFieldValue<NetTopologySuite.Geometries.Geometry>([n])”.

Are we missing something?

Thanks and best regards, Volker

Hi Volker,

It seems we had an issue parsing some of the wkbs with the Z value.

It works if using Feature(geometry.ToBinary()). I think it’s because the original wkb, which is valid but not well formalized, is supported by NTS but not by ThinkGeo. The new wkb returned from geometry.ToBinary() is formalized by NTS so can be correctly parsed by a ThinkGeo Feature as well.

Can you send me one of the original WKB bytes that work with NTS but fail with ThinkGeo, to help us fix the issue?

Before we fix it, I think what you are doing right now — using NTS to read the geometry, then re-serialize it to binary using geometry.ToBinary() before creating a ThinkGeo feature — is a good workaround.

Thanks,
Ben