-
Notifications
You must be signed in to change notification settings - Fork 661
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 encoded elevation to EdgeInfo - serialize in route and trace_attributes JSON #4279
Conversation
Valhalla route serializer and trace serializer to output elevation (JSON) if elevation_interval is specified.
awesome, great to have you back twiddling those bits! |
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 is a great addition, thanks for the effort to push this into the public project. I don't have much to add other than a few nits. I didn't look much at stuff past triplegbuilder.cc, but until there it made all sense. Great that you handled bridges & tunnels. That's currently not possible using the /height service with a route result!
One major drawback in this PR is the test coverage IMO. Just a single route request would probably exercise the majority of changed code. We already have test/pixels.h
which some elevation tests are using. Couldn't a gurka test be coerced to build a large-ish map in the geography of that elevation tile? Would you be up for that @dnesbitt61? Or maybe you thought about smth else to increase coverage?
I'm not too familiar with gurka tests. Are there any unit tests that build tiles with elevation that could be used to test? I don't have much time this week, but perhaps can look more next week. |
It's a bit complex-ish.. there's a header |
pixels.h adds some elevation data to create a sparse set of data within a tile. Does this elevation data run along any graph edges (hopefully 2 connected edges)? The sparse elevation data would have to fully surround the road since the skadi sample method looks at adjacent elevations when forming the elevation. If so, then we could create data with this and do trace route along the road path and check that the encoded elevation is close to matching what is expected along the path. |
im not sure if its near anything, i made that a long time ago and forget pretty much everything about where i put it. it is probably easier to create fake data on the fly in the test by just making an srtm tile with predictable data (each row of pixels has the same elevation and it maybe increases or decreases with each row in the tile). then north south roads in a gurka test would have increasing/decreasing elevation where as east west ones would have constant elevation. thats what id do for a test. |
Trying to use pixels.h but have some questions/issues:
|
@dnesbitt61 you can see how i created the data here: 6fb8b3d#diff-cdf1ee9054e7a0d87f469d85364ff34bc799e7655fbcc4baf3308ae4f6c10912R10 |
so duplicates (4x per index) are due to the way you created this. This shouldn't impact the test. However, the actual elevation values cannot be real if this is from N40W077.hgt. There should be no negative values in this land area. That and the large delta's between adjacent postings (such as {4521066, 1}, {4521067, 513}) |
@kevinkreiser what log infos are we to uncomment? re: |
@kevinkreiser nm. I was looking at |
remember that the values are in srtm format, which is big endian. to make use of the values (as is done in sample.cc) you need to flip the endianess. you cant look at the numbers in the pixels header and make sense of them like you're trying to do. they all go through this function to be read: Lines 42 to 44 in c30e6fb
|
that is what I was missing. thanks for clarifying. |
|
||
EXPECT_EQ(elevation_along_edges.size(), elevation_from_skadi.size()); | ||
for (size_t i = 0; i < elevation_along_edges.size(); ++i) { | ||
EXPECT_NEAR(elevation_along_edges[i], elevation_from_skadi[i], 0.5f); |
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.
@dnesbitt61 is 0.5f
tolerance ok 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.
This is fine for now. I suspect we could find cases (esp. long edges) where the accuracy could deviate more, requiring a higher tolerance. Statistically, the delta encoding should do pretty well except the cases where slope exceeds 45 percent.
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.
nice collaboration here
seems the test doesn't work on osx. lint build might just be a random failure |
…o elevation_in_tiles
Looks like I just forgot to close the file |
Issue
This PR adds elevation along all edges to Valhalla tiles. Elevation is added to each node (NodeInfo) and to each edge (EdgeInfo) using delta encoding in a byte array. Adding elevation in this manner does not increase tile size by more than about 2% (so there are not tile building options - elevation is always added where available. Edges that lie outside regions where elevation is available (as specified by the directory in the config file) have a
has_elevation
flag set to false.Elevation along an edge that is identified as a bridge or a tunnel is special: the elevation at the beginning and end of the bridge/tunnel edge is set at the end nodes and elevation along the edge is set using a linear interpolation between the elevation at the end nodes. This "fixes" elevation so it does not drop to the terrain below a bridge or rise to the terrain on top of a tunnel. However, this does not account for the true elevation along the bridge/tunnel if they rise of fall.
Elevation can be requested in route, trace_route, and trace_attribute calls by specifying elevation_interval. An elevation interval of 30 meters is recommended since this is the elevation interval used when encoding elevation in tiles.
Sample route request with elevation returned:
http://localhost:8002/route?json={"locations":[{"lat":40.134140,"lon":-75.515294},{"lat":40.132871,"lon":-75.518312}],"costing":"bicycle","elevation_interval":30}
JSON response includes:
Tasklist
Requirements / Relations
Link any requirements here. Other pull requests this PR is based on?