Skip to content

Read elevation from OSM node then fallback to elevation provider - #2373

Closed
gberaudo wants to merge 3 commits into
graphhopper:masterfrom
camptocamp:read_elevation_from_node
Closed

gberaudo wants to merge 3 commits into
graphhopper:masterfrom
camptocamp:read_elevation_from_node

Conversation

@gberaudo

Copy link
Copy Markdown
Contributor

Draft implementation of the idea discussed in #2230 (comment).

TODO with questions:

  • validate with @otbutz, @easbar, @karussell this is the way to go;
  • have mvn clean test verify pass as required by CONTRIBUTING.md (is there an easy way to set a breakpoint in OSMReader code?)
  • add a dedicated test (should I edit one of the OSM test files or add a new one? Should I use another tag name or stick with "ele"?)

if (eleString != null)
ele = Double.parseDouble(eleString);
}
if (Double.isNaN(ele)) {

@otbutz otbutz Jul 27, 2021 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really happy with this fallback mechanic. We might end up mixing values from different height models.
If we want to support this, it's either tag based elevation or from an external provider.

Or to cite Ghostbusters: don't cross the streams

@easbar

easbar commented Jul 27, 2021

Copy link
Copy Markdown
Member

In the current form I also don't think this should be included in this repository. Mostly because it adds additional complexity as there are now two ways to read elevation. At the same time it can be easily done in a forked version of GraphHopper.

But I also wonder if we should pass the ReaderNode to ElevationProvider:

public interface ElevationProvider {
    default double getEle(ReaderNode node) {
         return getEle(node.getLat(), node.getLon());
    }

    double getEle(double lat, double lon);
}

So for @gberaudo's use-case one would only implement the first method (and maybe just throw an error for the second). But this won't work with the long edge-sampling, which has to be disabled in this case. So not entirely clean, but I also do not see a real reason why ElevationProviders should not get hold of the ReaderNode, just like TagParsers have access to the ReaderWay.

@easbar

easbar commented Jul 27, 2021 •

Copy link
Copy Markdown
Member

Regarding the ElevationProvider interface, I think setInterpolate, setDAType, setAutoRemoveTemporaryFiles and setBaseURL all should not be there. They should rather be constructor parameters of the implementing subclasses (if needed). The abstraction of an 'elevation provider' is that it is something that provides an elevation, not something that you can set a DAType for etc.

getInterpolate could be useful here, though. We could make sure that the long edge sampling never runs if getInterpolate is false. So for @gberaudo's use-case this would simply return false.

So the contract for ElevationProviders would be that either getInterpolate is false and getEle(double lat, double lon) is guaranteed to never be called, or it is true, in which case it might be called.

@otbutz

otbutz commented Jul 27, 2021 •

Copy link
Copy Markdown
Contributor

The ElevationProvider interface could really need some overhaul. Most if not all of the other methods should be moved into an abstract baseclass.

@easbar i think your solution is a lot cleaner and can be supported upstream.

Edit: created #2374

@gberaudo

Copy link
Copy Markdown
Contributor Author

There is no consensus around the approach in this PR so I will close it.
Thanks @easbar. @otbutz for the discussions and feedbacks.

@gberaudo gberaudo closed this Jul 29, 2021
@otbutz

otbutz commented Jul 29, 2021

Copy link
Copy Markdown
Contributor

Not entirely correct. The consensus is described in #2374 which aims to provide a better ElevationProvider interface. This should allow you to easily implement your usecase without having to maintain a fork 😉

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

Successfully merging this pull request may close these issues.

3 participants