-
Notifications
You must be signed in to change notification settings - Fork 699
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
fix graphbuilder's elevation initialization #3571
Conversation
…ed mean_elevation to unsigned integer for /locate response leading to bogus values
src/mjolnir/edgeinfobuilder.cc
Outdated
@@ -24,10 +24,10 @@ void EdgeInfoBuilder::set_wayid(const uint64_t wayid) { | |||
|
|||
// Set the mean elevation. | |||
void EdgeInfoBuilder::set_mean_elevation(const float mean_elev) { | |||
if (mean_elev < kMinElevation) { | |||
if (mean_elev <= kNoElevationData) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got rid of the kMinElevation
as it's now the same value as kNoElevationData
. let me know if you want to keep it for semantics
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isnt it the case that we need to differentiate between no data and minimum value though? like when its no data then we serialize null and when its minimum value we serialize the minimum value, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minimum value (-500) will not be serialized, same as no data. Think that’s fine, there’s really no place on terrestrial earth at -500. Dead Sea depression is at -450 or so, roads near that have the lowest values in the world. What do you think @kevinkreiser ? Since it's only for enriching the graph where we only look at roads, the /height endpoint won't be affected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah you are saying in practice -500 wont happen so no_data can be the same as min_value but like you mentioned at the beginning it does seem a bit semantically strange in the computation later where you do an offset by the no data value. i'd be happy just duplicating the constant even if they were the same value so that when you read the code you offset by the min-value rather than the no-data-value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah true, wasn't very happy with that either but with the comment above the constant in graphconstants I found it ok-ish.. then let me duplicate that constant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reverted the change to edgeinfo.h where kMinElevation was set before, which reverted all changes to edgeinfo.h and edgeinfobuilder.h. kMinElevation is now used where appropriate
is the internet broken today?! github is being ridiculously slow or doesn't respond at all after pushing, geofabrik same, curl actually times out downloading some pbf.. maybe it's telling me to go home instead..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
case in point:
To github.com:gis-ops/docker-valhalla.git
! [remote rejected] master -> master (Internal Server Error)
error: failed to push some refs to 'github.com:gis-ops/docker-valhalla.git'
first time ever for me
(*nodes[target]).graph_id, w.way_id(), 1234, bike_network, | ||
speed_limit, shape, names, tagged_values, pronunciations, types, | ||
added, dual_refs); | ||
(*nodes[target]).graph_id, w.way_id(), kNoElevationData, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so I changed it from 0 to the no data value, which will return null
in the geojson response. I traced all usages of mean_elevation
& co and can't see how this change would affect anything negatively
} else { | ||
trip_edge->set_mean_elevation(kNoElevationData); | ||
} | ||
trip_edge->set_mean_elevation(edgeinfo.mean_elevation()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was redundant for elevation. the set_mean_elevation
will handle the case when there's no elevation set
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its redundant now that you fixed it! it wasnt redundant in the past, previously this protected us from getting 1234
in the response
…lue from skadi and convert to -500 in mjolnir
…i to return the no_data value
the osx build finished, it was triggered when github had their outages. probably the reason why win never started? |
fixed up the last minor things @kevinkreiser . thanks for the review |
edge_map->emplace("mean_elevation", static_cast<int64_t>(options.units() == Options::miles | ||
? mean | ||
: mean * kFeetPerMeter)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nilsnolde, it seems that the "inline if" is not correct here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
edge_map->emplace("mean_elevation", static_cast<int64_t>(options.units() == Options::miles | |
? mean | |
: mean * kFeetPerMeter)); | |
edge_map->emplace("mean_elevation", static_cast<int64_t>(options.units() == Options::miles | |
? mean * kFeetPerMeter | |
: mean )); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wow oops, i missed that. thanks for the catch and ill take care of that!
Co-authored-by: Christian-Nils Åkerberg Boda <[email protected]>
Co-authored-by: Christian-Nils Åkerberg Boda <[email protected]> Co-authored-by: Christian-Nils Åkerberg Boda <[email protected]>
* Fix in addition to #3571 * Update changelog
fixes #3258
finally getting some time to fix some of my old issues..
mostly fixes returning
"mean_elevation": null
when there is none, instead of1234
. also some others:EdgeInfo::json
was casting elevation to an unsigned integer, leading to bogus values for the (admittedly few) roads which are sub sea level, e.g. next to dead sea:leads to
"mean_elevation": 18446744073709551254
. with this PR it's"mean_elevation": -362
.