[Shapelib] possible bug when reading the boundaries ?

David.Gancarz at ci.orlando.fl.us David.Gancarz at ci.orlando.fl.us
Wed May 19 15:27:23 EDT 2004


ESRI does, in fact, state that the organization of the 100-byte header in 
the index file is identical to the main file header -- presumably this 
means the contents are identical, as well; although that is not stated 
explicitly.  This raises the obvious question then:  what is the history 
of your shapefile?  What might have caused its shx header to become 
different from its shp header?

Dave Gancarz




Stephane Routelous <route at CAE.COM> 
Sent by: shapelib-bounces at lists.maptools.org
05/19/2004 02:53 PM
Please respond to
Shapelib Development <shapelib at lists.maptools.org>


To
"'Frank Warmerdam'" <warmerdam at pobox.com>, Shapelib Development 
<shapelib at lists.maptools.org>
cc

Subject
RE: [Shapelib] possible bug when reading the boundaries ?






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
_______________________________________________
Shapelib mailing list
Shapelib at lists.maptools.org
http://lists.maptools.org/mailman/listinfo/shapelib

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/shapelib/attachments/20040519/db096e48/attachment.htm


More information about the Shapelib mailing list