Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add roadinfo=1 as default to queries? #7

Open
jpmens opened this issue Jun 18, 2024 · 17 comments
Open

Add roadinfo=1 as default to queries? #7

jpmens opened this issue Jun 18, 2024 · 17 comments

Comments

@jpmens
Copy link
Owner

jpmens commented Jun 18, 2024

As suggested by Ed.F in an email, it might be worth while for us to add roadinfo=1 to reverse geo queries to OpenCage; as we use revgeod mainly for vehicles, we'd profit from this additional data

  "roadinfo": {
    "drive_on": "right",
    "lanes": 3,
    "maxheight": "default",
    "maxspeed": 90,
    "oneway": "yes",
    "road": "Autoroute du Soleil",
    "road_reference": "A 7",
    "road_reference_intl": "E 15",
    "road_type": "motorway",
    "speed_in": "km/h",
    "surface": "asphalt",
    "toll": "yes"
  }

Ed writes:

The only issue is that if that if that parameter is set we geocode to the nearest road, not to the house address.

@freyfogle
Copy link

@jpmens
Copy link
Owner Author

jpmens commented Jun 18, 2024

I'm seeing toll on some of the French autoroutes, but stabbing around in Poland, for example, doesn't give me a toll value.

The position 52.203636, 21.700764 is indicated by OSM as being toll:bus and toll:hgv

Bildschirmfoto 2024-06-18 um 12 52 40

However, when querying it

curl -sSf 'https://api.opencagedata.com/geocode/v1/json?q=52.203636,21.700764&pretty=1&key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&roadinfo=1'

we're not seeing toll:

            "roadinfo" : {
               "drive_on" : "right",
               "lanes" : 2,
               "maxspeed" : 140,
               "oneway" : "yes",
               "road" : "Autostrada Wolno\u015bci",
               "road_reference" : "A2",
               "road_reference_intl" : "E 30",
               "road_type" : "motorway",
               "speed_in" : "km/h",
               "surface" : "asphalt"
            },

Stabbing around on large roads north and south of Warsaw doesn't show any toll road, which may be a coincidence.

@freyfogle
Copy link

freyfogle commented Jun 18, 2024

great example, thanks. probably we need to adapt how we handle roads that are toll only for some classes of vehicles.

investigating ...

@ckrey
Copy link
Collaborator

ckrey commented Jun 18, 2024

@freyfogle
Copy link

yes, that is the issue. It seems toll:hgv and a few others, has become much more popular since we launched this feature 5+ years ago. Thanks for making us aware. We are debating the best way to return this data.

@jpmens
Copy link
Owner Author

jpmens commented Jun 18, 2024

Breaking toll: true/false is likely a bad idea, so maybe an additional string would be useful, populated with the type of vehicle. Somthing like toll_type: hgv comes to mind. Just a thought. We're sure you'll do it properly.

@freyfogle
Copy link

freyfogle commented Jun 18, 2024

hmm, yes, that approach is good. I suppose multiple toll types - like your example - is then toll_type: bus, hgv

edit - not once in my life have I not mistyped "toll" as "tool"

@jpmens
Copy link
Owner Author

jpmens commented Jun 18, 2024

I personally would prefer an array:

"tool^H^Hll_type": [ "bus", "hgv" ]

but a comma-separated list would be fine if that's easier on your end.

@freyfogle
Copy link

The good news is it seems toll status has much better coverage than it did a few years ago. Unfortunately it seems there is quite the range of options to include the case where only some types of vehicles pay a toll, or the total opposite, where all vehicles pay a toll, but certain types are excluded. So we need to do a bit of thinking about how to present this.

@freyfogle
Copy link

ok I am now leaning towards something like

               "toll" : "yes",
               "toll_type" : {
                  "included" : [
                     "bus",
                     "hgv"
                  ],
               }

or

               "toll" : "yes",
               "toll_type" : {
                  "excluded" : [
                    "bicycle"
                  ]
               }

thoughts?

@jpmens
Copy link
Owner Author

jpmens commented Jun 18, 2024

Thinking aloud, that would permit something along these lines (in Python) which looks as though it's all there.

lorry = False
if "included" in toll_type and "hgv" in toll_type["included"]:
    lorry = True
if "excluded" in toll_type and "hgv" not in toll_type["excluded"]:
    lorry = True

So, yes, looks good to me.

@freyfogle
Copy link

Well the issue is how to handle ambiguous data.

For example we may simply have toll = yes, and no explicit types.
or the opposite, very precise data. We may have toll:N3 = yes (N3 being an EU classification of HGV).

So I think you will need to program more defensively than that I am afraid. Welcome to OpenStreetMap

@freyfogle
Copy link

ok, time to write lots of tests. Hopefully we will get this live tomorrow

@jpmens
Copy link
Owner Author

jpmens commented Jun 18, 2024

you will need to program more defensively than that

yes, of course

@freyfogle
Copy link

ok, this is now live with one tweak. We decided to name the field toll_details since we potentially also set other information about the toll (operator)

The relevant docs are updated, post on the OpenCage blog coming in the next hour or so.

@jpmens
Copy link
Owner Author

jpmens commented Jun 19, 2024

More toll road information

Thank you, @freyfogle

@jpmens
Copy link
Owner Author

jpmens commented Jun 19, 2024

            "roadinfo" : {
               "drive_on" : "right",
               "lanes" : 2,
               "maxspeed" : 140,
               "oneway" : "yes",
               "road" : "Autostrada Wolno\u015bci",
               "road_reference" : "A2",
               "road_reference_intl" : "E 30",
               "road_type" : "motorway",
               "speed_in" : "km/h",
               "surface" : "asphalt",
               "toll" : "yes",
               "toll_details" : {
                  "included" : [
                     "bus",
                     "hgv"
                  ]
               }
            },

Looks good to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants