[geos-devel] WKBReader Endian detection fails

Jeffrey J. Early jearly at alum.ups.edu
Sun Apr 30 00:19:39 EDT 2006


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