After adding a map with VE when I save the page, I see this error on the page in readmode instead of the map
<mapframe>: Attribute "latitude" has an invalid value
After adding a map with VE when I save the page, I see this error on the page in readmode instead of the map
<mapframe>: Attribute "latitude" has an invalid value
Project | Branch | Lines +/- | Subject | |
---|---|---|---|---|
mediawiki/extensions/Kartographer | master | +4 -3 | Round coordinates based on zoom level |
Reproduceable by inserting a map and saving without touching it, turns out it adds scientific notation:
<mapframe latitude="-1.1449996853268662e-13" longitude="0" zoom="0" width="400" height="300">
There is no reason to allow it in wikitext - it's confusing for non-technical people and not needed for ranges or precision in the context of web cartography. Let's round it to, say, 6 digits?
I think rounding should depend in the zoom level. At zoom 0, it should produce no decimals, and at zoom 18 -something like 7.
Even 6 decimal points is ~11cm, far more precise than what we need: https://en.wikipedia.org/wiki/Wikipedia:WikiProject_Geographical_coordinates#Precision_tables
I spoke with @JGirault this morning - apparently we already have that code in Kartographer to optimize the URL anchor portion. We should simply reuse that.
The code that we have in Kartographer rounds like this:
Zoom level | Decimal precision | Example with lat=37.77493 |
---|---|---|
0 | 0 | 38 |
1 | 0 | 38 |
2 | 1 | 37.8 |
3 | 2 | 37.77 |
4 | 2 | 37.77 |
5 | 3 | 37.775 |
6 | 3 | 37.775 |
7 | 3 | 37.775 |
8 | 3 | 37.775 |
9 | 3 | 37.7749 |
10 | 4 | 37.7749 |
11 | 4 | 37.7749 |
12 | 4 | 37.7749 |
13 | 4 | 37.7749 |
14 | 4 | 37.7749 |
15 | 4 | 37.7749 |
16 | 4 | 37.7749 |
17 | 5 | 37.77493 |
18 | 5 | 37.77493 |
Change 306064 had a related patch set uploaded (by JGirault):
Round coordinates based on zoom level