Page MenuHomePhabricator

Inline Kartographer mapframes: Take precision into account
Open, MediumPublic

Description

As an editor I want to have the map zoom level for a geocoordinate statement take into account the precision in order to avoid people being confused by a high zoom-level that implies a much higher precision than intended.

Problem:
The map is displayed at an inappropriately high zoom level (13) which does not include all of the area whose coordinates would round to that value. This is misleading and contributes to people thinking such coordinates are incorrect, rather than only imprecise.

The map should take the precision into account and use a more appropriate zoom level (e.g. 5), one which includes the entire area which would round to those coordinates.

Example:
https://test.wikidata.org/wiki/Q105715

Screenshots/mockups:
Screenshot of how 50°N 10°E currently displays:

point.png (352×919 px, 27 KB)

Screenshot showing the same coordinates but as a bounding box covering 49.5°N 9.5°E to 50.5°N 10.5°E (taken from http://bboxfinder.com/), zoomed out so that the bounding box is approximately the same size as the marker in the original map, and then cropped to be the same size as the original:

boundingbox.png (365×928 px, 70 KB)

BDD
GIVEN
AND
WHEN
AND
THEN
AND

Acceptance criteria:

Original ticket:

After T184933: Display map for geocoordinate statements we now have small inline maps which are obtained using Kartographer mapframes, but as @TheDJ pointed out in T184933#4812900:

Currently these are being generated by just creating a GeoJSON point from the value (in CachingKartographerEmbeddingHandler::getWikiText): "geometry": { "type": "Point", "coordinates": [' . $value->getLongitude() . ', ' . $value->getLatitude() . '] }, (where $value is a [[https://github.com/DataValues/Geo/blob/master/src/Values/GlobeCoordinateValue.php|GlobeCoordinateValue]]). This currently doesn't take the precision into account at all (also not for setting the map's zoom, which is hard coded at 13).

We should probably base both the zoom and the geometry on the precision of the GlobeCoordinateValue. For this we should probably stop using GeoJSON Point, but rather use Polygon with the min/max Lat/Long values within the precision (if Kartographer supports this)?

Is there some other/ nicer/more correct way to do this? How do we compute the zoom from the precision?

Event Timeline

I've updated the ticket description with what @Nikki wrote in T334086. Thank you!

Marius lined out a solution in the original report and asked if there is a better solution. Does anyone know?

There is a highly relevant piece of code in the Maps (Kartographer) extension that does the opposite: The input is a zoom factor from 0 to 19 and the output a precision. You "just" need to turn the formula around.

https://phabricator.wikimedia.org/diffusion/EKAR/browse/master/modules/box/Map.js$782

I also suggest to limit the zoom factor, i.e. never go to 19 but stop much earlier. Maybe just keep using the current 13 as a limit. I find this reasonable. Such a limit is relevant because many coordinates on Wikidata appear to have an unreasonably high precision because of conversion artifacts.

I'm not sure to what "Marius lined out a solution" refers to. Do you have a link?

Sorry I was referring to what is in the ticket description under "original ticket".