[openstreetmap/openstreetmap-website] Change zoom precision function (PR #5084)
Anton Khorev
notifications at github.com
Fri Aug 16 08:22:14 UTC 2024
This changes the number of fractional digits to log10(pixels / degrees) with pixels = 2**(8 + zoom) and degrees = 180.
---
If you apply the entire #5064, zoom in to the max zoom level, place an endpoint marker and try to drag it around, you'll notice it moves by jumping several pixels. This is because I limit its coordinates to zoom precision and zoom precision is not high enough. Its current version was introduced in https://github.com/openstreetmap/openstreetmap-website/commit/b28511faca45d8d8abc0d3c2fde5a501bbe94062. You can notice something strange about it: the zoom value went from being an argument of `Math.pow` to an argument of `Math.log`. `zoom` is already on a log scale, why do you need to take its log again?
| zoom | old zoomPrecision | new zoomPrecision |
| --- | --- | --- |
| 0 | 0 | 1 |
| 1 | 0 | 1 |
| 2 | 1 | 1 |
| 3 | 2 | 2 |
| 4 | 2 | 2 |
| 5 | 3 | 2 |
| 6 | 3 | 2 |
| 7 | 3 | 3 |
| 8 | 3 | 3 |
| 9 | 4 | 3 |
| 10 | 4 | 4 |
| 11 | 4 | 4 |
| 12 | 4 | 4 |
| 13 | 4 | 5 |
| 14 | 4 | 5 |
| 15 | 4 | 5 |
| 16 | 4 | 5 |
| 17 | 5 | 6 |
| 18 | 5 | 6 |
| 19 | 5 | 6 |
| 20 | 5 | 7 |
| 21 | 5 | 7 |
Some layers go up to zoom 21, precision limits become very noticeable there. Even on level 0 you need at least one digit after `.` to translate -90..+90 to 256 tile pixels.
You can view, comment on, or merge this pull request online at:
https://github.com/openstreetmap/openstreetmap-website/pull/5084
-- Commit Summary --
* Change zoom precision function
-- File Changes --
M app/assets/javascripts/osm.js.erb (2)
-- Patch Links --
https://github.com/openstreetmap/openstreetmap-website/pull/5084.patch
https://github.com/openstreetmap/openstreetmap-website/pull/5084.diff
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/5084
You are receiving this because you are subscribed to this thread.
Message ID: <openstreetmap/openstreetmap-website/pull/5084 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20240816/0d95faae/attachment-0001.htm>
More information about the rails-dev
mailing list