Skip to content

Commit

Permalink
1.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
warrieka committed Sep 20, 2017
1 parent 1474597 commit 1142fc1
Showing 7 changed files with 200 additions and 208 deletions.
237 changes: 105 additions & 132 deletions geopunt.py

Large diffs are not rendered by default.

15 changes: 1 addition & 14 deletions geopunt4QgisAdresdialog.py
Original file line number Diff line number Diff line change
@@ -133,11 +133,7 @@ def onZoekActivated(self):
self.ui.resultLijst.addItems(suggesties)
if len(suggesties) == 1:
self.ui.resultLijst.setCurrentRow(0)
elif type( suggesties ) is str:
self.bar.pushMessage(
QtCore.QCoreApplication.translate("geopunt4QgisAdresDialog","Waarschuwing"),
suggesties, level=QgsMessageBar.WARNING)


def onItemActivated( self, item):
txt = item.text()
self._zoomLoc(txt)
@@ -209,15 +205,6 @@ def _addToMap(self, txt):
self.gh.save_adres_point( pt, adres, typeAddress=LocationType,
layername=self.layerName, saveToFile=self.saveToFile, sender=self,
startFolder= os.path.join(self.startDir, self.layerName))

elif type( locations ) is str:
self.bar.pushMessage(
QtCore.QCoreApplication.translate("geopunt4QgisAdresDialog","Waarschuwing"),
locations, level=QgsMessageBar.WARNING)
else:
self.bar.pushMessage("Error",
QtCore.QCoreApplication.translate("geopunt4QgisAdresDialog","onbekende fout"),
level=QgsMessageBar.CRITICAL)

def layernameValid(self):
if not hasattr(self, 'layerName'):
19 changes: 6 additions & 13 deletions geopunt4QgisParcel.py
Original file line number Diff line number Diff line change
@@ -133,19 +133,12 @@ def saveParcel(self):

if '' in (niscode, departmentcode, section, parcelNr): return

try:
parcelInfo = self.parcel.getParcel( niscode, departmentcode, section, parcelNr, 31370, 'full')
shape = json.loads( parcelInfo['geometry']['shape'])
pts = [n.asPolygon() for n in self.PolygonsFromJson( shape )]
mPolygon = QgsGeometry.fromMultiPolygon( pts )
self.ph.save_parcel_polygon(mPolygon, parcelInfo, self.layerName, self.saveToFile,
self, os.path.join(self.startDir, self.layerName))
except geopunt.geopuntError as e:
self.bar.pushMessage("Error", str( e.message) , level=QgsMessageBar.WARNING, duration=5)
return
except Exception as e:
self.bar.pushMessage("Error", str( e.message) , level=QgsMessageBar.CRITICAL)
return
parcelInfo = self.parcel.getParcel( niscode, departmentcode, section, parcelNr, 31370, 'full')
shape = json.loads( parcelInfo['geometry']['shape'])
pts = [n.asPolygon() for n in self.PolygonsFromJson( shape )]
mPolygon = QgsGeometry.fromMultiPolygon( pts )
self.ph.save_parcel_polygon(mPolygon, parcelInfo, self.layerName, self.saveToFile,
self, os.path.join(self.startDir, self.layerName))

self.accept()

2 changes: 1 addition & 1 deletion metadata.txt
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ qgisMinimumVersion=2.4
description= NL: Plugin om geopunt diensten in QGIS te gebruiken: - Zoeken op adres [gewoon, in batch en prikken op kaart] op basis van CRAB (Vlaanderen) en URBIS (Brussel) - Zoeken naar Intressepunten in geopunt - zoeken naar wegenwerken en manifestaties in GIPOD - Hoogte Profielen tekenen - Zoeken naar percelen - Zoeken naar lagen in de geopunt catlogus EN: Plug-in to use geopunt services in QGIS: - Geocoding [regular, batch and reverse] based on CRAB (Flanders) and and URBIS (Brussels) - Search for POI's in geopunt - Search for trafic obstructions in GIPOD - Draw elevation profiles - Search for Parcels - Search for layers in the geopunt catalog
about="Geopunt voor QGIS" is een plugin voor de QGIS open source desktop GIS, die de webservices van het Vlaamse geoportaal Geopunt ontsluit naar desktop GIS-gebruikers. Het Vlaamse Geoportaal Geopunt biedt een aantal geografische diensten (web-services) aan die mogen gebruikt worden door derden zoals andere overheden en bedrijven.

version=1.6.9
version=1.7.0
author=Kay Warrie
[email protected]

84 changes: 43 additions & 41 deletions metadataParser.py
Original file line number Diff line number Diff line change
@@ -79,11 +79,12 @@ def __init__(self, timeout=15, proxyUrl='' ):
self.inspireannex = ["i","ii","iii"]

if (isinstance(proxyUrl, unicode) or isinstance(proxyUrl, str)) and proxyUrl != "":
auth = urllib2.HTTPBasicAuthHandler()
proxy = urllib2.ProxyHandler({'http': proxyUrl })
self.opener = urllib2.build_opener(proxy, auth, urllib2.HTTPHandler)
else:
self.opener = None
proxy = urllib2.ProxyHandler()

auth = urllib2.HTTPBasicAuthHandler()
self.opener = urllib2.build_opener(proxy, auth, urllib2.HTTPHandler)

def _createFindUrl(self, q='', start=1, to=20, themekey='', orgName='', dataType='', siteId='', inspiretheme='', inspireannex='', inspireServiceType=''):
geopuntUrl = self.geoNetworkUrl + "/q?fast=index&sortBy=changeDate&"
@@ -123,14 +124,12 @@ def _createFindUrl(self, q='', start=1, to=20, themekey='', orgName='', dataType
def list_GDI_theme(self, q=''):
url = self.geoNetworkUrl + "/xml.search.keywords?pNewSearch=true&pTypeSearch=1&pThesauri=external.theme.GDI-Vlaanderen-trefwoorden&pKeyword=*" + unicode(q).encode('utf-8') +"*"
try:
if self.opener: response = self.opener.open(url, timeout=self.timeout)
else: response = urllib2.urlopen(url, timeout=self.timeout)
response = self.opener.open(url, timeout=self.timeout)
except (urllib2.HTTPError, urllib2.URLError) as e:
#raise metaError( str( e.reason ))
return []
except:
print metaError( str( sys.exc_info()[1] ))
return []
raise metaError( str( e.reason ))
else:
result = ET.parse(response)
r= result.getroot()
@@ -141,14 +140,12 @@ def list_GDI_theme(self, q=''):
def list_inspire_theme(self, q=''):
url = self.geoNetworkUrl + "/xml.search.keywords?pNewSearch=true&pTypeSearch=1&pThesauri=external.theme.inspire-theme&pKeyword=*" + unicode(q).encode('utf-8') +"*"
try:
if self.opener: response = self.opener.open(url, timeout=self.timeout)
else: response = urllib2.urlopen(url, timeout=self.timeout)
response = self.opener.open(url, timeout=self.timeout)
except (urllib2.HTTPError, urllib2.URLError) as e:
#raise metaError( str( e.reason ))
return []
except:
print metaError( str( sys.exc_info()[1] ))
return []
raise metaError( str( e.reason ))
else:
result = ET.parse(response)
r= result.getroot()
@@ -160,12 +157,10 @@ def list_suggestionKeyword(self, q=''):
url = self.geoNetworkUrl + "/main.search.suggest?field=any"
if q:
url= url + "&q=" + unicode(q).encode('utf-8')

try:
if self.opener: response = self.opener.open(url, timeout=self.timeout)
else: response = urllib2.urlopen(url, timeout=self.timeout)
response = self.opener.open(url, timeout=self.timeout)
except (urllib2.HTTPError, urllib2.URLError) as e:
print metaError( str( e.reason ))
#raise metaError( str( e.reason ))
return []
except:
raise metaError( str( sys.exc_info()[1] ))
@@ -178,10 +173,9 @@ def list_organisations(self, q=''):
if q:
url= url + "&q=" + unicode(q).encode('utf-8')
try:
if self.opener: response = self.opener.open(url, timeout=self.timeout)
else: response = urllib2.urlopen(url, timeout=self.timeout)
response = self.opener.open(url, timeout=self.timeout)
except (urllib2.HTTPError, urllib2.URLError) as e:
print metaError( str( e.reason ))
#raise metaError( str( e.reason ))
return []
except:
raise metaError( str( sys.exc_info()[1] ))
@@ -197,10 +191,9 @@ def list_organisations(self, q=''):
def list_bronnen(self):
url = self.geoNetworkUrl + "/xml.info?type=sources"
try:
if self.opener: response = self.opener.open(url, timeout=self.timeout)
else: response = urllib2.urlopen(url, timeout=self.timeout)
response = self.opener.open(url, timeout=self.timeout)
except (urllib2.HTTPError, urllib2.URLError) as e:
raise metaError( str( e.reason ))
return []
except:
raise metaError( str( sys.exc_info()[1] ))
else:
@@ -214,10 +207,9 @@ def list_bronnen(self):
def search(self, q='', start=1, to=20, themekey='', orgName='', dataType='', siteId='', inspiretheme='', inspireannex='', inspireServiceType='' ):
url = self._createFindUrl( q, start, to, themekey, orgName, dataType, siteId, inspiretheme, inspireannex, inspireServiceType)
try:
if self.opener: response = self.opener.open(url, timeout=self.timeout)
else: response = urllib2.urlopen(url, timeout=self.timeout)
response = self.opener.open(url, timeout=self.timeout)
except (urllib2.HTTPError, urllib2.URLError) as e:
raise metaError( str( e.reason ) +' on '+ url )
return []
except:
raise metaError( str( sys.exc_info()[1] ))
else:
@@ -252,16 +244,18 @@ def getWmsLayerNames( url='', proxyUrl=''):
else:
capability = url

auth = urllib2.HTTPBasicAuthHandler()
if isinstance(proxyUrl, (unicode, str)) and proxyUrl != "":
if url.startswith("https"):
proxy = urllib2.ProxyHandler({'https': proxyUrl })
else:
proxy = urllib2.ProxyHandler({'http': proxyUrl })
auth = urllib2.HTTPBasicAuthHandler()
opener = urllib2.build_opener(proxy, auth, urllib2.HTTPHandler)
responseWMS = opener.open(capability)
else:
responseWMS = urllib2.urlopen(capability)
proxy = urllib2.ProxyHandler()
opener = urllib2.build_opener(proxy, auth, urllib2.HTTPHandler)
responseWMS = opener.open(capability)

result = ET.parse(responseWMS)
layers = result.findall( ".//{http://www.opengis.net/wms}Layer" ) + result.findall( ".//Layer" )
@@ -285,16 +279,18 @@ def getWFSLayerNames( url, proxyUrl=''):
else:
capability = url

auth = urllib2.HTTPBasicAuthHandler()
if isinstance(proxyUrl, (unicode, str)) and proxyUrl != "":
if url.startswith("https"):
proxy = urllib2.ProxyHandler({'https': proxyUrl })
else:
proxy = urllib2.ProxyHandler({'http': proxyUrl })
auth = urllib2.HTTPBasicAuthHandler()
opener = urllib2.build_opener(proxy, auth, urllib2.HTTPHandler)
responseWFS = opener.open(capability)
else:
responseWFS = urllib2.urlopen(capability)
proxy = urllib2.ProxyHandler()
opener = urllib2.build_opener(proxy, auth, urllib2.HTTPHandler)
responseWFS = opener.open(capability)

result = ET.parse(responseWFS)
layers = result.findall( ".//{http://www.opengis.net/wfs}FeatureType" )
@@ -315,16 +311,19 @@ def getWMTSlayersNames( url, proxyUrl='' ):
capability = url.split("?")[0] + "?service=WMTS&request=Getcapabilities"
else:
capability = url

auth = urllib2.HTTPBasicAuthHandler()
if isinstance(proxyUrl, (unicode, str)) and proxyUrl != "":
if url.startswith("https"):
if url.startswith("https"):
proxy = urllib2.ProxyHandler({'https': proxyUrl })
else:
else:
proxy = urllib2.ProxyHandler({'http': proxyUrl })
auth = urllib2.HTTPBasicAuthHandler()
opener = urllib2.build_opener(proxy, auth, urllib2.HTTPHandler)
responseWMTS = opener.open(capability)
opener = urllib2.build_opener(proxy, auth, urllib2.HTTPHandler)
responseWMTS = opener.open(capability)
else:
responseWMTS = urllib2.urlopen(capability)
proxy = urllib2.ProxyHandler()
opener = urllib2.build_opener(proxy, auth, urllib2.HTTPHandler)
responseWMTS = opener.open(capability)

result = ET.parse(responseWMTS).getroot()
content = result.find( "{http://www.opengis.net/wmts/1.0}Contents" )
@@ -357,16 +356,19 @@ def getWCSlayerNames( url, proxyUrl='' ):
capability = url.split("?")[0] + "?request=GetCapabilities&version=1.1.0&service=wcs"
else:
capability = url

auth = urllib2.HTTPBasicAuthHandler()
if isinstance(proxyUrl, (unicode, str)) and proxyUrl != "":
if url.startswith("https"):
if url.startswith("https"):
proxy = urllib2.ProxyHandler({'https': proxyUrl })
else:
else:
proxy = urllib2.ProxyHandler({'http': proxyUrl })
auth = urllib2.HTTPBasicAuthHandler()
opener = urllib2.build_opener(proxy, auth, urllib2.HTTPHandler)
responseWCS = opener.open(capability)
opener = urllib2.build_opener(proxy, auth, urllib2.HTTPHandler)
responseWCS = opener.open(capability)
else:
responseWCS = urllib2.urlopen(capability)
proxy = urllib2.ProxyHandler()
opener = urllib2.build_opener(proxy, auth, urllib2.HTTPHandler)
responseWCS = opener.open(capability)

responseTxt = responseWCS.read()
if 'xmlns:wcs="http://www.opengis.net/wcs/1.1.1"' in responseTxt:
@@ -391,7 +393,7 @@ def getWCSlayerNames( url, proxyUrl='' ):
opener = urllib2.build_opener(proxy, auth, urllib2.HTTPHandler)
responseDC = opener.open(DescribeCoverage)
else:
responseDC = urllib2.urlopen(DescribeCoverage)
responseDC = urllib2.urlopen(DescribeCoverage)

resultDC = ET.parse(responseDC).getroot()
CoverageDescription = resultDC.find( "{%s}CoverageDescription" % wcsNS)
17 changes: 11 additions & 6 deletions parcelHelper.py
Original file line number Diff line number Diff line change
@@ -37,9 +37,11 @@ def __init__(self, iface, parent= None, startFolder="" ):


def save_parcel_polygon(self, polygon, parcelInfo, layername="perceel", saveToFile=False, sender=None, startFolder=None ):
attributes =[ QgsField("macht", QVariant.Int), QgsField("bisnummer", QVariant.Int) , QgsField("exponent", QVariant.String),
QgsField("adres", QVariant.String), QgsField("capakey", QVariant.String), QgsField("grondnr", QVariant.Int),
QgsField("type", QVariant.String), QgsField("perceelnr", QVariant.String) ]
attributes =[ QgsField("niscode", QVariant.String), QgsField("afdeling", QVariant.String), QgsField("afdcode", QVariant.String),
QgsField("sectie", QVariant.String), QgsField("bisnummer", QVariant.Int) ,
QgsField("exponent", QVariant.String), QgsField("macht", QVariant.Int),
QgsField("grondnr", QVariant.Int), QgsField("capakey", QVariant.String),
QgsField("perceelnr", QVariant.String), QgsField("adres", QVariant.String) ]

if not QgsMapLayerRegistry.instance().mapLayer(self.parcellayerid):
self.parcellayer = QgsVectorLayer("MultiPolygon", layername, "memory")
@@ -55,14 +57,17 @@ def save_parcel_polygon(self, polygon, parcelInfo, layername="perceel", saveToFi
fet.setGeometry(polygon)

#populate fields
fet['macht'] = parcelInfo['macht']
fet['adres'] = ", ".join( parcelInfo['adres'] )
fet['sectie'] = parcelInfo['sectionCode']
fet['bisnummer'] = parcelInfo['bisnummer']
fet['exponent'] = parcelInfo['exponent']
fet['adres'] = ", ".join( parcelInfo['adres'] )
fet['capakey'] = parcelInfo['capakey']
fet['grondnr'] = parcelInfo['grondnummer']
fet['type'] = parcelInfo['type']
fet['perceelnr'] = parcelInfo['perceelnummer']
fet['NISCode'] = parcelInfo['municipalityCode']
fet['afdeling'] = parcelInfo['departmentName']
fet['perceelnr'] = parcelInfo['perceelnummer']
fet['afdcode'] = parcelInfo['departmentCode']

self.parcelProvider.addFeatures([ fet ])
""
34 changes: 33 additions & 1 deletion ui_geopunt4QgisBatchGeoCode.ui
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
<x>0</x>
<y>0</y>
<width>621</width>
<height>520</height>
<height>599</height>
</rect>
</property>
<property name="contextMenuPolicy">
@@ -647,5 +647,37 @@
</hint>
</hints>
</connection>
<connection>
<sender>multipleColChk</sender>
<signal>toggled(bool)</signal>
<receiver>huisnrLbl</receiver>
<slot>setVisible(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>165</x>
<y>157</y>
</hint>
<hint type="destinationlabel">
<x>170</x>
<y>248</y>
</hint>
</hints>
</connection>
<connection>
<sender>multipleColChk</sender>
<signal>toggled(bool)</signal>
<receiver>huisnrSelect</receiver>
<slot>setVisible(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>165</x>
<y>157</y>
</hint>
<hint type="destinationlabel">
<x>450</x>
<y>248</y>
</hint>
</hints>
</connection>
</connections>
</ui>

0 comments on commit 1142fc1

Please sign in to comment.