Open jpmens opened 5 months ago
Here is some background about roadinfo and here is a detailed documentation of all the possible fields we then return
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
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.
great example, thanks. probably we need to adapt how we handle roads that are toll only for some classes of vehicles.
investigating ...
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.
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.
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"
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.
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.
ok I am now leaning towards something like
"toll" : "yes",
"toll_type" : {
"included" : [
"bus",
"hgv"
],
}
or
"toll" : "yes",
"toll_type" : {
"excluded" : [
"bicycle"
]
}
thoughts?
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.
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
ok, time to write lots of tests. Hopefully we will get this live tomorrow
you will need to program more defensively than that
yes, of course
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.
Thank you, @freyfogle
"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.
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 dataEd writes: