postgis/examples/wkb_reader
Paul Ramsey ef3e0404dd This file is superceded by the Makefile.
git-svn-id: http://svn.osgeo.org/postgis/trunk@50 b70326c6-7e19-0410-871a-916f4a2858ee
2001-08-07 21:36:08 +00:00
..
Makefile Added a 'make clean' directive. 2001-07-16 16:53:31 +00:00
printwkb.inc Initial revision 2001-06-22 17:39:29 +00:00
README Initial revision 2001-06-22 17:39:29 +00:00
readwkb.c converting a GEOMETRYCOLLECTION to wkb had the size of the wkb off by 9 2001-06-28 17:52:15 +00:00

This is a very simple example of using binary cursors to move binary data from 
the server to the client.

We convert the GEOMETRY to the OpenGIS Well Known Binary (WKB) format before 
sending it to the client.

The WKB format contains information about the endian of the data, so it can be
used for transfer between servers and clients that are not the same endian 
(ie. between i386 and sparc)

See http://www.opengis.org/techno/specs/99-049.rtf page 3-24 for the WKB 
specification.

3d geometries are encoded as in OGR by adding 32768 to the type.  Points are 
then 24 bytes (X,Y,Z) instead of 16 bytes (X,Y).  

You can force 3d geometries to be returned as 2d geometries by using the
force_2d() function. For example:

  select wkb_ndr(force_2d(geom)) from mytable;

If the client is running on a i386, you should use wkb_ndr() and on a sparc 
you should use wkb_xdr() so you do not causes an endian shift on both the 
server and client.