Skip to content

Commit

Permalink
Fixed matching LatLon lowercase.
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinMikita committed Sep 5, 2017
1 parent 49211da commit 7c81143
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions web/websearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,11 +636,14 @@ def search(orig_query, query_filter, autocomplete=False, start=0, count=0,
query = query.replace('°', ' ')
query = query.replace('\'', ' ')
query = query.replace('\"', ' ')
latlon = re.compile(r"([-0-9. ]+)([N|S]) *([-0-9. ]+)([E|W])").match(query)
latlon = re.compile(r"([-0-9. ]+)([N|S]) *([-0-9. ]+)([E|W])").match(
query.upper())
if latlon:
def degree_to_float(val, face):
multipler = 1 if face in ['N', 'E'] else -1
return multipler * sum(float(x) / 60 ** n for n, x in enumerate(re.split(r" +", val)))
return multipler * sum(
float(x) / 60 ** n for n, x in enumerate(
re.split(r" +", val)))
lat = degree_to_float(latlon.group(1).strip(), latlon.group(2))
lon = degree_to_float(latlon.group(3).strip(), latlon.group(4))
if lat and lon:
Expand Down Expand Up @@ -1113,6 +1116,7 @@ def reverse_search(lon, lat, debug):
result['matches'] = [smallest_row]
result['start_index'] = 1
result['status'] = True
result['total_found'] = 1
return result, smallest_distance


Expand Down

0 comments on commit 7c81143

Please sign in to comment.