I'm starting with pgrouting. After suffering a bit unable to put the data in osm postgis using osm2po with the excellent tutorial http://anitagraser.com/2011/12/15/an-osm2po-quickstart/ ran the sql generated by osm2po visualized data with http: / / localhost: 8888/Osm2poService routing is fantastic and has also insert the data in my town in postgis successfully.

Then I started reading the manual and pgrouting in http://docs.pgrouting.org/2.0/en/doc/index.html me questions arose:

1 - The data provided by osm2po are already topologically arranged just so I do consultations?

2 - The fields of my table are:


Can I get the total distance in miles doing a "sum" of the KM field, is this correct?

Where can I learn what each field, for example, do not know what the field clazz, cost, reverse_cost ....?

3 - The flow of my application the user is typing two addresses, I'll get the latitude and longitude of the point of origin and destination and select the launch in postgis, how do this if the source and target parameter settings are whole?

4- Does anyone have any examples of how to do this with openlayers?

Edited here

I'm getting the distance of the route like this:


         sum (cost) cost AS 
FROM pgr_dijkstra (
                 'SELECT id, source, target, the cost km FROM at_2po_4pgr' 
                 50347, 32988, false, false 

Where 50347 and 32988 are my origin and destination. I do not understand what this format is, are coordinated? The coordinates of my geocode comes in decimal degrees are respectively 51.13, -29.77 and -51.21, -30.04 if I use them so do not run the sql.

Could you explain me I can pass the coordinates for the sql?

closed as too broad by underdark Jul 24 '14 at 20:42

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Please note that the Q&A format of this site requires us to stick to one question per thread. You're welcome to open multiple threads if you have more than one question. – underdark Jul 24 '14 at 20:42

(1) Yes. osm2po creates a SQL import file, which already contains the routing topology.

(2) Yes. You just need to convert kilometers to miles. If you use km AS cost in your pgRouting query, then your route cost attribute will be in km as well.

(3) For the address lookup you need a Geocoder, for example Nominatim. When you know the point coordinates, you can route from/to the nearest source or target ID in your network.

(4) You may find the pgRouting Workshop useful.

  • Thanks for the reply really helped me progress. But I still have a question about what format do I have to geocode the coordinates for the sql, I edited the question with details if you can thank me auxliar more. – csf Jul 24 '14 at 20:40
  • You need a node ID for start and end point. If you have an address for example, then you first will geocode a latitude/longitude, and with this point you search for the nearest start/end node. – dkastl Jul 25 '14 at 21:15

Not the answer you're looking for? Browse other questions tagged or ask your own question.