[postgis-devel] wkb parsing
David Blasby
dblasby at refractions.net
Tue Nov 25 09:42:48 PST 2003
strk wrote:
> I'm hardly trying to get wkb parsing to work, but it is not
> as easy as I expected (at least for me).
>
> I've seen the 3d extension brought to wkb by postgis, but I'm
> not sure about some other compatibility issues. For example:
> is a WKBMultiPolygon composed of WKBPolygons OR as for the
> postgis object of Polygons ? OGC spec is really loosy.
According to the spec::
wkbMultiPolygon {
byte byteOrder;
uint32 wkbType; // 6
uint32 num_wkbPolygons;
WKBPolygon wkbPolygons[num_wkbPolygons];
}
WKBPolygon {
byte byteOrder;
uint32 wkbType; // 3
uint32 numRings;
LinearRing rings[numRings];
}
So, in the byte stream you'll see a header ("wbkMultiPolygon")::
byte byteOrder; //NDR or XDR
uint32 wkbType; // 6
uint32 num_wkbPolygons; // number of polygons
Followed a set (num_wkbPolygons) of WKBPolygons.
byte byteOrder;
uint32 wkbType; // 3
uint32 numRings;
LinearRing rings[numRings];
byte byteOrder;
uint32 wkbType; // 3
uint32 numRings;
LinearRing rings[numRings];
...
There's a parser and creator in postgis, so you can look there. You can
also use unix commands like "od" and "hexedit" to look at the actual wkb
byte stream.
dave
More information about the postgis-devel
mailing list