<!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> </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. 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> </DIV>
<DIV><SPAN class=713152720-11042005><FONT face=Arial size=2>I have a database
full of linestrings (StreetLine). I am searching this database to find the
line string that is closest to a specified point. 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> </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> FROM tblImportData<BR> WHERE "StreetLine" &&
Expand(GeomFromText('POINT(' || $1 || ' ' || $2 ||
')',-1),.0004)<BR> AND Distance(GeomFromText('POINT(' || $1 || ' ' ||
$2 || ')',-1),"StreetLine") < .0004<BR> ORDER BY
Distance(GeomFromText('POINT(' || $1 || ' ' || $2 ||
')',-1),"StreetLine")<BR> 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. Basically, I want to know the intersecting
point on the linestring where the distance from the specified point to the line
is smallest. Thanks in advance for any info that you can provide
me.</FONT></SPAN></DIV>
<DIV align=left><FONT face=Arial size=2></FONT> </DIV>
<DIV align=left><FONT face=Arial size=2>Derek Figg</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV></BODY></HTML>