Repository navigation
Support 'height', 'weight', 'width' road attributes - #936
Conversation
There was a problem hiding this comment.
Might even make sense to put this to ReaderElement? Not sure about the implications.
Also if two several keys exist, only the last one is returned. Not sure if this is an issue.
There was a problem hiding this comment.
let us keep it here for now
Also if two several keys exist, only the last one is returned. Not sure if this is an issue
I think this is not a problem yet. (BTW: the first vs. last?)
There was a problem hiding this comment.
I think the first available value will be picked up. The intention is to have the list of semantically equivalent tags in descending order of preferences.
There was a problem hiding this comment.
Should we consider other measurement units, like kg?
There was a problem hiding this comment.
Wiki says it is tons ... but here is the real fun with units in OSM ;)
We can contribute our slightly more complex parsing methods from the commercial version.
There was a problem hiding this comment.
Would be really nice if you can contribute the commercial version here!
There was a problem hiding this comment.
According to the Wiki these vales might also happen: metre, metres, meter, meters. Couldn't find them via Taginfo, so not sure if this is relevant.
There was a problem hiding this comment.
Would be great if we could make the number of encoders configureable. Maybe if we pass a heightlimit of 0 via the Configmap to the DataflagEncoder, we don't register the heigthEncoder. WDYT?
There was a problem hiding this comment.
Yes, this would be indeed great.
The real problem is that we are currently limited to 64 bit, where have an idea to make this kind of 'unbounded', but no time :/ ... see the edge.getData(int) idea here.
There was a problem hiding this comment.
Sorry guys, didn't get the point here. What do you suggest in terms of configurable number of encoders? I understand the current limit of 32 bit or 64 bit for flags.
There was a problem hiding this comment.
What I meant is that in some use cases one might not need to disable this feature in order to save bits. But something like this might be interesting for other encoded values too and a different issue could be more appropriated.
There was a problem hiding this comment.
Got it now. I've just finished a commit that makes encoders for road attributes configurable. Will merge with Peter's change before push.
There was a problem hiding this comment.
Couldn't you use getHints().putAll or something?
There was a problem hiding this comment.
Spot on. I actually had the same thought yesterday :) Will remove this method.
There was a problem hiding this comment.
Do we really need to expose this :) ? I would like to hide it as long as possible as the API for the blocked areas is not really stable and e.g. the String could change to a domain object etc to be more accessible. Also as this is not related to this PR we should move this to another issue?
There was a problem hiding this comment.
I need access to 'blockedRectangularAreas' in my subclass of GraphHopper. But I agree with you, this is not related to this PR. Will cancel this change.
There was a problem hiding this comment.
Wiki says it is tons ... but here is the real fun with units in OSM ;)
We can contribute our slightly more complex parsing methods from the commercial version.
There was a problem hiding this comment.
let us keep it here for now
Also if two several keys exist, only the last one is returned. Not sure if this is an issue
I think this is not a problem yet. (BTW: the first vs. last?)
There was a problem hiding this comment.
Where is this used and why protected access?
There was a problem hiding this comment.
I have a custom FlagEncoder in my project that subclasses DataFlagEncoder. I needed this method there, so make it 'protected'. The method is actually not used at all in DataFlagEncoder (didn't realize this). Will move the method to my subclass.
There was a problem hiding this comment.
Yes, this would be indeed great.
The real problem is that we are currently limited to 64 bit, where have an idea to make this kind of 'unbounded', but no time :/ ... see the edge.getData(int) idea here.
There was a problem hiding this comment.
Here (maybe in a later version) we could do kind some kind of a compression: i.e. assign
- 2.5m to index 0
- 3.0m to index 1
- 3.1m to index 2
... so we could make it more precise with less bits and for the ones that do not fit we would still round. For this taginfo is useful: http://taginfo.openstreetmap.org/keys/height#values ... it seems 2m is very important for the world wide case. (Or even more sophisticated and area dependent and create statistics in the first parse run and then pick the best compression automatically)
There was a problem hiding this comment.
Yes, the current implementation is quite simple and is based on the value set for the particular area that I have. The value set was obtained from a source independent of OSM that I managed to incorporate into OSM using an internal data ingestion pipeline. As such, the value format is very good (as it is under my control :). I hope we can have more sophisticated implementation which is applicable to world wide data in later version.
For this PR, what I can do is investigating the value range that I can obtain from taginfo (Thanks for the reference - a great website). And see if we need more bits for the encoder and if I can enhance the parsing logic.
There was a problem hiding this comment.
Hmm...The issue with taginfo data is we don't know which values are for road attributes, as opposed to, for instance, building height or height of the road in relation to the underlying river :)
There was a problem hiding this comment.
I think I leave the current encoders for road attributes as-is, with only one minor improvement in the latest commit. If the value is too big for the encoder, we just log & ignore, and continue parsing the OSM data.
Given this change, I was able to parse Australian OSM with only few exceptions of "too large value".
There was a problem hiding this comment.
we just log & ignore, and continue parsing the OSM data.
If it is bigger than the accepted range we could ignore but maybe it is safer to still include it.
If it is smaller we have to throw an exception or warn the user and include it as a restriction (even it is wider)?
There was a problem hiding this comment.
For instance, a bridge section over a river has 'height' attribute set to 60m.
Does it have a height or maxheight of 60m? Height would be correctly mapped. Maxheight would be wrong. If it is maxheight, we could report an error to OSM.
There was a problem hiding this comment.
That's an interesting question. Let's me have a look at the detailed log file. The error message above ignored the actually tag being used.
There was a problem hiding this comment.
You're right Robin. It's maxheight in both cases I found:
https://www.openstreetmap.org/way/31539875
https://www.openstreetmap.org/way/238785424
There was a problem hiding this comment.
Thanks for looking into this. I reported an issue for both ways. Both are very small ways, so probably this is just a mapping issue.
There was a problem hiding this comment.
Wow, I think this was the fastest fix I've ever seen on OSM, one problem is already fixed: http://www.openstreetmap.org/note/857064
|
The OSM related parsing and converting should be done in the OSM reader module not in the encoder. But when I move it there we have to convert regardless if it is enabled or not (e.g. using dataflagencoder or not). Hmmh, interesting ;) |
|
But this is worth a separate issue #939 |
376763f to
4d2d361
Compare
|
Interesting. I was able to push to the road_attributes branch of Transtech/graphhopper (without explicit grant of permission I guess) ... even a force push. Seems that github has improved this to work together with different repos on the same pull request, nice. Please have a look - I hope I didn't messed up something! |
| private long extractTons(ReaderWay way, long flags, EncodedDoubleValue valueEncoder, List<String> keys) { | ||
| String value = extractRoadAttribute(way, keys); | ||
|
|
||
| String value = way.getFirstPriorityTag(keys); |
There was a problem hiding this comment.
This should be the same functionality (do we have a test covering a change like this?)
There was a problem hiding this comment.
Yes. OSMReaderTest#testRoadAttributes should do the job.
| } | ||
|
|
||
| double stringToMeter(String value) { | ||
| public static double stringToMeter(String value) { |
There was a problem hiding this comment.
Made it public to reuse it elsewhere which is not really nice ... before I thought putting it into OSMTagParser is better, but this does not work, see #939
|
Guys, I have committed a new change that makes road attribute encoders configurable. Merging fine with master. Let me know if there is anything else you would like me to change. Btw, I have resolved some conflicts when merging Peter's changes. Hopefully I didn't miss out anything :) |
|
Thanks, this looks good. Let us (shortly) discuss if we need three configurations or if one e.g. Furthermore the boolean methods should be setXY instead of enableXY
Sorry, I feared that. Force push is never a good idea if one works on the same branch with others :(. So instead I should have made my changes and the rebase/squash should have been done as the last step. Lesson learned ... |
|
Would you mind to just rename the methods? We do not need to debate on configuring and should just change it afterwards when necessary (?) |
|
I have renamed the methods and variables as requested. This naming convention makes more sense to me now. Please review and advise. In relation to choosing single configuration field vs multiple configuration fields for road attributes, IMHO, I would go with multiple fields. That would make it more flexible as you would be able to select the attributes of interest, rather than all or nothing. This is especially true when we are still limited to 64 bit length of the flag & the cost of having all fields is expensive. |
|
This looks good now - thanks again!
Yeah, this is ugly and needs a fix (better sooner than later :)) |
Unrecognized values will be logged and ignored.