[geos-devel] WKBReader Endian detection fails

strk at refractions.net strk at refractions.net
Tue May 2 10:02:38 EDT 2006

This was a bug. Thanks for pointing out.
It's been fixed in the 2.2 and head branches.


On Sat, Apr 29, 2006 at 09:19:39PM -0700, Jeffrey J. Early wrote:
> I'm running GEOS 2.2.1 on a big endian machine (macosx, ppc) and encountered
> troubles when trying to use the c -interface function GEOSGeomFromWKB_buf.
> Specifically it fails to properly set the internal byte ordering to big
> endian. In the file WKBReader.cpp I took the lines (68-70):
>     // default is machine endian
>     if (byteOrder == WKBConstants::wkbNDR)
>         dis.setOrder(ByteOrderValues::ENDIAN_LITTLE);
> And added,
>     else
>         dis.setOrder(ByteOrderValues::ENDIAN_BIG);
> after it. This solved the problem.
> I discovered this problem reading some WKB data from a Postgresql database
> via PostGIS and tried to dump it to GEOSGeomFromWKB_buf. This failed with
> the error message "Unknown WKB type ". I was pretty sure the data was valid
> having written my own WKB parser which worked successfully on the same data.
> I can't get the CVS code to compile, so I don't know if it's been fixed
> already -- but glancing at the WKBReader.cpp file in CVS I don't see an
> obvious change.
> Should this be patched? Or is something else possibly causing this problem?
> Jeffrey

More information about the geos-devel mailing list