[pgrouting-users] osm2pgrouting oneway misreading

Dear all,

I think that something is wrong with osm2pgrouting:

The code (Export2DB.cpp, called by osm2pgrouting.cpp) writes :

if(way->oneway)
row_data += TO_STR(way->length*1000000);
else
row_data += TO_STR(way->length);

(this row_data will be the reverse_cost value)
but after exporting france.osm I unfortunately observe that this condition never seems to be met:

franceRouting=> select count (*) from ways where reverse_cost <> length;
count

Hi Sylvain,

Thank you for pointing out this issue!
I think osm2pgrouting hasn’t changed regarding this for long time, so roundabouts and the discouraged use of tag values may have changed in the meanwhile. I think there are many OSM bots these days trying to fix things like this, so could be that osm2pgrouting is now looking for the wrong tag value.

If you are able to improve this and submit a pull request I’m happy to merge it into the main repository.

Daniel

On Tue, Oct 2, 2012 at 1:44 AM, Sylvain Housseman <hsylvio@gmail.com> wrote:

Dear all,

I think that something is wrong with osm2pgrouting:

The code (Export2DB.cpp, called by osm2pgrouting.cpp) writes :

if(way->oneway)
row_data += TO_STR(way->length*1000000);
else
row_data += TO_STR(way->length);

(this row_data will be the reverse_cost value)
but after exporting france.osm I unfortunately observe that this condition never seems to be met:

franceRouting=> select count (*) from ways where reverse_cost <> length;
count

0
(1 row)

So I guess that the condition (way->oneway) is not appropriated…
Does any version deal with this problem (or did I forget something when launching osm2pgrouting)?

Thanks again for these great tools;
HSylvio.

BTW, the osm wiki page (http://wiki.openstreetmap.org/wiki/Key:oneway) explains that
"Some tags (such as [junction](http://wiki.openstreetmap.org/wiki/Key:junction)=[roundabout](http://wiki.openstreetmap.org/wiki/Tag:junction%3Droundabout), [highway](http://wiki.openstreetmap.org/wiki/Key:highway)=[motorway](http://wiki.openstreetmap.org/wiki/Tag:highway%3Dmotorway) and others) imply **oneway**=yes. You don’t need to add a oneway tag

## Values- **oneway**=yes (discouraged alternative: “true”, “1”)

  • **oneway**=no (discouraged alternative: “false”, “0”)
  • **oneway**=-1 (discouraged alternative: “reverse”)
    "

I did not understand yet how the XMLParser works, but could the problem be solved by changing the type of “bool oneway” to a string or char[?] in the “Way” class?
Best,
HSylvio.


Pgrouting-users mailing list
Pgrouting-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/pgrouting-users


Georepublic UG & Georepublic Japan
eMail: daniel.kastl@georepublic.de
Web: http://georepublic.de

Hi Sylvain,

I think I was not able to import data using osm2pgrouting, so I
instead used osm2po.
Here is the memo I made for myself on how to use it:

IMPORTING DATA FROM OSM INTO THE DATABASE

1. Download osm2po from http://osm2po.de/download.php?lnk=osm2po-4.4.4a.zip
2. Install in for example /usr/share/osm2po:
sudo unzip /home/tao/Downloads/osm2po-4.4.4a.zip

3. Download osm file
4. Copy file to your osm2po folder:
sudo cp /home/tao/Downloads/map.osm ./

4. Convert OSM file to DB file:
sudo java -jar osm2po-core-4.4.4a-signed.jar prefix=at <file>.osm

5. Import DB file into database (username = postgres):
psql -U postgres -d <your_DB> -q -f "/usr/share/osm2po/at/at_2po_4pgr.sql"

Good luck,

Tao

2012/10/2 Sylvain Housseman <hsylvio@gmail.com>:

Dear all,

I think that something is wrong with osm2pgrouting:

The code (Export2DB.cpp, called by osm2pgrouting.cpp) writes :

        if(way->oneway)
            row_data += TO_STR(way->length*1000000);
        else
            row_data += TO_STR(way->length);

(this row_data will be the reverse_cost value)
but after exporting france.osm I unfortunately observe that this condition
never seems to be met:

franceRouting=> select count (*) from ways where reverse_cost <> length;
count
-------
      0
(1 row)

So I guess that the condition (way->oneway) is not appropriated...
Does any version deal with this problem (or did I forget something when
launching osm2pgrouting)?

Thanks again for these great tools;
HSylvio.

BTW, the osm wiki page (http://wiki.openstreetmap.org/wiki/Key:oneway)
explains that
"Some tags (such as junction=roundabout, highway=motorway and others) imply
oneway=yes. You don't need to add a oneway tag

...

Values

oneway=yes (discouraged alternative: "true", "1")
oneway=no (discouraged alternative: "false", "0")
oneway=-1 (discouraged alternative: "reverse")

"

I did not understand yet how the XMLParser works, but could the problem be
solved by changing the type of "bool oneway" to a string or char[?] in the
"Way" class?
Best,
HSylvio.

_______________________________________________
Pgrouting-users mailing list
Pgrouting-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/pgrouting-users

Thank you, Tao!

I started changing the code as described below.

I added outputs, and "oneway" key contains many values corresponding to the various versions of osm specs, such as:
Edge 140678882 has oneway entry with value yes
Edge 140678886 has oneway entry with value no
Edge 140678888 has oneway entry with value -1
Edge 140503091 has oneway entry with value true

but there also are aberrations such as
Edge 138507974 has oneway entry with value Bing which I will consider as a "no"

I am downloading a most recent version of this .osm for testings and I'll make osm2pgrouting work (more) properly (except if someone already made the job; plz tell it!)

Thanks again for the answer Tao, but even if osm2pgrouting is far from optimized I want to believe in open-source...
See you soon on GitHub then...

Le 02/10/2012 09:34, Tao Romera Martinez a écrit :

Hi Sylvain,

I think I was not able to import data using osm2pgrouting, so I
instead used osm2po.
Here is the memo I made for myself on how to use it:

IMPORTING DATA FROM OSM INTO THE DATABASE

1. Download osm2po from http://osm2po.de/download.php?lnk=osm2po-4.4.4a.zip
2. Install in for example /usr/share/osm2po:
sudo unzip /home/tao/Downloads/osm2po-4.4.4a.zip

3. Download osm file
4. Copy file to your osm2po folder:
sudo cp /home/tao/Downloads/map.osm ./

4. Convert OSM file to DB file:
sudo java -jar osm2po-core-4.4.4a-signed.jar prefix=at <file>.osm

5. Import DB file into database (username = postgres):
psql -U postgres -d <your_DB> -q -f "/usr/share/osm2po/at/at_2po_4pgr.sql"

Good luck,

Tao

2012/10/2 Sylvain Housseman <hsylvio@gmail.com>:

Dear all,

I think that something is wrong with osm2pgrouting:

The code (Export2DB.cpp, called by osm2pgrouting.cpp) writes :

         if(way->oneway)
             row_data += TO_STR(way->length*1000000);
         else
             row_data += TO_STR(way->length);

(this row_data will be the reverse_cost value)
but after exporting france.osm I unfortunately observe that this condition
never seems to be met:

  franceRouting=> select count (*) from ways where reverse_cost <> length;
  count
  -------
       0
  (1 row)

So I guess that the condition (way->oneway) is not appropriated...
Does any version deal with this problem (or did I forget something when
launching osm2pgrouting)?

Thanks again for these great tools;
HSylvio.

BTW, the osm wiki page (http://wiki.openstreetmap.org/wiki/Key:oneway)
explains that
"Some tags (such as junction=roundabout, highway=motorway and others) imply
oneway=yes. You don't need to add a oneway tag

...

Values

oneway=yes (discouraged alternative: "true", "1")
oneway=no (discouraged alternative: "false", "0")
oneway=-1 (discouraged alternative: "reverse")

"

I did not understand yet how the XMLParser works, but could the problem be
solved by changing the type of "bool oneway" to a string or char[?] in the
"Way" class?
Best,
HSylvio.

_______________________________________________
Pgrouting-users mailing list
Pgrouting-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/pgrouting-users

_______________________________________________
Pgrouting-users mailing list
Pgrouting-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/pgrouting-users

Good, Sylvain. Good luck with your fork!

Tao

2012/10/2 Sylvain Housseman <hsylvio@gmail.com>:

Thank you, Tao!

I started changing the code as described below.

I added outputs, and "oneway" key contains many values corresponding to the
various versions of osm specs, such as:
Edge 140678882 has oneway entry with value yes
Edge 140678886 has oneway entry with value no
Edge 140678888 has oneway entry with value -1
Edge 140503091 has oneway entry with value true

but there also are aberrations such as
Edge 138507974 has oneway entry with value Bing which I will consider as a
"no"

I am downloading a most recent version of this .osm for testings and I'll
make osm2pgrouting work (more) properly (except if someone already made the
job; plz tell it!)

Thanks again for the answer Tao, but even if osm2pgrouting is far from
optimized I want to believe in open-source...
See you soon on GitHub then...

Le 02/10/2012 09:34, Tao Romera Martinez a écrit :

Hi Sylvain,

I think I was not able to import data using osm2pgrouting, so I
instead used osm2po.
Here is the memo I made for myself on how to use it:

IMPORTING DATA FROM OSM INTO THE DATABASE

1. Download osm2po from
http://osm2po.de/download.php?lnk=osm2po-4.4.4a.zip
2. Install in for example /usr/share/osm2po:
sudo unzip /home/tao/Downloads/osm2po-4.4.4a.zip

3. Download osm file
4. Copy file to your osm2po folder:
sudo cp /home/tao/Downloads/map.osm ./

4. Convert OSM file to DB file:
sudo java -jar osm2po-core-4.4.4a-signed.jar prefix=at <file>.osm

5. Import DB file into database (username = postgres):
psql -U postgres -d <your_DB> -q -f "/usr/share/osm2po/at/at_2po_4pgr.sql"

Good luck,

Tao

2012/10/2 Sylvain Housseman <hsylvio@gmail.com>:

Dear all,

I think that something is wrong with osm2pgrouting:

The code (Export2DB.cpp, called by osm2pgrouting.cpp) writes :

         if(way->oneway)
             row_data += TO_STR(way->length*1000000);
         else
             row_data += TO_STR(way->length);

(this row_data will be the reverse_cost value)
but after exporting france.osm I unfortunately observe that this
condition
never seems to be met:

  franceRouting=> select count (*) from ways where reverse_cost <>
length;
  count
  -------
       0
  (1 row)

So I guess that the condition (way->oneway) is not appropriated...
Does any version deal with this problem (or did I forget something when
launching osm2pgrouting)?

Thanks again for these great tools;
HSylvio.

BTW, the osm wiki page (http://wiki.openstreetmap.org/wiki/Key:oneway)
explains that
"Some tags (such as junction=roundabout, highway=motorway and others)
imply
oneway=yes. You don't need to add a oneway tag

...

Values

oneway=yes (discouraged alternative: "true", "1")
oneway=no (discouraged alternative: "false", "0")
oneway=-1 (discouraged alternative: "reverse")

"

I did not understand yet how the XMLParser works, but could the problem
be
solved by changing the type of "bool oneway" to a string or char[?] in
the
"Way" class?
Best,
HSylvio.

_______________________________________________
Pgrouting-users mailing list
Pgrouting-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/pgrouting-users

_______________________________________________
Pgrouting-users mailing list
Pgrouting-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/pgrouting-users

_______________________________________________
Pgrouting-users mailing list
Pgrouting-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/pgrouting-users