osmandapp / OsmAnd

OsmAnd
https://osmand.net
Other
4.66k stars 1.02k forks source link

Widget for altitude of intermediate point and destination #14441

Open sgelb opened 2 years ago

sgelb commented 2 years ago

🚀 feature request

Description

As a road cyclist, I'd like to have widgets to see the absolute altitude of the next intermediate point and/or the destination point to quickly estimate the remaining altitude meters. I already like to set intermediate points at the end of a longer ascents, so I can use the DistanceToPointWidget to quickly see how far I have to cycling up. Adding information about the altitude would help me a lot to tackle long ascents.

Describe the solution you'd like

Two additional widgets that show the absolute altitude of the next intermediate point respectivly the destination. Knowing about the difficulties of calculation the correct ascend/descent of a route, I have no need to see the remaining altitude difference. Using the widget for the current altitude I can quickly estimate the absolute difference by myself.

Describe alternatives you've considered

I implemented this feature for myself. It is working but is probably not implemented in the best way. Before I publish the code and/or create a PR, I'd like some feedback about the feature in general.

image

vshcherb commented 2 years ago

We plan to invest into making Elevation widget more functional with that respect i.e. hide graphs for example and 'dynamic next summit' selection

vshcherb commented 2 years ago

As you've already did it for yourself main issue with product design, it's a static widget information i.e. it doesn't change over time. So we prefer to have something Uphill left to destination / Uphill left to intermediate

tradavyvy commented 2 years ago

For bicycling remaining uphill is probably verry usefull. But besides that I see also use for the original request of info about the absolute altitude of destination and (next) intermidiate point. Why not make it like the time widget where you can choose between time-remaining and absolute-arival-time.

sgelb commented 2 years ago

Thank you both for your input. I like the idea to make it an option to choose between absolute altitude and remaining altitude difference.

But first things first. My main problem right now is that I do not know an efficient way to get the altitude of intermediate points or the destination. Only methods I found to get the points return either LatLon or TargetPoint, both have no altitude data. So what I do is get the calculated route as a List<Location>, because Location can contain the altitude and the points should be on or at least near that route. Iterating over the route I find a location within some minimum distance to the point and take that location's altitude. This is not the most accurate result, but in my experience it is good enough, especially if you keep the accuracy of altitude data in mind. But more important, it is very obvious that this is not a very efficient way to get the altitude values. It works good enough in my use cases where this calculation has only be done once for every intermediate point and is then cached and the route is not longer than 200km. But this seems too costly to calculate on every widget update if we try to dynamically update the widget with the remaining altitude difference.

tl;dr: This is what I basically came up with (I removed some caching stuff). Do you know a better way to get the altitude of the intermediate points and the destination? What would be your approach to get the remaining altitude difference?

LatLon target = getPointToNavigate();  // same method as DistanceToPointWidget::getPointToNavigate
List<Location> locations = app.getRoutingHelper().getCurrentCalculatedRoute();
double minimumDistanceInMeter = 10.0; 
for (Location location: locations) {
    if (!location.hasAltitude()) {
        continue;
    }

    if (MapUtils.getDistance(target, location.getLatitude(), location.getLongitude()) <= minimumDistanceInMeter) {
        return location.getAltitude();
    }
}
tradavyvy commented 2 years ago

I do not know enough about programming. But there are a number of issues that request to display altitude for a givven marked point on the map #10194, #11265, #13279 and more. Once those issues are dealt with, it would maybe be easier to make the widget that is discussed here.

sgelb commented 2 years ago
  1. I had an error in thinking. Of course it is possible to cache the altitude of an intermediate point or the destination. The question for a more efficient way to get the altitude of a point still remains.
  2. I implemented the possibility to switch between absolute altitude and altitude difference. Altitude difference is just the difference between the altitudes of the current position and a point. It does not take the elevation profile of the route between these points into account. Is that what you meant with "Uphill left", @vshcherb ?
vshcherb commented 2 years ago

Actually no, but it's a better widget than a static one.

Uphill should account all climbs / downhills, so it's not a difference but a sum similar to Track Information.