Filter duplicates in get_bounds
Signed-off-by: merspieler <merspieler@airmail.cc>
This commit is contained in:
parent
c6ded8dd65
commit
b93b520cc4
1 changed files with 12 additions and 2 deletions
14
build
14
build
|
@ -72,13 +72,23 @@ if project == "":
|
||||||
def get_bounds(file_path):
|
def get_bounds(file_path):
|
||||||
try:
|
try:
|
||||||
with open(file_path) as f:
|
with open(file_path) as f:
|
||||||
ret = []
|
hits = []
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
for line in lines:
|
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)
|
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 != []:
|
if match != []:
|
||||||
bounds = { "west": float(match[0][0]), "south": float(match[0][1]), "east": float(match[0][2]), "north": float(match[0][3]) }
|
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
|
return ret
|
||||||
except:
|
except:
|
||||||
print("WARNING: Getting bounds failed")
|
print("WARNING: Getting bounds failed")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue