0002507: [Place-Dialog] "Unhandled exception" when pasting some invalid string
Fixing the bug, no features or improvements svn: r11416
This commit is contained in:
parent
d3cee34e11
commit
228e2b81bd
@ -178,9 +178,10 @@ def conv_lat_lon(latitude, longitude, format="D.D4"):
|
|||||||
#allow some special unicode symbols
|
#allow some special unicode symbols
|
||||||
val = val.replace( u'\u2033',r'"')
|
val = val.replace( u'\u2033',r'"')
|
||||||
val = val.replace( u'\u2032',r"'")
|
val = val.replace( u'\u2032',r"'")
|
||||||
#ignore spaces
|
#ignore spaces, a regex with \s* would be better here...
|
||||||
val = val.replace(r'\s*', r'')
|
val = val.replace(r' ', r'')
|
||||||
# get the degrees, must be present
|
val = val.replace(r'\t', r'')
|
||||||
|
# get the degrees, must be present to parse as old degree notation
|
||||||
if val.find(r'_') != -1:
|
if val.find(r'_') != -1:
|
||||||
l = val.split('_')
|
l = val.split('_')
|
||||||
if len(l) != 2:
|
if len(l) != 2:
|
||||||
@ -220,22 +221,22 @@ def conv_lat_lon(latitude, longitude, format="D.D4"):
|
|||||||
error = True
|
error = True
|
||||||
except:
|
except:
|
||||||
error = True
|
error = True
|
||||||
# last entry should be the direction
|
# last entry should be the direction
|
||||||
last = last.strip() #remove leading/trailing spaces
|
last = last.strip() #remove leading/trailing spaces
|
||||||
if typedeg == 'lat':
|
if typedeg == 'lat':
|
||||||
if last == 'N':
|
if last == 'N':
|
||||||
sign = '+'
|
sign = '+'
|
||||||
elif last == 'S':
|
elif last == 'S':
|
||||||
sign = '-'
|
sign = '-'
|
||||||
else:
|
else:
|
||||||
error = True
|
error = True
|
||||||
if typedeg == 'lon':
|
if typedeg == 'lon':
|
||||||
if last == 'E':
|
if last == 'E':
|
||||||
sign = '+'
|
sign = '+'
|
||||||
elif last == 'W':
|
elif last == 'W':
|
||||||
sign = '-'
|
sign = '-'
|
||||||
else:
|
else:
|
||||||
error = True
|
error = True
|
||||||
# degs should have a value now
|
# degs should have a value now
|
||||||
if degs is None:
|
if degs is None:
|
||||||
error = True
|
error = True
|
||||||
@ -492,6 +493,8 @@ if __name__ == '__main__':
|
|||||||
test_formats_fail(lat,lon)
|
test_formats_fail(lat,lon)
|
||||||
lat, lon = ' 50°59.60"N', ' 2°53\'E'
|
lat, lon = ' 50°59.60"N', ' 2°53\'E'
|
||||||
test_formats_success(lat,lon)
|
test_formats_success(lat,lon)
|
||||||
|
lat, lon = ' 11° 11\' 11" N, 11° 11\' 11" O', ' '
|
||||||
|
test_formats_fail(lat,lon)
|
||||||
# very small negative
|
# very small negative
|
||||||
lat, lon = '-0.00006', '-0.00006'
|
lat, lon = '-0.00006', '-0.00006'
|
||||||
test_formats_success(lat,lon)
|
test_formats_success(lat,lon)
|
||||||
|
Loading…
Reference in New Issue
Block a user