-
Notifications
You must be signed in to change notification settings - Fork 75
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
Use Heightgraph in lieu of Elevation to show the elevation profile #345
Conversation
- Heightgraph supports resizing; remove the Elevation specific workaround which was readding the data - resize the elevation chart on window resize and chart show
- remove old comments and unusable commented out code
Build the GeoJSON object manually.
- fix the grade calculation - don't show the grade labels, as they are all over (should be normalized) - fix the display issues by overridding the heightgraph CSS
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.
Thanks for working on this!
Some issues:
- Leaflet.Heightgraph and the plugin wrapper Heightgraph.js don't seem to handle missing elevation data:
TypeError: Cannot read property 'text' of undefined at NewClass._prepareData (L.Control. Heightgraph.js:4994)
TypeError: Cannot read property 'geometry' of undefined at Heightgraph.js:267
- see issues Missing elevation data for specific routes abrensch/brouter#137, No calculation of distance, travel time, etc. #203 and Leaflet.Elevation#63 (comment)
- collapsed state is not remembered for the next session
- this is due to missing
initCollapse
method and it's call inindex.js
- this is due to missing
- missing bottom tiles after resizing window and closing height graph
map._onResize();
call after collapse missing, also ininitCollapse
method
- applying a patch to a distribution bundle is a bit fragile and will probably fail (need maintenance) with some future update
- wrapping the bundle inside a closure using an IIFE (immediately invoked function expression), so d3 doesn't pollute the global scope, seems to work as well:
Automatically adding those lines at the top and bottom of the bundle file would be less fragile, so I would prefer that instead of the patch, if there is a way
(function() { ... }());
- wrapping the bundle inside a closure using an IIFE (immediately invoked function expression), so d3 doesn't pollute the global scope, seems to work as well:
Thanks for looking at this, @nrenner . I will have a look at issues 1 through 3 and fix them. About 4 (patching the Heightgraph bundle):
|
I guess that would already be an improvement and maybe easier to check if the patch is still ok. I intend to open separate/new Heightgraph issues for 1. and 4. |
The geojson for the heightgraph profile is built in the Heightgraph plugin. I could easily filter out all latLng points which don't have an |
What I have in mind is the same approach I implemented for Leaflet.Elevation in PR MrMufflon/Leaflet.Elevation#84 (we're using my fork). Leaflet.Heightgraph should support |
I opened an issue for 4.: GIScience/Leaflet.Heightgraph#107. The minified bundle has an IIFE, so we might just use that for now, but for some reason it didn't get included when I had a quick try changing the main reference to it. |
It's not obvious why, all I can say is that the Heightgraph attribute is not available in that scope. I have been working on handling points with |
A short update on the progress:
I am currently working on fixing items 2 and 3 above. |
Just finished fixing items 2 and 3. To summarize: the only outstanding issue currently is in Leaflet.Heightgraph, when the track contains points without elevation data. Given the recent activity on that project (or the lack thereof), I am not too optimistic about it being fixed soon. |
Like I said in the previous comment, I have the feeling that the bug in Leaflet.Heightgraph around handling points without elevation would take quite a while to get fixed. Because of this, I handled such points in the Heightgraph plugin and inferred their elevation from the closest points with elevation in the track: d83fddd Speaking of this bug in Leaflet.Heightgraph, since you fixed the similar one in Leaflet.Elevation and you have more context, could you open an issue for it please? Thanks. |
Thanks for the updates. I'm not sure about interpolating missing elevation values. While interpolation might work for some cases, it will be misleading or just wrong for others. I personally consider showing the data as it is - with gaps in the graph for missing values - as the proper solution, which is why I implemented this for Leaflet.Elevation. Switching to Heightgraph without this feature feels like a step back in this regard. I have opened an issue for missing elevation data: Heightgraph#108. And I will look into making a PR for this. |
👍 to your statement. Undoing it is easy, I just have to revert the last commit. |
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.
Thanks for your contribution!
Thanks for integrating this change, I look forward to using it. My impression was that the major blocker to using Heightgraph was its inability to handle tracks with points with undefined elevation. I see that you fixed it, and the IIFE issue as well, but the PRs were not merged in. |
Things to note:
that is because Heightgraph only works with d3 5.x, whereas this project
used d3 3.x;
I had to use its transpiled bundle (which includes d3 5.x);
with the rest of brouter-web; I had to comment them out via a patch
applied in the postinstall phase.
This PR is related to #343;
since I used the transpiled Heightgraph, the upgrade to d3 5.x is not necessary.