Corrected bug with polygon regex
This commit is contained in:
parent
e709259a8f
commit
36a541eef0
8
fetch.py
8
fetch.py
@ -29,7 +29,7 @@ def runfetch(url='https://www.legifrance.gouv.fr/eli/arrete/2018/10/12/PRMD18245
|
|||||||
|
|
||||||
|
|
||||||
def dms2dd(dms):
|
def dms2dd(dms):
|
||||||
coordslst = re.search("(\d{1,3})° (\d{2})' (\d{2},?\d{0,2})(?:\"|”|\'\')", dms).groups()
|
coordslst = re.search("(\d{1,3})° (\d{2})(?:'|′) (\d{2},?\d{0,2})(?:\"|”|\'\')", dms).groups()
|
||||||
dd = float(coordslst[0].replace(",", ".")) + float(coordslst[1].replace(",", "."))/60 + float(coordslst[2].replace(",", "."))/3600
|
dd = float(coordslst[0].replace(",", ".")) + float(coordslst[1].replace(",", "."))/60 + float(coordslst[2].replace(",", "."))/3600
|
||||||
return dd
|
return dd
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ def fetch(url='https://www.legifrance.gouv.fr/eli/arrete/2018/10/12/PRMD1824595A
|
|||||||
tmp = re.compile(".*zone.*").split(area["zone"]) # List of polygons
|
tmp = re.compile(".*zone.*").split(area["zone"]) # List of polygons
|
||||||
del tmp[0]
|
del tmp[0]
|
||||||
for polygon in tmp:
|
for polygon in tmp:
|
||||||
lst.append(re.findall(".{0,35} ?:? ?.? ?: ?(\d{1,3}° \d{2}' \d{2},?\d{0,2}(?:\"|”) .) ?\/ ?(\d{1,3}° \d{2}' \d{2},?\d{0,2}(?:\"|”) .)", polygon))
|
lst.append(re.findall(".{0,35} ?:? ?.? ?: ?(\d{1,3}° \d{2}(?:'|′) \d{2},?\d{0,2}(?:\"|”) .) ?\/ ?(\d{1,3}° \d{2}(?:'|′) \d{2},?\d{0,2}(?:\"|”) .)", polygon))
|
||||||
area["zone"] = []
|
area["zone"] = []
|
||||||
for index, polygon in enumerate(lst):
|
for index, polygon in enumerate(lst):
|
||||||
area["zone"].append([])
|
area["zone"].append([])
|
||||||
@ -64,7 +64,7 @@ def fetch(url='https://www.legifrance.gouv.fr/eli/arrete/2018/10/12/PRMD1824595A
|
|||||||
# Polygons
|
# Polygons
|
||||||
elif "polygone" in area["zone"]:
|
elif "polygone" in area["zone"]:
|
||||||
lst = []
|
lst = []
|
||||||
lst.append(re.findall(".{0,35} ?:? ?.? ?: ?(\d{1,3}° \d{2}' \d{2},?\d{0,2}(?:\"|”|\'\') ?.) ?\/ ?(\d{1,3}° \d{2}' \d{2},?\d{0,2}(?:\"|”|\'\') ?.)", area["zone"]))
|
lst.append(re.findall(".{0,35} ?:? ?.? ?: ?(\d{1,3}° \d{2}(?:'|′) \d{2},?\d{0,2}(?:\"|”|\'\') ?.) ?\/ ?(\d{1,3}° \d{2}(?:'|′) \d{2},?\d{0,2}(?:\"|”|\'\') ?.)", area["zone"]))
|
||||||
area["zone"] = []
|
area["zone"] = []
|
||||||
for index, polygon in enumerate(lst):
|
for index, polygon in enumerate(lst):
|
||||||
area["zone"].append([])
|
area["zone"].append([])
|
||||||
@ -93,7 +93,7 @@ if __name__ == '__main__':
|
|||||||
# Print the dict (keep this code in the end of the file)
|
# Print the dict (keep this code in the end of the file)
|
||||||
print("===== Dict =====")
|
print("===== Dict =====")
|
||||||
for index, area in enumerate(diclist):
|
for index, area in enumerate(diclist):
|
||||||
if index == 277:
|
if index == 30:
|
||||||
print(f"\n-------------{index}----------------\n")
|
print(f"\n-------------{index}----------------\n")
|
||||||
for element in area:
|
for element in area:
|
||||||
print(f" {element}: {diclist[index][element]}")
|
print(f" {element}: {diclist[index][element]}")
|
||||||
|
Loading…
Reference in New Issue
Block a user