This may be obvious, but for whatever reason, I'm not able to figure it out. When calculating driving directions with pgrouting, to find the starting and ending points for the path finding algorithm, I'm using the sample "findNearestEdge" function from pgrouting's website, which looks like this:<br>
<br>function findNearestEdge($lonlat) {<br><br> $con = pg_connect("dbname=".PG_DB." host=".PG_HOST." user=".PG_USER);<br><br> $sql = "SELECT gid, source, target, the_geom,<br> distance(the_geom, GeometryFromText(<br>
'POINT(".$lonlat[0]." ".$lonlat[1].")', 4326)) AS dist<br> FROM ".TABLE."<br> WHERE the_geom && setsrid(<br> 'BOX3D(".($lonlat[0]-0.1)."<br>
".($lonlat[1]-0.1).",<br> ".($lonlat[0]+0.1)."<br> ".($lonlat[1]+0.1).")'::box3d, 4326)<br> ORDER BY dist LIMIT 1";<br>
<br> $query = pg_query($con,$sql);<br><br> $edge['gid'] = pg_fetch_result($query, 0, 0);<br> $edge['source'] = pg_fetch_result($query, 0, 1);<br> $edge['target'] = pg_fetch_result($query, 0, 2);<br>
$edge['the_geom'] = pg_fetch_result($query, 0, 3);<br><br> pg_close($con);<br><br> return $edge;<br>}<br><br><br>What I'd like to do is adjust the starting and ending points so they match up exactly with my lat/lon beginning/ending points. For example, the way it works now if my destination is mid-way down a particular street and I plot the route on a map, it may look like the route takes you to the end of the block, when it should have stopped earlier, or vice-versa. I hope that makes sense...<br>
<br>My lack of expertise with pgrouting keeps me from understanding some other posts I've seen about this topic. Could someone point me in the right direction... thanks a lot.<br>