<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2800.1476" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=713152720-11042005><FONT face=Arial size=2>Hello 
all,</FONT></SPAN></DIV>
<DIV><SPAN class=713152720-11042005><FONT face=Arial 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=713152720-11042005><FONT face=Arial size=2>Please excuse this 
question if it is very basic or has been answered recently.&nbsp; I have 
searched online for hours to no avail looking for an answer.</FONT></SPAN></DIV>
<DIV><SPAN class=713152720-11042005><FONT face=Arial 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=713152720-11042005><FONT face=Arial size=2>I have a database 
full of linestrings (StreetLine).&nbsp; I am searching this database to find the 
line string that is closest to a specified point.&nbsp; I am successfully able 
to do this with this code:</FONT></SPAN></DIV>
<DIV><SPAN class=713152720-11042005><FONT face=Arial 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=713152720-11042005><FONT face=Arial size=2>CREATE FUNCTION rg 
(decimal (9,6), decimal (9,6)) RETURNS SET OF tblImportData AS $$<BR>SELECT 
*<BR>&nbsp;FROM tblImportData<BR>&nbsp;WHERE "StreetLine" &amp;&amp; 
Expand(GeomFromText('POINT(' || $1 || ' ' || $2 || 
')',-1),.0004)<BR>&nbsp;&nbsp;AND Distance(GeomFromText('POINT(' || $1 || ' ' || 
$2 || ')',-1),"StreetLine") &lt; .0004<BR>&nbsp;ORDER BY 
Distance(GeomFromText('POINT(' || $1 || ' ' || $2 || 
')',-1),"StreetLine")<BR>&nbsp;LIMIT 1;<BR>$$ LANGUAGE 
SQL;<BR></FONT></SPAN></DIV>
<DIV><SPAN class=713152720-11042005><FONT face=Arial size=2>I want to go a step 
further though, and determine what exact point on the linestring is closest to 
the point I have specified.&nbsp; Basically, I want to know the intersecting 
point on the linestring where the distance from the specified point to the line 
is smallest.&nbsp; Thanks in advance for any info that you can provide 
me.</FONT></SPAN></DIV>
<DIV align=left><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV align=left><FONT face=Arial size=2>Derek Figg</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV></BODY></HTML>