<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from rtf -->
<style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<font face="Arial, sans-serif" size="2">
<div>I think I need to clarify my previous post. It is really two-part.  Here is the first part:</div>
<div><font face="Times New Roman, serif" size="3"> </font></div>
<div>Closest point problem:</div>
<div>-------------------------------------------------------------------------------------------------------------------------</div>
<div>Given a point, find the closest point in our data to it.  I was thinking of a query such as this from an old posting (<a href="http://postgis.refractions.net/pipermail/postgis-users/2005-June/008262.html">http://postgis.refractions.net/pipermail/postgis-users/2005-June/008262.html</a>):</div>
<div> </div>
<div style="padding-left: 36pt; ">SELECT the_point</div>
<div style="padding-left: 36pt; ">FROM foo</div>
<div style="padding-left: 36pt; ">ORDER BY distance(the_point, GeomFromText('POINT(-80 45)', -1))</div>
<div style="padding-left: 36pt; ">LIMIT 1;</div>
<div><font face="Times New Roman, serif" size="3"> </font></div>
<div>But this must doia full table scan  The post had a way to first get a bounding box and then do the distance query to cut down the search size (<a href="http://postgis.refractions.net/pipermail/postgis-users/2005-June/008262.html">http://postgis.refractions.net/pipermail/postgis-users/2005-June/008262.html</a>):</div>
<div> </div>
<div style="padding-left: 36pt; "><font face="Courier New, monospace">SELECT the_point</font></div>
<div style="padding-left: 36pt; "><font face="Courier New, monospace">FROM foo</font></div>
<div style="padding-left: 36pt; "><font face="Courier New, monospace">WHERE the_point && 'BOX3D(-180 -55, 20 145)'::box3d</font></div>
<div style="padding-left: 36pt; "><font face="Courier New, monospace">ORDER BY distance(the_point, GeomFromText('POINT(-80 45)', -1))</font></div>
<div style="padding-left: 36pt; "><font face="Courier New, monospace">LIMIT 1;</font></div>
<div><font face="Times New Roman, serif" size="3"> </font></div>
<div>Is there a better way to do this?</div>
<div> </div>
<div><font face="Times New Roman, serif" size="3"> </font></div>
<div>A lot of closest point problems:</div>
<div>---------------------------------------------------------------------------------------------------------------------------------</div>
<div>My second question is this: I will be running this query 100-200 times, once for each item in my query.  We are modeling a ship steaming in a straight line, every 5 miles we will want to find the closest point in our data to the ship.  Is there a way to
do this query in one step instead of solving 100-200 closest point problems?</div>
<div><font face="Times New Roman, serif" size="3"> </font></div>
<div><font face="Times New Roman, serif" size="3"> </font></div>
</font>
</body>
</html>