From 410cffe8320d3d8d08727c02f7f43346b79613f2 Mon Sep 17 00:00:00 2001 From: Benedikt Werner <1benediktwerner@gmail.com> Date: Thu, 6 May 2021 17:16:21 +0200 Subject: [PATCH] Allow entering place latlong without space (#1190) * Allow entering place latlong without space * Allow entering place latlong without space in editplaceref --- gramps/gui/editors/editplace.py | 10 +++++++--- gramps/gui/editors/editplaceref.py | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/gramps/gui/editors/editplace.py b/gramps/gui/editors/editplace.py index 117f7cecd..df724da25 100644 --- a/gramps/gui/editors/editplace.py +++ b/gramps/gui/editors/editplace.py @@ -187,9 +187,13 @@ class EditPlace(EditPrimary): def set_latlongitude(self, value): try: - coma = value.index(', ') - longitude = value[coma+2:].strip().replace(',','.') - latitude = value[:coma].strip().replace(',','.') + parts = value.index(', ') + if len(parts) == 2: + longitude = parts[0].strip().replace(',', '.') + latitude = parts[1].strip().replace(',', '.') + else: + longitude, latitude = value.split(',') + self.longitude.set_text(longitude) self.latitude.set_text(latitude) self.top.get_object("lat_entry").validate(force=True) diff --git a/gramps/gui/editors/editplaceref.py b/gramps/gui/editors/editplaceref.py index eee6c3ae2..89590ee67 100644 --- a/gramps/gui/editors/editplaceref.py +++ b/gramps/gui/editors/editplaceref.py @@ -181,9 +181,13 @@ class EditPlaceRef(EditReference): def set_latlongitude(self, value): try: - coma = value.index(', ') - longitude = value[coma+2:].strip().replace(',','.') - latitude = value[:coma].strip().replace(',','.') + parts = value.index(', ') + if len(parts) == 2: + longitude = parts[0].strip().replace(',', '.') + latitude = parts[1].strip().replace(',', '.') + else: + longitude, latitude = value.split(',') + self.longitude.set_text(longitude) self.latitude.set_text(latitude) self.top.get_object("lat_entry").validate(force=True)