[Shapelib] possible bug when reading the boundaries ?

Stephane Routelous route at CAE.COM
Wed May 19 14:53:33 EDT 2004


Hi Frank,

Yes, I have a shape file where your code give me wrong results for the
boundaries (
xmin == ymin == 999999999
xmax == ymax == -999999999 ) where min > max

If you want, I can send you the files.

what about 
if ( boundaries in shx are not valid )
 readBoundariesFronShp();
 ?

Stephane Routelous
http://www.exotk.org





-----Original Message-----
From: Frank Warmerdam [mailto:warmerdam at pobox.com]
Sent: Wednesday, May 19, 2004 12:42 PM
To: Shapelib Development; route at cae.com
Subject: Re: [Shapelib] possible bug when reading the boundaries ?


Stephane Routelous wrote:
> Hi,
> 
> I'm investigating using ShapeLib instead of our own library because of
> performace issues.
> 
> I think I found a bug in the code for reading the bounds of a shape file
in
> SHPOpen
> at line 448, you have :
>     fread( pabyBuf, 100, 1, psSHP->fpSHX );
> meaning that you are reading informations from the shx file.
> 
> But after, you are reading the bounds with :
>     if( bBigEndian ) SwapWord( 8, pabyBuf+36 ); //line 480
>     memcpy( &dValue, pabyBuf+36, 8 );
>     psSHP->adBoundsMin[0] = dValue;
> 
> it means that the bounds are read from the SHX file, but according to the
> specifications, the bounds are in the SHP file.
> So, I think you should move the reading of the boundaries before the line
> 448.

Stephane,

Generally speaking the first 100 byte header of the SHP and SHX files are
the same.  One could argue about which should be consider "more
authoritative"
if they differ but I haven't really run into a problem with this so I am not
inclined to change it for hypothetical reasons.

Have you actually encountered a problem with this code?

Best regards,
-- 
---------------------------------------+------------------------------------
--
I set the clouds in motion - turn up   | Frank Warmerdam,
warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent


More information about the Shapelib mailing list