From 7dc532c743a53cdf15e4b8cb7a32fb474f2c56a5 Mon Sep 17 00:00:00 2001 From: Serge Noiraud Date: Mon, 10 Jun 2019 09:27:03 +0200 Subject: [PATCH] Avoid comma in a lat/lon entry field. (#812) * Avoid comma in a lat/lon entry field. * Be more precise on the tooltip text. * conv_lat_lon should not accept comma in lat/lon * Tests failed with comma in lat/lon * geoplaces fails to center if bad lat/lon --- gramps/gen/utils/place.py | 7 ------- gramps/gen/utils/test/place_test.py | 4 ++-- gramps/plugins/view/geoplaces.py | 6 ++++-- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/gramps/gen/utils/place.py b/gramps/gen/utils/place.py index 7283f9711..910232df8 100644 --- a/gramps/gen/utils/place.py +++ b/gramps/gen/utils/place.py @@ -283,13 +283,6 @@ def __convert_float_val(val, typedeg="lat"): # it is checked that degree >0, 0<= minutes <= 60, # 0<= seconds <= 60, direction is in the directions dic. - #change , to . so that , input works in non , localization - #this is no problem, as a number like 100,000.20 cannot appear in - #lat/lon - #change XX,YY into XX.YY - if val.find(r'.') == -1: - val = val.replace(',', '.') - # format: XX.YYYY v = __convert_using_float_repr(val) if v is not None: diff --git a/gramps/gen/utils/test/place_test.py b/gramps/gen/utils/test/place_test.py index f59043afc..e7cdec5d5 100644 --- a/gramps/gen/utils/test/place_test.py +++ b/gramps/gen/utils/test/place_test.py @@ -183,10 +183,10 @@ class PlaceTest(unittest.TestCase): def test_decimal_localization(self): lat, lon = '50.849888888888', '2,885897222222' - self._test_formats_success(lat, lon) + self._test_formats_fail(lat, lon) lat, lon = '89°59\'59.9999"S', '179°59\'59,9999"W' - self._test_formats_success(lat, lon) + self._test_formats_fail(lat, lon) lat, lon = '89°59\'1.599,999"S', '179°59\'59,9999"W' self._test_formats_fail(lat, lon) diff --git a/gramps/plugins/view/geoplaces.py b/gramps/plugins/view/geoplaces.py index 9a4cb6423..41a6f7dc2 100644 --- a/gramps/plugins/view/geoplaces.py +++ b/gramps/plugins/view/geoplaces.py @@ -378,8 +378,10 @@ class GeoPlaces(GeoGraphyView): latitude, longitude = conv_lat_lon(place.get_latitude(), place.get_longitude(), "D.D8") - self.osm.set_center_and_zoom(float(latitude), float(longitude), - int(config.get( + if latitude and longitude: + self.osm.set_center_and_zoom(float(latitude), + float(longitude), + int(config.get( "geography.zoom_when_center"))) else: self.message_layer.add_message(