#44 WKBReader byte order determination is incomplete

v1.0 (example)
open
nobody
None
5
2013-11-12
2013-11-04
No

In JTS 1.13 WKBReader.readGeometry() stars with the following code:

private Geometry readGeometry()
throws IOException, ParseException
{
// determine byte order
byte byteOrder = dis.readByte();
// default is big endian
if (byteOrder == WKBConstants.wkbNDR)
dis.setOrder(ByteOrderValues.LITTLE_ENDIAN);

when processing multiple geometries in a loop having mixed LITTLE- and BIG-ENDIAN, when geometry i has LITTLE_ENDIAN and i+1 has BIG_ENDIAN, in fact geometry (i+1) will be parsed as LITTLE_ENDIAN which will apparently fail.

The possible solution would be to add also if-check for WKBConstants.wkbXDR.

Discussion

  • Jukka Rahkonen
    Jukka Rahkonen
    2013-11-12

    If the WKB reader code will be touched perhaps issue #36 could be considered at the same?