Last modified: 2014-05-13 12:30:57 UTC
I'm writing a bot to import coordinates to Wikidata and I ran into problems with the "precision" field. For a lot of values it throws 'The value does not comply with the property's definition. The value's data value type "ununserializable" does not match the property's data type's data value type "globecoordinate".' Example json: {'latitude': 41.9689, 'altitude': None, 'globe': 'http://www.wikidata.org/entity /Q2', 'longitude': 12.4092, 'precision': 0.012082121278963331} I did some testing on https://www.wikidata.org/wiki/Q3969823 * 0.012039052310050358 fails * 0.012058 fails (round on 6 decimals) * 0.00001 works (hard coded) * 0.00002 fails (hard coded)
Ok. Did some digging. The type is defined at https://meta.wikimedia.org/wiki/Wikidata/Data_model#Geographic_locations a precision (decimal, representing degrees of distance, defaults to 0, 9 digits after the dot and three before, unsigned, used to save the precision of the representation) After some digging I found http://git.wikimedia.org/blob/mediawiki%2Fextensions%2FDataValues.git/727ccd66b03f42e1f5458ea204ca15b315cf5f04/DataValues%2Fresources%2FglobeCoordinate.js%2Fsrc%2FglobeCoordinate.GlobeCoordinate.js function isValidPrecision( precision ) { var precisions = globeCoordinate.GlobeCoordinate.PRECISIONS; for( var i in precisions ) { if( Math.abs( precision - precisions[i] ) < 0.0000001 ) { return true; } } return false; } /** * Precisions a globe coordinate may feature. * @type {number[]} */ GlobeCoordinate.PRECISIONS = [ 10, 1, 0.1, 1 / 60, 0.01, 0.001, 1 / 3600, 0.0001, 1 / 36000, 0.00001, 1 / 360000, 0.000001, 1 / 3600000 ]; So it looks like only these values (with a minor deviation of 0.0000001) are considered valid. Is this true? Is this intentional? Where the hell is this documented? If this is true, why does the api accept invalid precisions?
Looks like the JS cant render anything that isn't explicitly defined as okay!? http://git.wikimedia.org/blob/mediawiki%2Fextensions%2FDataValues.git/727ccd66b03f42e1f5458ea204ca15b315cf5f04/DataValues%2Fresources%2FglobeCoordinate.js%2Fsrc%2FglobeCoordinate.GlobeCoordinate.js#L180 https://www.wikidata.org/w/index.php?title=Q3969823&oldid=113061813 has a precision value of 2.0e-5 but displays as undeserializable with JS off its okay.
*** This bug has been marked as a duplicate of bug 64887 ***