2
Vote

WKBWriter adds 4 null bytes?

description

Using the following code with polygon and multipolygons, I'm seeing an extra 4 zero'ed bytes at the end of any WKB output. PostGIS doesn't care about them, but SQL Server sees this as invalid WKB. EG:
 
Yeilds:
0x010300000001000000070000004...33BCC4B4000000000
 
Should yeild:
0x010300000001000000070000004...33BCC4B40
 
 
Shapefile shapefile = Shapefile.OpenFile(tempShpPath);
foreach (var feature in shapefile.Features)
{
byte[] wkb = feature.BasicGeometry.ToBinary();
Array.Resize(ref wkb, wkb.Length - 4); //chop off the weird last 4 bytes
//do something with the wkb
}

comments

mudnug wrote Apr 10, 2012 at 6:01 PM

It looks like that code was take from Net Topology Suite. Perhaps they have already posted an update.