demo (#22) - Routing from point to point - Code not working (#353) - Message List

Routing from point to point - Code not working

Hello!

At first i have to say thank you for making this project come so far! I am searching for a solution to route from a Point on a line to another point on a line. I wonder why this hasnt been implemented yet in pgrouting, because i think its (one of the) most used feature! I found two different ways to achieve this, but both ways dont work for me. What i got till now is routing with different algorithms on Openstreetmap data from and to vertices and edges. I have sucessfully calculated the nearest points on the nearest edge to my start and endpoints. I tried to fill the missing last part of the route with the tutorial from here : http://pgrouting.postlbs.org/wiki/LoadingtheCode5 But i could not get it working. The function throws errors on the following SQL statement:

SELECT
astext(give_we_wkt(".$startEdge['gid'].",".$ergebnis_nebengeometrie_anfang_gid.",'".
$point_on_line_anfang."'))

It says, that st_intersects is neither false nor true on:

SELECT INTO p ST_intersects(line,buffer($3,0.001));
FEHLER:  Funktion st_intersects(text, geometry) ist nicht eindeutig
ZEILE 1: SELECT ST_intersects( $1 ,buffer( $2 ,0.001))

I found out that there are multiple problems in the give_we_wkt function. First problem is, that the creation of the linestring ('line') in the functioncode fails. Here is the code:

line:= line || X(endgeometry[j])||' '||Y(endgeometry[j])||', '||X(endgeometry[j-1])||' '||Y(endgeometry[j-1]);

The problem is, that endgeometry[j-1] returns <NULL>, and because of that the line becomes NULL. If i use endgeometry[j-0.5] instead it works, but i dont know if this is a good idea. After correcting this the function still throws erros, because the second parameter seems to be parsed incorrectly. if i call the sql manually like this:

SELECT ST_intersects('LINESTRING(6.6463522 50.9528275, 6.6463522 50.9528275)',buffer('01010000003435BD6FE4CA1B405949C4F07B7D4940' ,0.001));

it works. But the give_we_wkt function seems to fill in the second parameter without the "'" and fails.

Then i found the "routing_core_smart.sql" wrapper, and tried to solve my problem with it. But also i cant get this working. After adding the function and calling the following:

SELECT gid, AsText(the_geom) AS the_geom
      FROM shootingstar_sp_smart('ways', 293, 761, 0.1, 'length','to_cost', true, true);

I got the answer, that the function doesnt exist:

FEHLER:  Funktion shootingstar_sp_smart(unknown, integer, integer, numeric, unknown, unknown, boolean, boolean) existiert nicht
ZEILE 2:       FROM shootingstar_sp_smart('ways', 293, 761, 0.1, 'len...

Could someone please help me with this? I dont know how to solve this problems and i am no expert in postgresql and postgis at the moment.

Is there maybe another / easier solution to route from one point to another?

Im using Postgis 1.5 and Postgresql 8.4

Thanks for answers in adavance!

  • Message #1464

    Sorry, i did a mistake (edges instead of coordinates) in the last part. My query for the shootingstar_sp_smart looks like this:

    SELECT gid, AsText?(the_geom) AS wkt FROM shootingstar_sp_smart('ways', 6.95160982151212, 50.9798034072931, 6.9481370410188, 50.9803448637419,0.1,'length','to_cost',false,false);

    And it returns:

    PL/pgSQL function "shootingstar_sp_smart" line 5 at FOR-über-EXECUTE-Anweisung

    I have no clue whats wrong. please point me into the right direction! Thanks!

    • Message #1467

      shootingstar_sp_smart is just a wrapper we made to split the road links and add the missing parts. But it's not a function that is well documented, I must admit.

      What you need is an extra table with network information:

      SELECT add_network_info(<table>);
      

      Because virtual links have to be added to the network, and it would take quite some time to count all the links in your network for every request, if your network is large. So this table stores some network parameters.

      Maybe this thread provides some more information: http://pgrouting.postlbs.org/discussion/message/1411#1411

      Hope that helps.

      • Message #1468

        Thanks for your answer! I forgot to mention, that i already used the function SELECT add_network_info(<table>);

        But the problem still is the same. Do i have any problems in my query? And do you have an idea with the give_we_wkt function?

        Thanks again!