Hello. Recently I have debugged ShapefileReader with one shapefile that
caused rendering problems in UDIG from 1.1.x codebase. The shapefile is
generated by las2ogr utility taking LiDAR file (points cloud in (X,Y,Z)
space) as an input. Actually points are written to shapefile by OGR (I
use alomost latest GDAL with OGR version of 1.6.1). And OGR generates a
shapefile record of format:
0-4 - ShapeType (Integer)
4-12 - X (Double)
12-20 - Y (Double)
20-28 - Z (Double)
The length is 28 bytes in total. At the same time shapefile specs says
about forth band called "M" like "Measure".
From specs:
=====================================
Position Field Value Type Number Order
Byte 0 Shape Type 11 Integer 1 Little
Byte 4 X X Double 1 Little
Byte 12 Y Y Double 1 Little
Byte 20 Z Z Double 1 Little
Byte 28 Measure M Double 1 Little
======================================
The M value can be nullable (aka "no data").
LiDAR files can be huge and contain million of points. Having this band
for every point can waste the space in many cases. Seems OGR ignores
generation of this band, but ShapefileReader of GeoTools does not handle
this specific case in a code:
===================================
buffer.mark();
if (recordType.isMultiPoint()) {
record.minX = buffer.getDouble();
record.minY = buffer.getDouble();
record.maxX = buffer.getDouble();
record.maxY = buffer.getDouble();
} else if (recordType != ShapeType.NULL) {
record.minX = record.maxX = buffer.getDouble();
record.minY = record.maxY = buffer.getDouble();
}
buffer.reset();
=========================================
Last " record.maxY = buffer.getDouble();" throws an exception:
BufferUnderflowException when it tries to read last point record in
shapefile.
Shouldn't we just check this shapefile configuration somewhere in
initialization routine and handle PointZ without M component as not
"MultiPoint"? .. and add one more if/else to read only (X, Y, Z)
components in ShapefileReader.nextRecord().
Vitali Diatchkov.
------------------------------------------------------------------------------
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel