Saturday 9 April 2016

pgrouting - Why mobile routing is so fast?


Why my mobile GPS routing calculates routes almost instantly and using pgRouting in my robust PC is so time costly ?


EDIT:


My test:


In my cellphone (Android 4.2.2 - 1G RAM - Dual core - Arm v9) I have iGo Primo. In my PC ( 8G RAM - Core i5 ) I have Postgre + PostGIS + pgRouting


Table OSM Planet "planet_osm_line" with previous work:


alter table planet_osm_line add column source integer;
alter table planet_osm_line add column target integer;
select pgr_createTopology('planet_osm_line', 0.0001, 'way', 'osm_id');


select * from planet_osm_line where name like '%BR-040%' // (source : 2751784)
select * from planet_osm_line where name like '%BR-101%' // (target : 2040999)

SELECT seq, id1 AS node, id2 AS edge, cost, name, way
FROM pgr_dijkstra('SELECT osm_id as id, source, target, st_length(way) as cost FROM planet_osm_line', 2751784, 2040999, false, false ) as di
JOIN planet_osm_line pt
ON di.id2 = pt.osm_id ;

The route is (both Brazil Highway):


Source: BR-040



Target: BR-101


My cellphone do the job in less than two seconds and my PC takes more than 3 minutes (only the SELECT route - pgr_dijkstra - part).



Answer



Probably because it uses pre-calculated routes.


As an example of an open source routing app with pre-calculated routes, OSRM uses contraction hierarchies to create shortcuts: http://algo2.iti.kit.edu/routeplanning.php


PgRouting just creates the relations between source and target with the pgr_network_topology function. http://workshop.pgrouting.org/chapters/topology.html


pgRouting allows you to change conditions in real time. Does your phone app allow you to do that? Like, for example, add traffic data and recalculate the route depending on this new data?


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...