Fixed some bugs with regex
This commit is contained in:
parent
9f1c871cb4
commit
ea45572406
4
fetch.py
4
fetch.py
@ -29,7 +29,7 @@ def runfetch(url='https://www.legifrance.gouv.fr/eli/arrete/2018/10/12/PRMD18245
|
||||
|
||||
|
||||
def dms2dd(dms):
|
||||
coordslst = re.search("(\d{1,3})° (\d{2})(?:'|′) (\d{2},?\d{0,3})(?:\"|”|\'\')", dms).groups()
|
||||
coordslst = re.search("(\d{1,3})° (\d{2})(?:'|′) (\d{2}(?:,|.)?\d{0,3})(?:\"|”|\'\')", dms).groups()
|
||||
dd = float(coordslst[0].replace(",", ".")) + float(coordslst[1].replace(",", "."))/60 + float(coordslst[2].replace(",", "."))/3600
|
||||
return dd
|
||||
|
||||
@ -65,7 +65,7 @@ def fetch(url='https://www.legifrance.gouv.fr/eli/arrete/2018/10/12/PRMD1824595A
|
||||
# Polygons
|
||||
elif "polygone" in area["zone"]:
|
||||
lst = []
|
||||
lst.append(re.findall(".{0,35} ?:? ?.? ?: ?(\d{1,3}° \d{2}(?:'|′) \d{2},?\d{0,3}(?:\"|”|\'\') ?.) ?\/ ?(\d{1,3}° \d{2}(?:'|′|\'\') \d{2},?\d{0,3}(?:\"|”|\'\') ?.)", area["zone"]))
|
||||
lst.append(re.findall(".{0,35} ?:? ?.? ?: ?(\d{1,3}° \d{2}(?:'|′) \d{2}(?:,|.)?\d{0,3}(?:\"|”|\'\') ?.) ?\/ ?(\d{1,3}° \d{2}(?:'|′|\'\') \d{2}(?:,|.)?\d{0,3}(?:\"|”|\'\') ?.)", area["zone"]))
|
||||
area["zone"] = []
|
||||
for index, polygon in enumerate(lst):
|
||||
area["zone"].append([])
|
||||
|
Loading…
Reference in New Issue
Block a user