[Shapelib] How to Extract line data with in given extents.
Frank Warmerdam
fwarmerdam at gmail.com
Wed Feb 9 13:27:40 EST 2005
On Wed, 9 Feb 2005 23:38:36 +0530, Chandra Murali.S, ASDC Chennai
<chandramuralis at hcltech.com> wrote:
>
>
> Hi Frank,
> Thanks a lot for your kind reply. I've gone through this Is there
> any sample code available to accomplish this operation.
Murali,
Do you mean the operation of comparing a SHPObject's extents
with your bounding box?
This code from shputils.c seems to compare SHPObject psCShape to
a bounding box defined by cxmin,cymin,cxmax,cymax.
/*** FIRST check the boundary of the feature ***/
if ( ( (psCShape->dfXMin < cxmin) && (psCShape->dfXMax < cxmin) ) ||
( (psCShape->dfYMin < cymin) && (psCShape->dfYMax < cymin) ) ||
( (psCShape->dfXMin > cxmax) && (psCShape->dfXMax > cxmax) ) ||
( (psCShape->dfYMin > cymax) && (psCShape->dfYMax > cymax) ) )
{ /** Feature is totally outside clip area **/
if (ierase) return(1); /** WRITE RECORD **/
else return(0); /** SKIP RECORD **/
}
There is actually a bunch more "clipping to rectangle" code in the same function
(clip_boundary() in shputils.c) that might be of interest.
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