demo (#22) - Don't get the tutorium running (#98) - Message List

Don't get the tutorium running

Dear list, I again tried to start the pgRouting/Open Layers tutorium. My application runs under:

 http://www.tourismus-maps.de/behncke/tutorial_ol/06.index.html

But I don`t get it to run. I can set start and endpoints but after pressing on "Caluculate Route" nothing happens?

In the background I have my database that looks like:

 http://www.tourismus-maps.de/behncke/bilder/screenshot_routing_ol.PNG

Also the routing functions are in that database.

Does anybody can give me a hint what might be the problem?

Thank you very much, Kai

  • Message #369

    Hi Kai,

    On your server you get the following PHP Warning:

    <b>Warning</b>:  pg_query(): supplied argument is not a
    valid PostgreSQL link resource in <b>/home/promotion
    /behncke/tutorial_ol/ax_routing.php</b> on line <b>131</b>
    

    Probably something wrong with the SQL statement. Can you post the generated SQL query string here? Also, are you sure your connection to PostgreSQL is working?

    • Message #370

      Hi Daniel, the connection to the PostgreSQL-Server works fine. I tested it with:

      if ($con = pg_connect("dbname=".PG_DB." password=".PG_PASSWORD." host=".PG_HOST." user=".PG_USER))

      echo "Connection works!"; else echo "Connection does not work";

      The sql-String and the next connection test looks like:

      $sql = "SELECT gid, source, target, the_geom,

      distance(the_geom, GeometryFromText?(

      'POINT(".$lonlat[0]." ".$lonlat[1].")', 54004)) AS dist

      FROM ".TABLE." WHERE the_geom && setsrid(

      'BOX3D(".($lonlat[0]-200)."

      ".($lonlat[1]-200).", ".($lonlat[0]+200)." ".($lonlat[1]+200).")'::box3d, 54004)

      ORDER BY dist LIMIT 1";

      if ($query = pg_query($con,$sql)) echo "Verbindung klappt"; else echo "Fehler";

      Might there be an error in the SQL-statement? Thank you very much, Kai

      • Message #371

        Maybe you can insert

        error_log($sql);
        

        into the php script to write the generated SQL statement to the error log. Then look into the server log and you can copy and execute it directly in PostgreSQL and see if it works or not.

        • Message #372

          Hi Daniel, thank you again. I checked that out.

          No problems with the sql-strings. The first one is: SELECT gid, source, target, the_geom,

          distance(the_geom, GeometryFromText?(

          'POINT(-13734128.805252185 6147755.471565573)', 54004)) AS dist

          FROM victoria WHERE the_geom && setsrid(

          'BOX3D(-13734328.8053

          6147555.47157, -13733928.8053 6147955.47157)'::box3d, 54004)

          ORDER BY dist LIMIT 1

          ....and gave a clean result.

          The second one (in case of shortest path dijkstra) is: SELECT rt.gid, AsText?(rt.the_geom) AS wkt,

          length(rt.the_geom) AS length, victoria.id

          FROM victoria,

          (SELECT gid, the_geom

          FROM dijkstra_sp_delta(

          'victoria', 123, 124, 3000)

          ) as rt WHERE victoria.gid=rt.gid;

          ...no problem in Postgresql.

          I wrote these both SQL-string fix in the ax_routing.php but I still get an error at that line:

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

          ...supplied argument is not a valid PostgreSQL link resource

          I think I need to dive a bit deeper in that syntax.

          • Message #373

            Oh, I had an error in the second connection, I cleared that. But now I get:

            Warning: Cannot modify header information - headers already sent by (output started at /home/promotion/behncke/tutorial_ol/ax_routing.php:48) in /home/promotion/behncke/tutorial_ol/ax_routing.php on line 207

            Oh deer, that`s more difficult than I thought............

            • Message #375

              Maybe you forgot to remove some output like

              echo "xyz";
              print("xyz");
              

              This usually leads to this error. There shouldn't be any kind of text output before setting the XML header part.

              • Message #376

                Great, that was it :-)

                I also put away the static SQL-Values and work now with the originall scripts and it wokrs fine!!!! Thank you again very much

                • Message #377

                  That's good news! Just one remark:

                  The tutorial was made for the FOSS4G2007. That time OpenLayers? used 54004 projection for Google Maps layers. In the meanwhile (since version 2.5) there is a better solution with a customized Google projection (EPSG:900913).

                  I recommend you to update to the current version. Otherwise you always need to keep the older OpenLayers? code. It shouldn't be that difficult.

                  • Message #379

                    All right, so you mean just to put the transform(the_geom,900913)-command in SQL and than I can put in the actual OpenLayers?-Code in the tutorium?

                    • Message #380

                      For example ... reproject start/end as well as result. Or reproject the the complete table. That's up to you.

              • Message #378

                Great, that was it :-)

                I also put away the static SQL-Values and work now with the originall scripts and it wokrs fine!!!! Thank you again very much