<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2653.12">
<TITLE>RE: [Shapelib] How to Extract line data with in given extents.</TITLE>
</HEAD>
<BODY>
<P><FONT SIZE=2>Hi Frank,</FONT>
<BR> <FONT SIZE=2>Thanks a lot for your kind reply. I've gone through this Is there any sample code available to accomplish this operation. </FONT></P>
<P><FONT SIZE=2>Thanks in advance.</FONT>
</P>
<P><FONT SIZE=2>Regards,</FONT>
<BR><FONT SIZE=2>Murali.</FONT>
</P>
<P><FONT SIZE=2>-----Original Message-----</FONT>
<BR><FONT SIZE=2>From: Frank Warmerdam [<A HREF="mailto:fwarmerdam@gmail.com">mailto:fwarmerdam@gmail.com</A>]</FONT>
<BR><FONT SIZE=2>Sent: Wednesday, February 09, 2005 8:14 PM</FONT>
<BR><FONT SIZE=2>To: Shapelib Development</FONT>
<BR><FONT SIZE=2>Subject: Re: [Shapelib] How to Extract line data with in given extents.</FONT>
</P>
<BR>
<P><FONT SIZE=2>On Wed, 9 Feb 2005 19:06:08 +0530, Chandra Murali.S, ASDC Chennai</FONT>
<BR><FONT SIZE=2><chandramuralis@hcltech.com> wrote:</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> Hi all, </FONT>
<BR><FONT SIZE=2>> I'm new to Shape Library. I've started using this library and its</FONT>
<BR><FONT SIZE=2>> helps me a lot in reducing my effort to reading and using the shape files.</FONT>
<BR><FONT SIZE=2>> In this I faced a problem in finding the line data that exists in given</FONT>
<BR><FONT SIZE=2>> extents. For example, I need to find the list of roads that falls within the</FONT>
<BR><FONT SIZE=2>> bounding box. Is there any API is available to find this. </FONT>
</P>
<P><FONT SIZE=2>Murali, </FONT>
</P>
<P><FONT SIZE=2>If you look at the SHPObject structure you will see it has min/max</FONT>
<BR><FONT SIZE=2>values for X, Y, Z and M. So it is pretty easy to read all the</FONT>
<BR><FONT SIZE=2>shapes and then compare the bounding box information for each</FONT>
<BR><FONT SIZE=2>shape to your bounding box you want to search for to see if they</FONT>
<BR><FONT SIZE=2>intersect. Of course, this might identify some lines that aren't</FONT>
<BR><FONT SIZE=2>actually in your bounding box, if they "wrap around" it to some </FONT>
<BR><FONT SIZE=2>extent. </FONT>
</P>
<P><FONT SIZE=2>If want to do want to do fast searches, you will need a spatial index.</FONT>
<BR><FONT SIZE=2>The CVS version of Shapelib has added support for loading and</FONT>
<BR><FONT SIZE=2>saving a spatial index format, and using it for fast spatial searches. </FONT>
<BR><FONT SIZE=2>It is not the ESRI spatial index format though, it is another from </FONT>
<BR><FONT SIZE=2>MapServer. </FONT>
</P>
<P><FONT SIZE=2>If you want to do precise spatial predicates to see what linestrings</FONT>
<BR><FONT SIZE=2>cross a bounding box or many other kinds of complex spatial</FONT>
<BR><FONT SIZE=2>operations, you might want to look at GEOS (geos.refractions.net).</FONT>
<BR><FONT SIZE=2>But it is a fairly heavyweight. </FONT>
</P>
<P><FONT SIZE=2>I also provide an OGR library that is "higher level" that shapelib</FONT>
<BR><FONT SIZE=2>and supports Shapefiles amoung other things. </FONT>
</P>
<P><FONT SIZE=2> <A HREF="http://ogr.maptools.org/" TARGET="_blank">http://ogr.maptools.org/</A></FONT>
</P>
<P><FONT SIZE=2>Best regards,</FONT>
<BR><FONT SIZE=2>-- </FONT>
<BR><FONT SIZE=2>---------------------------------------+--------------------------------------</FONT>
<BR><FONT SIZE=2>I set the clouds in motion - turn up | Frank Warmerdam, warmerdam@pobox.com</FONT>
<BR><FONT SIZE=2>light and sound - activate the windows | <A HREF="http://pobox.com/~warmerdam" TARGET="_blank">http://pobox.com/~warmerdam</A></FONT>
<BR><FONT SIZE=2>and watch the world go round - Rush | Geospatial Programmer for Rent</FONT>
</P>
</BODY>
</HTML>