Skip to content
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

Feature Request: Road surface as quality color #621

Merged
merged 4 commits into from
Nov 3, 2022

Conversation

tbsmark86
Copy link
Contributor

This is similar to #310

Of course the actual numbers used are highly subjective.

Notes:

  • Required fork of leaflet-hotline with a new option to disable the gradient display.
    This is was done so that short stretches of very bad surface adjacent to very good ones are visible.
    (The original author does not maintain it anymore so no harm in forking.)
  • I've ignored the compat warning:
    URLSearchParams is not supported in Safari 7, op_mini all, IE 10, android 4.1
    don't seem relevant today. Those are all EOL maybe eslint configuration should be updated?
    And supporting opera-mini seems pointless.

Required fork of leaflet-hotline with a new option to disable the
gradient display.
This is was done so that short stretches of very bad surface adjacent to
very good ones are visible.

Also note the eslint-disable-line for this compat warning:
  URLSearchParams is not supported in Safari 7, op_mini all, IE 10, android 4.1
don't seem relevant today because those are EOL for a long time now.
Copy link
Owner

@nrenner nrenner left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

(The original author does not maintain it anymore so no harm in forking.)

Maybe a PR would be nice anyway to let other users know of this improvement.

URLSearchParams is not supported in Safari 7, op_mini all, IE 10, android 4.1

URLSearchParams should be polyfilled by babel/core-js. I can take care of eslint config, probably adding it to polyfills.
Supported browsers could indeed be updated, created issue #628.

Some thoughts:

  1. What I also still have in mind is separate color codings of highway, surface and smoothness tag values, corresponding to the Analysis tab, with distinct colors (e.g. aspalt=gray, grass=green, ground=brown, gravel=yellow, ...). Then we would have two types of surface codings and the name in code and UI would need to be more specific, e.g. surface-rating or -index. But don't know if worth changing that now in foresight while unclear if feasible or ever implemented, so I don't really mind.
  2. I personally don't like the simple red-green color palette, in-between colors look muddy, what about either using the default palette with yellow in the middle or the incline palette (#313)?

See also inline comments.

surface = 0.9;
} /* else {
don't change
} */
Copy link
Owner

Choose a reason for hiding this comment

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

Tabs instead of spaces

case null:
break;
default:
console.warn('unhandled surface type', data.get('surface'));
Copy link
Owner

Choose a reason for hiding this comment

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

Please comment out console warning, as with a selected choice of values there will always be warnings without any actionable implication.

}

// limit normal values 0-0.9 so 1.0 can be unknown
const final = surface === null ? 1.0 : surface * 0.9;
Copy link
Owner

Choose a reason for hiding this comment

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

surface=asphalt + smoothness=excellent looks more like unknown, probably because final = ~0.99 (1 * 1.1 * 0.9), which is closer to gray for unknown than green, example:

@tbsmark86
Copy link
Contributor Author

To solve this "what color is what" a bit better I added a more usable way to find the message for a certain part of the route.

What I also still have in mind is separate color codings of highway, surface and smoothness tag values.

Yeah sounds nice. But I feel there are to many different surface values ... so finding colors that are somewhat self-explanatory could be very hard. For example is light-grey concrete or cobblestone?
This soulution is at least something. You could also rename it 'smoothness' rating because essentially red is very rough (dirt, cobbelstone) and green is very smooth (asphalt) - so no real conflict :)

I personally don't like the simple red-green color palette

Ok. I did put much thought into the colors.

Copy link
Owner

@nrenner nrenner left a comment

Choose a reason for hiding this comment

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

To solve this "what color is what" a bit better I added a more usable way to find the message for a certain part of the route.

Nice, but just finding the closest node will sometimes return a node from another road nearby. See this example, when hovering along the "Europastraße" (highway=primary) it will also highlight the two other segments in some parts:

https://localhost:3000/#map=19/47.66680/9.16253/standard&lonlats=9.162721,47.666876;9.162458,47.667085

The height marker jumps to the other segments as well, it looks like you've actually taken the code from Leaflet.Heightgraph.

A better solution might be to use Turf.nearestPointOnLine, then maybe the index or location return values can help finding the next/previous node along the line (again not closest). There are also Turf.pointToLineDistance, L.LineUtil.closestPointOnSegment and L.LineUtil.pointToSegmentDistance.

You could also rename it

Yes, my comment was just about the naming, but that can be addressed once there is actually a conflict. Both approaches are valid and not exclusive.

More accurate on routes that are shaped like an 'U' for whatever reason.
@tbsmark86
Copy link
Contributor Author

tbsmark86 commented Nov 2, 2022

Added the proposed changes. Less code & more reuse nice!
Yes, I've used the code from Heightgraph which of course means that this has the same bug. But probably less relevant there.

Here the most extreme example for Heightgraph I could find (which also led me to another bug in my code ...):
https://localhost:3000/#map=17/46.59409/11.52860/standard&lonlats=11.527732,46.594296;11.527188,46.593598&profile=fastbike

Copy link
Owner

@nrenner nrenner left a comment

Choose a reason for hiding this comment

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

Yes, I've used the code from Heightgraph which of course means that this has the same bug. But probably less relevant there.

Yes, I would also consider it undesired behavior there, but as the marker and info is shown at the selected point it's less of an issue.

Thanks for your contribution!

@nrenner nrenner merged commit b3e788e into nrenner:master Nov 3, 2022
@tbsmark86 tbsmark86 deleted the road-quality branch November 3, 2022 17:15
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