Anomalie #225 » test.py
1 |
#!/usr/bin/python3.5
|
---|---|
2 |
|
3 |
import urllib.request |
4 |
|
5 |
url="https://wxs.ign.fr/iqqdkoa235g0mf1gr3si0162/isochrone/isochrone.xml?location=935800,6850112&srs=epsg:2154&method=Time&graph=Voiture&graphName=Voiture&exclusions=&time=1200&holes=false&smoothing=false" |
6 |
request = urllib.request.Request(url) |
7 |
valid="False" |
8 |
try: |
9 |
response = urllib.request.urlopen(request) |
10 |
htmlBytes = response.read() |
11 |
htmlStr = htmlBytes.decode("utf8") |
12 |
print ("something cool") |
13 |
valid="True" |
14 |
except: |
15 |
print("something wrong") |
16 |
if valid =="True" : |
17 |
tab_iso=htmlStr |
18 |
index1=tab_iso.find("wktGeometry") |
19 |
index2=tab_iso.rfind("wktGeometry") |
20 |
index3=len(tab_iso) |
21 |
iso=tab_iso[index1+12:index2-2] |
22 |
mLayer = QgsVectorLayer('Polygon?crs=epsg:4326', "test", "memory") |
23 |
mProvider = mLayer.dataProvider() |
24 |
geomWkt= iso |
25 |
geomPoly = QgsGeometry.fromWkt(geomWkt) |
26 |
feat = QgsFeature() |
27 |
feat.setGeometry(geomPoly) |
28 |
mProvider.addFeatures( [feat] ) |
29 |
mLayer.commitChanges() |
30 |
mLayer.updateExtents() |
31 |
if mLayer.isValid(): |
32 |
QgsProject.instance().addMapLayer(mLayer) |