[postgis-devel] Review of TWKB spec

Even Rouault even.rouault at mines-paris.org
Wed Jun 19 10:00:39 PDT 2013


Hi Nicklas,

I've had a look at the TWKB spec, and here are some ideas to improve it I 
wanted to share :

* I would drop the bit for endianness. Just state that the endianness is 
little endian, and let the few big endian hosts in the wild do the byte 
swapping. This will make implementation of the spec easier.

* use the bit that has been saved above to indicate if the geometries have an 
id or not. There are certainly use cases where we don't need the id, or where 
it is transported by other means.

* instead of using UINT32 that is always 4 byte long, I would rather use the 
Google Protocol Buffer way of encoding integers. That way if the number is 
lesser than 128, it will fit on a single byte. See 
https://developers.google.com/protocol-buffers/docs/encoding#varints .

* for polygons and multipolygons, you could save a few bytes by specifying 
that the last vertex of a ring isn't serialized. It is left to the decoder to 
add it to properly close the ring.

* typos in paragraph "Type 24, MultiGometryCollection (with individual id)",
	- MultiGometryCollection --> MultiGeometryCollection
	- you don't mean "UINT32 npolygons a 4 byte integer holding number of 
polygons", but probably "UINT32 ngeometries a 4 byte integer holding number of 
geometries".
	- Instead of MultiGeometryCollection, I would call it "GeometryCollection 
(with individual id)" and would allow any geometry in it.

* As we live in a binary world, it might perhaps be better to use 2^precision 
scaling instead of 10^precision. Someone smart could probably avoid any 
floating point operation by having fun with the IEEE754 representation of 
floating point numbers and bit shift operations.

* Delta value encoding : use GPB varint. This would also enable you to support 
easily 64bit or 128bit deltas when they sometimes occur. That would remove the 
need for method nr 1.

	--> The idea of using GPB actually comes from the PBF encoding of OSM 
data : http://wiki.openstreetmap.org/wiki/PBF_Format

Suggestion if you want more visibility: advertize your spec on 
standards at lists.osgeo.org

Best regards,

Even

-- 
Geospatial professional services
http://even.rouault.free.fr/services.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-devel/attachments/20130619/fa39d547/attachment.html>


More information about the postgis-devel mailing list