# Geometry :

Subject: [ggl] [Ticket #2] Implementation of io/wkb module
From: Mateusz Loskot (mateusz)
Date: 2009-06-14 08:35:23

Barend Gehrels wrote:
>>
>> Reading and parsing of linestring WKB added.
>>
>
> This goes quite fast now :-) Cool. I'll have a look today or tomorrow
> (am finishing some other things) to this and the endians.

OK, no rush.

> One questions already: is an EMPTY point supported? :-) Is it supported
> by OGC?

This is a good question.
For point there is no such thing as empty point in WKB.

Point geometry, a building block of all other geometries, it's defined
as follows:

Point
{
double x;
double y;
};

WKBPoint
{
byte byteOrder;
uint32 wkbType; // 1
Point point;
};

The size of point geometry in bytes is fixed: 1 + 4 + 8 + 8.

For instance, binary form (in hex) of "POINT (1.234 5.678)", visually
decomposed, is given as:

01
01000000
5839B4C876BEF33F
83C0CAA145B61640

So, there is no way to represent EMPTY point with "no coordinates
included", because bytes of coordinates must always be present.

In PostGIS, empty point/linestring/polygon/... in WKB form is
represented as empty collection

test=# SELECT ST_GeometryFromText('POINT EMPTY')::text;
st_geometryfromtext
---------------------
010700000000000000

what represents how the collection is defined:

WKBGeometryCollection
{
byte byte_order;
uint32 wkbType; // 7
uint32 num_wkbGeometries;
WKBGeometry wkbGeometries[num_wkbGeometries]
};

with size in bytes: 1 + 4 + 4 + 0

01
07000000
00000000 // <--- no geometries, stream terminator

PostGIS approach seems to be reasonable.

> p.s. NOTE: today I will commit changes, but I've many made (for
> concept:: etc), so please do not touch too much from the common sources
> today... (WKB/endian of course is untouched by me )

Understood.

Cheers,

```--
Mateusz Loskot, http://mateusz.loskot.net
Charter Member of OSGeo, http://osgeo.org
```

Geometry list run by mateusz at loskot.net