├── .github └── workflows │ ├── pythonapp.yml │ └── requirements.txt ├── .gitignore ├── GetMapCoordinates.py ├── HqgisAlgorithm_POIs.py ├── HqgisAlgorithm_geocode.py ├── HqgisAlgorithm_isochrone.py ├── HqgisProvider.py ├── LICENSE ├── Makefile ├── __init__.py ├── categories.md ├── data ├── SemiMassData.txt ├── addresses.txt └── massData.txt ├── decodeGeom.py ├── help ├── Makefile ├── make.bat └── source │ ├── conf.py │ └── index.rst ├── hqgis.py ├── hqgis_dialog.py ├── hqgis_dialog_base.ui ├── i18n └── af.ts ├── icon.png ├── mapCat.py ├── metadata.txt ├── pb_tool.cfg ├── plugin_upload.py ├── pylintrc ├── readme.md ├── resources.py ├── resources.qrc ├── scripts ├── compile-strings.sh ├── run-env-linux.sh └── update-strings.sh ├── target.png └── test ├── __init__.py ├── qgis_interface.py ├── tenbytenraster.asc ├── tenbytenraster.asc.aux.xml ├── tenbytenraster.keywords ├── tenbytenraster.lic ├── tenbytenraster.prj ├── tenbytenraster.qml ├── test_hereqgis_dialog.py ├── test_init.py ├── test_qgis_environment.py ├── test_resources.py ├── test_translations.py └── utilities.py /.github/workflows/pythonapp.yml: -------------------------------------------------------------------------------- 1 | name: Format python code 2 | on: push 3 | jobs: 4 | autopep8: 5 | runs-on: ubuntu-latest 6 | steps: 7 | - uses: actions/checkout@v2 8 | - name: autopep8 9 | uses: peter-evans/autopep8@v1 10 | with: 11 | args: --recursive --in-place --aggressive --aggressive . 12 | - name: Create Pull Request 13 | uses: peter-evans/create-pull-request@v2 14 | with: 15 | token: ${{ secrets.GITHUB_TOKEN }} 16 | commit-message: autopep8 action fixes 17 | committer: Peter Evans 18 | title: Fixes by autopep8 action 19 | body: This is an auto-generated PR with fixes by autopep8. 20 | labels: autopep8, automated pr 21 | reviewers: peter-evans 22 | branch: autopep8-patches 23 | -------------------------------------------------------------------------------- /.github/workflows/requirements.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.json 2 | *.pyc 3 | __pycache__ 4 | -------------------------------------------------------------------------------- /GetMapCoordinates.py: -------------------------------------------------------------------------------- 1 | from qgis.PyQt.QtCore import Qt, QUrl 2 | from qgis.PyQt.QtGui import * 3 | from qgis.PyQt.QtWidgets import * 4 | from qgis.core import Qgis, QgsCoordinateReferenceSystem, QgsCoordinateTransform, QgsProject 5 | from qgis.gui import QgsMapToolEmitPoint, QgsMapToolPan 6 | import requests 7 | import json 8 | 9 | 10 | class GetMapCoordinates(QgsMapToolEmitPoint): 11 | '''Class to interact with the map canvas to capture the coordinate 12 | when the mouse button is pressed.''' 13 | 14 | def __init__(self, iface): 15 | QgsMapToolEmitPoint.__init__(self, iface.mapCanvas()) 16 | self.iface = iface 17 | self.canvas = iface.mapCanvas() 18 | self.canvasClicked.connect(self.clicked) 19 | # self.pt4326=None 20 | 21 | def activate(self): 22 | '''When activated set the cursor to a crosshair.''' 23 | 24 | def getCredentials(self): 25 | self.appId = self.dlg.AppId.text() 26 | #self.appCode = self.dlg.AppCode.text() 27 | 28 | def clicked(self, pt, b): 29 | # if self.dlg.captureButton.isChecked(): 30 | '''Capture the coordinate when the mouse button has been released, 31 | format it, and copy it to dashboard''' 32 | # transform the coordinate to 4326 but display it in the original crs 33 | canvasCRS = self.canvas.mapSettings().destinationCrs() 34 | epsg4326 = QgsCoordinateReferenceSystem('EPSG:4326') 35 | transform = QgsCoordinateTransform( 36 | canvasCRS, epsg4326, QgsProject.instance()) 37 | pt4326 = transform.transform(pt.x(), pt.y()) 38 | lat = pt4326.y() 39 | lon = pt4326.x() 40 | self.getCredentials() 41 | # change dockwidget corrdinate with the original crs 42 | if self.dlg.captureButton.isChecked(): 43 | url = "https://revgeocode.search.hereapi.com/v1/revgeocode?at=" + \ 44 | str(lat) + "%2C" + str(lon) + "%2C10&limit=1&lang=en-US&apiKey=" + self.appId 45 | print(url) 46 | r = requests.get(url) 47 | try: 48 | self.dlg.fromAddress.setText( 49 | json.loads( 50 | r.text)["items"][0]["title"]) 51 | except BaseException: 52 | self.dlg.fromAddress.setText("no address found") 53 | print("something went wrong") 54 | self.dlg.FromLabel.setText( 55 | str("%.5f" % lat) + ',' + str("%.5f" % lon)) 56 | self.dlg.captureButton.setChecked(False) 57 | if self.dlg.captureButton_2.isChecked(): 58 | url = "https://revgeocode.search.hereapi.com/v1/revgeocode?at=" + \ 59 | str(lat) + "%2C" + str(lon) + "%2C10&limit=1&lang=en-US&apiKey=" + self.appId 60 | r = requests.get(url) 61 | try: 62 | self.dlg.toAddress.setText( 63 | json.loads( 64 | r.text)["items"][0]["title"]) 65 | except BaseException: 66 | self.dlg.toAddress.setText("no address found") 67 | print("something went wrong") 68 | self.dlg.ToLabel.setText( 69 | str("%.5f" % lat) + ',' + str("%.5f" % lon)) 70 | self.setWidget(self.dlg) 71 | self.iface.mapCanvas().setCursor(Qt.ArrowCursor) 72 | self.dlg.captureButton_2.setChecked(False) 73 | if self.dlg.captureButton_4.isChecked(): 74 | url = "https://revgeocode.search.hereapi.com/v1/revgeocode?at=" + \ 75 | str(lat) + "%2C" + str(lon) + "%2C10&limit=1&lang=en-US&apiKey=" + self.appId 76 | 77 | r = requests.get(url) 78 | try: 79 | self.dlg.placesAddress.setText(json.loads( 80 | r.text)["items"][0]["title"]) 81 | except BaseException: 82 | self.dlg.placesAddress.setText("no address found") 83 | print("something went wrong") 84 | self.dlg.placeLabel.setText( 85 | str("%.5f" % lat) + ',' + str("%.5f" % lon)) 86 | self.dlg.findPOISButton.setEnabled(True) 87 | self.setWidget(self.dlg) 88 | self.iface.mapCanvas().setCursor(Qt.ArrowCursor) 89 | self.dlg.captureButton_4.setChecked(False) 90 | 91 | if self.dlg.captureButton_3.isChecked(): 92 | url = "https://revgeocode.search.hereapi.com/v1/revgeocode?at=" + \ 93 | str(lat) + "%2C" + str(lon) + "%2C10&limit=1&lang=en-US&apiKey=" + self.appId 94 | 95 | r = requests.get(url) 96 | # print(r.text) 97 | try: 98 | self.dlg.IsoAddress.setText( 99 | json.loads( 100 | r.text)["items"][0]["title"]) 101 | except BaseException: 102 | self.dlg.IsoAddress.setText("no address found") 103 | print("something went wrong") 104 | self.dlg.IsoLabel.setText( 105 | str("%.5f" % lat) + ',' + str("%.5f" % lon)) 106 | self.dlg.calcIsoButton.setEnabled(True) 107 | self.setWidget(self.dlg) 108 | self.iface.mapCanvas().setCursor(Qt.ArrowCursor) 109 | self.dlg.captureButton_3.setChecked(False) 110 | 111 | def setWidget(self, dockwidget): 112 | print(dockwidget) 113 | self.dlg = dockwidget 114 | -------------------------------------------------------------------------------- /HqgisAlgorithm_POIs.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | *************************************************************************** 5 | * * 6 | * This program is free software; you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | *************************************************************************** 12 | """ 13 | 14 | from PyQt5.QtCore import (QCoreApplication, QUrl, QVariant) 15 | from PyQt5.QtNetwork import (QNetworkReply, 16 | QNetworkAccessManager, 17 | QNetworkRequest) 18 | from qgis.core import (QgsProcessing, 19 | QgsProject, 20 | QgsFeatureSink, 21 | QgsProcessingParameterField, 22 | QgsProcessingException, 23 | QgsProcessingAlgorithm, 24 | QgsProcessingParameterFeatureSource, 25 | QgsProcessingParameterEnum, 26 | QgsProcessingParameterNumber, 27 | QgsProcessingParameterField, 28 | QgsProcessingParameterFeatureSink, 29 | QgsNetworkAccessManager, 30 | QgsField, 31 | QgsFields, 32 | QgsWkbTypes, 33 | QgsCoordinateReferenceSystem, 34 | QgsCoordinateTransform, 35 | QgsFeature, 36 | QgsGeometry, 37 | QgsUnitTypes, 38 | QgsPointXY, 39 | QgsSettings) 40 | from functools import partial 41 | from .mapCat import mapCategories 42 | import processing 43 | import Hqgis 44 | import os 45 | import requests 46 | import json 47 | import time 48 | import urllib 49 | 50 | 51 | class getPois(QgsProcessingAlgorithm): 52 | def __init__(self): 53 | super().__init__() 54 | 55 | """ 56 | This is an example algorithm that takes a vector layer and 57 | creates a new identical one. 58 | 59 | It is meant to be used as an example of how to create your own 60 | algorithms and explain methods and variables used to do it. An 61 | algorithm like this will be available in all elements, and there 62 | is not need for additional work. 63 | 64 | All Processing algorithms should extend the QgsProcessingAlgorithm 65 | class. 66 | """ 67 | 68 | # Constants used to refer to parameters and outputs. They will be 69 | # used when calling the algorithm from another algorithm, or when 70 | # calling from the QGIS console. 71 | 72 | INPUT = 'INPUT' 73 | OUTPUT = 'OUTPUT' 74 | KEYS = 'KEYS' 75 | MODES = 'MODES' 76 | RADIUS = 'RADIUS' 77 | 78 | def tr(self, string): 79 | """ 80 | Returns a translatable string with the self.tr() function. 81 | """ 82 | return QCoreApplication.translate('Processing', string) 83 | 84 | def createInstance(self): 85 | return type(self)() 86 | 87 | def name(self): 88 | """ 89 | Returns the algorithm name, used for identifying the algorithm. This 90 | string should be fixed for the algorithm, and must not be localised. 91 | The name should be unique within each provider. Names should contain 92 | lowercase alphanumeric characters only and no spaces or other 93 | formatting characters. 94 | """ 95 | return 'getPOIsForPoints' 96 | 97 | def displayName(self): 98 | """ 99 | Returns the translated algorithm name, which should be used for any 100 | user-visible display of the algorithm name. 101 | """ 102 | return self.tr('Get POIs around Points') 103 | 104 | def group(self): 105 | """ 106 | Returns the name of the group this algorithm belongs to. This string 107 | should be localised. 108 | """ 109 | return self.tr('POIs') 110 | 111 | def groupId(self): 112 | """ 113 | Returns the unique ID of the group this algorithm belongs to. This 114 | string should be fixed for the algorithm, and must not be localised. 115 | The group id should be unique within each provider. Group id should 116 | contain lowercase alphanumeric characters only and no spaces or other 117 | formatting characters. 118 | """ 119 | return 'POIs' 120 | 121 | def shortHelpString(self): 122 | """ 123 | Returns a localised short helper string for the algorithm. This string 124 | should provide a basic description about what the algorithm does and the 125 | parameters and outputs associated with it.. 126 | """ 127 | return self.tr( 128 | """This processing algorithm supports POI search for different categories for a set of points.
129 | The complete list of categories can be found on github.
Make sure your HERE credentials are stored in the QGIS global settings using the plugin itself. Please read the referenced Terms of Usage prior usage.""") 130 | 131 | def loadCredFunctionAlg(self): 132 | import json 133 | import os 134 | #fileLocation = QFileDialog.getOpenFileName(self.dlg, "JSON with credentials",os.path.dirname(os.path.realpath(__file__))+ os.sep + "creds", "JSON(*.JSON)") 135 | # print(fileLocation) 136 | scriptDirectory = os.path.dirname(os.path.realpath(__file__)) 137 | # self.dlg.credentialInteraction.setText("") 138 | creds = {} 139 | try: 140 | s = QgsSettings() 141 | creds["id"] = s.value("HQGIS/api_key", None) 142 | #self.dlg.credentialInteraction.setText("credits used from " + scriptDirectory + os.sep + 'creds' + os.sep + 'credentials.json') 143 | except BaseException: 144 | print("cred load failed, check QGIS global settings") 145 | #self.dlg.credentialInteraction.setText("no credits found in. Check for file" + scriptDirectory + os.sep + 'creds' + os.sep + 'credentials.json') 146 | # self.dlg.geocodeButton.setEnabled(False) 147 | # if not id in creds: 148 | # self.feedback.reportError("no id / appcode found! Check file " + scriptDirectory + os.sep + 'creds' + os.sep + 'credentials.json') 149 | return creds 150 | 151 | def initAlgorithm(self, config=None): 152 | """ 153 | Here we define the inputs and output of the algorithm, along 154 | with some other properties. 155 | """ 156 | 157 | # We add the input vector features source. It can have any kind of 158 | # point. 159 | self.addParameter( 160 | QgsProcessingParameterFeatureSource( 161 | self.INPUT, 162 | self.tr('Input Point Layer'), 163 | [QgsProcessing.TypeVectorPoint] 164 | ) 165 | ) 166 | self.keys = [ 167 | "Administrative Region-Streets", 168 | "Airport", 169 | "ATM", 170 | "Banking", 171 | "Body of Water", 172 | "Bookstore", 173 | "Building", 174 | "Business-Industry", 175 | "Car Dealer-Sales", 176 | "Car Rental", 177 | "Car Repair-Service", 178 | "Cargo Transportation", 179 | "Cinema", 180 | "City, Town or Village", 181 | "Clothing and Accessories", 182 | "Coffee-Tea", 183 | "Commercial Services", 184 | "Communication-Media", 185 | "Consumer Goods", 186 | "Consumer Services", 187 | "Convenience Store", 188 | "Department Store", 189 | "Drugstore or Pharmacy", 190 | "Education Facility", 191 | "Electronics", 192 | "Event Spaces", 193 | "Facilities", 194 | "Food and Drink", 195 | "Forest,Heath or Other Vegetation", 196 | "Fueling Station", 197 | "Government or Community Facility", 198 | "Hair and Beauty", 199 | "Hardware, House and Garden", 200 | "Hospital or Health Care Facility", 201 | "Hotel-Motel", 202 | "Landmark-Attraction", 203 | "Leisure", 204 | "Library", 205 | "Lodging", 206 | "Mall-Shopping Complex", 207 | "Money-Cash Services", 208 | "Mountain or Hill", 209 | "Museum", 210 | "Natural and Geographical", 211 | "Nightlife-Entertainment", 212 | "Outdoor Area-Complex", 213 | "Outdoor-Recreation", 214 | "Parking", 215 | "Police-Fire-Emergency", 216 | "Post Office", 217 | "Public Transport", 218 | "Religious Place", 219 | "Rest Area", 220 | "Restaurant", 221 | "Sports Facility-Venue", 222 | "Theatre, Music and Culture", 223 | "Tourist Information", 224 | "Truck-Semi Dealer-Services", 225 | "Undersea Feature" 226 | ] 227 | self.keys2 = [] 228 | for entry in self.keys: 229 | self.keys2.append(entry) 230 | self.addParameter( 231 | QgsProcessingParameterEnum( 232 | self.KEYS, 233 | self.tr("POI Categories"), 234 | options=self.keys2, 235 | # defaultValue=0, 236 | optional=False, 237 | allowMultiple=True, 238 | ) 239 | ) 240 | # self.modes = [ 241 | # "walk", #indicates that the user is on foot. 242 | # "drive", #indicates that the user is driving. 243 | # "public_transport", #indicates that the user is on public transport. 244 | # "bicycle", #indicates that the user is on bicycle. 245 | # "none" #if the user is neither on foot nor driving. 246 | # ] 247 | # self.addParameter( 248 | # QgsProcessingParameterEnum( 249 | # self.MODES, 250 | # self.tr('Traffic Mode'), 251 | # options=self.modes, 252 | # #defaultValue=0, 253 | # optional=False, 254 | # allowMultiple=False 255 | # ) 256 | # ) 257 | # self.addParameter( 258 | # QgsProcessingParameterNumber( 259 | # self.RADIUS, 260 | # self.tr('Radius around Points [m]'), 261 | # parentParameterName=self.INPUT, 262 | # options=self.keys, 263 | # defaultValue=100, 264 | # minValue=1, 265 | # maxValue=100000, 266 | # defaultUnit="DistanceMeters", 267 | # optional=False, 268 | # )#.setDefaultUnit(QgsUnitTypes.DistanceMeters) 269 | # ) 270 | 271 | # We add a feature sink in which to store our processed features (this 272 | # usually takes the form of a newly created vector layer when the 273 | # algorithm is run in QGIS). 274 | self.addParameter( 275 | QgsProcessingParameterFeatureSink( 276 | self.OUTPUT, 277 | self.tr('POI layer') 278 | ) 279 | ) 280 | 281 | def convertGeocodeResponse(self, responseAddress): 282 | geocodeResponse = {} 283 | try: 284 | geocodeResponse["Label"] = responseAddress["Location"]["Address"]["Label"] 285 | except BaseException: 286 | geocodeResponse["Label"] = "" 287 | try: 288 | geocodeResponse["Country"] = responseAddress["Location"]["Address"]["Country"] 289 | except BaseException: 290 | geocodeResponse["Country"] = "" 291 | try: 292 | geocodeResponse["State"] = responseAddress["Location"]["Address"]["State"] 293 | except BaseException: 294 | geocodeResponse["State"] = "" 295 | try: 296 | geocodeResponse["County"] = responseAddress["Location"]["Address"]["County"] 297 | except BaseException: 298 | geocodeResponse["County"] = "" 299 | try: 300 | geocodeResponse["City"] = responseAddress["Location"]["Address"]["City"] 301 | except BaseException: 302 | geocodeResponse["City"] = "" 303 | try: 304 | geocodeResponse["District"] = responseAddress["Location"]["Address"]["District"] 305 | except BaseException: 306 | geocodeResponse["District"] = "" 307 | try: 308 | geocodeResponse["Street"] = responseAddress["Location"]["Address"]["Street"] 309 | except BaseException: 310 | geocodeResponse["Street"] = "" 311 | try: 312 | geocodeResponse["HouseNumber"] = responseAddress["Location"]["Address"]["HouseNumber"] 313 | except BaseException: 314 | geocodeResponse["HouseNumber"] = "" 315 | try: 316 | geocodeResponse["PostalCode"] = responseAddress["Location"]["Address"]["PostalCode"] 317 | except BaseException: 318 | geocodeResponse["PostalCode"] = "" 319 | try: 320 | geocodeResponse["Relevance"] = responseAddress["Relevance"] 321 | except BaseException: 322 | geocodeResponse["Relevance"] = None 323 | try: 324 | geocodeResponse["CountryQuality"] = responseAddress["MatchQuality"]["Country"] 325 | except BaseException: 326 | geocodeResponse["CountryQuality"] = None 327 | try: 328 | geocodeResponse["CityQuality"] = responseAddress["MatchQuality"]["City"] 329 | except BaseException: 330 | geocodeResponse["CityQuality"] = None 331 | try: 332 | geocodeResponse["StreetQuality"] = responseAddress["MatchQuality"]["Street"][0] 333 | except BaseException: 334 | geocodeResponse["StreetQuality"] = None 335 | try: 336 | geocodeResponse["NumberQuality"] = responseAddress["MatchQuality"]["HouseNumber"] 337 | except BaseException: 338 | geocodeResponse["NumberQuality"] = None 339 | try: 340 | geocodeResponse["MatchType"] = responseAddress["MatchType"] 341 | except BaseException: 342 | geocodeResponse["MatchType"] = "" 343 | return(geocodeResponse) 344 | 345 | def processAlgorithm(self, parameters, context, feedback): 346 | """ 347 | Here is where the processing itself takes place. 348 | """ 349 | 350 | # Retrieve the feature source and sink. The 'dest_id' variable is used 351 | # to uniquely identify the feature sink, and must be included in the 352 | # dictionary returned by the processAlgorithm function. 353 | source = self.parameterAsSource( 354 | parameters, 355 | self.INPUT, 356 | context 357 | ) 358 | # allow only regular point layers. no Multipoints 359 | if (source.wkbType() == 4 360 | or source.wkbType() == 1004 361 | or source.wkbType() == 3004): 362 | raise QgsProcessingException( 363 | "MultiPoint layer is not supported!") 364 | # radius = self.parameterAsString( 365 | # parameters, 366 | # self.RADIUS, 367 | # context 368 | # ) 369 | # mode = self.parameterAsEnum( 370 | # parameters, 371 | # self.MODES, 372 | # context 373 | # ) 374 | categories = self.parameterAsEnums( 375 | parameters, 376 | self.KEYS, 377 | context 378 | ) 379 | # feedback.pushInfo(addressField) 380 | 381 | # If source was not found, throw an exception to indicate that the algorithm 382 | # encountered a fatal error. The exception text can be any string, but in this 383 | # case we use the pre-built invalidSourceError method to return a standard 384 | # helper text for when a source cannot be evaluated 385 | if source is None: 386 | raise QgsProcessingException( 387 | self.invalidSourceError( 388 | parameters, self.INPUT)) 389 | 390 | fields = QgsFields() 391 | fields.append(QgsField("id", QVariant.String)) 392 | fields.append(QgsField("origin_id", QVariant.Int)) 393 | fields.append(QgsField("title", QVariant.String)) 394 | fields.append(QgsField("label", QVariant.String)) 395 | fields.append(QgsField("distance", QVariant.Double)) 396 | fields.append(QgsField("categories", QVariant.String)) 397 | (sink, dest_id) = self.parameterAsSink( 398 | parameters, 399 | self.OUTPUT, 400 | context, 401 | fields, 402 | QgsWkbTypes.Point, 403 | QgsCoordinateReferenceSystem(4326) 404 | ) 405 | # Send some information to the user 406 | feedback.pushInfo( 407 | '{} points for POI finding'.format( 408 | source.featureCount())) 409 | # If sink was not created, throw an exception to indicate that the algorithm 410 | # encountered a fatal error. The exception text can be any string, but in this 411 | # case we use the pre-built invalidSinkError method to return a standard 412 | # helper text for when a sink cannot be evaluated 413 | if sink is None: 414 | raise QgsProcessingException( 415 | self.invalidSinkError( 416 | parameters, self.OUTPUT)) 417 | 418 | # Compute the number of steps to display within the progress bar and 419 | # get features from source 420 | total = 100.0 / source.featureCount() if source.featureCount() else 0 421 | features = source.getFeatures() 422 | # get the keys: 423 | creds = self.loadCredFunctionAlg() 424 | # convert categories to list for API call: 425 | categoriesList = [] 426 | # self.keys[keyField].split(" | ")[1] 427 | for category in categories: 428 | feedback.pushInfo(self.keys[category]) 429 | categoriesList.append(mapCategories(self.keys[category])) 430 | categories = ",".join(categoriesList) 431 | #for category in categories: 432 | # categoryID = mapCategories(category) 433 | # categoriesList.append(categoryID) 434 | #categories = ",".join(categoriesList) 435 | layerCRS = source.sourceCrs() 436 | if layerCRS != QgsCoordinateReferenceSystem(4326): 437 | sourceCrs = source.sourceCrs() 438 | destCrs = QgsCoordinateReferenceSystem(4326) 439 | tr = QgsCoordinateTransform( 440 | sourceCrs, destCrs, QgsProject.instance()) 441 | for current, feature in enumerate(features): 442 | # Stop the algorithm if cancel button has been clicked 443 | if feedback.isCanceled(): 444 | break 445 | # convert coordinates: 446 | if layerCRS != QgsCoordinateReferenceSystem(4326): 447 | # we reproject: 448 | geom = feature.geometry() 449 | newGeom = tr.transform(geom.asPoint()) 450 | x = newGeom.x() 451 | y = newGeom.y() 452 | else: 453 | x = feature.geometry().asPoint().x() 454 | y = feature.geometry().asPoint().y() 455 | coordinates = str(y) + "," + str(x) 456 | # get the location from the API: 457 | header = {"referer": "HQGIS"} 458 | ApiUrl = 'https://browse.search.hereapi.com/v1/browse?at=' + coordinates + \ 459 | "&categories=" + categories + "&limit=100&apiKey=" + creds["id"] 460 | feedback.pushInfo('calling Url {}'.format(ApiUrl)) 461 | r = requests.get(ApiUrl, headers=header) 462 | 463 | responsePlaces = json.loads(r.text)["items"] 464 | for place in responsePlaces: 465 | lat = place["position"]["lat"] 466 | lng = place["position"]["lng"] 467 | # iterate over categories: 468 | 469 | categoriesResp = [] 470 | 471 | fet = QgsFeature() 472 | fet.setGeometry(QgsGeometry.fromPointXY(QgsPointXY(lng, lat))) 473 | fet.setAttributes([ 474 | place["id"], 475 | feature.id(), 476 | place["title"], 477 | place["address"]["label"], 478 | place["distance"], 479 | ";".join(categoriesResp) 480 | ]) 481 | sink.addFeature(fet, QgsFeatureSink.FastInsert) 482 | #lat = responseAddress["Location"]["DisplayPosition"]["Latitude"] 483 | #lng = responseAddress["Location"]["DisplayPosition"]["Longitude"] 484 | # Add a feature in the sink 485 | # feedback.pushInfo(str(lat)) 486 | 487 | # fet.setGeometry(QgsGeometry.fromPointXY(QgsPointXY(lng,lat))) 488 | # fet.setAttributes([ 489 | 490 | # Update the progress bar 491 | feedback.setProgress(int(current * total)) 492 | 493 | # To run another Processing algorithm as part of this algorithm, you can use 494 | # processing.run(...). Make sure you pass the current context and feedback 495 | # to processing.run to ensure that all temporary layer outputs are available 496 | # to the executed algorithm, and that the executed algorithm can send feedback 497 | # reports to the user (and correctly handle cancelation and progress 498 | # reports!) 499 | 500 | # Return the results of the algorithm. In this case our only result is 501 | # the feature sink which contains the processed features, but some 502 | # algorithms may return multiple feature sinks, calculated numeric 503 | # statistics, etc. These should all be included in the returned 504 | # dictionary, with keys matching the feature corresponding parameter 505 | # or output names. 506 | return {self.OUTPUT: dest_id} 507 | -------------------------------------------------------------------------------- /HqgisAlgorithm_geocode.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | *************************************************************************** 5 | * * 6 | * This program is free software; you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | *************************************************************************** 12 | """ 13 | 14 | from PyQt5.QtCore import (QCoreApplication, QUrl, QVariant) 15 | from PyQt5.QtNetwork import (QNetworkReply, 16 | QNetworkAccessManager, 17 | QNetworkRequest) 18 | from qgis.core import (QgsProcessing, 19 | QgsFeatureSink, 20 | QgsProcessingParameterField, 21 | QgsProcessingException, 22 | QgsProcessingAlgorithm, 23 | QgsProcessingParameterFeatureSource, 24 | QgsProcessingParameterField, 25 | QgsProcessingParameterFeatureSink, 26 | QgsNetworkAccessManager, 27 | QgsField, 28 | QgsFields, 29 | QgsWkbTypes, 30 | QgsCoordinateReferenceSystem, 31 | QgsFeature, 32 | QgsGeometry, 33 | QgsPointXY, 34 | QgsSettings) 35 | from functools import partial 36 | import processing 37 | import Hqgis 38 | import os 39 | import requests 40 | import json 41 | import time 42 | import urllib 43 | 44 | 45 | class geocodeList(QgsProcessingAlgorithm): 46 | def __init__(self): 47 | super().__init__() 48 | 49 | """ 50 | This is an example algorithm that takes a vector layer and 51 | creates a new identical one. 52 | 53 | It is meant to be used as an example of how to create your own 54 | algorithms and explain methods and variables used to do it. An 55 | algorithm like this will be available in all elements, and there 56 | is not need for additional work. 57 | 58 | All Processing algorithms should extend the QgsProcessingAlgorithm 59 | class. 60 | """ 61 | 62 | # Constants used to refer to parameters and outputs. They will be 63 | # used when calling the algorithm from another algorithm, or when 64 | # calling from the QGIS console. 65 | 66 | INPUT = 'INPUT' 67 | OUTPUT = 'OUTPUT' 68 | AddressField = 'Address Field' 69 | 70 | def tr(self, string): 71 | """ 72 | Returns a translatable string with the self.tr() function. 73 | """ 74 | return QCoreApplication.translate('Processing', string) 75 | 76 | def createInstance(self): 77 | return type(self)() 78 | 79 | def name(self): 80 | """ 81 | Returns the algorithm name, used for identifying the algorithm. This 82 | string should be fixed for the algorithm, and must not be localised. 83 | The name should be unique within each provider. Names should contain 84 | lowercase alphanumeric characters only and no spaces or other 85 | formatting characters. 86 | """ 87 | return 'geocodeFieldAddress' 88 | 89 | def displayName(self): 90 | """ 91 | Returns the translated algorithm name, which should be used for any 92 | user-visible display of the algorithm name. 93 | """ 94 | return self.tr('Geocode List') 95 | 96 | def group(self): 97 | """ 98 | Returns the name of the group this algorithm belongs to. This string 99 | should be localised. 100 | """ 101 | return self.tr('geocode') 102 | 103 | def groupId(self): 104 | """ 105 | Returns the unique ID of the group this algorithm belongs to. This 106 | string should be fixed for the algorithm, and must not be localised. 107 | The group id should be unique within each provider. Group id should 108 | contain lowercase alphanumeric characters only and no spaces or other 109 | formatting characters. 110 | """ 111 | return 'geocode' 112 | 113 | def shortHelpString(self): 114 | """ 115 | Returns a localised short helper string for the algorithm. This string 116 | should provide a basic description about what the algorithm does and the 117 | parameters and outputs associated with it. 118 | """ 119 | return self.tr( 120 | "This processing algorithm supports geocoding of a list of addresses in a single field originating from a txt/csv/table.
Make sure your HERE credentials are stored in the QGIS global settings using the plugin itself. Please read the referenced Terms of Usage prior usage") 121 | 122 | def loadCredFunctionAlg(self): 123 | import json 124 | import os 125 | #fileLocation = QFileDialog.getOpenFileName(self.dlg, "JSON with credentials",os.path.dirname(os.path.realpath(__file__))+ os.sep + "creds", "JSON(*.JSON)") 126 | # print(fileLocation) 127 | scriptDirectory = os.path.dirname(os.path.realpath(__file__)) 128 | # self.dlg.credentialInteraction.setText("") 129 | creds = {} 130 | try: 131 | s = QgsSettings() 132 | creds["id"] = s.value("HQGIS/api_key", None) 133 | #self.dlg.credentialInteraction.setText("credits used from " + scriptDirectory + os.sep + 'creds' + os.sep + 'credentials.json') 134 | except BaseException: 135 | print("cred load failed, check QGIS global settings") 136 | #self.dlg.credentialInteraction.setText("no credits found in. Check for file" + scriptDirectory + os.sep + 'creds' + os.sep + 'credentials.json') 137 | # self.dlg.geocodeButton.setEnabled(False) 138 | # if not id in creds: 139 | # self.feedback.reportError("no id / appcode found! Check file " + scriptDirectory + os.sep + 'creds' + os.sep + 'credentials.json') 140 | return creds 141 | 142 | def initAlgorithm(self, config=None): 143 | """ 144 | Here we define the inputs and output of the algorithm, along 145 | with some other properties. 146 | """ 147 | 148 | # We add the input vector features source. It can have any kind of 149 | # geometry. 150 | self.addParameter( 151 | QgsProcessingParameterFeatureSource( 152 | self.INPUT, 153 | self.tr('Input table'), 154 | [QgsProcessing.TypeVector] 155 | ) 156 | ) 157 | self.addParameter( 158 | QgsProcessingParameterField( 159 | self.AddressField, 160 | self.tr('Address Field'), 161 | parentLayerParameterName=self.INPUT, 162 | type=QgsProcessingParameterField.String 163 | 164 | ) 165 | ) 166 | 167 | # We add a feature sink in which to store our processed features (this 168 | # usually takes the form of a newly created vector layer when the 169 | # algorithm is run in QGIS). 170 | self.addParameter( 171 | QgsProcessingParameterFeatureSink( 172 | self.OUTPUT, 173 | self.tr('Geocoded Addresses') 174 | ) 175 | ) 176 | 177 | def convertGeocodeResponse(self, responseAddress): 178 | geocodeResponse = {} 179 | try: 180 | geocodeResponse["Label"] = responseAddress["address"]["label"] 181 | except BaseException: 182 | geocodeResponse["Label"] = "" 183 | try: 184 | geocodeResponse["Country"] = responseAddress["address"]["country"] 185 | except BaseException: 186 | geocodeResponse["Country"] = "" 187 | try: 188 | geocodeResponse["State"] = responseAddress["address"]["state"] 189 | except BaseException: 190 | geocodeResponse["State"] = "" 191 | try: 192 | geocodeResponse["County"] = responseAddress["address"]["county"] 193 | except BaseException: 194 | geocodeResponse["County"] = "" 195 | try: 196 | geocodeResponse["City"] = responseAddress["address"]["city"] 197 | except BaseException: 198 | geocodeResponse["City"] = "" 199 | try: 200 | geocodeResponse["District"] = responseAddress["address"][ 201 | "district" 202 | ] 203 | except BaseException: 204 | geocodeResponse["District"] = "" 205 | try: 206 | geocodeResponse["Street"] = responseAddress["address"]["street"] 207 | except BaseException: 208 | geocodeResponse["Street"] = "" 209 | try: 210 | geocodeResponse["HouseNumber"] = responseAddress["address"][ 211 | "houseNumber" 212 | ] 213 | except BaseException: 214 | geocodeResponse["HouseNumber"] = "" 215 | try: 216 | geocodeResponse["PostalCode"] = responseAddress["address"][ 217 | "postalCode" 218 | ] 219 | except BaseException: 220 | geocodeResponse["PostalCode"] = "" 221 | try: 222 | geocodeResponse["Relevance"] = responseAddress["scoring"]["queryScore"] 223 | except BaseException: 224 | geocodeResponse["Relevance"] = None 225 | try: 226 | geocodeResponse["CountryQuality"] = responseAddress["scoring"]["fieldscore"][ 227 | "country" 228 | ] 229 | except BaseException: 230 | geocodeResponse["CountryQuality"] = None 231 | try: 232 | geocodeResponse["CityQuality"] = responseAddress["scoring"]["fieldscore"]["city"] 233 | except BaseException: 234 | geocodeResponse["CityQuality"] = None 235 | try: 236 | geocodeResponse["StreetQuality"] = responseAddress["scoring"]["fieldscore"][ 237 | "street" 238 | ][0] 239 | except BaseException: 240 | geocodeResponse["StreetQuality"] = None 241 | try: 242 | geocodeResponse["NumberQuality"] = responseAddress["scoring"]["fieldscore"][ 243 | "houseNumber" 244 | ] 245 | except BaseException: 246 | geocodeResponse["NumberQuality"] = None 247 | try: 248 | geocodeResponse["MatchType"] = responseAddress["resultType"] 249 | except BaseException: 250 | geocodeResponse["MatchType"] = "" 251 | return geocodeResponse 252 | 253 | def processAlgorithm(self, parameters, context, feedback): 254 | """ 255 | Here is where the processing itself takes place. 256 | """ 257 | 258 | # Retrieve the feature source and sink. The 'dest_id' variable is used 259 | # to uniquely identify the feature sink, and must be included in the 260 | # dictionary returned by the processAlgorithm function. 261 | source = self.parameterAsSource( 262 | parameters, 263 | self.INPUT, 264 | context 265 | ) 266 | addressField = self.parameterAsString( 267 | parameters, 268 | self.AddressField, 269 | context 270 | ) 271 | feedback.pushInfo(addressField) 272 | 273 | # If source was not found, throw an exception to indicate that the algorithm 274 | # encountered a fatal error. The exception text can be any string, but in this 275 | # case we use the pre-built invalidSourceError method to return a standard 276 | # helper text for when a source cannot be evaluated 277 | if source is None: 278 | raise QgsProcessingException( 279 | self.invalidSourceError( 280 | parameters, self.INPUT)) 281 | 282 | fields = QgsFields() 283 | fields.append(QgsField("id", QVariant.Int)) 284 | fields.append(QgsField("oldAddress", QVariant.String)) 285 | fields.append(QgsField("lat", QVariant.Double)) 286 | fields.append(QgsField("lng", QVariant.Double)) 287 | fields.append(QgsField("address", QVariant.String)) 288 | fields.append(QgsField("country", QVariant.String)) 289 | fields.append(QgsField("state", QVariant.String)) 290 | fields.append(QgsField("county", QVariant.String)) 291 | fields.append(QgsField("city", QVariant.String)) 292 | fields.append(QgsField("district", QVariant.String)) 293 | fields.append(QgsField("street", QVariant.String)) 294 | fields.append(QgsField("number", QVariant.String)) 295 | fields.append(QgsField("zip", QVariant.String)) 296 | fields.append(QgsField("relevance", QVariant.Double)) 297 | fields.append(QgsField("qu_country", QVariant.Double)) 298 | fields.append(QgsField("qu_city", QVariant.Double)) 299 | fields.append(QgsField("qu_street", QVariant.Double)) 300 | fields.append(QgsField("qu_number", QVariant.Double)) 301 | fields.append(QgsField("matchtype", QVariant.String)) 302 | (sink, dest_id) = self.parameterAsSink( 303 | parameters, 304 | self.OUTPUT, 305 | context, 306 | fields, 307 | QgsWkbTypes.Point, 308 | QgsCoordinateReferenceSystem(4326) 309 | ) 310 | 311 | # Send some information to the user 312 | feedback.pushInfo( 313 | '{} addresses to geocode'.format( 314 | source.featureCount())) 315 | 316 | # If sink was not created, throw an exception to indicate that the algorithm 317 | # encountered a fatal error. The exception text can be any string, but in this 318 | # case we use the pre-built invalidSinkError method to return a standard 319 | # helper text for when a sink cannot be evaluated 320 | if sink is None: 321 | raise QgsProcessingException( 322 | self.invalidSinkError( 323 | parameters, self.OUTPUT)) 324 | 325 | # Compute the number of steps to display within the progress bar and 326 | # get features from source 327 | total = 100.0 / source.featureCount() if source.featureCount() else 0 328 | features = source.getFeatures() 329 | # get the keys: 330 | creds = self.loadCredFunctionAlg() 331 | for current, feature in enumerate(features): 332 | # Stop the algorithm if cancel button has been clicked 333 | if feedback.isCanceled(): 334 | break 335 | 336 | # get the location from the API: 337 | ApiUrl = "https://geocode.search.hereapi.com/v1/geocode?apiKey=" + \ 338 | creds["id"] + "&q=" + feature[addressField] 339 | r = requests.get(ApiUrl) 340 | responseAddress = json.loads(r.text)["items"][0] 341 | geocodeResponse = self.convertGeocodeResponse(responseAddress) 342 | lat = responseAddress["position"]["lat"] 343 | lng = responseAddress["position"]["lng"] 344 | # Add a feature in the sink 345 | # feedback.pushInfo(str(lat)) 346 | fet = QgsFeature() 347 | fet.setGeometry(QgsGeometry.fromPointXY(QgsPointXY(lng, lat))) 348 | fet.setAttributes([ 349 | feature.id(), 350 | feature[addressField], 351 | lat, 352 | lng, 353 | geocodeResponse["Label"], 354 | geocodeResponse["Country"], 355 | geocodeResponse["State"], 356 | geocodeResponse["County"], 357 | geocodeResponse["City"], 358 | geocodeResponse["District"], 359 | geocodeResponse["Street"], 360 | geocodeResponse["HouseNumber"], 361 | geocodeResponse["PostalCode"], 362 | geocodeResponse["Relevance"], 363 | geocodeResponse["CountryQuality"], 364 | geocodeResponse["CityQuality"], 365 | geocodeResponse["StreetQuality"], 366 | geocodeResponse["NumberQuality"], 367 | geocodeResponse["MatchType"] 368 | ]) 369 | sink.addFeature(fet, QgsFeatureSink.FastInsert) 370 | 371 | # Update the progress bar 372 | feedback.setProgress(int(current * total)) 373 | 374 | # To run another Processing algorithm as part of this algorithm, you can use 375 | # processing.run(...). Make sure you pass the current context and feedback 376 | # to processing.run to ensure that all temporary layer outputs are available 377 | # to the executed algorithm, and that the executed algorithm can send feedback 378 | # reports to the user (and correctly handle cancelation and progress 379 | # reports!) 380 | if False: 381 | buffered_layer = processing.run("native:buffer", { 382 | 'INPUT': dest_id, 383 | 'DISTANCE': 1.5, 384 | 'SEGMENTS': 5, 385 | 'END_CAP_STYLE': 0, 386 | 'JOIN_STYLE': 0, 387 | 'MITER_LIMIT': 2, 388 | 'DISSOLVE': False, 389 | 'OUTPUT': 'memory:' 390 | }, context=context, feedback=feedback)['OUTPUT'] 391 | 392 | # Return the results of the algorithm. In this case our only result is 393 | # the feature sink which contains the processed features, but some 394 | # algorithms may return multiple feature sinks, calculated numeric 395 | # statistics, etc. These should all be included in the returned 396 | # dictionary, with keys matching the feature corresponding parameter 397 | # or output names. 398 | return {self.OUTPUT: dest_id} 399 | -------------------------------------------------------------------------------- /HqgisAlgorithm_isochrone.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | *************************************************************************** 5 | * * 6 | * This program is free software; you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | *************************************************************************** 12 | """ 13 | 14 | from PyQt5.QtCore import QCoreApplication, QVariant 15 | from PyQt5.QtGui import QColor 16 | from qgis.core import ( 17 | QgsProcessing, 18 | QgsFeatureSink, 19 | QgsRendererRange, 20 | QgsGraduatedSymbolRenderer, 21 | QgsProject, 22 | QgsProcessingParameterEnum, 23 | QgsCoordinateTransform, 24 | QgsProcessingException, 25 | QgsProcessingAlgorithm, 26 | QgsProcessingParameterString, 27 | QgsProcessingParameterFeatureSource, 28 | QgsProcessingParameterFeatureSink, 29 | QgsSymbol, 30 | QgsField, 31 | QgsFields, 32 | QgsWkbTypes, 33 | QgsCoordinateReferenceSystem, 34 | QgsFeature, 35 | QgsGeometry, 36 | QgsPointXY, 37 | QgsSettings, 38 | ) 39 | from .decodeGeom import decode 40 | from functools import partial 41 | from datetime import datetime 42 | import Hqgis 43 | import os 44 | import requests 45 | import json 46 | import time 47 | import urllib 48 | 49 | 50 | class isochroneList(QgsProcessingAlgorithm): 51 | def __init__(self): 52 | super().__init__() 53 | 54 | """ 55 | This is an example algorithm that takes a vector layer and 56 | creates a new identical one. 57 | 58 | It is meant to be used as an example of how to create your own 59 | algorithms and explain methods and variables used to do it. An 60 | algorithm like this will be available in all elements, and there 61 | is not need for additional work. 62 | 63 | All Processing algorithms should extend the QgsProcessingAlgorithm 64 | class. 65 | """ 66 | 67 | # Constants used to refer to parameters and outputs. They will be 68 | # used when calling the algorithm from another algorithm, or when 69 | # calling from the QGIS console. 70 | 71 | INPUT = "INPUT" 72 | OUTPUT = "OUTPUT" 73 | KEYS = "KEYS" 74 | MODES = "MODES" 75 | METRIC = "METRIC" 76 | DISTANCES = "DISTANCE" 77 | DEPARTURETIME = "DEPARTURETIME" 78 | 79 | def tr(self, string): 80 | """ 81 | Returns a translatable string with the self.tr() function. 82 | """ 83 | return QCoreApplication.translate("Processing", string) 84 | 85 | def createInstance(self): 86 | return type(self)() 87 | 88 | def name(self): 89 | """ 90 | Returns the algorithm name, used for identifying the algorithm. This 91 | string should be fixed for the algorithm, and must not be localised. 92 | The name should be unique within each provider. Names should contain 93 | lowercase alphanumeric characters only and no spaces or other 94 | formatting characters. 95 | """ 96 | return "getIsochrones" 97 | 98 | def displayName(self): 99 | """ 100 | Returns the translated algorithm name, which should be used for any 101 | user-visible display of the algorithm name. 102 | """ 103 | return self.tr("Get Isochrones around Points") 104 | 105 | def group(self): 106 | """ 107 | Returns the name of the group this algorithm belongs to. This string 108 | should be localised. 109 | """ 110 | return self.tr("Isochrones") 111 | 112 | def groupId(self): 113 | """ 114 | Returns the unique ID of the group this algorithm belongs to. This 115 | string should be fixed for the algorithm, and must not be localised. 116 | The group id should be unique within each provider. Group id should 117 | contain lowercase alphanumeric characters only and no spaces or other 118 | formatting characters. 119 | """ 120 | return "Isochrones" 121 | 122 | def shortHelpString(self): 123 | """ 124 | Returns a localised short helper string for the algorithm. This string 125 | should provide a basic description about what the algorithm does and the 126 | parameters and outputs associated with it.. 127 | """ 128 | return self.tr( 129 | """This processing algorithm supports Isochrone search for a set of points.
Departure Time is treated as local time of the departure locations! 130 | Make sure your HERE credentials are stored in the QGIS global settings using the plugin itself. Please read the referenced Terms of Usage prior usage.""" 131 | ) 132 | 133 | def loadCredFunctionAlg(self): 134 | import json 135 | import os 136 | 137 | # fileLocation = QFileDialog.getOpenFileName(self.dlg, "JSON with credentials",os.path.dirname(os.path.realpath(__file__))+ os.sep + "creds", "JSON(*.JSON)") 138 | # print(fileLocation) 139 | scriptDirectory = os.path.dirname(os.path.realpath(__file__)) 140 | # self.dlg.credentialInteraction.setText("") 141 | creds = {} 142 | try: 143 | s = QgsSettings() 144 | creds["id"] = s.value("HQGIS/api_key", None) 145 | # self.dlg.credentialInteraction.setText("credits used from " + scriptDirectory + os.sep + 'creds' + os.sep + 'credentials.json') 146 | except BaseException: 147 | print("cred load failed, check QGIS global settings") 148 | # self.dlg.credentialInteraction.setText("no credits found in. Check for file" + scriptDirectory + os.sep + 'creds' + os.sep + 'credentials.json') 149 | # self.dlg.geocodeButton.setEnabled(False) 150 | # if not id in creds: 151 | # self.feedback.reportError("no id / appcode found! Check file " + scriptDirectory + os.sep + 'creds' + os.sep + 'credentials.json') 152 | return creds 153 | 154 | def initAlgorithm(self, config=None): 155 | """ 156 | Here we define the inputs and output of the algorithm, along 157 | with some other properties. 158 | """ 159 | 160 | # We add the input vector features source. It can have any kind of 161 | # point. 162 | self.addParameter( 163 | QgsProcessingParameterFeatureSource( 164 | self.INPUT, 165 | self.tr("Input Point Layer"), 166 | [QgsProcessing.TypeVectorPoint], 167 | ) 168 | ) 169 | self.keys = [ 170 | "car", 171 | "bicycle", 172 | "pedestrian", 173 | "truck", 174 | ] 175 | self.addParameter( 176 | QgsProcessingParameterEnum( 177 | self.KEYS, 178 | self.tr("routing mode"), 179 | options=self.keys, 180 | defaultValue="car", 181 | optional=False, 182 | allowMultiple=False, 183 | ) 184 | ) 185 | self.modes = ["fast", "short"] 186 | self.addParameter( 187 | QgsProcessingParameterEnum( 188 | self.MODES, 189 | self.tr("Traffic Mode"), 190 | options=self.modes, 191 | defaultValue="fast", 192 | optional=False, 193 | allowMultiple=False, 194 | ) 195 | ) 196 | self.metric = ["time", "distance"] 197 | self.addParameter( 198 | QgsProcessingParameterEnum( 199 | self.METRIC, 200 | self.tr("Metric"), 201 | options=self.metric, 202 | defaultValue="seconds", 203 | optional=False, 204 | allowMultiple=False, 205 | ) 206 | ) 207 | self.addParameter( 208 | QgsProcessingParameterString( 209 | self.DISTANCES, 210 | self.tr("Distance(s)"), 211 | "300,600,900", 212 | optional=False, 213 | ) 214 | ) 215 | self.addParameter( 216 | QgsProcessingParameterString( 217 | self.DEPARTURETIME, 218 | self.tr("Local Departure Time"), # 2019-06-24T01:23:45 219 | datetime.now().strftime("%Y-%m-%dT%H:%M:%S"), 220 | optional=False, 221 | ) 222 | ) 223 | 224 | # We add a feature sink in which to store our processed features (this 225 | # usually takes the form of a newly created vector layer when the 226 | # algorithm is run in QGIS). 227 | self.addParameter( 228 | QgsProcessingParameterFeatureSink(self.OUTPUT, self.tr("Isochrone layer")) 229 | ) 230 | 231 | def processAlgorithm(self, parameters, context, feedback): 232 | """ 233 | Here is where the processing itself takes place. 234 | """ 235 | 236 | # Retrieve the feature source and sink. The 'dest_id' variable is used 237 | # to uniquely identify the feature sink, and must be included in the 238 | # dictionary returned by the processAlgorithm function. 239 | source = self.parameterAsSource(parameters, self.INPUT, context) 240 | # allow only regular point layers. no Multipoints 241 | if ( 242 | source.wkbType() == 4 243 | or source.wkbType() == 1004 244 | or source.wkbType() == 3004 245 | ): 246 | raise QgsProcessingException("MultiPoint layer is not supported!") 247 | transportMode = self.keys[self.parameterAsEnum(parameters, self.KEYS, context)] 248 | mode = self.modes[self.parameterAsEnum(parameters, self.MODES, context)] 249 | slots = self.parameterAsString(parameters, self.DISTANCES, context) 250 | metric = self.metric[self.parameterAsEnum(parameters, self.METRIC, context)] 251 | departureTime = self.parameterAsString(parameters, self.DEPARTURETIME, context) 252 | print(type(transportMode), type(metric), type(slots), type(mode), type(time)) 253 | # feedback.pushInfo(addressField) 254 | 255 | # If source was not found, throw an exception to indicate that the algorithm 256 | # encountered a fatal error. The exception text can be any string, but in this 257 | # case we use the pre-built invalidSourceError method to return a standard 258 | # helper text for when a source cannot be evaluated 259 | 260 | if source is None: 261 | raise QgsProcessingException( 262 | self.invalidSourceError(parameters, self.INPUT) 263 | ) 264 | 265 | fields = QgsFields() 266 | # fields.append(QgsField("id", QVariant.String)) 267 | fields.append(QgsField("origin_id", QVariant.Int)) 268 | fields.append(QgsField("url", QVariant.String)), 269 | fields.append(QgsField("type", QVariant.String)), 270 | fields.append(QgsField("distance", QVariant.Double)) 271 | (sink, dest_id) = self.parameterAsSink( 272 | parameters, 273 | self.OUTPUT, 274 | context, 275 | fields, 276 | QgsWkbTypes.Polygon, 277 | QgsCoordinateReferenceSystem(4326), 278 | ) 279 | # Send some information to the user 280 | feedback.pushInfo( 281 | "{} points for isochrone finding".format(source.featureCount()) 282 | ) 283 | # If sink was not created, throw an exception to indicate that the algorithm 284 | # encountered a fatal error. The exception text can be any string, but in this 285 | # case we use the pre-built invalidSinkError method to return a standard 286 | # helper text for when a sink cannot be evaluated 287 | if sink is None: 288 | raise QgsProcessingException(self.invalidSinkError(parameters, self.OUTPUT)) 289 | 290 | # Compute the number of steps to display within the progress bar and 291 | # get features from source 292 | total = 100.0 / source.featureCount() if source.featureCount() else 0 293 | features = source.getFeatures() 294 | # get the keys: 295 | creds = self.loadCredFunctionAlg() 296 | layerCRS = source.sourceCrs() 297 | if layerCRS != QgsCoordinateReferenceSystem(4326): 298 | sourceCrs = source.sourceCrs() 299 | destCrs = QgsCoordinateReferenceSystem(4326) 300 | tr = QgsCoordinateTransform(sourceCrs, destCrs, QgsProject.instance()) 301 | for current, feature in enumerate(features): 302 | # Stop the algorithm if cancel button has been clicked 303 | if feedback.isCanceled(): 304 | break 305 | # convert coordinates: 306 | if layerCRS != QgsCoordinateReferenceSystem(4326): 307 | # we reproject: 308 | geom = feature.geometry() 309 | newGeom = tr.transform(geom.asPoint()) 310 | x = newGeom.x() 311 | y = newGeom.y() 312 | else: 313 | x = feature.geometry().asPoint().x() 314 | y = feature.geometry().asPoint().y() 315 | coordinates = str(y) + "," + str(x) 316 | print(coordinates) 317 | # get the location from the API: 318 | header = {"referer": "HQGIS"} 319 | time.sleep(1) 320 | print(sink, type(sink)) 321 | print(self.OUTPUT, type(self.OUTPUT)) 322 | ApiUrl = ( 323 | "https://isoline.router.hereapi.com/v8/isolines?origin=" 324 | + coordinates 325 | + "&departureTime=" 326 | + departureTime 327 | + "&range[type]=" 328 | + metric 329 | + "&range[values]=" 330 | + slots 331 | + "&routingMode=" 332 | + mode 333 | + "&transportMode=" 334 | + transportMode 335 | + "&apiKey=" 336 | + creds["id"] 337 | ) 338 | 339 | feedback.pushInfo("calling Url {}".format(ApiUrl)) 340 | r = requests.get(ApiUrl, headers=header) 341 | print(json.loads(r.text)) 342 | # layer = self.createRouteLayer() 343 | for line in reversed(json.loads(r.text)["isolines"]): 344 | # print(decode(line["polygons"][0]["outer"])) 345 | for polygon in line["polygons"]: 346 | for key, value in polygon.items(): 347 | Points = decode(value) 348 | vertices = [] 349 | for Point in Points: 350 | lat = Point[0] 351 | lng = Point[1] 352 | vertices.append(QgsPointXY(lng, lat)) 353 | fet = QgsFeature() 354 | fet.setGeometry(QgsGeometry.fromPolygonXY([vertices])) 355 | fet.setAttributes( 356 | [feature.id(), ApiUrl, key, line["range"]["value"]] 357 | ) 358 | sink.addFeature(fet, QgsFeatureSink.FastInsert) 359 | # QgsProject.instance().addMapLayer(layer) 360 | 361 | # Update the progress bar 362 | feedback.setProgress(int(current * total)) 363 | return {self.OUTPUT: dest_id} 364 | -------------------------------------------------------------------------------- /HqgisProvider.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | /*************************************************************************** 5 | HqgisAlgorithm 6 | A QGIS plugin 7 | Processing plugin for Hqgis 8 | ------------------- 9 | begin : 2019-02-06 10 | copyright : (C) 2019 by Riccardo Klinger 11 | email : riccardo.klinger@gmail.com 12 | ***************************************************************************/ 13 | 14 | /*************************************************************************** 15 | * * 16 | * This program is free software; you can redistribute it and/or modify * 17 | * it under the terms of the GNU General Public License as published by * 18 | * the Free Software Foundation; either version 2 of the License, or * 19 | * (at your option) any later version. * 20 | * * 21 | ***************************************************************************/ 22 | """ 23 | 24 | from qgis.core import QgsProcessingProvider 25 | from processing.core.ProcessingConfig import Setting, ProcessingConfig 26 | from .HqgisAlgorithm_geocode import geocodeList 27 | from .HqgisAlgorithm_isochrone import isochroneList 28 | from .HqgisAlgorithm_POIs import getPois 29 | 30 | __author__ = 'Riccardo Klinger' 31 | __date__ = '2020-03-04' 32 | __copyright__ = '(C) 2020 Riccardo Klinger' 33 | 34 | # This will get replaced with a git SHA1 when you do a git archive 35 | 36 | __revision__ = '$Format:%H$' 37 | 38 | 39 | class HqgisProvider(QgsProcessingProvider): 40 | 41 | def __init__(self): 42 | QgsProcessingProvider.__init__(self) 43 | 44 | # Deactivate provider by default 45 | self.activate = False 46 | 47 | def unload(self): 48 | """Setting should be removed here, so they do not appear anymore 49 | when the plugin is unloaded. 50 | """ 51 | QgsProcessingProvider.unload(self) 52 | # ProcessingConfig.removeSetting( 53 | # qgis2webProvider.MY_DUMMY_SETTING) 54 | 55 | def id(self): 56 | """This is the name that will appear on the toolbox group. 57 | 58 | It is also used to create the command line name of all the 59 | algorithms from this provider. 60 | """ 61 | return 'Hqgis' 62 | 63 | def name(self): 64 | """This is the provired full name. 65 | """ 66 | return 'Hqgis' 67 | 68 | def icon(self): 69 | """We return the default icon. 70 | """ 71 | return QgsProcessingProvider.icon(self) 72 | 73 | def load(self): 74 | self.refreshAlgorithms() 75 | return True 76 | 77 | def loadAlgorithms(self): 78 | """Here we fill the list of algorithms in self.algs. 79 | 80 | This method is called whenever the list of algorithms should 81 | be updated. If the list of algorithms can change (for instance, 82 | if it contains algorithms from user-defined scripts and a new 83 | script might have been added), you should create the list again 84 | here. 85 | 86 | In this case, since the list is always the same, we assign from 87 | the pre-made list. This assignment has to be done in this method 88 | even if the list does not change, since the self.algs list is 89 | cleared before calling this method. 90 | """ 91 | 92 | self.alglist = [geocodeList(), getPois(),isochroneList()] 93 | for alg in self.alglist: 94 | self.addAlgorithm(alg) 95 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | #/*************************************************************************** 2 | # HEREqgis 3 | # 4 | # Access the HERE API in QGIS 5 | # ------------------- 6 | # begin : 2018-12-22 7 | # git sha : $Format:%H$ 8 | # copyright : (C) 2018 by Riccardo Klinger 9 | # email : riccardo.klinger@gmail.com 10 | # ***************************************************************************/ 11 | # 12 | #/*************************************************************************** 13 | # * * 14 | # * This program is free software; you can redistribute it and/or modify * 15 | # * it under the terms of the GNU General Public License as published by * 16 | # * the Free Software Foundation; either version 2 of the License, or * 17 | # * (at your option) any later version. * 18 | # * * 19 | # ***************************************************************************/ 20 | 21 | ################################################# 22 | # Edit the following to match your sources lists 23 | ################################################# 24 | 25 | 26 | #Add iso code for any locales you want to support here (space separated) 27 | # default is no locales 28 | # LOCALES = af 29 | LOCALES = 30 | 31 | # If locales are enabled, set the name of the lrelease binary on your system. If 32 | # you have trouble compiling the translations, you may have to specify the full path to 33 | # lrelease 34 | #LRELEASE = lrelease 35 | #LRELEASE = lrelease-qt4 36 | 37 | 38 | # translation 39 | SOURCES = \ 40 | __init__.py \ 41 | hereqgis.py hereqgis_dialog.py 42 | 43 | PLUGINNAME = hereqgis 44 | 45 | PY_FILES = \ 46 | __init__.py \ 47 | hereqgis.py hereqgis_dialog.py 48 | 49 | UI_FILES = hereqgis_dialog_base.ui 50 | 51 | EXTRAS = metadata.txt icon.png 52 | 53 | EXTRA_DIRS = 54 | 55 | COMPILED_RESOURCE_FILES = resources.py 56 | 57 | PEP8EXCLUDE=pydev,resources.py,conf.py,third_party,ui 58 | 59 | 60 | ################################################# 61 | # Normally you would not need to edit below here 62 | ################################################# 63 | 64 | HELP = help/build/html 65 | 66 | PLUGIN_UPLOAD = $(c)/plugin_upload.py 67 | 68 | RESOURCE_SRC=$(shell grep '^ *@@g;s/.*>//g' | tr '\n' ' ') 69 | 70 | QGISDIR=.qgis2 71 | 72 | default: compile 73 | 74 | compile: $(COMPILED_RESOURCE_FILES) 75 | 76 | %.py : %.qrc $(RESOURCES_SRC) 77 | pyrcc5 -o $*.py $< 78 | 79 | %.qm : %.ts 80 | $(LRELEASE) $< 81 | 82 | test: compile transcompile 83 | @echo 84 | @echo "----------------------" 85 | @echo "Regression Test Suite" 86 | @echo "----------------------" 87 | 88 | @# Preceding dash means that make will continue in case of errors 89 | @-export PYTHONPATH=`pwd`:$(PYTHONPATH); \ 90 | export QGIS_DEBUG=0; \ 91 | export QGIS_LOG_FILE=/dev/null; \ 92 | nosetests -v --with-id --with-coverage --cover-package=. \ 93 | 3>&1 1>&2 2>&3 3>&- || true 94 | @echo "----------------------" 95 | @echo "If you get a 'no module named qgis.core error, try sourcing" 96 | @echo "the helper script we have provided first then run make test." 97 | @echo "e.g. source run-env-linux.sh ; make test" 98 | @echo "----------------------" 99 | 100 | deploy: compile doc transcompile 101 | @echo 102 | @echo "------------------------------------------" 103 | @echo "Deploying plugin to your .qgis2 directory." 104 | @echo "------------------------------------------" 105 | # The deploy target only works on unix like operating system where 106 | # the Python plugin directory is located at: 107 | # $HOME/$(QGISDIR)/python/plugins 108 | mkdir -p $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME) 109 | cp -vf $(PY_FILES) $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME) 110 | cp -vf $(UI_FILES) $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME) 111 | cp -vf $(COMPILED_RESOURCE_FILES) $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME) 112 | cp -vf $(EXTRAS) $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME) 113 | cp -vfr i18n $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME) 114 | cp -vfr $(HELP) $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME)/help 115 | # Copy extra directories if any 116 | (foreach EXTRA_DIR,(EXTRA_DIRS), cp -R (EXTRA_DIR) (HOME)/(QGISDIR)/python/plugins/(PLUGINNAME)/;) 117 | 118 | 119 | # The dclean target removes compiled python files from plugin directory 120 | # also deletes any .git entry 121 | dclean: 122 | @echo 123 | @echo "-----------------------------------" 124 | @echo "Removing any compiled python files." 125 | @echo "-----------------------------------" 126 | find $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME) -iname "*.pyc" -delete 127 | find $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME) -iname ".git" -prune -exec rm -Rf {} \; 128 | 129 | 130 | derase: 131 | @echo 132 | @echo "-------------------------" 133 | @echo "Removing deployed plugin." 134 | @echo "-------------------------" 135 | rm -Rf $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME) 136 | 137 | zip: deploy dclean 138 | @echo 139 | @echo "---------------------------" 140 | @echo "Creating plugin zip bundle." 141 | @echo "---------------------------" 142 | # The zip target deploys the plugin and creates a zip file with the deployed 143 | # content. You can then upload the zip file on http://plugins.qgis.org 144 | rm -f $(PLUGINNAME).zip 145 | cd $(HOME)/$(QGISDIR)/python/plugins; zip -9r $(CURDIR)/$(PLUGINNAME).zip $(PLUGINNAME) 146 | 147 | package: compile 148 | # Create a zip package of the plugin named $(PLUGINNAME).zip. 149 | # This requires use of git (your plugin development directory must be a 150 | # git repository). 151 | # To use, pass a valid commit or tag as follows: 152 | # make package VERSION=Version_0.3.2 153 | @echo 154 | @echo "------------------------------------" 155 | @echo "Exporting plugin to zip package. " 156 | @echo "------------------------------------" 157 | rm -f $(PLUGINNAME).zip 158 | git archive --prefix=$(PLUGINNAME)/ -o $(PLUGINNAME).zip $(VERSION) 159 | echo "Created package: $(PLUGINNAME).zip" 160 | 161 | upload: zip 162 | @echo 163 | @echo "-------------------------------------" 164 | @echo "Uploading plugin to QGIS Plugin repo." 165 | @echo "-------------------------------------" 166 | $(PLUGIN_UPLOAD) $(PLUGINNAME).zip 167 | 168 | transup: 169 | @echo 170 | @echo "------------------------------------------------" 171 | @echo "Updating translation files with any new strings." 172 | @echo "------------------------------------------------" 173 | @chmod +x scripts/update-strings.sh 174 | @scripts/update-strings.sh $(LOCALES) 175 | 176 | transcompile: 177 | @echo 178 | @echo "----------------------------------------" 179 | @echo "Compiled translation files to .qm files." 180 | @echo "----------------------------------------" 181 | @chmod +x scripts/compile-strings.sh 182 | @scripts/compile-strings.sh $(LRELEASE) $(LOCALES) 183 | 184 | transclean: 185 | @echo 186 | @echo "------------------------------------" 187 | @echo "Removing compiled translation files." 188 | @echo "------------------------------------" 189 | rm -f i18n/*.qm 190 | 191 | clean: 192 | @echo 193 | @echo "------------------------------------" 194 | @echo "Removing uic and rcc generated files" 195 | @echo "------------------------------------" 196 | rm $(COMPILED_UI_FILES) $(COMPILED_RESOURCE_FILES) 197 | 198 | doc: 199 | @echo 200 | @echo "------------------------------------" 201 | @echo "Building documentation using sphinx." 202 | @echo "------------------------------------" 203 | cd help; make html 204 | 205 | pylint: 206 | @echo 207 | @echo "-----------------" 208 | @echo "Pylint violations" 209 | @echo "-----------------" 210 | @pylint --reports=n --rcfile=pylintrc . || true 211 | @echo 212 | @echo "----------------------" 213 | @echo "If you get a 'no module named qgis.core' error, try sourcing" 214 | @echo "the helper script we have provided first then run make pylint." 215 | @echo "e.g. source run-env-linux.sh ; make pylint" 216 | @echo "----------------------" 217 | 218 | 219 | # Run pep8 style checking 220 | #http://pypi.python.org/pypi/pep8 221 | pep8: 222 | @echo 223 | @echo "-----------" 224 | @echo "PEP8 issues" 225 | @echo "-----------" 226 | @pep8 --repeat --ignore=E203,E121,E122,E123,E124,E125,E126,E127,E128 --exclude $(PEP8EXCLUDE) . || true 227 | @echo "-----------" 228 | @echo "Ignored in PEP8 check:" 229 | @echo $(PEP8EXCLUDE) 230 | -------------------------------------------------------------------------------- /__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | /*************************************************************************** 4 | Hqgis 5 | A QGIS plugin 6 | Access the HERE API in QGIS 7 | Generated by Plugin Builder: http://g-sherman.github.io/Qgis-Plugin-Builder/ 8 | ------------------- 9 | begin : 2018-12-22 10 | copyright : (C) 2018 by Riccardo Klinger 11 | email : riccardo.klinger@gmail.com 12 | git sha : $Format:%H$ 13 | ***************************************************************************/ 14 | 15 | /*************************************************************************** 16 | * * 17 | * This program is free software; you can redistribute it and/or modify * 18 | * it under the terms of the GNU General Public License as published by * 19 | * the Free Software Foundation; either version 2 of the License, or * 20 | * (at your option) any later version. * 21 | * * 22 | ***************************************************************************/ 23 | This script initializes the plugin, making it known to QGIS. 24 | """ 25 | 26 | 27 | # noinspection PyPep8Naming 28 | def classFactory(iface): # pylint: disable=invalid-name 29 | """Load Hqgis class from file Hqgis. 30 | 31 | :param iface: A QGIS interface instance. 32 | :type iface: QgsInterface 33 | """ 34 | # 35 | from .hqgis import Hqgis 36 | return Hqgis(iface) 37 | -------------------------------------------------------------------------------- /categories.md: -------------------------------------------------------------------------------- 1 | # List of Categories 2 | 'accommodation', [0]
3 | 'administrative-areas-buildings', [1]
4 | 'administrative-region', [2]
5 | 'airport', [3]
6 | 'ambulance-services', [4]
7 | 'amusement-holiday-park', [5]
8 | 'atm-bank-exchange', [6]
9 | 'bar-pub', [7]
10 | 'body-of-water', [8]
11 | 'bookshop', [9]
12 | 'building', [10]
13 | 'business-industry', [11]
14 | 'business-services', [12]
15 | 'camping', [13]
16 | 'car-dealer-repair', [14]
17 | 'car-rental', [15]
18 | 'casino', [16]
19 | 'cinema', [17]
20 | 'city-town-village', [18]
21 | 'clothing-accessories-shop', [19]
22 | 'coffee', [20]
23 | 'coffee-tea', [21]
24 | 'communication-media', [22]
25 | 'dance-night-club', [23]
26 | 'department-store', [24]
27 | 'eat-drink', [25]
28 | 'education-facility', [26]
29 | 'electronics-shop', [27]
30 | 'ev-charging-station', [28]
31 | 'facilities', [29]
32 | 'facility', [30]
33 | 'fair-convention-facility', [31]
34 | 'ferry-terminal', [32]
35 | 'fire-department', [33]
36 | 'food-drink', [34]
37 | 'forest-heath-vegetation', [35]
38 | 'going-out', [36]
39 | 'government-community-facility', [37]
40 | 'hardware-house-garden-shop', [38]
41 | 'hospital-health-care-facility', [39]
42 | 'hospital-health-care-facility', [40]
43 | 'hostel', [41]
44 | 'hotel', [42]
45 | 'intersection', [43]
46 | 'kiosk-convenience-store', [44]
47 | 'landmark-attraction', [45]
48 | 'leisure-outdoor', [46]
49 | 'library', [47]
50 | 'mall', [48]
51 | 'motel', [49]
52 | 'mountain-hill', [50]
53 | 'museum', [51]
54 | 'natural-geographical', [52]
55 | 'outdoor-area-complex', [53]
56 | 'parking-facility', [54]
57 | 'petrol-station', [55]
58 | 'pharmacy', [56]
59 | 'police-emergency', [57]
60 | 'police-station', [58]
61 | 'post-office', [59]
62 | 'postal-area', [60]
63 | 'public-transport', [61]
64 | 'railway-station', [62]
65 | 'recreation', [63]
66 | 'religious-place', [64]
67 | 'restaurant', [65]
68 | 'service', [66]
69 | 'shop', [67]
70 | 'shopping', [68]
71 | 'sights-museums', [69]
72 | 'snacks-fast-food', [70]
73 | 'sport-outdoor-shop', [71]
74 | 'sports-facility-venue', [72]
75 | 'street-square', [73]
76 | 'taxi-stand', [74]
77 | 'tea', [75]
78 | 'theatre-music-culture', [76]
79 | 'toilet-rest-area', [77]
80 | 'tourist-information', [78]
81 | 'transport', [79]
82 | 'travel-agency', [80]
83 | 'undersea-feature', [81]
84 | 'wine-and-liquor', [82]
85 | 'zoo' [83]
86 | -------------------------------------------------------------------------------- /data/SemiMassData.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/riccardoklinger/Hqgis/087923c59d0f9f7970c4579b43f650201ea9550b/data/SemiMassData.txt -------------------------------------------------------------------------------- /data/addresses.txt: -------------------------------------------------------------------------------- 1 | address Name ID 2 | 11 Wall Street, New York, NY Wall Street 0 3 | Berlin, Germany Berlin 1 4 | Gorzów Wielkopolski, 66-400, Pologne some place in Poland 2 -------------------------------------------------------------------------------- /data/massData.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/riccardoklinger/Hqgis/087923c59d0f9f7970c4579b43f650201ea9550b/data/massData.txt -------------------------------------------------------------------------------- /decodeGeom.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2019 HERE Europe B.V. 2 | # Licensed under MIT, see full license in LICENSE 3 | # SPDX-License-Identifier: MIT 4 | # License-Filename: LICENSE 5 | 6 | from collections import namedtuple 7 | LEVEL = 1 8 | ALTITUDE = 2 9 | ELEVATION = 3 10 | # Reserved values 4 and 5 should not be selectable 11 | CUSTOM1 = 6 12 | CUSTOM2 = 7 13 | THIRD_DIM_MAP = {ALTITUDE: 'alt', ELEVATION: 'elv', LEVEL: 'lvl', CUSTOM1: 'cst1', CUSTOM2: 'cst2'} 14 | FORMAT_VERSION = 1 15 | 16 | __all__ = [ 17 | 'decode', 'dict_decode', 'iter_decode', 18 | 'get_third_dimension', 'decode_header', 'PolylineHeader' 19 | ] 20 | 21 | DECODING_TABLE = [ 22 | 62, -1, -1, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, -1, 23 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 24 | 22, 23, 24, 25, -1, -1, -1, -1, 63, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 25 | 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51 26 | ] 27 | 28 | 29 | PolylineHeader = namedtuple('PolylineHeader', 'precision,third_dim,third_dim_precision') 30 | 31 | 32 | def decode_header(decoder): 33 | """Decode the polyline header from an `encoded_char`. Returns a PolylineHeader object.""" 34 | version = next(decoder) 35 | if version != FORMAT_VERSION: 36 | raise ValueError('Invalid format version') 37 | value = next(decoder) 38 | precision = value & 15 39 | value >>= 4 40 | third_dim = value & 7 41 | third_dim_precision = (value >> 3) & 15 42 | return PolylineHeader(precision, third_dim, third_dim_precision) 43 | 44 | 45 | def get_third_dimension(encoded): 46 | """Return the third dimension of an encoded polyline. 47 | Possible returned values are: ABSENT, LEVEL, ALTITUDE, ELEVATION, CUSTOM1, CUSTOM2.""" 48 | header = decode_header(decode_unsigned_values(encoded)) 49 | return header.third_dim 50 | 51 | 52 | def decode_char(char): 53 | """Decode a single char to the corresponding value""" 54 | char_value = ord(char) 55 | 56 | try: 57 | value = DECODING_TABLE[char_value - 45] 58 | except IndexError: 59 | raise ValueError('Invalid encoding') 60 | if value < 0: 61 | raise ValueError('Invalid encoding') 62 | return value 63 | 64 | 65 | def to_signed(value): 66 | """Decode the sign from an unsigned value""" 67 | if value & 1: 68 | value = ~value 69 | value >>= 1 70 | return value 71 | 72 | 73 | def decode_unsigned_values(encoded): 74 | """Return an iterator over encoded unsigned values part of an `encoded` polyline""" 75 | result = shift = 0 76 | 77 | for char in encoded: 78 | value = decode_char(char) 79 | 80 | result |= (value & 0x1F) << shift 81 | if (value & 0x20) == 0: 82 | yield result 83 | result = shift = 0 84 | else: 85 | shift += 5 86 | 87 | if shift > 0: 88 | raise ValueError('Invalid encoding') 89 | 90 | 91 | def iter_decode(encoded): 92 | """Return an iterator over coordinates. The number of coordinates are 2 or 3 93 | depending on the polyline content.""" 94 | 95 | last_lat = last_lng = last_z = 0 96 | decoder = decode_unsigned_values(encoded) 97 | 98 | header = decode_header(decoder) 99 | factor_degree = 10.0 ** header.precision 100 | factor_z = 10.0 ** header.third_dim_precision 101 | third_dim = header.third_dim 102 | 103 | while True: 104 | try: 105 | last_lat += to_signed(next(decoder)) 106 | except StopIteration: 107 | return # sequence completed 108 | 109 | try: 110 | last_lng += to_signed(next(decoder)) 111 | 112 | if third_dim: 113 | last_z += to_signed(next(decoder)) 114 | yield (last_lat / factor_degree, last_lng / factor_degree, last_z / factor_z) 115 | else: 116 | yield (last_lat / factor_degree, last_lng / factor_degree) 117 | except StopIteration: 118 | raise ValueError("Invalid encoding. Premature ending reached") 119 | 120 | def decode(encoded): 121 | """Return a list of coordinates. The number of coordinates are 2 or 3 122 | depending on the polyline content.""" 123 | return list(iter_decode(encoded)) -------------------------------------------------------------------------------- /help/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | PAPER = 8 | BUILDDIR = build 9 | 10 | # Internal variables. 11 | PAPEROPT_a4 = -D latex_paper_size=a4 12 | PAPEROPT_letter = -D latex_paper_size=letter 13 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source 14 | 15 | .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest 16 | 17 | help: 18 | @echo "Please use \`make ' where is one of" 19 | @echo " html to make standalone HTML files" 20 | @echo " dirhtml to make HTML files named index.html in directories" 21 | @echo " singlehtml to make a single large HTML file" 22 | @echo " pickle to make pickle files" 23 | @echo " json to make JSON files" 24 | @echo " htmlhelp to make HTML files and a HTML help project" 25 | @echo " qthelp to make HTML files and a qthelp project" 26 | @echo " devhelp to make HTML files and a Devhelp project" 27 | @echo " epub to make an epub" 28 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 29 | @echo " latexpdf to make LaTeX files and run them through pdflatex" 30 | @echo " text to make text files" 31 | @echo " man to make manual pages" 32 | @echo " changes to make an overview of all changed/added/deprecated items" 33 | @echo " linkcheck to check all external links for integrity" 34 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 35 | 36 | clean: 37 | -rm -rf $(BUILDDIR)/* 38 | 39 | html: 40 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 41 | @echo 42 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 43 | 44 | dirhtml: 45 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml 46 | @echo 47 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." 48 | 49 | singlehtml: 50 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml 51 | @echo 52 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." 53 | 54 | pickle: 55 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle 56 | @echo 57 | @echo "Build finished; now you can process the pickle files." 58 | 59 | json: 60 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json 61 | @echo 62 | @echo "Build finished; now you can process the JSON files." 63 | 64 | htmlhelp: 65 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp 66 | @echo 67 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 68 | ".hhp project file in $(BUILDDIR)/htmlhelp." 69 | 70 | qthelp: 71 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp 72 | @echo 73 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ 74 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:" 75 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/template_class.qhcp" 76 | @echo "To view the help file:" 77 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/template_class.qhc" 78 | 79 | devhelp: 80 | $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp 81 | @echo 82 | @echo "Build finished." 83 | @echo "To view the help file:" 84 | @echo "# mkdir -p $$HOME/.local/share/devhelp/template_class" 85 | @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/template_class" 86 | @echo "# devhelp" 87 | 88 | epub: 89 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub 90 | @echo 91 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub." 92 | 93 | latex: 94 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 95 | @echo 96 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." 97 | @echo "Run \`make' in that directory to run these through (pdf)latex" \ 98 | "(use \`make latexpdf' here to do that automatically)." 99 | 100 | latexpdf: 101 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 102 | @echo "Running LaTeX files through pdflatex..." 103 | make -C $(BUILDDIR)/latex all-pdf 104 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 105 | 106 | text: 107 | $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text 108 | @echo 109 | @echo "Build finished. The text files are in $(BUILDDIR)/text." 110 | 111 | man: 112 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man 113 | @echo 114 | @echo "Build finished. The manual pages are in $(BUILDDIR)/man." 115 | 116 | changes: 117 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes 118 | @echo 119 | @echo "The overview file is in $(BUILDDIR)/changes." 120 | 121 | linkcheck: 122 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck 123 | @echo 124 | @echo "Link check complete; look for any errors in the above output " \ 125 | "or in $(BUILDDIR)/linkcheck/output.txt." 126 | 127 | doctest: 128 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest 129 | @echo "Testing of doctests in the sources finished, look at the " \ 130 | "results in $(BUILDDIR)/doctest/output.txt." 131 | -------------------------------------------------------------------------------- /help/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | REM Command file for Sphinx documentation 4 | 5 | if "%SPHINXBUILD%" == "" ( 6 | set SPHINXBUILD=sphinx-build 7 | ) 8 | set BUILDDIR=build 9 | set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% source 10 | if NOT "%PAPER%" == "" ( 11 | set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% 12 | ) 13 | 14 | if "%1" == "" goto help 15 | 16 | if "%1" == "help" ( 17 | :help 18 | echo.Please use `make ^` where ^ is one of 19 | echo. html to make standalone HTML files 20 | echo. dirhtml to make HTML files named index.html in directories 21 | echo. singlehtml to make a single large HTML file 22 | echo. pickle to make pickle files 23 | echo. json to make JSON files 24 | echo. htmlhelp to make HTML files and a HTML help project 25 | echo. qthelp to make HTML files and a qthelp project 26 | echo. devhelp to make HTML files and a Devhelp project 27 | echo. epub to make an epub 28 | echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter 29 | echo. text to make text files 30 | echo. man to make manual pages 31 | echo. changes to make an overview over all changed/added/deprecated items 32 | echo. linkcheck to check all external links for integrity 33 | echo. doctest to run all doctests embedded in the documentation if enabled 34 | goto end 35 | ) 36 | 37 | if "%1" == "clean" ( 38 | for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i 39 | del /q /s %BUILDDIR%\* 40 | goto end 41 | ) 42 | 43 | if "%1" == "html" ( 44 | %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html 45 | echo. 46 | echo.Build finished. The HTML pages are in %BUILDDIR%/html. 47 | goto end 48 | ) 49 | 50 | if "%1" == "dirhtml" ( 51 | %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml 52 | echo. 53 | echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. 54 | goto end 55 | ) 56 | 57 | if "%1" == "singlehtml" ( 58 | %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml 59 | echo. 60 | echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. 61 | goto end 62 | ) 63 | 64 | if "%1" == "pickle" ( 65 | %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle 66 | echo. 67 | echo.Build finished; now you can process the pickle files. 68 | goto end 69 | ) 70 | 71 | if "%1" == "json" ( 72 | %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json 73 | echo. 74 | echo.Build finished; now you can process the JSON files. 75 | goto end 76 | ) 77 | 78 | if "%1" == "htmlhelp" ( 79 | %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp 80 | echo. 81 | echo.Build finished; now you can run HTML Help Workshop with the ^ 82 | .hhp project file in %BUILDDIR%/htmlhelp. 83 | goto end 84 | ) 85 | 86 | if "%1" == "qthelp" ( 87 | %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp 88 | echo. 89 | echo.Build finished; now you can run "qcollectiongenerator" with the ^ 90 | .qhcp project file in %BUILDDIR%/qthelp, like this: 91 | echo.^> qcollectiongenerator %BUILDDIR%\qthelp\template_class.qhcp 92 | echo.To view the help file: 93 | echo.^> assistant -collectionFile %BUILDDIR%\qthelp\template_class.ghc 94 | goto end 95 | ) 96 | 97 | if "%1" == "devhelp" ( 98 | %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp 99 | echo. 100 | echo.Build finished. 101 | goto end 102 | ) 103 | 104 | if "%1" == "epub" ( 105 | %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub 106 | echo. 107 | echo.Build finished. The epub file is in %BUILDDIR%/epub. 108 | goto end 109 | ) 110 | 111 | if "%1" == "latex" ( 112 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 113 | echo. 114 | echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. 115 | goto end 116 | ) 117 | 118 | if "%1" == "text" ( 119 | %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text 120 | echo. 121 | echo.Build finished. The text files are in %BUILDDIR%/text. 122 | goto end 123 | ) 124 | 125 | if "%1" == "man" ( 126 | %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man 127 | echo. 128 | echo.Build finished. The manual pages are in %BUILDDIR%/man. 129 | goto end 130 | ) 131 | 132 | if "%1" == "changes" ( 133 | %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes 134 | echo. 135 | echo.The overview file is in %BUILDDIR%/changes. 136 | goto end 137 | ) 138 | 139 | if "%1" == "linkcheck" ( 140 | %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck 141 | echo. 142 | echo.Link check complete; look for any errors in the above output ^ 143 | or in %BUILDDIR%/linkcheck/output.txt. 144 | goto end 145 | ) 146 | 147 | if "%1" == "doctest" ( 148 | %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest 149 | echo. 150 | echo.Testing of doctests in the sources finished, look at the ^ 151 | results in %BUILDDIR%/doctest/output.txt. 152 | goto end 153 | ) 154 | 155 | :end 156 | -------------------------------------------------------------------------------- /help/source/conf.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # HEREqgis documentation build configuration file, created by 4 | # sphinx-quickstart on Sun Feb 12 17:11:03 2012. 5 | # 6 | # This file is execfile()d with the current directory set to its containing dir. 7 | # 8 | # Note that not all possible configuration values are present in this 9 | # autogenerated file. 10 | # 11 | # All configuration values have a default; values that are commented out 12 | # serve to show the default. 13 | 14 | import sys 15 | import os 16 | 17 | # If extensions (or modules to document with autodoc) are in another directory, 18 | # add these directories to sys.path here. If the directory is relative to the 19 | # documentation root, use os.path.abspath to make it absolute, like shown here. 20 | #sys.path.insert(0, os.path.abspath('.')) 21 | 22 | # -- General configuration ----------------------------------------------- 23 | 24 | # If your documentation needs a minimal Sphinx version, state it here. 25 | #needs_sphinx = '1.0' 26 | 27 | # Add any Sphinx extension module names here, as strings. They can be extensions 28 | # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. 29 | extensions = ['sphinx.ext.todo', 'sphinx.ext.pngmath', 'sphinx.ext.viewcode'] 30 | 31 | # Add any paths that contain templates here, relative to this directory. 32 | templates_path = ['_templates'] 33 | 34 | # The suffix of source filenames. 35 | source_suffix = '.rst' 36 | 37 | # The encoding of source files. 38 | #source_encoding = 'utf-8-sig' 39 | 40 | # The master toctree document. 41 | master_doc = 'index' 42 | 43 | # General information about the project. 44 | project = u'HEREqgis' 45 | copyright = u'2013, Riccardo Klinger' 46 | 47 | # The version info for the project you're documenting, acts as replacement for 48 | # |version| and |release|, also used in various other places throughout the 49 | # built documents. 50 | # 51 | # The short X.Y version. 52 | version = '0.1' 53 | # The full version, including alpha/beta/rc tags. 54 | release = '0.1' 55 | 56 | # The language for content autogenerated by Sphinx. Refer to documentation 57 | # for a list of supported languages. 58 | #language = None 59 | 60 | # There are two options for replacing |today|: either, you set today to some 61 | # non-false value, then it is used: 62 | #today = '' 63 | # Else, today_fmt is used as the format for a strftime call. 64 | #today_fmt = '%B %d, %Y' 65 | 66 | # List of patterns, relative to source directory, that match files and 67 | # directories to ignore when looking for source files. 68 | exclude_patterns = [] 69 | 70 | # The reST default role (used for this markup: `text`) to use for all documents. 71 | #default_role = None 72 | 73 | # If true, '()' will be appended to :func: etc. cross-reference text. 74 | #add_function_parentheses = True 75 | 76 | # If true, the current module name will be prepended to all description 77 | # unit titles (such as .. function::). 78 | #add_TemplateModuleNames = True 79 | 80 | # If true, sectionauthor and moduleauthor directives will be shown in the 81 | # output. They are ignored by default. 82 | #show_authors = False 83 | 84 | # The name of the Pygments (syntax highlighting) style to use. 85 | pygments_style = 'sphinx' 86 | 87 | # A list of ignored prefixes for module index sorting. 88 | #modindex_common_prefix = [] 89 | 90 | 91 | # -- Options for HTML output --------------------------------------------- 92 | 93 | # The theme to use for HTML and HTML Help pages. See the documentation for 94 | # a list of builtin themes. 95 | html_theme = 'default' 96 | 97 | # Theme options are theme-specific and customize the look and feel of a theme 98 | # further. For a list of options available for each theme, see the 99 | # documentation. 100 | #html_theme_options = {} 101 | 102 | # Add any paths that contain custom themes here, relative to this directory. 103 | #html_theme_path = [] 104 | 105 | # The name for this set of Sphinx documents. If None, it defaults to 106 | # " v documentation". 107 | #html_title = None 108 | 109 | # A shorter title for the navigation bar. Default is the same as html_title. 110 | #html_short_title = None 111 | 112 | # The name of an image file (relative to this directory) to place at the top 113 | # of the sidebar. 114 | #html_logo = None 115 | 116 | # The name of an image file (within the static path) to use as favicon of the 117 | # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 118 | # pixels large. 119 | #html_favicon = None 120 | 121 | # Add any paths that contain custom static files (such as style sheets) here, 122 | # relative to this directory. They are copied after the builtin static files, 123 | # so a file named "default.css" will overwrite the builtin "default.css". 124 | html_static_path = ['_static'] 125 | 126 | # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, 127 | # using the given strftime format. 128 | #html_last_updated_fmt = '%b %d, %Y' 129 | 130 | # If true, SmartyPants will be used to convert quotes and dashes to 131 | # typographically correct entities. 132 | #html_use_smartypants = True 133 | 134 | # Custom sidebar templates, maps document names to template names. 135 | #html_sidebars = {} 136 | 137 | # Additional templates that should be rendered to pages, maps page names to 138 | # template names. 139 | #html_additional_pages = {} 140 | 141 | # If false, no module index is generated. 142 | #html_domain_indices = True 143 | 144 | # If false, no index is generated. 145 | #html_use_index = True 146 | 147 | # If true, the index is split into individual pages for each letter. 148 | #html_split_index = False 149 | 150 | # If true, links to the reST sources are added to the pages. 151 | #html_show_sourcelink = True 152 | 153 | # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. 154 | #html_show_sphinx = True 155 | 156 | # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. 157 | #html_show_copyright = True 158 | 159 | # If true, an OpenSearch description file will be output, and all pages will 160 | # contain a tag referring to it. The value of this option must be the 161 | # base URL from which the finished HTML is served. 162 | #html_use_opensearch = '' 163 | 164 | # This is the file name suffix for HTML files (e.g. ".xhtml"). 165 | #html_file_suffix = None 166 | 167 | # Output file base name for HTML help builder. 168 | htmlhelp_basename = 'TemplateClassdoc' 169 | 170 | 171 | # -- Options for LaTeX output -------------------------------------------- 172 | 173 | # The paper size ('letter' or 'a4'). 174 | #latex_paper_size = 'letter' 175 | 176 | # The font size ('10pt', '11pt' or '12pt'). 177 | #latex_font_size = '10pt' 178 | 179 | # Grouping the document tree into LaTeX files. List of tuples 180 | # (source start file, target name, title, author, documentclass [howto/manual]). 181 | latex_documents = [ 182 | ('index', 'HEREqgis.tex', u'HEREqgis Documentation', 183 | u'Riccardo Klinger', 'manual'), 184 | ] 185 | 186 | # The name of an image file (relative to this directory) to place at the top of 187 | # the title page. 188 | #latex_logo = None 189 | 190 | # For "manual" documents, if this is true, then toplevel headings are parts, 191 | # not chapters. 192 | #latex_use_parts = False 193 | 194 | # If true, show page references after internal links. 195 | #latex_show_pagerefs = False 196 | 197 | # If true, show URL addresses after external links. 198 | #latex_show_urls = False 199 | 200 | # Additional stuff for the LaTeX preamble. 201 | #latex_preamble = '' 202 | 203 | # Documents to append as an appendix to all manuals. 204 | #latex_appendices = [] 205 | 206 | # If false, no module index is generated. 207 | #latex_domain_indices = True 208 | 209 | 210 | # -- Options for manual page output -------------------------------------- 211 | 212 | # One entry per manual page. List of tuples 213 | # (source start file, name, description, authors, manual section). 214 | man_pages = [ 215 | ('index', 'TemplateClass', u'HEREqgis Documentation', 216 | [u'Riccardo Klinger'], 1) 217 | ] 218 | -------------------------------------------------------------------------------- /help/source/index.rst: -------------------------------------------------------------------------------- 1 | .. HEREqgis documentation master file, created by 2 | sphinx-quickstart on Sun Feb 12 17:11:03 2012. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Welcome to HEREqgis's documentation! 7 | ============================================ 8 | 9 | Contents: 10 | 11 | .. toctree:: 12 | :maxdepth: 2 13 | 14 | Indices and tables 15 | ================== 16 | 17 | * :ref:`genindex` 18 | * :ref:`modindex` 19 | * :ref:`search` 20 | 21 | -------------------------------------------------------------------------------- /hqgis_dialog.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | /*************************************************************************** 4 | HqgisDialog 5 | A QGIS plugin 6 | Access the HERE API in QGIS 7 | Generated by Plugin Builder: http://g-sherman.github.io/Qgis-Plugin-Builder/ 8 | ------------------- 9 | begin : 2018-12-22 10 | git sha : $Format:%H$ 11 | copyright : (C) 2018 by Riccardo Klinger 12 | email : riccardo.klinger@gmail.com 13 | ***************************************************************************/ 14 | 15 | /*************************************************************************** 16 | * * 17 | * This program is free software; you can redistribute it and/or modify * 18 | * it under the terms of the GNU General Public License as published by * 19 | * the Free Software Foundation; either version 2 of the License, or * 20 | * (at your option) any later version. * 21 | * * 22 | ***************************************************************************/ 23 | """ 24 | 25 | import os 26 | 27 | from PyQt5 import uic 28 | from PyQt5 import QtWidgets 29 | 30 | FORM_CLASS, _ = uic.loadUiType(os.path.join( 31 | os.path.dirname(__file__), 'hqgis_dialog_base.ui')) 32 | 33 | 34 | class HqgisDialog(QtWidgets.QDialog, FORM_CLASS): 35 | def __init__(self, parent=None): 36 | """Constructor.""" 37 | super(HqgisDialog, self).__init__(parent) 38 | # Set up the user interface from Designer. 39 | # After setupUI you can access any designer object by doing 40 | # self., and you can use autoconnect slots - see 41 | # http://qt-project.org/doc/qt-4.8/designer-using-a-ui-file.html 42 | # #widgets-and-dialogs-with-auto-connect 43 | self.setupUi(self) 44 | -------------------------------------------------------------------------------- /i18n/af.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | @default 5 | 6 | 7 | Good morning 8 | Goeie more 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/riccardoklinger/Hqgis/087923c59d0f9f7970c4579b43f650201ea9550b/icon.png -------------------------------------------------------------------------------- /mapCat.py: -------------------------------------------------------------------------------- 1 | def mapCategories(categoryName): 2 | keys = [{"name": "Restaurant", 3 | "categories": "100-1000", 4 | }, 5 | {"name": "Coffee-Tea", 6 | "categories": "100-1100", 7 | }, 8 | {"name": "Nightlife-Entertainment", 9 | "categories": "200-2000", 10 | }, 11 | {"name": "Cinema", 12 | "categories": "200-2100", 13 | }, 14 | {"name": "Theatre, Music and Culture", 15 | "categories": "200-2200", 16 | }, 17 | {"name": "Landmark-Attraction", 18 | "categories": "300-3000", 19 | }, 20 | {"name": "Museum", 21 | "categories": "300-3100", 22 | }, 23 | {"name": "Religious Place", 24 | "categories": "300-3200", 25 | }, 26 | {"name": "Body of Water", 27 | "categories": "350-3500", 28 | }, 29 | {"name": "Mountain or Hill", 30 | "categories": "350-3510", 31 | }, 32 | {"name": "Undersea Feature", 33 | "categories": "350-3520", 34 | }, 35 | {"name": "Forest, Heath or Other Vegetation", 36 | "categories": "350-3522", 37 | }, 38 | {"name": "Natural and Geographical", 39 | "categories": "350-3550", 40 | }, 41 | 42 | {"name": "Airport", 43 | "categories": "400-4000", 44 | }, 45 | {"name": "Public Transport", 46 | "categories": "400-4100", 47 | }, 48 | {"name": "Cargo Transportation", 49 | "categories": "400-4200", 50 | }, 51 | {"name": "Rest Area", 52 | "categories": "400-4300", 53 | }, 54 | 55 | {"name": "Hotel-Motel", 56 | "categories": "500-5000", 57 | }, 58 | {"name": "Lodging", 59 | "categories": "500-5100", 60 | }, 61 | 62 | 63 | {"name": "Outdoor-Recreation", 64 | "categories": "550-5510", 65 | }, 66 | {"name": "Leisure", 67 | "categories": "550-5520", 68 | }, 69 | 70 | 71 | {"name": "Convenience Store", 72 | "categories": "600-6000", 73 | }, 74 | {"name": "Mall-Shopping Complex", 75 | "categories": "600-6100", 76 | }, 77 | {"name": "Department Store", 78 | "categories": "600-6200", 79 | }, 80 | {"name": "Food and Drink", 81 | "categories": "600-6300", 82 | }, 83 | {"name": "Drugstore or Pharmacy", 84 | "categories": "600-6400", 85 | }, 86 | {"name": "Electronics", 87 | "categories": "600-6500", 88 | }, 89 | {"name": "Hardware, House and Garden", 90 | "categories": "600-6600", 91 | }, 92 | {"name": "Bookstore", 93 | "categories": "600-6700", 94 | }, 95 | {"name": "Clothing and Accessories", 96 | "categories": "600-6800", 97 | }, 98 | {"name": "Consumer Goods", 99 | "categories": "600-6900", 100 | }, 101 | {"name": "Hair and Beauty", 102 | "categories": "600-6950", 103 | }, 104 | 105 | {"name": "Banking", 106 | "categories": "700-7000", 107 | }, 108 | {"name": "ATM", 109 | "categories": "700-7010", 110 | }, 111 | {"name": "Money-Cash Services", 112 | "categories": "700-7050", 113 | }, 114 | {"name": "Communication-Media", 115 | "categories": "700-7100", 116 | }, 117 | {"name": "Commercial Services", 118 | "categories": "700-7200", 119 | }, 120 | {"name": "Business-Industry", 121 | "categories": "700-7250", 122 | }, 123 | {"name": "Police-Fire-Emergency", 124 | "categories": "700-7300", 125 | }, 126 | {"name": "Consumer Services", 127 | "categories": "700-7400", 128 | }, 129 | {"name": "Post Office", 130 | "categories": "700-7450", 131 | }, 132 | {"name": "Tourist Information", 133 | "categories": "700-7460", 134 | }, 135 | {"name": "Fueling Station", 136 | "categories": "700-7600", 137 | }, 138 | {"name": "Car Dealer-Sales", 139 | "categories": "700-7800", 140 | }, 141 | {"name": "Car Repair-Service", 142 | "categories": "700-7850", 143 | }, 144 | {"name": "Car Rental", 145 | "categories": "700-7851", 146 | }, 147 | {"name": "Truck-Semi Dealer-Services", 148 | "categories": "700-7900", 149 | }, 150 | 151 | 152 | {"name": "Hospital or Health Care Facility", 153 | "categories": "800-8000", 154 | }, 155 | {"name": "Government or Community Facility", 156 | "categories": "800-8100", 157 | }, 158 | {"name": "Education Facility", 159 | "categories": "800-8200", 160 | }, 161 | {"name": "Library", 162 | "categories": "800-8300", 163 | }, 164 | {"name": "Event Spaces", 165 | "categories": "800-8400", 166 | }, 167 | {"name": "Parking", 168 | "categories": "800-8500", 169 | }, 170 | {"name": "Sports Facility-Venue", 171 | "categories": "800-8600", 172 | }, 173 | {"name": "Facilities", 174 | "categories": "800-8700", 175 | }, 176 | 177 | {"name": "City, Town or Village", 178 | "categories": "900-9100", 179 | }, 180 | {"name": "Outdoor Area-Complex", 181 | "categories": "900-9200", 182 | }, 183 | {"name": "Building", 184 | "categories": "900-9300", 185 | }, 186 | {"name": "Administrative Region-Streets", 187 | "categories": "900-9400", 188 | }, 189 | 190 | 191 | ] 192 | for itemID in keys: 193 | if itemID["name"] == categoryName: 194 | 195 | categoryID = itemID["categories"] 196 | break 197 | 198 | 199 | else: 200 | categoryID="" 201 | return categoryID -------------------------------------------------------------------------------- /metadata.txt: -------------------------------------------------------------------------------- 1 | # This file contains metadata for your plugin. Since 2 | # version 2.0 of QGIS this is the proper way to supply 3 | # information about a plugin. The old method of 4 | # embedding metadata in __init__.py will 5 | # is no longer supported since version 2.0. 6 | 7 | # This file should be included when you package your plugin.# Mandatory items: 8 | 9 | [general] 10 | name=Hqgis 11 | qgisMinimumVersion=3.0 12 | description=Routing, Geocoding, POI search, Isochrones with the HERE API. 13 | version=1.2.3 14 | author=Riccardo Klinger 15 | email=riccardo.klinger@gmail.com 16 | 17 | about=Access the HERE API from inside QGIS using your own HERE-API key. Currently supports Geocoding, Routing, POI-search and isochrone analysis. 18 | Attention: The plugin needs to have credentials from HERE. Therefore you need to register a freemium account (free of charge at HERE.com). Fill in the generated API key in the credentials-tab of the plugin. 19 | 20 | tracker=https://github.com/riccardoklinger/Hqgis/issues 21 | repository=https://github.com/riccardoklinger/Hqgis 22 | # End of mandatory metadata 23 | 24 | # Recommended items: 25 | 26 | # Uncomment the following line and add your changelog: 27 | changelog= 1.2.3 fixes issue with distance based isochrones in gui 28 | 1.2.2 fixes issue with fields based geocode in batch mode with housenumbers 29 | 1.2.1 fixes for category mapping in POI Search 30 | 1.2.0 update for newest HERE API V8 31 | 1.1.1 issues with Multipoint layers ( https://github.com/riccardoklinger/Hqg°°Gs/issues/58 ) solved 32 | 1.1.0 application keys are stored in global settings, fix for reverse geocoding 33 | 1.0.1 address issue with POI in GUI box 34 | 1.0 new API connection and authentication, small bugfixes, hdpi support thanks to @tjukanov 35 | 0.4.4 resolved an issue with high-occupancy car routing 36 | 0.4.3 adds POI search to processing toolbox 37 | 0.4.2 removed MacOS directory as reported by Paolo here https://github.com/riccardoklinger/Hqgis/issues/26 38 | 0.4.1 adds geoprocessing capabilities for geoding single field addresses from txt/layer 39 | 0.3.6 bicylce isochrones are not supported by HERE. removed the option 40 | 0.3.5 public transport routes solved 41 | 0.3.4 saving of time attribute in Attribute tabel for Isochrones and Routing 42 | 0.3.3: correct values for attribute "metric" in batch-isochrone mode 43 | 0.3.2: solves issue with distance based isochrones https://github.com/riccardoklinger/Hqgis/issues/16 44 | 0.3.1: respect of traffic in routing and isochrone calculations 45 | 0.2.1: new batch mode for POI search, different name 46 | 0.1.3: rendering of isochrones fixed 47 | 0.1.2: no CRS warning for routes as well 48 | 0.1.1: default CRS for new memory layers 49 | 0.1: initial upload to qgis plugin repo 50 | 51 | # Tags are comma separated with spaces allowed 52 | tags=HERE, routing, python, Isochrone, POI, API 53 | 54 | homepage=https://github.com/riccardoklinger/Hqgis 55 | category=Web 56 | icon=icon.png 57 | # experimental flag 58 | experimental=False 59 | 60 | # deprecated flag (applies to the whole plugin, not just a single version) 61 | deprecated=False 62 | -------------------------------------------------------------------------------- /pb_tool.cfg: -------------------------------------------------------------------------------- 1 | #/*************************************************************************** 2 | # HEREqgis 3 | # 4 | # Configuration file for plugin builder tool (pb_tool) 5 | # Generated by Plugin Builder: http://g-sherman.github.io/Qgis-Plugin-Builder/ 6 | # ------------------- 7 | # begin : 2018-12-22 8 | # copyright : (C) 2018 by Riccardo Klinger 9 | # email : riccardo.klinger@gmail.com 10 | # ***************************************************************************/ 11 | # 12 | #/*************************************************************************** 13 | # * * 14 | # * This program is free software; you can redistribute it and/or modify * 15 | # * it under the terms of the GNU General Public License as published by * 16 | # * the Free Software Foundation; either version 2 of the License, or * 17 | # * (at your option) any later version. * 18 | # * * 19 | # ***************************************************************************/ 20 | # 21 | # 22 | # You can install pb_tool using: 23 | # pip install http://geoapt.net/files/pb_tool.zip 24 | # 25 | # Consider doing your development (and install of pb_tool) in a virtualenv. 26 | # 27 | # For details on setting up and using pb_tool, see: 28 | # http://g-sherman.github.io/plugin_build_tool/ 29 | # 30 | # Issues and pull requests here: 31 | # https://github.com/g-sherman/plugin_build_tool: 32 | # 33 | # Sane defaults for your plugin generated by the Plugin Builder are 34 | # already set below. 35 | # 36 | # As you add Python source files and UI files to your plugin, add 37 | # them to the appropriate [files] section below. 38 | 39 | [plugin] 40 | # Name of the plugin. This is the name of the directory that will 41 | # be created in .qgis2/python/plugins 42 | name: hereqgis 43 | 44 | # Full path to where you want your plugin directory copied. If empty, 45 | # the QGIS default path will be used. Don't include the plugin name in 46 | # the path. 47 | plugin_path: 48 | 49 | [files] 50 | # Python files that should be deployed with the plugin 51 | python_files: __init__.py hereqgis.py hereqgis_dialog.py 52 | 53 | # The main dialog file that is loaded (not compiled) 54 | main_dialog: hereqgis_dialog_base.ui 55 | 56 | # Other ui files for dialogs you create (these will be compiled) 57 | compiled_ui_files: 58 | 59 | # Resource file(s) that will be compiled 60 | resource_files: resources.qrc 61 | 62 | # Other files required for the plugin 63 | extras: metadata.txt icon.png 64 | 65 | # Other directories to be deployed with the plugin. 66 | # These must be subdirectories under the plugin directory 67 | extra_dirs: 68 | 69 | # ISO code(s) for any locales (translations), separated by spaces. 70 | # Corresponding .ts files must exist in the i18n directory 71 | locales: 72 | 73 | [help] 74 | # the built help directory that should be deployed with the plugin 75 | dir: help/build/html 76 | # the name of the directory to target in the deployed plugin 77 | target: help 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /plugin_upload.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf-8 3 | """This script uploads a plugin package on the server. 4 | Authors: A. Pasotti, V. Picavet 5 | git sha : $TemplateVCSFormat 6 | """ 7 | 8 | import sys 9 | import getpass 10 | import xmlrpc.client 11 | from optparse import OptionParser 12 | 13 | # Configuration 14 | PROTOCOL = 'http' 15 | SERVER = 'plugins.qgis.org' 16 | PORT = '80' 17 | ENDPOINT = '/plugins/RPC2/' 18 | VERBOSE = False 19 | 20 | 21 | def main(parameters, arguments): 22 | """Main entry point. 23 | 24 | :param parameters: Command line parameters. 25 | :param arguments: Command line arguments. 26 | """ 27 | address = "%s://%s:%s@%s:%s%s" % ( 28 | PROTOCOL, 29 | parameters.username, 30 | parameters.password, 31 | parameters.server, 32 | parameters.port, 33 | ENDPOINT) 34 | print("Connecting to: %s" % hide_password(address)) 35 | 36 | server = xmlrpc.client.ServerProxy(address, verbose=VERBOSE) 37 | 38 | try: 39 | plugin_id, version_id = server.plugin.upload( 40 | xmlrpc.client.Binary(open(arguments[0]).read())) 41 | print("Plugin ID: %s" % plugin_id) 42 | print("Version ID: %s" % version_id) 43 | except xmlrpc.client.ProtocolError as err: 44 | print("A protocol error occurred") 45 | print("URL: %s" % hide_password(err.url, 0)) 46 | print("HTTP/HTTPS headers: %s" % err.headers) 47 | print("Error code: %d" % err.errcode) 48 | print("Error message: %s" % err.errmsg) 49 | except xmlrpc.client.Fault as err: 50 | print("A fault occurred") 51 | print("Fault code: %d" % err.faultCode) 52 | print("Fault string: %s" % err.faultString) 53 | 54 | 55 | def hide_password(url, start=6): 56 | """Returns the http url with password part replaced with '*'. 57 | 58 | :param url: URL to upload the plugin to. 59 | :type url: str 60 | 61 | :param start: Position of start of password. 62 | :type start: int 63 | """ 64 | start_position = url.find(':', start) + 1 65 | end_position = url.find('@') 66 | return "%s%s%s" % ( 67 | url[:start_position], 68 | '*' * (end_position - start_position), 69 | url[end_position:]) 70 | 71 | 72 | if __name__ == "__main__": 73 | parser = OptionParser(usage="%prog [options] plugin.zip") 74 | parser.add_option( 75 | "-w", "--password", dest="password", 76 | help="Password for plugin site", metavar="******") 77 | parser.add_option( 78 | "-u", "--username", dest="username", 79 | help="Username of plugin site", metavar="user") 80 | parser.add_option( 81 | "-p", "--port", dest="port", 82 | help="Server port to connect to", metavar="80") 83 | parser.add_option( 84 | "-s", "--server", dest="server", 85 | help="Specify server name", metavar="plugins.qgis.org") 86 | options, args = parser.parse_args() 87 | if len(args) != 1: 88 | print("Please specify zip file.\n") 89 | parser.print_help() 90 | sys.exit(1) 91 | if not options.server: 92 | options.server = SERVER 93 | if not options.port: 94 | options.port = PORT 95 | if not options.username: 96 | # interactive mode 97 | username = getpass.getuser() 98 | print("Please enter user name [%s] :" % username, end=' ') 99 | res = input() 100 | if res != "": 101 | options.username = res 102 | else: 103 | options.username = username 104 | if not options.password: 105 | # interactive mode 106 | options.password = getpass.getpass() 107 | main(options, args) 108 | -------------------------------------------------------------------------------- /pylintrc: -------------------------------------------------------------------------------- 1 | [MASTER] 2 | 3 | # Specify a configuration file. 4 | #rcfile= 5 | 6 | # Python code to execute, usually for sys.path manipulation such as 7 | # pygtk.require(). 8 | #init-hook= 9 | 10 | # Profiled execution. 11 | profile=no 12 | 13 | # Add files or directories to the blacklist. They should be base names, not 14 | # paths. 15 | ignore=CVS 16 | 17 | # Pickle collected data for later comparisons. 18 | persistent=yes 19 | 20 | # List of plugins (as comma separated values of python modules names) to load, 21 | # usually to register additional checkers. 22 | load-plugins= 23 | 24 | 25 | [MESSAGES CONTROL] 26 | 27 | # Enable the message, report, category or checker with the given id(s). You can 28 | # either give multiple identifier separated by comma (,) or put this option 29 | # multiple time. See also the "--disable" option for examples. 30 | #enable= 31 | 32 | # Disable the message, report, category or checker with the given id(s). You 33 | # can either give multiple identifiers separated by comma (,) or put this 34 | # option multiple times (only on the command line, not in the configuration 35 | # file where it should appear only once).You can also use "--disable=all" to 36 | # disable everything first and then reenable specific checks. For example, if 37 | # you want to run only the similarities checker, you can use "--disable=all 38 | # --enable=similarities". If you want to run only the classes checker, but have 39 | # no Warning level messages displayed, use"--disable=all --enable=classes 40 | # --disable=W" 41 | # see http://stackoverflow.com/questions/21487025/pylint-locally-defined-disables-still-give-warnings-how-to-suppress-them 42 | disable=locally-disabled,C0103 43 | 44 | 45 | [REPORTS] 46 | 47 | # Set the output format. Available formats are text, parseable, colorized, msvs 48 | # (visual studio) and html. You can also give a reporter class, eg 49 | # mypackage.mymodule.MyReporterClass. 50 | output-format=text 51 | 52 | # Put messages in a separate file for each module / package specified on the 53 | # command line instead of printing them on stdout. Reports (if any) will be 54 | # written in a file name "pylint_global.[txt|html]". 55 | files-output=no 56 | 57 | # Tells whether to display a full report or only the messages 58 | reports=yes 59 | 60 | # Python expression which should return a note less than 10 (10 is the highest 61 | # note). You have access to the variables errors warning, statement which 62 | # respectively contain the number of errors / warnings messages and the total 63 | # number of statements analyzed. This is used by the global evaluation report 64 | # (RP0004). 65 | evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) 66 | 67 | # Add a comment according to your evaluation note. This is used by the global 68 | # evaluation report (RP0004). 69 | comment=no 70 | 71 | # Template used to display messages. This is a python new-style format string 72 | # used to format the message information. See doc for all details 73 | #msg-template= 74 | 75 | 76 | [BASIC] 77 | 78 | # Required attributes for module, separated by a comma 79 | required-attributes= 80 | 81 | # List of builtins function names that should not be used, separated by a comma 82 | bad-functions=map,filter,apply,input 83 | 84 | # Regular expression which should only match correct module names 85 | module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ 86 | 87 | # Regular expression which should only match correct module level names 88 | const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$ 89 | 90 | # Regular expression which should only match correct class names 91 | class-rgx=[A-Z_][a-zA-Z0-9]+$ 92 | 93 | # Regular expression which should only match correct function names 94 | function-rgx=[a-z_][a-z0-9_]{2,30}$ 95 | 96 | # Regular expression which should only match correct method names 97 | method-rgx=[a-z_][a-z0-9_]{2,30}$ 98 | 99 | # Regular expression which should only match correct instance attribute names 100 | attr-rgx=[a-z_][a-z0-9_]{2,30}$ 101 | 102 | # Regular expression which should only match correct argument names 103 | argument-rgx=[a-z_][a-z0-9_]{2,30}$ 104 | 105 | # Regular expression which should only match correct variable names 106 | variable-rgx=[a-z_][a-z0-9_]{2,30}$ 107 | 108 | # Regular expression which should only match correct attribute names in class 109 | # bodies 110 | class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ 111 | 112 | # Regular expression which should only match correct list comprehension / 113 | # generator expression variable names 114 | inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ 115 | 116 | # Good variable names which should always be accepted, separated by a comma 117 | good-names=i,j,k,ex,Run,_ 118 | 119 | # Bad variable names which should always be refused, separated by a comma 120 | bad-names=foo,bar,baz,toto,tutu,tata 121 | 122 | # Regular expression which should only match function or class names that do 123 | # not require a docstring. 124 | no-docstring-rgx=__.*__ 125 | 126 | # Minimum line length for functions/classes that require docstrings, shorter 127 | # ones are exempt. 128 | docstring-min-length=-1 129 | 130 | 131 | [MISCELLANEOUS] 132 | 133 | # List of note tags to take in consideration, separated by a comma. 134 | notes=FIXME,XXX,TODO 135 | 136 | 137 | [TYPECHECK] 138 | 139 | # Tells whether missing members accessed in mixin class should be ignored. A 140 | # mixin class is detected if its name ends with "mixin" (case insensitive). 141 | ignore-mixin-members=yes 142 | 143 | # List of classes names for which member attributes should not be checked 144 | # (useful for classes with attributes dynamically set). 145 | ignored-classes=SQLObject 146 | 147 | # When zope mode is activated, add a predefined set of Zope acquired attributes 148 | # to generated-members. 149 | zope=no 150 | 151 | # List of members which are set dynamically and missed by pylint inference 152 | # system, and so shouldn't trigger E0201 when accessed. Python regular 153 | # expressions are accepted. 154 | generated-members=REQUEST,acl_users,aq_parent 155 | 156 | 157 | [VARIABLES] 158 | 159 | # Tells whether we should check for unused import in __init__ files. 160 | init-import=no 161 | 162 | # A regular expression matching the beginning of the name of dummy variables 163 | # (i.e. not used). 164 | dummy-variables-rgx=_$|dummy 165 | 166 | # List of additional names supposed to be defined in builtins. Remember that 167 | # you should avoid to define new builtins when possible. 168 | additional-builtins= 169 | 170 | 171 | [FORMAT] 172 | 173 | # Maximum number of characters on a single line. 174 | max-line-length=80 175 | 176 | # Regexp for a line that is allowed to be longer than the limit. 177 | ignore-long-lines=^\s*(# )??$ 178 | 179 | # Allow the body of an if to be on the same line as the test if there is no 180 | # else. 181 | single-line-if-stmt=no 182 | 183 | # List of optional constructs for which whitespace checking is disabled 184 | no-space-check=trailing-comma,dict-separator 185 | 186 | # Maximum number of lines in a module 187 | max-module-lines=1000 188 | 189 | # String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 190 | # tab). 191 | indent-string=' ' 192 | 193 | 194 | [SIMILARITIES] 195 | 196 | # Minimum lines number of a similarity. 197 | min-similarity-lines=4 198 | 199 | # Ignore comments when computing similarities. 200 | ignore-comments=yes 201 | 202 | # Ignore docstrings when computing similarities. 203 | ignore-docstrings=yes 204 | 205 | # Ignore imports when computing similarities. 206 | ignore-imports=no 207 | 208 | 209 | [IMPORTS] 210 | 211 | # Deprecated modules which should not be used, separated by a comma 212 | deprecated-modules=regsub,TERMIOS,Bastion,rexec 213 | 214 | # Create a graph of every (i.e. internal and external) dependencies in the 215 | # given file (report RP0402 must not be disabled) 216 | import-graph= 217 | 218 | # Create a graph of external dependencies in the given file (report RP0402 must 219 | # not be disabled) 220 | ext-import-graph= 221 | 222 | # Create a graph of internal dependencies in the given file (report RP0402 must 223 | # not be disabled) 224 | int-import-graph= 225 | 226 | 227 | [DESIGN] 228 | 229 | # Maximum number of arguments for function / method 230 | max-args=5 231 | 232 | # Argument names that match this expression will be ignored. Default to name 233 | # with leading underscore 234 | ignored-argument-names=_.* 235 | 236 | # Maximum number of locals for function / method body 237 | max-locals=15 238 | 239 | # Maximum number of return / yield for function / method body 240 | max-returns=6 241 | 242 | # Maximum number of branch for function / method body 243 | max-branches=12 244 | 245 | # Maximum number of statements in function / method body 246 | max-statements=50 247 | 248 | # Maximum number of parents for a class (see R0901). 249 | max-parents=7 250 | 251 | # Maximum number of attributes for a class (see R0902). 252 | max-attributes=7 253 | 254 | # Minimum number of public methods for a class (see R0903). 255 | min-public-methods=2 256 | 257 | # Maximum number of public methods for a class (see R0904). 258 | max-public-methods=20 259 | 260 | 261 | [CLASSES] 262 | 263 | # List of interface methods to ignore, separated by a comma. This is used for 264 | # instance to not check methods defines in Zope's Interface base class. 265 | ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by 266 | 267 | # List of method names used to declare (i.e. assign) instance attributes. 268 | defining-attr-methods=__init__,__new__,setUp 269 | 270 | # List of valid names for the first argument in a class method. 271 | valid-classmethod-first-arg=cls 272 | 273 | # List of valid names for the first argument in a metaclass class method. 274 | valid-metaclass-classmethod-first-arg=mcs 275 | 276 | 277 | [EXCEPTIONS] 278 | 279 | # Exceptions that will emit a warning when being caught. Defaults to 280 | # "Exception" 281 | overgeneral-exceptions=Exception 282 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Hqgis 2 | Hqgis is a python based plugin for QGIS that offers access to the [HERE API](https://developer.here.com/) and combines different traffic/routing/geocoding actions in one plugin. 3 | With Hqgis you can geocode single and multiple addresses, find routes, places of interests around a or multiple locations and many more. 4 | This plugin is designed to work in QGIS 3.4 and above. 5 | 6 | ## Sponsors 7 | Thank you: 8 | @zoefSmoelt 9 | 10 | ## Contents and Usage 11 | The Hqgis plugin comes with different analytical tools as the HERE API povides different endpoints: 12 | + Geocode 13 | 14 | With the three tools you can geocode a single address, choose a point layer / delimited layer with an address field or a layer with dedicated address-content fields (like street, city, zip code, etc.). You will receive a single point memory layer with found addresses, quality indicators and the original searched address/address content. 15 | ![Geocoding Tab Hqgis](https://i.imgur.com/f1KV0NL.png) 16 | + Routing 17 | 18 | Currently the toolset supports one-to-one routing ("manual input") using different routing types (fast, short, balanced) and routing modes (pedestrian, bicycle, car, ...). The reuslt will be added as a memory layer to your QGIS project. 19 | ![Routing Tab Hqgis](https://i.imgur.com/vJZQSFn.png) 20 | + POI search 21 | 22 | Using the POI search you can query the HERE API for places of interest around an address/coordinate pair in a given vicinity (radius). The API will respond with a maximum of 100 search results in the categories you queried. 23 | ![POI Search Tab Hqgis](https://i.imgur.com/7ALhD7e.png) 24 | 25 | + Isochrone Analysis 26 | 27 | Isochrones, or lines of equal (travel) times are possible to calculated using different modes and types as well as for different times of the day. This can be done on a single address/map point or using a point layer. The result will be color coded (categorized) in QGIS in red (long travel times/distances) to grenn (short travel times/distances). Find some nice examples at [Topi Tjukanovs Homepage](https://tjukanov.org/vintage-isochrones/). 28 | ![Isochrones in HQGIS](https://i.imgur.com/pX9qEeJ.png) 29 | 30 | 31 | ## Installation 32 | Currently the plugin is only hosted here on github as the version is premature. 33 | If you want to use it in QGIS, please download the repository and place the content of the zip in your python plugins folder (linux: */home/USER/.local/share/QGIS/QGIS3/profiles/default/python/plugins* / win: *C:\Users\USER\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins*). You can also install it directly in QGIS using the [plugin from ZIP option](https://gis.stackexchange.com/questions/302196/downloading-and-saving-plugins-for-qgis-3-4) 34 | 35 | ## Credentials 36 | The plugin needs to have credentials from HERE. Therefore you need to register at least a freemium account (free of charge at [HERE.com](https://developer.here.com/) by creating a project and generate a REST API Key if not already generated. 37 | Fill in the generated API Key in the credentials-tab of the plugin and click on "save credentials". 38 | 39 | ![Credential Tab Hqgis](https://i.imgur.com/IPvR5LV.png) 40 | 41 | The credentials will be stored for convenience in a file called credentials.json in the *creds* subfolder of your Hqgis plugin folder (linux: */home/USER/.local/share/QGIS/QGIS3/profiles/default/python/plugins* / win: *C:\Users\USER\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins*). 42 | 43 | ## TOS / Usage 44 | Please take a look at the [*Terms and Contitions*](https://developer.here.com/terms-and-conditions) when using the Freemium plan (as most people might want to...). 45 | Furthermore: 46 | According to the [*Acceptable Use Policy*](https://legal.here.com/en-gb/terms/acceptable-use-policy) you're not allowed to store the results. Yet you can use them *cached* aka work with the memory layer for 30 days max. 47 | Further Questions and Answers can be found at the [*FAQ*](https://developer.here.com/faqs) page as well as the [main page of the freemium model](https://go.engage.here.com/freemium). 48 | 49 | ## Known Limitations 50 | The plugin is using the [requests module](http://docs.python-requests.org/en/master/) at the current stage and is not respecting any proxy settings from QGIS. 51 | -------------------------------------------------------------------------------- /resources.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Resource object code 4 | # 5 | # Created by: The Resource Compiler for PyQt5 (Qt v5.15.10) 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | from PyQt5 import QtCore 10 | 11 | qt_resource_data = b"\ 12 | \x00\x00\x08\x61\ 13 | \x89\ 14 | \x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\ 15 | \x00\x00\x36\x00\x00\x00\x25\x08\x06\x00\x00\x00\x09\x07\x1a\xe8\ 16 | \x00\x00\x00\x04\x73\x42\x49\x54\x08\x08\x08\x08\x7c\x08\x64\x88\ 17 | \x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0e\xc4\x00\x00\x0e\xc4\ 18 | \x01\x95\x2b\x0e\x1b\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\ 19 | \x74\x77\x61\x72\x65\x00\x77\x77\x77\x2e\x69\x6e\x6b\x73\x63\x61\ 20 | \x70\x65\x2e\x6f\x72\x67\x9b\xee\x3c\x1a\x00\x00\x07\xde\x49\x44\ 21 | \x41\x54\x58\x85\xd5\x99\x79\x70\xd5\xd5\x15\xc7\x3f\xe7\xf7\x5e\ 22 | \x16\xf6\x5d\x20\xa2\x75\x92\x30\x12\xa1\xac\x95\x6a\xb1\x33\x50\ 23 | \x2c\x6a\x19\xc0\x32\x10\x09\x50\x29\x4b\x40\x65\xa8\xb8\x21\xc5\ 24 | \xaa\xaf\x4c\x51\x07\x07\x01\x59\x04\x82\xa0\x22\xa2\x6c\xd2\x4e\ 25 | \xa9\x6d\x2d\xa0\xa5\xb6\x15\xa6\x2d\x51\x02\x92\xb0\x0a\x86\x25\ 26 | \x90\xe4\xbd\x2c\x2f\x09\xbf\xdf\x3d\xfd\xe3\x2d\xbc\x24\xef\x41\ 27 | \x42\x30\x69\xbf\x33\x77\xe6\x77\x7f\xe7\x9e\xfb\x3b\xdf\x7b\xce\ 28 | \xbd\xf7\xdc\xfb\x13\x82\xf8\xf5\xa6\xb4\xa9\x8a\xae\x06\x50\x45\ 29 | \x0a\xcf\x55\x7d\xba\xec\xc9\xe3\x8b\x83\xe2\xfd\xc0\x39\xea\x88\ 30 | \xf9\x1b\x7b\x0c\x30\x16\x9f\x87\xea\x15\xe5\xe6\xcc\x2b\x53\x73\ 31 | \x67\x05\xab\x47\x80\xdc\x90\x6c\xd9\x8e\xe4\xef\xaa\xc8\xfd\x62\ 32 | \xb8\x0b\xe1\x76\x20\x09\x68\x03\xd8\x08\x5e\x0c\xa7\x45\xe4\x30\ 33 | \x6a\x3e\x73\xdc\xec\x7c\x7c\xc4\xf1\xaf\xeb\x62\x83\xfb\xca\xa3\ 34 | \x5a\x80\x0b\x40\x04\xf2\x8f\x57\x0c\x01\x86\x04\x85\x3f\x05\x76\ 35 | \xd4\x95\x98\xb1\x54\x40\x5c\xa1\x7a\x49\x91\xfd\x1d\xe0\x77\x21\ 36 | \xde\x9e\xcd\x3d\x17\xb4\x8b\xab\xf8\xb9\x08\xb3\x14\x7a\xa1\xa0\ 37 | \x12\xd1\x81\x02\x10\x8f\xd2\x09\xe8\xa4\xaa\xfd\x41\x26\x88\x8d\ 38 | \xbe\xfe\x61\xca\x6e\x63\x59\xf3\x67\x8f\xca\xfb\x6b\x1d\x89\x35\ 39 | \x0e\x6e\x4d\x4d\x4c\x6e\x1b\x57\x79\x48\x91\x14\xd5\x7a\xab\x0b\ 40 | \x30\x14\xa3\x43\x97\x6c\x4f\xdd\xa3\xc8\xcc\x27\x46\xe7\x1d\x8e\ 41 | \xd6\xd0\x6a\xa8\xa1\xf5\xc5\xed\xfd\x9a\x4f\x30\x4a\x8a\x51\x68\ 42 | \x50\x81\x21\x8a\xee\x7b\x6d\x7b\xca\xb8\xff\x09\x62\x80\x18\x15\ 43 | \x6e\x50\x69\x69\xd4\xda\xb4\x68\x5b\xea\x8b\x35\x3f\xd2\xe8\xa1\ 44 | \x08\x10\x19\x82\x11\x8f\x36\xc8\x5e\x51\xf3\x4f\x44\xce\x05\x1b\ 45 | \x76\x51\x91\xbb\x81\x1f\x12\x9c\xff\xd1\x21\x9e\x85\x5b\x53\x4f\ 46 | \xcf\x19\x73\x74\x5d\xe8\x4d\xa3\x13\xd3\xe0\x68\x47\xc0\x2f\xe8\ 47 | \x32\xeb\xb2\xbc\xfa\xf4\xf8\xdc\x8b\xd1\x74\x5e\xdd\x9e\x72\x93\ 48 | \x63\xac\x79\xa8\x3c\x0a\xc4\x47\xef\x59\x56\x2d\xdc\x9c\x7a\x6c\ 49 | \x4e\xfa\xd1\x4f\xa1\x09\x42\x51\x01\x73\xa5\x1c\x77\xd4\x7c\x6f\ 50 | \xce\xd8\xbc\x67\x63\x91\x02\x78\x66\xf4\xb1\x0b\x73\xc7\xe4\xcd\ 51 | \x56\x87\x7b\x8c\x72\x36\xc6\xbc\x8b\xb3\xb1\xd6\x7a\xd6\xdf\x96\ 52 | \x08\x4d\x45\x2c\xe0\xb5\x63\xaa\xe6\xae\x79\xe9\x47\x0f\xd5\x55\ 53 | \xf7\x97\xe3\x72\xf7\x3b\xc8\x20\x83\x14\x18\x84\x28\x25\xd5\xdd\ 54 | \x3c\x61\x3a\x34\x19\x31\xfc\x8e\xed\x1a\x35\x2f\xfd\x68\x41\x7d\ 55 | \xf5\x9f\x4f\x3f\x72\xc2\x71\x34\x43\x15\xd5\xe8\xab\xe5\x13\x1e\ 56 | \x0f\x56\xe3\x13\x53\xc1\xc0\xeb\x2f\x8c\x3f\x94\x73\xbd\x7d\xbc\ 57 | \x98\x91\xbb\xcb\x20\x3b\x8c\x0a\x5a\xa3\x18\x95\xdb\x48\x4b\xbb\ 58 | \xa7\xd1\x89\x19\x55\x47\xc5\xbd\xb0\xa1\xfd\xa8\x6d\x5e\x89\x36\ 59 | \xd7\x34\x10\x12\xf7\xc7\x5c\x15\xd3\x06\xb6\xe2\xe9\x37\x52\x01\ 60 | \x88\x4f\xb4\xde\x71\xb9\xa5\xaa\xae\x1f\x75\x0c\x6e\x57\x8c\x21\ 61 | \x2b\xf7\x39\x27\x3d\xe9\x39\x85\xf5\xa3\x51\x1b\x9e\xf1\xb9\xfb\ 62 | \x9f\xdf\x94\x96\x4f\x20\xb7\xac\x01\xfd\x7e\x4c\x62\xee\x38\xa1\ 63 | \x65\xdb\xb0\xb8\x55\x43\x0d\x09\xa1\xc4\xeb\x9c\x8a\x25\x2b\x9a\ 64 | \xdf\x7d\xa9\xd5\xbc\x4d\xbb\xf0\x0b\x41\x71\xdb\xbf\x69\xf3\xf8\ 65 | \x81\xbc\x5a\x8d\x05\x35\x1b\xf9\x0c\x18\x5b\xbb\x27\xe9\xde\xe8\ 66 | \xfb\x58\x65\xb9\x53\x12\x4b\xa6\xfe\xc2\x0c\x75\xbb\x3b\x49\x42\ 67 | \xc4\x38\xda\xf1\x3f\xf6\x2d\x1a\x38\xb8\xf5\x53\xfb\x72\x6b\xb6\ 68 | \x37\x62\x7d\x43\xf4\x84\xb3\x43\x4c\x62\xa5\x5e\x9b\x82\x33\x75\ 69 | \x8e\xbe\x6a\x48\x68\x66\x91\x94\x9c\x18\x55\xe6\xd8\x57\x0f\x69\ 70 | \x53\x72\x01\x0b\x88\x20\xd7\x55\x91\x3d\xbe\x45\x03\x87\xd4\x24\ 71 | \xa7\x8e\x7a\xab\xef\xf5\x61\xc4\xc5\x24\x76\xe2\x60\x39\xdb\x96\ 72 | \xe7\x87\xaa\x59\xc0\x97\x57\x33\x28\x12\x77\x0e\x6b\xd7\x23\x29\ 73 | \x39\xf1\xb1\xa8\x5f\x4c\xa4\xf9\xb5\xf4\x6b\x93\xd3\xa4\x68\xe4\ 74 | \x1c\xa4\x2d\x51\x1d\x86\xb7\xae\xa1\xf8\x07\xea\x71\x1e\x1b\x3e\ 75 | \x2d\x69\x20\x8e\x13\x95\x58\x7c\x33\x57\xbb\x68\xef\x6b\xc2\x94\ 76 | \x5c\xc0\xca\xe8\x9b\xed\x4a\x6c\xdd\x32\xfc\x52\xcd\x07\xfe\x29\ 77 | \x77\x3e\xd8\xac\xdd\x8a\x53\x00\x46\xe9\x11\x43\xfd\xfc\xb7\xb3\ 78 | \xdc\x3b\xb6\x89\x25\x6a\xd1\x2e\xbe\x7b\x2c\x99\x22\xcf\x11\x91\ 79 | \x17\x4b\x7c\x71\x67\x23\xa5\x29\xea\x32\x81\xe2\xa6\x6f\xd5\xe5\ 80 | \xaa\x4f\xca\x2f\xcd\xea\x06\x60\x54\x56\xab\xca\x65\xad\x95\xf5\ 81 | \x93\xdd\xe8\xfb\x98\x3b\xc1\xea\xf4\xe4\xdb\x77\xf4\x8b\x26\xeb\ 82 | \xf0\xf2\xc5\x2c\x45\x66\x10\x41\x4e\x4d\x11\x7b\x8f\x15\xec\xff\ 83 | \x38\xaf\x2c\xe7\xe3\xbc\xb2\x9c\xbf\xe4\x95\x95\xbd\xff\x9f\xb3\ 84 | \x1b\x96\xfc\x36\xa3\xf3\xe2\x49\x07\x3f\x34\xe8\x78\xa3\xd8\x1a\ 85 | \xdc\xc3\x54\xc1\x60\xfd\xa3\x09\x32\x0f\x70\x54\x16\xc4\x92\x47\ 86 | \x23\xb7\xef\xd4\xc9\x9b\xff\x7d\xfa\x4c\xcf\xc3\xe7\xbd\x3d\x0f\ 87 | \x9f\xf7\xf6\xcc\xf7\xf9\x07\x97\x9a\xd2\xdd\x8b\xff\x38\xba\xeb\ 88 | \x92\x49\x39\x5b\x1d\xd1\x0c\x03\x76\x30\xb1\x36\x8e\x5d\xb5\xbd\ 89 | \x49\x72\x45\x47\xad\x07\x66\xad\xef\x35\x25\x56\x9b\x0e\x2f\x5f\ 90 | \xcc\x42\x08\x5d\xfe\x60\x10\xbc\xfe\x22\xca\x2a\x4b\xaf\x84\x9b\ 91 | \xd1\x3b\x4a\xcb\x2f\xef\xf2\x6c\x1e\xdb\x65\xd9\xa4\x9c\xad\x46\ 92 | \x65\x92\x51\x71\x8c\x91\x3f\x2d\x9f\x7a\x24\xbf\xf1\x4f\xd0\xa1\ 93 | \x70\x51\x59\xf9\xd8\x9b\xbd\x86\xc5\x6a\xd6\xfe\xa5\x4b\x2b\x54\ 94 | \x78\x01\x30\xa1\x64\xd7\xeb\x2f\xa4\xac\xb2\x24\x9c\x3e\x39\x46\ 95 | \xd3\x70\xf9\x77\x7b\x36\x8f\xed\xb2\x7c\xf2\x97\xef\x29\x3a\xd9\ 96 | \xa8\xf5\x12\x80\x75\x69\x5e\xfb\x74\x80\xaa\x0a\x13\x17\xed\x03\ 97 | \x96\xc0\xce\x89\xad\xd3\x83\xd5\x78\xa0\x7d\xc3\x78\x85\x27\x79\ 98 | \x82\x62\xed\x7c\x64\x5d\xef\x5f\x78\x3c\xd1\x4f\x19\x6d\x93\x3e\ 99 | \xca\x12\xf4\x61\x5b\x45\x43\x9e\x0a\x79\x4e\x91\x40\x51\x49\x33\ 100 | \x56\xc5\x9e\x05\xdb\x46\x77\x5d\x31\xf9\xe0\x86\x95\x53\xb3\xff\ 101 | \x16\xb0\x5b\xe5\xdd\xc2\xb9\x1d\x33\x3e\xff\x73\xd1\x98\x9a\x1d\ 102 | \x0b\xb0\x70\x58\x0b\xfa\x74\x89\xbb\x17\x88\x03\x36\x03\x31\x57\ 103 | \xb5\xba\x11\xab\x76\xd0\x74\xab\x61\xe9\xd9\x6e\xbd\xff\x35\x23\ 104 | \xab\xf7\x98\xe9\xab\x07\xd4\xda\xe3\xda\x24\x7d\xb4\xb1\xa8\xcc\ 105 | \x9e\xad\x8a\x6d\x22\x3c\x57\x1a\xe1\x39\x55\x7a\xf8\x9d\xcb\x7b\ 106 | \x9f\xdb\x34\xea\x96\x90\x9e\x05\x58\x88\x6e\x18\x92\xa8\xb7\xd6\ 107 | \x22\x75\x5f\x0b\xa6\xf4\x4f\x44\x02\xb7\x7e\x1b\x80\x51\x41\xd1\ 108 | \xf5\x13\x53\xaa\x2f\xcd\x81\x03\x62\x5f\x23\xb2\x45\x2d\xfb\xe2\ 109 | \xb4\xb5\xbd\xff\x9e\xf9\x66\xdf\x2d\x99\x6b\xfb\xbc\x33\x2d\xab\ 110 | \xcf\x43\x00\xab\x33\xbf\xd8\xaa\x58\xe3\x15\xb1\x43\x9e\xf2\xf9\ 111 | \x8b\x28\xad\xba\x32\xe7\x14\x49\x51\x97\xee\x09\x91\xb3\x82\x83\ 112 | \xe7\x9a\xde\x59\x93\x93\xbd\x55\xe1\x61\x1d\x97\x68\x33\xb5\x7f\ 113 | \x20\x2d\x2a\xbb\xac\xad\x80\x87\x22\x06\xe3\xfa\x89\x71\xd5\x2b\ 114 | \xb5\x66\xaa\x72\xb7\x31\x3a\xc6\x28\x3f\x53\xd8\x38\x25\xab\xf7\ 115 | \xc3\x00\x6b\xa6\x1d\xd8\xa2\xca\x44\xa3\x38\xa1\xf6\xbe\xf2\x42\ 116 | \xca\xaa\x4a\x50\xc2\x4b\x68\x8a\x71\x99\x4f\x9e\xdd\x3c\xe2\x56\ 117 | \x2b\xf4\xce\x25\xc8\x03\x5f\xfb\x48\xf6\x55\x31\xe8\x5c\x19\x3f\ 118 | \x8a\x73\xc2\xc6\xd8\x86\x84\x08\xdb\x1a\xe4\x31\xbb\x52\x8b\xeb\ 119 | \x71\xbd\xe6\x52\xb5\xde\x9a\xb2\xa6\xdf\x23\x00\x6b\x33\xb3\x3f\ 120 | \x30\x90\x69\x54\x4c\x78\xce\x95\x07\xe7\x5c\xf0\xa0\x89\x5a\xc9\ 121 | \x18\x96\x86\x3c\x06\x80\x4b\x95\xe1\x27\xbd\x0c\x28\x28\xaf\x66\ 122 | \x8c\x55\x9d\x4a\x83\x3c\x76\x64\x6f\x61\x96\x41\x57\x45\x8e\xfc\ 123 | \x35\x8a\x38\xaa\x2b\x26\xad\xea\x37\x15\x60\x7d\x66\xf6\x7a\x45\ 124 | \x33\x8d\x62\x42\x6d\x8a\xcb\x0b\x29\xa9\xf0\x45\xcc\x39\x49\x08\ 125 | \x7b\x2c\x84\x68\xee\x90\xab\x56\xeb\x87\x2a\xbf\xed\x7f\x7b\x7a\ 126 | \xf6\xa3\xc6\x32\xdd\x1d\x95\xd7\x14\xc9\xaf\x83\xe7\x2c\x03\x6b\ 127 | \x26\xae\xec\x37\x12\xe0\xad\xe9\xd9\xeb\x1c\x98\x61\xaa\xad\x96\ 128 | \xc5\x41\x72\x82\x21\x70\xaf\x18\x33\xaf\x0b\x33\xa9\xa7\xc7\x2c\ 129 | \x75\xf9\x8d\x98\x1c\x80\x92\x62\xbb\x73\xe1\xb9\xaa\x8e\x35\xdb\ 130 | \x6c\xc8\xfc\xe2\x04\xf0\x94\xc7\xc3\x33\x5f\x75\xee\xd3\xc7\xa5\ 131 | \xae\x1f\xa8\x68\x0f\x44\xba\x89\x6a\x4b\x44\x2a\x51\xbd\x28\x2a\ 132 | \x05\x8a\x39\xe8\x68\xdc\xee\xf7\x67\xee\x3f\x1d\xd2\x7f\x77\xc6\ 133 | \x81\xb5\x13\xde\xe8\x2b\x20\xab\x09\x0e\xb6\xd7\x5f\x8c\x51\x68\ 134 | \x11\xdf\x0a\x29\x9c\xdb\xfe\xf7\x88\x0c\xbf\x9a\xa1\x87\x0b\x1c\ 135 | \x06\xad\x2d\x0e\x55\x87\x02\xbb\xaf\x45\x2e\x02\xc3\x08\xdc\xe4\ 136 | \x86\xb0\xa7\x9e\xfa\x57\xc5\xb8\x95\xfd\x67\x8a\xf0\x20\x10\x8e\ 137 | \xbd\x56\x09\x6d\xf6\x89\xce\x4a\x4d\x28\x6a\x59\xb8\x1d\xe4\x27\ 138 | \xd1\x14\xcf\xf8\x0c\x23\x36\x7a\x39\x55\x6c\x00\xb2\x09\xfc\x5a\ 139 | \x2a\xba\x51\x86\x7d\x5b\xb0\x64\xd9\xd1\xca\xb2\x8a\xe6\x63\x14\ 140 | \x76\xd5\x14\x7e\xe3\x33\x8c\xdc\xe8\x0b\x91\xfa\x0a\xb8\x8f\xff\ 141 | \x03\x52\x10\x9c\x2f\xb7\x2c\x3e\xe3\xaf\x4c\x48\x18\x49\x20\x4c\ 142 | \x00\xc8\x2f\x31\x8c\x7c\xcf\xc7\xc9\x62\x07\x02\x7f\x21\x87\x00\ 143 | \xe7\x9b\xc4\xca\xeb\x40\xb5\x65\x21\xdf\x93\xd4\x3c\xb1\xb2\x72\ 144 | \xa7\x63\xb4\xd7\xe0\x75\xde\xca\x9c\x02\xe7\x66\x02\xbf\x55\x07\ 145 | \x03\x67\x9b\xc2\xc0\x1b\x86\x82\x39\x1d\x5b\x15\xff\xea\xa6\x14\ 146 | \x02\x39\xe1\x6e\xa0\x6b\x13\x9b\x74\x5d\xf8\x2f\x17\xe3\x90\xa2\ 147 | \x4d\x95\xa7\xe1\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\ 148 | \ 149 | " 150 | 151 | qt_resource_name = b"\ 152 | \x00\x07\ 153 | \x07\x3b\xe0\xb3\ 154 | \x00\x70\ 155 | \x00\x6c\x00\x75\x00\x67\x00\x69\x00\x6e\x00\x73\ 156 | \x00\x08\ 157 | \x0c\x8c\x73\xc3\ 158 | \x00\x68\ 159 | \x00\x65\x00\x72\x00\x65\x00\x71\x00\x67\x00\x69\x00\x73\ 160 | \x00\x08\ 161 | \x0a\x61\x5a\xa7\ 162 | \x00\x69\ 163 | \x00\x63\x00\x6f\x00\x6e\x00\x2e\x00\x70\x00\x6e\x00\x67\ 164 | " 165 | 166 | qt_resource_struct_v1 = b"\ 167 | \x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\ 168 | \x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x02\ 169 | \x00\x00\x00\x14\x00\x02\x00\x00\x00\x01\x00\x00\x00\x03\ 170 | \x00\x00\x00\x2a\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\ 171 | " 172 | 173 | qt_resource_struct_v2 = b"\ 174 | \x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\ 175 | \x00\x00\x00\x00\x00\x00\x00\x00\ 176 | \x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x02\ 177 | \x00\x00\x00\x00\x00\x00\x00\x00\ 178 | \x00\x00\x00\x14\x00\x02\x00\x00\x00\x01\x00\x00\x00\x03\ 179 | \x00\x00\x00\x00\x00\x00\x00\x00\ 180 | \x00\x00\x00\x2a\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\ 181 | \x00\x00\x01\x8b\x0a\x60\xed\x9e\ 182 | " 183 | 184 | qt_version = [int(v) for v in QtCore.qVersion().split('.')] 185 | if qt_version < [5, 8, 0]: 186 | rcc_version = 1 187 | qt_resource_struct = qt_resource_struct_v1 188 | else: 189 | rcc_version = 2 190 | qt_resource_struct = qt_resource_struct_v2 191 | 192 | def qInitResources(): 193 | QtCore.qRegisterResourceData(rcc_version, qt_resource_struct, qt_resource_name, qt_resource_data) 194 | 195 | def qCleanupResources(): 196 | QtCore.qUnregisterResourceData(rcc_version, qt_resource_struct, qt_resource_name, qt_resource_data) 197 | 198 | qInitResources() 199 | -------------------------------------------------------------------------------- /resources.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | icon.png 4 | 5 | 6 | -------------------------------------------------------------------------------- /scripts/compile-strings.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | LRELEASE=$1 3 | LOCALES=$2 4 | 5 | 6 | for LOCALE in ${LOCALES} 7 | do 8 | echo "Processing: ${LOCALE}.ts" 9 | # Note we don't use pylupdate with qt .pro file approach as it is flakey 10 | # about what is made available. 11 | $LRELEASE i18n/${LOCALE}.ts 12 | done 13 | -------------------------------------------------------------------------------- /scripts/run-env-linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | QGIS_PREFIX_PATH=/usr/local/qgis-2.0 4 | if [ -n "$1" ]; then 5 | QGIS_PREFIX_PATH=$1 6 | fi 7 | 8 | echo ${QGIS_PREFIX_PATH} 9 | 10 | 11 | export QGIS_PREFIX_PATH=${QGIS_PREFIX_PATH} 12 | export QGIS_PATH=${QGIS_PREFIX_PATH} 13 | export LD_LIBRARY_PATH=${QGIS_PREFIX_PATH}/lib 14 | export PYTHONPATH=${QGIS_PREFIX_PATH}/share/qgis/python:${QGIS_PREFIX_PATH}/share/qgis/python/plugins:${PYTHONPATH} 15 | 16 | echo "QGIS PATH: $QGIS_PREFIX_PATH" 17 | export QGIS_DEBUG=0 18 | export QGIS_LOG_FILE=/tmp/inasafe/realtime/logs/qgis.log 19 | 20 | export PATH=${QGIS_PREFIX_PATH}/bin:$PATH 21 | 22 | echo "This script is intended to be sourced to set up your shell to" 23 | echo "use a QGIS 2.0 built in $QGIS_PREFIX_PATH" 24 | echo 25 | echo "To use it do:" 26 | echo "source $BASH_SOURCE /your/optional/install/path" 27 | echo 28 | echo "Then use the make file supplied here e.g. make guitest" 29 | -------------------------------------------------------------------------------- /scripts/update-strings.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | LOCALES=$* 3 | 4 | # Get newest .py files so we don't update strings unnecessarily 5 | 6 | CHANGED_FILES=0 7 | PYTHON_FILES=`find . -regex ".*\(ui\|py\)$" -type f` 8 | for PYTHON_FILE in $PYTHON_FILES 9 | do 10 | CHANGED=$(stat -c %Y $PYTHON_FILE) 11 | if [ ${CHANGED} -gt ${CHANGED_FILES} ] 12 | then 13 | CHANGED_FILES=${CHANGED} 14 | fi 15 | done 16 | 17 | # Qt translation stuff 18 | # for .ts file 19 | UPDATE=false 20 | for LOCALE in ${LOCALES} 21 | do 22 | TRANSLATION_FILE="i18n/$LOCALE.ts" 23 | if [ ! -f ${TRANSLATION_FILE} ] 24 | then 25 | # Force translation string collection as we have a new language file 26 | touch ${TRANSLATION_FILE} 27 | UPDATE=true 28 | break 29 | fi 30 | 31 | MODIFICATION_TIME=$(stat -c %Y ${TRANSLATION_FILE}) 32 | if [ ${CHANGED_FILES} -gt ${MODIFICATION_TIME} ] 33 | then 34 | # Force translation string collection as a .py file has been updated 35 | UPDATE=true 36 | break 37 | fi 38 | done 39 | 40 | if [ ${UPDATE} == true ] 41 | # retrieve all python files 42 | then 43 | print ${PYTHON_FILES} 44 | # update .ts 45 | echo "Please provide translations by editing the translation files below:" 46 | for LOCALE in ${LOCALES} 47 | do 48 | echo "i18n/"${LOCALE}".ts" 49 | # Note we don't use pylupdate with qt .pro file approach as it is flakey 50 | # about what is made available. 51 | pylupdate4 -noobsolete ${PYTHON_FILES} -ts i18n/${LOCALE}.ts 52 | done 53 | else 54 | echo "No need to edit any translation files (.ts) because no python files" 55 | echo "has been updated since the last update translation. " 56 | fi 57 | -------------------------------------------------------------------------------- /target.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/riccardoklinger/Hqgis/087923c59d0f9f7970c4579b43f650201ea9550b/target.png -------------------------------------------------------------------------------- /test/__init__.py: -------------------------------------------------------------------------------- 1 | # import qgis libs so that ve set the correct sip api version 2 | import qgis # pylint: disable=W0611 # NOQA -------------------------------------------------------------------------------- /test/qgis_interface.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """QGIS plugin implementation. 3 | 4 | .. note:: This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | .. note:: This source code was copied from the 'postgis viewer' application 10 | with original authors: 11 | Copyright (c) 2010 by Ivan Mincik, ivan.mincik@gista.sk 12 | Copyright (c) 2011 German Carrillo, geotux_tuxman@linuxmail.org 13 | Copyright (c) 2014 Tim Sutton, tim@linfiniti.com 14 | 15 | """ 16 | 17 | __author__ = 'tim@linfiniti.com' 18 | __revision__ = '$Format:%H$' 19 | __date__ = '10/01/2011' 20 | __copyright__ = ( 21 | 'Copyright (c) 2010 by Ivan Mincik, ivan.mincik@gista.sk and ' 22 | 'Copyright (c) 2011 German Carrillo, geotux_tuxman@linuxmail.org' 23 | 'Copyright (c) 2014 Tim Sutton, tim@linfiniti.com' 24 | ) 25 | 26 | import logging 27 | from PyQt5.QtCore import QObject, pyqtSlot, pyqtSignal 28 | from qgis.core import QgsMapLayerRegistry 29 | from qgis.gui import QgsMapCanvasLayer 30 | LOGGER = logging.getLogger('QGIS') 31 | 32 | 33 | # noinspection PyMethodMayBeStatic,PyPep8Naming 34 | class QgisInterface(QObject): 35 | """Class to expose QGIS objects and functions to plugins. 36 | 37 | This class is here for enabling us to run unit tests only, 38 | so most methods are simply stubs. 39 | """ 40 | currentLayerChanged = pyqtSignal(QgsMapCanvasLayer) 41 | 42 | def __init__(self, canvas): 43 | """Constructor 44 | :param canvas: 45 | """ 46 | QObject.__init__(self) 47 | self.canvas = canvas 48 | # Set up slots so we can mimic the behaviour of QGIS when layers 49 | # are added. 50 | LOGGER.debug('Initialising canvas...') 51 | # noinspection PyArgumentList 52 | QgsMapLayerRegistry.instance().layersAdded.connect(self.addLayers) 53 | # noinspection PyArgumentList 54 | QgsMapLayerRegistry.instance().layerWasAdded.connect(self.addLayer) 55 | # noinspection PyArgumentList 56 | QgsMapLayerRegistry.instance().removeAll.connect(self.removeAllLayers) 57 | 58 | # For processing module 59 | self.destCrs = None 60 | 61 | @pyqtSlot('QStringList') 62 | def addLayers(self, layers): 63 | """Handle layers being added to the registry so they show up in canvas. 64 | 65 | :param layers: list list of map layers that were added 66 | 67 | .. note:: The QgsInterface api does not include this method, 68 | it is added here as a helper to facilitate testing. 69 | """ 70 | #LOGGER.debug('addLayers called on qgis_interface') 71 | #LOGGER.debug('Number of layers being added: %s' % len(layers)) 72 | #LOGGER.debug('Layer Count Before: %s' % len(self.canvas.layers())) 73 | current_layers = self.canvas.layers() 74 | final_layers = [] 75 | for layer in current_layers: 76 | final_layers.append(QgsMapCanvasLayer(layer)) 77 | for layer in layers: 78 | final_layers.append(QgsMapCanvasLayer(layer)) 79 | 80 | self.canvas.setLayerSet(final_layers) 81 | #LOGGER.debug('Layer Count After: %s' % len(self.canvas.layers())) 82 | 83 | @pyqtSlot('QgsMapLayer') 84 | def addLayer(self, layer): 85 | """Handle a layer being added to the registry so it shows up in canvas. 86 | 87 | :param layer: list list of map layers that were added 88 | 89 | .. note: The QgsInterface api does not include this method, it is added 90 | here as a helper to facilitate testing. 91 | 92 | .. note: The addLayer method was deprecated in QGIS 1.8 so you should 93 | not need this method much. 94 | """ 95 | pass 96 | 97 | @pyqtSlot() 98 | def removeAllLayers(self): 99 | """Remove layers from the canvas before they get deleted.""" 100 | self.canvas.setLayerSet([]) 101 | 102 | def newProject(self): 103 | """Create new project.""" 104 | # noinspection PyArgumentList 105 | QgsMapLayerRegistry.instance().removeAllMapLayers() 106 | 107 | # ---------------- API Mock for QgsInterface follows ------------------- 108 | 109 | def zoomFull(self): 110 | """Zoom to the map full extent.""" 111 | pass 112 | 113 | def zoomToPrevious(self): 114 | """Zoom to previous view extent.""" 115 | pass 116 | 117 | def zoomToNext(self): 118 | """Zoom to next view extent.""" 119 | pass 120 | 121 | def zoomToActiveLayer(self): 122 | """Zoom to extent of active layer.""" 123 | pass 124 | 125 | def addVectorLayer(self, path, base_name, provider_key): 126 | """Add a vector layer. 127 | 128 | :param path: Path to layer. 129 | :type path: str 130 | 131 | :param base_name: Base name for layer. 132 | :type base_name: str 133 | 134 | :param provider_key: Provider key e.g. 'ogr' 135 | :type provider_key: str 136 | """ 137 | pass 138 | 139 | def addRasterLayer(self, path, base_name): 140 | """Add a raster layer given a raster layer file name 141 | 142 | :param path: Path to layer. 143 | :type path: str 144 | 145 | :param base_name: Base name for layer. 146 | :type base_name: str 147 | """ 148 | pass 149 | 150 | def activeLayer(self): 151 | """Get pointer to the active layer (layer selected in the legend).""" 152 | # noinspection PyArgumentList 153 | layers = QgsMapLayerRegistry.instance().mapLayers() 154 | for item in layers: 155 | return layers[item] 156 | 157 | def addToolBarIcon(self, action): 158 | """Add an icon to the plugins toolbar. 159 | 160 | :param action: Action to add to the toolbar. 161 | :type action: QAction 162 | """ 163 | pass 164 | 165 | def removeToolBarIcon(self, action): 166 | """Remove an action (icon) from the plugin toolbar. 167 | 168 | :param action: Action to add to the toolbar. 169 | :type action: QAction 170 | """ 171 | pass 172 | 173 | def addToolBar(self, name): 174 | """Add toolbar with specified name. 175 | 176 | :param name: Name for the toolbar. 177 | :type name: str 178 | """ 179 | pass 180 | 181 | def mapCanvas(self): 182 | """Return a pointer to the map canvas.""" 183 | return self.canvas 184 | 185 | def mainWindow(self): 186 | """Return a pointer to the main window. 187 | 188 | In case of QGIS it returns an instance of QgisApp. 189 | """ 190 | pass 191 | 192 | def addDockWidget(self, area, dock_widget): 193 | """Add a dock widget to the main window. 194 | 195 | :param area: Where in the ui the dock should be placed. 196 | :type area: 197 | 198 | :param dock_widget: A dock widget to add to the UI. 199 | :type dock_widget: QDockWidget 200 | """ 201 | pass 202 | 203 | def legendInterface(self): 204 | """Get the legend.""" 205 | return self.canvas 206 | -------------------------------------------------------------------------------- /test/tenbytenraster.asc: -------------------------------------------------------------------------------- 1 | NCOLS 10 2 | NROWS 10 3 | XLLCENTER 1535380.000000 4 | YLLCENTER 5083260.000000 5 | DX 10 6 | DY 10 7 | NODATA_VALUE -9999 8 | 0 1 2 3 4 5 6 7 8 9 9 | 0 1 2 3 4 5 6 7 8 9 10 | 0 1 2 3 4 5 6 7 8 9 11 | 0 1 2 3 4 5 6 7 8 9 12 | 0 1 2 3 4 5 6 7 8 9 13 | 0 1 2 3 4 5 6 7 8 9 14 | 0 1 2 3 4 5 6 7 8 9 15 | 0 1 2 3 4 5 6 7 8 9 16 | 0 1 2 3 4 5 6 7 8 9 17 | 0 1 2 3 4 5 6 7 8 9 18 | CRS 19 | NOTES 20 | -------------------------------------------------------------------------------- /test/tenbytenraster.asc.aux.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Point 4 | 5 | 6 | 7 | 9 8 | 4.5 9 | 0 10 | 2.872281323269 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /test/tenbytenraster.keywords: -------------------------------------------------------------------------------- 1 | title: Tenbytenraster 2 | -------------------------------------------------------------------------------- /test/tenbytenraster.lic: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Tim Sutton, Linfiniti Consulting CC 5 | 6 | 7 | 8 | tenbytenraster.asc 9 | 2700044251 10 | Yes 11 | Tim Sutton 12 | Tim Sutton (QGIS Source Tree) 13 | Tim Sutton 14 | This data is publicly available from QGIS Source Tree. The original 15 | file was created and contributed to QGIS by Tim Sutton. 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /test/tenbytenraster.prj: -------------------------------------------------------------------------------- 1 | GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]] -------------------------------------------------------------------------------- /test/tenbytenraster.qml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 0 26 | 27 | -------------------------------------------------------------------------------- /test/test_hereqgis_dialog.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """Dialog test. 3 | 4 | .. note:: This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | """ 10 | 11 | __author__ = 'riccardo.klinger@gmail.com' 12 | __date__ = '2018-12-22' 13 | __copyright__ = 'Copyright 2018, Riccardo Klinger' 14 | 15 | import unittest 16 | 17 | from PyQt5.QtGui import QDialogButtonBox, QDialog 18 | 19 | from hereqgis_dialog import HEREqgisDialog 20 | 21 | from utilities import get_qgis_app 22 | QGIS_APP = get_qgis_app() 23 | 24 | 25 | class HEREqgisDialogTest(unittest.TestCase): 26 | """Test dialog works.""" 27 | 28 | def setUp(self): 29 | """Runs before each test.""" 30 | self.dialog = HEREqgisDialog(None) 31 | 32 | def tearDown(self): 33 | """Runs after each test.""" 34 | self.dialog = None 35 | 36 | def test_dialog_ok(self): 37 | """Test we can click OK.""" 38 | 39 | button = self.dialog.button_box.button(QDialogButtonBox.Ok) 40 | button.click() 41 | result = self.dialog.result() 42 | self.assertEqual(result, QDialog.Accepted) 43 | 44 | def test_dialog_cancel(self): 45 | """Test we can click cancel.""" 46 | button = self.dialog.button_box.button(QDialogButtonBox.Cancel) 47 | button.click() 48 | result = self.dialog.result() 49 | self.assertEqual(result, QDialog.Rejected) 50 | 51 | 52 | if __name__ == "__main__": 53 | suite = unittest.makeSuite(HEREqgisDialogTest) 54 | runner = unittest.TextTestRunner(verbosity=2) 55 | runner.run(suite) 56 | -------------------------------------------------------------------------------- /test/test_init.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """Tests QGIS plugin init.""" 3 | 4 | __author__ = 'Tim Sutton ' 5 | __revision__ = '$Format:%H$' 6 | __date__ = '17/10/2010' 7 | __license__ = "GPL" 8 | __copyright__ = 'Copyright 2012, Australia Indonesia Facility for ' 9 | import configparser 10 | import logging 11 | import unittest 12 | import os 13 | __copyright__ += 'Disaster Reduction' 14 | 15 | 16 | LOGGER = logging.getLogger('QGIS') 17 | 18 | 19 | class TestInit(unittest.TestCase): 20 | """Test that the plugin init is usable for QGIS. 21 | 22 | Based heavily on the validator class by Alessandro 23 | Passoti available here: 24 | 25 | http://github.com/qgis/qgis-django/blob/master/qgis-app/ 26 | plugins/validator.py 27 | 28 | """ 29 | 30 | def test_read_init(self): 31 | """Test that the plugin __init__ will validate on plugins.qgis.org.""" 32 | 33 | # You should update this list according to the latest in 34 | # https://github.com/qgis/qgis-django/blob/master/qgis-app/ 35 | # plugins/validator.py 36 | 37 | required_metadata = [ 38 | 'name', 39 | 'description', 40 | 'version', 41 | 'qgisMinimumVersion', 42 | 'email', 43 | 'author'] 44 | 45 | file_path = os.path.abspath(os.path.join( 46 | os.path.dirname(__file__), os.pardir, 47 | 'metadata.txt')) 48 | LOGGER.info(file_path) 49 | metadata = [] 50 | parser = configparser.ConfigParser() 51 | parser.optionxform = str 52 | parser.read(file_path) 53 | message = 'Cannot find a section named "general" in %s' % file_path 54 | assert parser.has_section('general'), message 55 | metadata.extend(parser.items('general')) 56 | 57 | for expectation in required_metadata: 58 | message = ('Cannot find metadata "%s" in metadata source (%s).' % ( 59 | expectation, file_path)) 60 | 61 | self.assertIn(expectation, dict(metadata), message) 62 | 63 | 64 | if __name__ == '__main__': 65 | unittest.main() 66 | -------------------------------------------------------------------------------- /test/test_qgis_environment.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """Tests for QGIS functionality. 3 | 4 | 5 | .. note:: This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | """ 11 | __author__ = 'tim@linfiniti.com' 12 | __date__ = '20/01/2011' 13 | __copyright__ = ('Copyright 2012, Australia Indonesia Facility for ' 14 | 'Disaster Reduction') 15 | 16 | import os 17 | import unittest 18 | from qgis.core import ( 19 | QgsProviderRegistry, 20 | QgsCoordinateReferenceSystem, 21 | QgsRasterLayer) 22 | 23 | from .utilities import get_qgis_app 24 | QGIS_APP = get_qgis_app() 25 | 26 | 27 | class QGISTest(unittest.TestCase): 28 | """Test the QGIS Environment""" 29 | 30 | def test_qgis_environment(self): 31 | """QGIS environment has the expected providers""" 32 | 33 | r = QgsProviderRegistry.instance() 34 | self.assertIn('gdal', r.providerList()) 35 | self.assertIn('ogr', r.providerList()) 36 | self.assertIn('postgres', r.providerList()) 37 | 38 | def test_projection(self): 39 | """Test that QGIS properly parses a wkt string. 40 | """ 41 | crs = QgsCoordinateReferenceSystem() 42 | wkt = ( 43 | 'GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",' 44 | 'SPHEROID["WGS_1984",6378137.0,298.257223563]],' 45 | 'PRIMEM["Greenwich",0.0],UNIT["Degree",' 46 | '0.0174532925199433]]') 47 | crs.createFromWkt(wkt) 48 | auth_id = crs.authid() 49 | expected_auth_id = 'EPSG:4326' 50 | self.assertEqual(auth_id, expected_auth_id) 51 | 52 | # now test for a loaded layer 53 | path = os.path.join(os.path.dirname(__file__), 'tenbytenraster.asc') 54 | title = 'TestRaster' 55 | layer = QgsRasterLayer(path, title) 56 | auth_id = layer.crs().authid() 57 | self.assertEqual(auth_id, expected_auth_id) 58 | 59 | 60 | if __name__ == '__main__': 61 | unittest.main() 62 | -------------------------------------------------------------------------------- /test/test_resources.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """Resources test. 3 | 4 | .. note:: This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | """ 10 | 11 | __author__ = 'riccardo.klinger@gmail.com' 12 | __date__ = '2018-12-22' 13 | __copyright__ = 'Copyright 2018, Riccardo Klinger' 14 | 15 | import unittest 16 | 17 | from PyQt5.QtGui import QIcon 18 | 19 | 20 | class HEREqgisDialogTest(unittest.TestCase): 21 | """Test rerources work.""" 22 | 23 | def setUp(self): 24 | """Runs before each test.""" 25 | pass 26 | 27 | def tearDown(self): 28 | """Runs after each test.""" 29 | pass 30 | 31 | def test_icon_png(self): 32 | """Test we can click OK.""" 33 | path = ':/plugins/HEREqgis/icon.png' 34 | icon = QIcon(path) 35 | self.assertFalse(icon.isNull()) 36 | 37 | 38 | if __name__ == "__main__": 39 | suite = unittest.makeSuite(HEREqgisResourcesTest) 40 | runner = unittest.TextTestRunner(verbosity=2) 41 | runner.run(suite) 42 | -------------------------------------------------------------------------------- /test/test_translations.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """Safe Translations Test. 3 | 4 | .. note:: This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | """ 10 | from .utilities import get_qgis_app 11 | 12 | __author__ = 'ismailsunni@yahoo.co.id' 13 | __date__ = '12/10/2011' 14 | __copyright__ = ('Copyright 2012, Australia Indonesia Facility for ' 15 | 'Disaster Reduction') 16 | import unittest 17 | import os 18 | 19 | from PyQt5.QtCore import QCoreApplication, QTranslator 20 | 21 | QGIS_APP = get_qgis_app() 22 | 23 | 24 | class SafeTranslationsTest(unittest.TestCase): 25 | """Test translations work.""" 26 | 27 | def setUp(self): 28 | """Runs before each test.""" 29 | if 'LANG' in iter(os.environ.keys()): 30 | os.environ.__delitem__('LANG') 31 | 32 | def tearDown(self): 33 | """Runs after each test.""" 34 | if 'LANG' in iter(os.environ.keys()): 35 | os.environ.__delitem__('LANG') 36 | 37 | def test_qgis_translations(self): 38 | """Test that translations work.""" 39 | parent_path = os.path.join(__file__, os.path.pardir, os.path.pardir) 40 | dir_path = os.path.abspath(parent_path) 41 | file_path = os.path.join( 42 | dir_path, 'i18n', 'af.qm') 43 | translator = QTranslator() 44 | translator.load(file_path) 45 | QCoreApplication.installTranslator(translator) 46 | 47 | expected_message = 'Goeie more' 48 | real_message = QCoreApplication.translate("@default", 'Good morning') 49 | self.assertEqual(real_message, expected_message) 50 | 51 | 52 | if __name__ == "__main__": 53 | suite = unittest.makeSuite(SafeTranslationsTest) 54 | runner = unittest.TextTestRunner(verbosity=2) 55 | runner.run(suite) 56 | -------------------------------------------------------------------------------- /test/utilities.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """Common functionality used by regression tests.""" 3 | 4 | import sys 5 | import logging 6 | 7 | 8 | LOGGER = logging.getLogger('QGIS') 9 | QGIS_APP = None # Static variable used to hold hand to running QGIS app 10 | CANVAS = None 11 | PARENT = None 12 | IFACE = None 13 | 14 | 15 | def get_qgis_app(): 16 | """ Start one QGIS application to test against. 17 | 18 | :returns: Handle to QGIS app, canvas, iface and parent. If there are any 19 | errors the tuple members will be returned as None. 20 | :rtype: (QgsApplication, CANVAS, IFACE, PARENT) 21 | 22 | If QGIS is already running the handle to that app will be returned. 23 | """ 24 | 25 | try: 26 | from PyQt5 import QtGui, QtCore 27 | from qgis.core import QgsApplication 28 | from qgis.gui import QgsMapCanvas 29 | from .qgis_interface import QgisInterface 30 | except ImportError: 31 | return None, None, None, None 32 | 33 | global QGIS_APP # pylint: disable=W0603 34 | 35 | if QGIS_APP is None: 36 | gui_flag = True # All test will run qgis in gui mode 37 | # noinspection PyPep8Naming 38 | QGIS_APP = QgsApplication(sys.argv, gui_flag) 39 | # Make sure QGIS_PREFIX_PATH is set in your env if needed! 40 | QGIS_APP.initQgis() 41 | s = QGIS_APP.showSettings() 42 | LOGGER.debug(s) 43 | 44 | global PARENT # pylint: disable=W0603 45 | if PARENT is None: 46 | # noinspection PyPep8Naming 47 | PARENT = QtGui.QWidget() 48 | 49 | global CANVAS # pylint: disable=W0603 50 | if CANVAS is None: 51 | # noinspection PyPep8Naming 52 | CANVAS = QgsMapCanvas(PARENT) 53 | CANVAS.resize(QtCore.QSize(400, 400)) 54 | 55 | global IFACE # pylint: disable=W0603 56 | if IFACE is None: 57 | # QgisInterface is a stub implementation of the QGIS plugin interface 58 | # noinspection PyPep8Naming 59 | IFACE = QgisInterface(CANVAS) 60 | 61 | return QGIS_APP, CANVAS, IFACE, PARENT 62 | --------------------------------------------------------------------------------