[geos-devel] WKB representation is EWKB, not OGC

Paul Ramsey pramsey at cleverelephant.ca
Wed Dec 4 21:38:58 PST 2013


Right, at the time JTS/GEOS came into being, the only standard WKB was
2D WKB, so from an interop point of view, it was golden.

It might be time to update the reader to ingest more variants, and the
writer to emit ISO standard 3D/4D variants. That would imply also
updating the WKT writer and reader, etc, etc. And how about an M
coordinate? :)

P.

On Wed, Dec 4, 2013 at 8:51 PM, Martin Davis <mtnclimb at telus.net> wrote:
> The JTS doc for the WKBReader says:
>
> "It also partially handles the Extended WKB format used by PostGIS".
>
> My recollection is that at the time JTS was original developed, the OGC SFS
> spec was at version 1.1 (99-049), and did not specify 3D support for WKB.
> PostGIS extended the spec to allow this - but when the OGC got around to
> specifying it, it did so in a different way. Hence the discrepancy.
>
>
>
> On 12/4/2013 12:33 PM, Mike Toews wrote:
>>
>> Hi,
>>
>> It appears that the WKB format used by the WKBReader/Writer is not the
>> OGC WKB as documented in the API [1,2], but is the PostGIS' EWKB
>> format [3]. This distinction is not mentioned.
>>
>> >From what I can tell, these two formats are different when used with
>> non-2D geometries. For example, take 'POINT Z (1 2 3)'.
>>
>> SELECT
>>    encode(ST_AsBinary(g, 'xdr'), 'hex') as ogc,
>>    encode(ST_AsEWKB(g, 'xdr'), 'hex') as ewkb
>> FROM (SELECT 'POINT Z (1 2 3)'::geometry AS g) AS f;
>>
>> -[ RECORD 1 ]----------------------------------------------------
>> ogc  | 00000003e93ff000000000000040000000000000004008000000000000
>> ewkb | 00800000013ff000000000000040000000000000004008000000000000
>>
>> The geometry type parts of the hex strings are:
>>
>> ogc: 0x000003e9 or better known as 1001 in base-10
>> ewkb: 0x80000001, from 1 | 0x80000000
>>
>> Not to mention the differences of M in OGC (parsed, but ignored by
>> GEOS), and SRID bit mask in EWKB (supported by GEOS).
>>
>> The WKBWriter doesn't write OGC WKB, as the documentation appears to
>> claim[2], and the WKBReader actually cannot parse the OpenGIS WKB,
>> which is also claimed in the documentation [1].
>>
>> Attempting to read the OGC WKB example throws:
>> ParseException: Unknown WKB type 48
>>
>> -Mike
>>
>> [1] http://geos.osgeo.org/doxygen/classgeos_1_1io_1_1WKBReader.html
>> [2] http://geos.osgeo.org/doxygen/classgeos_1_1io_1_1WKBWriter.html
>> [3] http://trac.osgeo.org/postgis/browser/trunk/doc/ZMSgeoms.txt
>> _______________________________________________
>> geos-devel mailing list
>> geos-devel at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/geos-devel
>>
>>
>> -----
>> No virus found in this message.
>> Checked by AVG - www.avg.com
>> Version: 2013.0.3426 / Virus Database: 3657/6891 - Release Date: 12/04/13
>>
>>
>
> _______________________________________________
> geos-devel mailing list
> geos-devel at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/geos-devel


More information about the geos-devel mailing list