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

Improve hash control precision #5767

Merged
merged 1 commit into from
Nov 30, 2017
Merged

Improve hash control precision #5767

merged 1 commit into from
Nov 30, 2017

Conversation

mourner
Copy link
Member

@mourner mourner commented Nov 29, 2017

It always slightly annoyed me that the hash control isn't very precise — e.g. if you navigate to a certain place, then open a new tab and copy the url, it will be slightly off, with a bigger error the more you zoom in. So I derived a new formula for the hash that makes it always precise while keeping the low number of digits on lower zoom levels.

Here's a table with a comparison of the number of digits after the decimal point:

z old new
z0 0 1
z1 0 1
z2 1 2
z3 2 2
z4 2 2
z5 3 2
z6 3 3
z7 3 3
z8 3 3
z9 4 4
z10 4 4
z11 4 4
z12 4 5
z13 4 5
z14 4 5
z15 4 5
z16 4 6
z17 5 6
z18 5 6
z19 5 7
z20 5 7
z21 5 7
z22 5 8

The calculation is derived from the following formula:

512px * 2^zoom / 360 / 10^numDigits < 0.5px

Launch Checklist

  • briefly describe the changes in this PR
  • write tests for all new functionality
  • manually test the debug page

@mourner mourner requested a review from anandthakker November 29, 2017 17:48
Copy link
Contributor

@anandthakker anandthakker left a comment

Choose a reason for hiding this comment

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

Nice! The new formula makes more sense, too 👍

@mourner mourner merged commit 24373a4 into master Nov 30, 2017
@mourner mourner deleted the improve-hash-precision branch November 30, 2017 13:29
@jfirebaugh jfirebaugh mentioned this pull request Dec 14, 2017
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