1

I am trying to get pgRouting based on OSM data to run and have some problems in getting it right.

I installed PostgreSQL 9.5 on an Ubuntu machine. PostGIS_full_version comes back with

  • "POSTGIS="2.2.2 r14797"
  • GEOS="3.4.2-CAPI-1.8.2 r3921"
  • PROJ="Rel. 4.8.0, 6 March 2012"
  • GDAL="GDAL 1.11.2, released 2015/02/10"
  • LIBXML="2.9.1"
  • LIBJSON="0.11.99"
  • TOPOLOGY RASTER",

and pgRouting is in version 2.2.3 installed.

I am using osm2pgrouting in version 2.1 to import the osm file from Geofabrik and build the topology.

After importing, the column 'length' in table ways holds very small values, while supposed to have the distance information in kilometres. An comparison to the column 'length_m' shows that either the distance in meter or the one in kilometres is wrong. Based on this discussion I can fix the distance issue.

However, the column 'cost' seems to be a copy of column 'length' and in the discussion linked above the cost column isn't recalculated, and I am not sure if this should be done as well.

Hence I added another column ('to_cost') with recalculated distances. The following SQL query makes use of this:

SELECT SUM(distance) as "Distance (km)", SUM(zeit) as "Time (min)" FROM
  (SELECT b.length as distance, b.length/b.maxspeed_forward*60 as zeit
    FROM pgr_dijkstra('SELECT gid::integer as id,
                            source::integer,
                            target::integer,
                            to_cost as cost,
                            reverse_cost
                     FROM ways',
                     728126, 508421, true, false) a,
                     ways b
  WHERE a.id1=b.gid::integer) AS my routing;

The returned distance is 232.388203319894 km and the time in minutes needed for this trip would be 275.537860166885 minutes.

I tried to calculate the same route at OpenStreetMap, and here I am getting a slightly longer, but much faster route returned. Therefore, I would like to know if I am doing the correct things here or not.

Also, when I use the 'cost' column with the import data from osm2pgrouting instead of the 'to_cost' column, then I am getting 123.397950457207 km, no matter if I say reverse_cost is true, or false.

Using the 'to_cost' column and turning reverse_cost to true then I am getting a distance of only 143.048209059395 km, and a time value of 169.415916099922 minutes back.

TomGeo
  • 1,213
  • 2
  • 12
  • 24

0 Answers0