pgRouting / osm2pgrouting

Import tool for OpenStreetMap data to pgRouting database
https://pgrouting.org
GNU General Public License v2.0
289 stars 111 forks source link

Fixed wrong assumption in implied_oneWay() function #198

Closed cayetanobv closed 6 years ago

cayetanobv commented 6 years ago

Hi,

I fixed a wrong assumption(*) in implied_oneWay() function (see below OSM info about it):

if (key == "highway"
            && (value == "primary"
                || value == "secondary"
                || value == "tertiary")) {
        m_oneWay = "NO";
        return;
    }

(*) Following OSM wiki, oneway in these key/value combinations can be equal to yes or no:

This assumption makes that a lot of roads with oneway=yes changes automatically to oneway=no (and this is a problem in PgRouting). You can see this example:

Original info (OSM): image

New info processed with osm2pgrouting: image

Thanks,

Cayetano

cvvergara commented 6 years ago

Then should it be like this?

  if (key == "highway"
            && (value == "primary"
                || value == "secondary"
                || value == "tertiary")) {
        m_oneWay = "YES";
        return;
    }
cayetanobv commented 6 years ago

Hi @cvvergara ,

In this PR I removed this IF statement because any of these key/value combinations (highway=primary, highway=secondary, highway=tertiary) can be either oneway=yes or oneway=no. This IF statement is a wrong assumption in any case.

Thanks,

cvvergara commented 6 years ago

But what happens when oneway tag is not there?

cayetanobv commented 6 years ago

When oneway tag does not exist osm2pgrouting assign 0 (this is equal to unknown). I think this is correctly solved in osm2pgrouting: https://github.com/pgRouting/osm2pgrouting/blob/master/src/osm_elements/Way.cpp#L311

In PgRouting oneway=0 (oneway=unknown) is the same as oneway=2 (oneway=NO).

cvvergara commented 6 years ago

Adding more links: http://wiki.openstreetmap.org/wiki/Talk:Key:oneway#Default.3F http://wiki.openstreetmap.org/wiki/OSM_tags_for_routing#Oneway

@dkastl Can you comment on this? It looks to me that he is right. (but my experience using real data is very limited)

cayetanobv commented 6 years ago

Hi @cvvergara @dkastl , do you have any new ideas about this PR?

dkastl commented 6 years ago

Honestly I haven't looked into detail about tagging streets oneway. Even if there are Wiki pages about this, they look a bit confusing, and I guess that there are cases where mappers might do something wrong.

I would vote for the PR of @cayetanobv , because - as he says - we currently do some assumption, that may not be correct. Let's remove the assumption, make it more simple, and see, if there will be complaints, that oneway was handled wrong.

cvvergara commented 6 years ago

@cayetanobv at what time is a good time for you so we can work together he merges? I am on this gitter: https://gitter.im/pgRouting/pgrouting with 3 PR I need to work it out with you

cvvergara commented 6 years ago

@cayetanobv I made the three PR, but to be v2.3.3 Before I make the new release, can you verify that works as expected?

cayetanobv commented 6 years ago

Ok @cvvergara , I'm going to test now. By the way, I'm on gitter if you want something (my timezone is UTC+1, Spain).

cayetanobv commented 6 years ago

@cvvergara I tested master branch with new PRs with real datasets and all is Ok. You can release new version 2.3.3.

cvvergara commented 6 years ago

@cayetanobv I wonder if you can try it using a schema

cayetanobv commented 6 years ago

@cvvergara Yes, I used a database schema.