[postgis-users] Correct routing path, segmets of geometry

paweluz paweluz at o2.pl
Fri Apr 24 06:11:57 PDT 2009


Hi everybody!

First sorry for my poor English. My name is Paul. I have some problem with
the routing. I was doing tutorial form page

http://pgrouting.postlbs.org/wiki/WorkshopFOSS4G2007
http://pgrouting.postlbs.org/wiki/WorkshopFOSS4G2007 

I got pretty good. The results can be see at page:

http://img509.imageshack.us/img509/9250/routing.jpg
http://img509.imageshack.us/img509/9250/routing.jpg 

I you can see, it does work but not to the end. I have to segment the start
end ending geometry. 
Get the right start and end point. I read a lot about this in the Internet.
I found some 
informations. I know that I have to use this 2 functions

line_locate_point();
line_substring();

Then I read more, and I found that I actually cant use them because I don't
have coreect geometry. 

I should have linestring but I have multilinestring - as you can see on the
screen 

http://img22.imageshack.us/img22/2484/dbase900913.jpg
http://img22.imageshack.us/img22/2484/dbase900913.jpg 

So I started to look for other function and I found out about function
'line_interpolate_point'. I 

try to use it but all I got were empty rows. I used like this. 

SELECT line_interpolate_point(GeometryN(the_geom,900913),
line_locate_point(GeometryN(the_geom,900913),PointFromText('POINT(1725140.73233
6788749.88889)'))) 

FROM zielona_gora_routing 

But it gives me only empty rows :( SO I don't know what to do now. I am so
close to the answer but 

I don't know how to get it right. Can anybody please help me. I thinking
that I have to update 

this function


$start = split(' ',$_REQUEST["startpoint"]);
$startPoint = array($start[0], $start[1]);

  // Retrieve end point
$end = split(' ',$_REQUEST["finalpoint"]);
$endPoint = array($end[0], $end[1]);

$startEdge = findNearestEdge($startPoint);
$endEdge   = findNearestEdge($endPoint);


//FUNCTION!!!!!!
unction findNearestEdge($lonlat) {
  	    // Connect to database
    $con = pg_connect("dbname=".PG_DB." host=".PG_HOST." user=".PG_USER);
	$lonlat1=$lonlat[0]-200;
	$lonlat2=$lonlat[1]-200;
	$lonlat3=$lonlat[0]+200;
	$lonlat4=$lonlat[1]+200;

    $sql = "SELECT gid, source, target, the_geom,
			 distance(the_geom, GeometryFromText(
                  'POINT(".$lonlat[0]." ".$lonlat[1].")', 900913)) AS dist
            FROM ".TABLE."
            WHERE the_geom && setsrid(
                  'BOX3D(".$lonlat1."
                         ".$lonlat2.",
                         ".$lonlat3."
                         ".$lonlat4.")'::box3d, 900913)
            ORDER BY dist LIMIT 1";

    $query = pg_query($con,$sql);

    $edge['gid']      = pg_fetch_result($query, 0, 0);
    $edge['source']   = pg_fetch_result($query, 0, 1);
    $edge['target']   = pg_fetch_result($query, 0, 2);
    $edge['the_geom'] = pg_fetch_result($query, 0, 3);

    // Close database connection
    pg_close($con);

    return $edge;
  }

You can see this function in the tutorial that link I gave at the top of
this post. Can anybody please help me. I would really appreciate...

Regards
Paul

-- 
View this message in context: http://www.nabble.com/Correct-routing-path%2C-segmets-of-geometry-tp23216206p23216206.html
Sent from the PostGIS - User mailing list archive at Nabble.com.




More information about the postgis-users mailing list