Skip to content

Calculate and display the overall incline and decline - #209

Closed
ratrun wants to merge 2 commits into
graphhopper:masterfrom
ratrun:calcClimb
Closed

ratrun wants to merge 2 commits into
graphhopper:masterfrom
ratrun:calcClimb

Conversation

@ratrun

@ratrun ratrun commented May 15, 2014

Copy link
Copy Markdown
Contributor

in order to smooth the input elevation data, which currently sometimes is not smooth at all.

@ratrun

ratrun commented May 16, 2014

Copy link
Copy Markdown
Contributor Author

ratrun@5b516fa adds calculation of a waytype summary information for bicycles.

@karussell karussell changed the title Calculate and dsiplay the overall climb and fallmeters with a simple filtering mecha... Calculate and display the overall incline and decline May 17, 2014
@karussell

Copy link
Copy Markdown
Member

What do you mean with 'to smooth the input elevation data'?

  • Would you rename to incline/decline
  • there should not be casting in those classes - maybe we should postpone this change until we have the wayType for all vehicles
  • getWayTypeCode/isPaved should not be appended to the encoder, not sure if they could be added to InstructionAnnotation
  • currently PathMerger always calculates this overhead, it should only for 3d
  • there are 0 tests. this is fixable
  • don't use special chars for i18n. use include/decline or similar instead

@ratrun

ratrun commented May 21, 2014

Copy link
Copy Markdown
Contributor Author

Thanks for the feedback. Please have a look to the changes made. I have tackled every issue mentioned except for the last one: "don't use special chars for i18n. use include/decline or similar instead". I believe that the special characters "↑" and "↓" have following advantages compared to some verbal expressions:

  • They are already international and don't need to be translated.
  • They are easy to understand
  • They are very short.

Therefore I would like to keep this if possible.

With "smothing" the input elevation data I mean that I don't sum up elevation differences smaller to 15 meters and also neglect differences bigger than 100 meters. Without the first we get an noteable ammount of incline/decline meters even in totally flat areas, the other one is a kind of plausability check for rather bad SRTM elevation data.

@karussell

Copy link
Copy Markdown
Member

They are already international and don't need to be translated.
...

Sure but they are hard to write :).

Also now that we have encoder.getDouble this might be more suitable than introducing more methods for this.

@karussell

Copy link
Copy Markdown
Member

It is hard to include a big issue - but I would really like to have the overall incline and decline. Would you mind separating them from the rest of this issue? E.g. smoothing is now done when reading from SRTM data, also we can now read CGIAR which provides better elevation data.

@ratrun
ratrun force-pushed the calcClimb branch 2 times, most recently from fbd35c8 to af16fba Compare August 30, 2015 07:29
@ratrun

ratrun commented Aug 30, 2015

Copy link
Copy Markdown
Contributor Author

After a long break I included the suggestion. Now the pull request contains only ascend and descend calculation as suggested. My tests showed that the elevation low pass filtering on reading SRTM is still not sufficient for calculating an overall ascend and descend. See https://graphhopper.com/maps/?point=48.079914%2C15.968628&point=47.995436%2C16.387482&vehicle=bike&elevation=true&layer=Omniscale
Therefore I included a second filter. Initially I also changed the original elevation values into the smoothed values. But I reverted that, because this would mess up all the existing SRTM tests and probably make things worse, as the smoothing algorithm also slightly changes the values of the initial and the last value.
In case that this request gets included, please note somewhere in the release notes that this calculation is a limited guess only and cannot calculate exact values due to principle reasons. Otherwise we probably cannot avoid endless discussions of the results, see http://regex.info/blog/2015-05-09/2568 .
I didn't make detailed tests of the results based on a reference route, where the ascend and descend values are exactly known, because i don't know where I could find such an example on at least 100km distance case, with multiple mountain segments are included. Instead, I just compared the results with some segments I'm familar with and here the results look plausible. Please note that I'm living in Austria, where we have a lot of hills and mountains and I therefore don't care about 50 meters more or less.
In case that somebody finds a better filter and can prove that the results improve with it, then we always can exchange the filter into the improved one.

@karussell

Copy link
Copy Markdown
Member

Thanks for taking the time again!

Would still love to see two issues :)
Please would you mind to separate the filtering in another PR? Then we can easier integrate this without fear and polish the filtering/smoothing later.

For this PR I would like to avoid mixing this bike specific info in the general translation info. Please create two new translation keys e.g. "ascent %$1" and "descent %$1". Furthermore the GHResponse now contains a hints field where I currently would like to prefer the values as they are not usable for all vehicles.

Thanks for the link too, interesting read.

@ratrun

ratrun commented Sep 5, 2015

Copy link
Copy Markdown
Contributor Author

I do not see a reason why separating the filtering would bring benefits. I know that without the filtering the calculated results are worse compared with the filtering. What do you fear? The filtering is only used for the calculation of the ascend and descent, so it cannot destroy/influence any existing functionality. Therefore I would like to keep it included.

As you again suggested usage on the translation keys I will create them. I had hoped that you forgot about it in the meantime ;)

I think that I understood the hints field on the java side. But I do not understand your plan for the java script side. Here I only found the usage as an error indication in this line: main.js#L982

Could you please provide some more hints for the hints usage on the java script client side? I problably overlooked something.

@karussell

Copy link
Copy Markdown
Member

I would like to have this feature and feel the smoothing is not ready. But with 'not ready' I more mean that it could be applied in more scenarios like while import so that not only bike benefits.

What do you fear? The filtering is only used for the calculation of the ascend and descent, so it cannot destroy/influence any existing functionality. Therefore I would like to keep it included.

I don't like to have it in an inconsistent manner. Smoothing should be done earlier if it is of an advantage.

Re the translation key: do not include the english translation, just provide EN (+DE) and the other languages fall back to english. I can do this, plus the JS side (when I finally find a bit time ;()

@ratrun

ratrun commented Sep 11, 2015

Copy link
Copy Markdown
Contributor Author

I didn't know about the automatic Engish language fall-back. I removed all the translation strings (except EN+DE) as proposed.

With a heavy heart I also included the requested elimiation of the smoothing. Now the patch is quite small.

Please note following commented test lines in GraphHopperIT.java:
This was the testresult with smoothing:

        //assertEquals(8, rsp.getAscendMeters(), 1e-1);
        //assertEquals(59, rsp.getDescendMeters(), 1e-1);

This is the testresult without the smoothing:

        assertEquals(84, rsp.getAscendMeters(), 1e-1);
        assertEquals(135, rsp.getDescendMeters(), 1e-1);

for

https://graphhopper.com/maps/?point=43.730729%2C7.421288&point=43.727697%2C7.419199&vehicle=foot&elevation=true&layer=Omniscale

In case that you really want to have it this way, then I'll make one more commit and delete the two commented test results.

I don't think that this change is bike/foot related. The results are also of interest for other vehicles, even for car.
I would ask you to make the JS side change as proposed.

@karussell

Copy link
Copy Markdown
Member

Thanks, will look into it next week and add the JS where necessary!

With a heavy heart I also included the requested elimiation of the smoothing.

But please not without creating a new separate issue with the smoothing only :)

I want to highlight that I don't criticize you or anything, it is even the opposite that GraphHopper lives from many such improvements with this 'love for the detail'. Now for this case I just wanted to make sure that two independent issues get its own dedicated discussion and improvement. Also having smaller pull requests makes it easier to review, integrate, test and deploy.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would avoid creating a new array here, instead pass fullPoints directly to calcAscendDescend

As the smoothing will happen on import (and done in a separate issue). BTW: see also #507 where this then should be placed

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'll do ...

@karussell karussell mentioned this pull request Sep 15, 2015
@karussell

Copy link
Copy Markdown
Member

@ratrun As I just saw the commit where you noted the GPL code for smoothing: would you please just provide a single commit for the ascend+ascend stuff without any smoothing? This is really important to keep GraphHopper free of licensing issues.

@ratrun

ratrun commented Sep 15, 2015

Copy link
Copy Markdown
Contributor Author

I used the GPL code just for experiments and replaced it later, no part of it is active any longer. I'll try to combine the changes into a single commit.

@karussell

Copy link
Copy Markdown
Member

Okay, thanks!

Just for the future: commiting GPL code into the repository should not be done. Also when looking for inspiration (aka implementing) then GPL code must not be used.

@ratrun

ratrun commented Sep 15, 2015

Copy link
Copy Markdown
Contributor Author

I'm sorry for the troubles. Now I think that I have tackled every comment. Please take a look. As suggested I didn't try to implement the JS hint stuff.

@karussell

Copy link
Copy Markdown
Member

Sorry for pinging here again. Can you provide just one commit where the commits where you eliminated code are removed?

@ratrun

ratrun commented Sep 17, 2015

Copy link
Copy Markdown
Contributor Author

I'm still sometimes struggling with git. Is it OK now?

@karussell

Copy link
Copy Markdown
Member

Thanks and no problem :)
Now I can take it and rebase this one commit ... this here has helped me to understand a bit more.

To avoid the merge commits you should do git pull --rebase instead of git pull ... BUT do this only if you know what you are doing and push force only into a feature branch :)

@karussell

Copy link
Copy Markdown
Member

Please have a look into my changes. I added the translation stuff to the google doc and made an automatic update of the translation files, so there are these many changes. But actually we don't need this due to the simple arrows I use in the web UI. Let me know if you think we should remove the text or keep it.

Also we should document the descend and ascend in the web docs

@ratrun

ratrun commented Sep 17, 2015

Copy link
Copy Markdown
Contributor Author

Thank you. Looks good. As said, I totally agree to get rid of the translation stuff. I always wanted to have it that way and only included the translation keys because you insisted on them. But this is much more easy to understand in every language.

Now there is only one major problem: the missing smoothing and my algorithm, which cannot be used for smoothing during reading, because it messes up every start and end elevation. Do you already have an idea how to solve this? I think that a good 2D smoothing algorithm should have all evlevation data for every point available. When you do the smoothing during reading then I beleive that one probably needs a 3D smoothing algorithm. Anywhow, 3D smoothing is beyond my mathematical skills.

@karussell

Copy link
Copy Markdown
Member

Ok, I'll get rid of the translations ... re the smoothing: let us discuss this in the other issue.

@karussell

Copy link
Copy Markdown
Member

Hmmh, the translations are useful for navigational purposes .. I'll keep it but'll remove the 'web' prefix

@karussell karussell closed this in f331f40 Sep 21, 2015
@karussell

Copy link
Copy Markdown
Member

Is now also deployed.

dabiih pushed a commit to dabiih/graphhopper that referenced this pull request Jan 7, 2025
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.

2 participants