John Vandenberg has uploaded a new change for review. https://gerrit.wikimedia.org/r/264740
Change subject: Allow Coordinate.precision to be None ...................................................................... Allow Coordinate.precision to be None Wikibase has coordinates without a precision. They cause an exception when saving unmodified. Also add a setter for Coordinate.precision, so existing data without a precision can be improved. Bug: T123910 Change-Id: I9ce758c7271c78ba9b97bf2f52b4b34160d935e1 --- M pywikibot/__init__.py 1 file changed, 12 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core refs/changes/40/264740/1 diff --git a/pywikibot/__init__.py b/pywikibot/__init__.py index c2f4dd5..d3353d4 100644 --- a/pywikibot/__init__.py +++ b/pywikibot/__init__.py @@ -331,6 +331,11 @@ u""" Return the precision of the geo coordinate. + The precision is calculated if the Coordinate does not have a precision, + and self._dim is set. + + When no precision and no self._dim exists, None is returned. + The biggest error (in degrees) will be given by the longitudinal error; the same error in meters becomes larger (in degrees) further up north. We can thus ignore the latitudinal error. @@ -346,13 +351,19 @@ Therefore:: precision = math.degrees(self._dim/(radius*math.cos(math.radians(self.lat)))) + + @rtype: float or None """ - if not self._precision: + if self._precision is None and self._dim is not None: radius = 6378137 # TODO: Support other globes self._precision = math.degrees( self._dim / (radius * math.cos(math.radians(self.lat)))) return self._precision + @precision.setter + def precision(self, value): + self._precision = value + def precisionToDim(self): """Convert precision from Wikibase to GeoData's dim.""" raise NotImplementedError -- To view, visit https://gerrit.wikimedia.org/r/264740 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9ce758c7271c78ba9b97bf2f52b4b34160d935e1 Gerrit-PatchSet: 1 Gerrit-Project: pywikibot/core Gerrit-Branch: master Gerrit-Owner: John Vandenberg <jay...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits