1
0
Fork 0

Filter duplicates in get_bounds

Signed-off-by: merspieler <merspieler@airmail.cc>
This commit is contained in:
merspieler 2019-03-16 02:19:02 +00:00
parent c6ded8dd65
commit b93b520cc4

14
build
View file

@ -72,13 +72,23 @@ if project == "":
def get_bounds(file_path):
try:
with open(file_path) as f:
ret = []
hits = []
lines = f.readlines()
for line in lines:
match = re.findall("(-?[0-9]{1,3}\.?[0-9]{0,4})_(-?[0-9]{1,2}\.?[0-9]{0,4})_(-?[0-9]{1,3}\.?[0-9]{0,4})_(-?[0-9]{1,2}\.?[0-9]{0,4})", line)
if match != []:
bounds = { "west": float(match[0][0]), "south": float(match[0][1]), "east": float(match[0][2]), "north": float(match[0][3]) }
ret.append(bounds)
hits.append(bounds)
# Filter duplicates
ret = []
ret.append(hits[0])
for hit in hits:
duplicate = False
for coords in ret:
if coords == hit:
duplicate = True
if !duplicate:
ret.append(coords)
return ret
except:
print("WARNING: Getting bounds failed")