TransWikia.com

What is priority in mapconfig_for_cars.xml of osm2pgrouting?

Geographic Information Systems Asked by Bimo Aji Widyantoro on July 16, 2021

I am new user to pgrouting. I wonder what the meaning of "priority" value means? By default, the values are 1, 1.05, 1.15, 1.5, etc. How to calculate it and why it becomes a value. Also, is this value the same as the penalty value that can be used in routing queries with Dijkstra?

One Answer

When you import OSM data with osm2pgrouting several tables are created. One of these tables is osm_way_classes and it may look like this:

routing=# SELECT * FROM osm_way_classes;
 class_id | type_id |       name        | priority | default_maxspeed 
----------+---------+-------------------+----------+------------------
      201 |       2 | lane              |        1 |               50
      204 |       2 | opposite          |        1 |               50
      203 |       2 | opposite_lane     |        1 |               50
[...]
      305 |       3 | grade5            |        1 |               50
(36 rows)

You can specify a value for priority in your mapconfig.xml file and it will be written into that table when you import data. And you can change that value any time later in that table. The priority field is also added to the ways table and you can change the value as well.

You can see the priority attribute as a suggestion and you can make use of it in your query as part of your cost function. pgRouting minimizes costs, and to find the shortest path for example you would take the length of a road segment as cost.

Now, if you want to prioritize certain road segments, you had to decrease their costs, and you can do this with a factor using priority.

For example, you could make your cost function be length * priority. In this case lower priority value lowers the cost of a road segment and higher priority value makes it more expensive, so the shortest path function will likely follow road segments with smaller priority value.

How you build your query and cost function is up to you. You can just ignore the priority attribute and create your own schema.

I would suggest you this chapter of the pgRouting workshop to learn how you can manipulate the costs: https://workshop.pgrouting.org/2.6/en/chapters/advanced.html#cost-manipulations

Answered by dkastl on July 16, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP