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
This commit is contained in:
parent
2951a0acf0
commit
7dc532c743
@ -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:
|
||||
|
@ -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)
|
||||
|
@ -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(
|
||||
|
Loading…
Reference in New Issue
Block a user