Page MenuHomePhabricator

<mapframe>: Attribute "longitude" has an invalid value - when value is close to zero
Closed, ResolvedPublic

Description

When adding the coordinates to https://www.wikidata.org/wiki/Q26295695 I could enter 0.00004 for longitude, but instead of a map there was a message "<mapframe>: Attribute "longitude" has an invalid value". It seems to be the same for any non-zero latitude or longitude less than 0.0001 or 0°0'0.36".

Event Timeline

TheDJ added a subscriber: TheDJ.

This is a bug in Wikibase's CachingKartographerEmbeddingHandler::getWikiText function.
It inserts its float values directly into the string, which in php causes it to output scientific notation for such small values. The JSON part adding the marker can handle that, but the mapframe attributes cannot handle it. (should it ?)

<mapframe width="310" height="180" zoom="13" latitude="50.87305555555555" longitude="2.7777777777778E-5" frameless align="left">
			{
			"type": "Feature",
			"geometry": { "type": "Point", "coordinates": [ 2.7777777777778E-5, 50.87305555555555] },
			"properties": {
			  "marker-symbol": "marker",
			  "marker-size": "large",
			  "marker-color": "0050d0"
			}
		  }
</mapframe>

Change 581726 had a related patch set uploaded (by TheDJ; owner: TheDJ):
[mediawiki/extensions/Wikibase@master] Do not use scientific notation in Mapframes

https://gerrit.wikimedia.org/r/581726

@thiemowmde would you mind taking a look at this ?

I tried adding a testcase for this, but had some trouble getting the unittests to run and I didn't want to do a deepdive in setting up a wikibase development environment

Change 582110 had a related patch set uploaded (by Thiemo Kreuz (WMDE); owner: Thiemo Kreuz (WMDE)):
[mediawiki/extensions/Wikibase@master] Remove "kartographer" page prop removed in Kartographer extension

https://gerrit.wikimedia.org/r/582110

Change 582110 abandoned by Thiemo Kreuz (WMDE):
Remove "kartographer" page prop removed in Kartographer extension

https://gerrit.wikimedia.org/r/582110

Change 581726 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Do not use scientific notation in Mapframes

https://gerrit.wikimedia.org/r/581726

hoo assigned this task to TheDJ.
hoo removed a project: Patch-For-Review.