Skip to content

Commit

Permalink
Merge branch 'main' into use-QgsSettings-instead-of-config-yml
Browse files Browse the repository at this point in the history
  • Loading branch information
koebi authored Aug 30, 2024
2 parents ab0c375 + 0131012 commit 3bdc804
Show file tree
Hide file tree
Showing 59 changed files with 7,058 additions and 5,109 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

name: Testing

on:
pull_request:

jobs:
test_3_16:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run test 3.16
run: |
docker run -v ${GITHUB_WORKSPACE}:/src -w /src qgis/qgis:release-3_16 sh -c 'apt-get -y update && apt-get -y install xvfb && export ORS_API_KEY=${{ secrets.ORS_API_KEY }} && export DISPLAY=:0.0 && pip install -U pytest && xvfb-run pytest'
env:
DOCKER_IMAGE: ${{ steps.docker-build.outputs.FULL_IMAGE_NAME }}
test_3_22:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run test 3.22
run: |
docker run -v ${GITHUB_WORKSPACE}:/src -w /src qgis/qgis:release-3_22 sh -c 'apt-get -y update && apt-get -y install xvfb && export DISPLAY=:0.0 && export ORS_API_KEY=${{ secrets.ORS_API_KEY }} && export DISPLAY=:0.0 && pip install -U pytest && xvfb-run pytest'
env:
DOCKER_IMAGE: ${{ steps.docker-build.outputs.FULL_IMAGE_NAME }}
test_latest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run test latest
run: |
docker run -v ${GITHUB_WORKSPACE}:/src -w /src qgis/qgis:latest sh -c 'apt-get -y update && apt-get -y install xvfb && export DISPLAY=:0.0 && export ORS_API_KEY=${{ secrets.ORS_API_KEY }} && apt install python3-pytest && xvfb-run pytest'
env:
DOCKER_IMAGE: ${{ steps.docker-build.outputs.FULL_IMAGE_NAME }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
tets/
docs/wiki/OSMtools.wiki/
.idea/
Expand Down
49 changes: 47 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,55 @@ RELEASING:
-->

## Unreleased

### Changed
- Use QgsSettings instead of config.yml file to avoid deletion of providers on update ([#108](https://github.com/GIScience/orstools-qgis-plugin/issues/108))

## [1.8.4] - 2024-07-29

### Fixed
- issue with missing locale value for non-default user([#271](https://github.com/GIScience/orstools-qgis-plugin/issues/271))

## [1.8.3] - 2024-05-29

### Fixed
- Add csv\_column parameter to request made by points\_layers\_proc([#260](https://github.com/GIScience/orstools-qgis-plugin/issues/260))
- make extra\_info work with two points layers

## [1.8.2] - 2024-05-20

### Fixed
- use python 3.9-compatible type hint

## [1.8.1] - 2024-05-17

### Fixed
- use if-else instead of structural pattern matching

## [1.8.0] - 2024-05-17

### Added
- Add support for decimal ranges with isochrones([#237](https://github.com/GIScience/orstools-qgis-plugin/issues/237))
- Add hint for joining with `Layer ID Field` ([#143](https://github.com/GIScience/orstools-qgis-plugin/issues/143))
- Add option to export order of optimization route points ([#145](https://github.com/GIScience/orstools-qgis-plugin/issues/145))
- Add `extra_info` parameter to directions processing algorithms ([#251](https://github.com/GIScience/orstools-qgis-plugin/pull/251))

### Changed
- Rename `Ok` button in configuration window to `Save` for clarification ([#241](https://github.com/GIScience/orstools-qgis-plugin/issues/241))
- Replace PyQt5 imports with qgis.PyQt imports to prepare for Qt6-QGis builds

### Fixed
- QGis crashes when selecting more than two vertices for deletion ([#230](https://github.com/GIScience/orstools-qgis-plugin/issues/230))
- Vertices on canvas not depicted fully with n having more than one digit in length ([#235](https://github.com/GIScience/orstools-qgis-plugin/issues/235))
- Replace qt QSettings with QgsSettings for centralized configuration management ([#239](https://github.com/GIScience/orstools-qgis-plugin/issues/239))
- Point Annotations stay after saving project and not deleting them manually ([#229](https://github.com/GIScience/orstools-qgis-plugin/issues/229))
- Issue with MultiPoint-layers and optimization
- Improved type hints


# Unreleased
### Added
- Add support for decimal ranges with isochrones([#237](https://github.com/GIScience/orstools-qgis-plugin/issues/237))
- Unit- and e2e-testing

## [1.7.1] - 2024-01-15

Expand Down Expand Up @@ -231,7 +271,12 @@ RELEASING:
- first working version of ORS Tools, after replacing OSM Tools plugin


[unreleased]: https://github.com/GIScience/orstools-qgis-plugin/compare/v1.7.1...HEAD
[unreleased]: https://github.com/GIScience/orstools-qgis-plugin/compare/v1.8.4...HEAD
[1.8.4]: https://github.com/GIScience/orstools-qgis-plugin/compare/v1.8.3...v1.8.4
[1.8.3]: https://github.com/GIScience/orstools-qgis-plugin/compare/v1.8.2...v1.8.3
[1.8.2]: https://github.com/GIScience/orstools-qgis-plugin/compare/v1.8.1...v1.8.2
[1.8.1]: https://github.com/GIScience/orstools-qgis-plugin/compare/v1.8.0...v1.8.1
[1.8.0]: https://github.com/GIScience/orstools-qgis-plugin/compare/v1.7.1...v1.8.0
[1.7.1]: https://github.com/GIScience/orstools-qgis-plugin/compare/v1.7.0...v1.7.1
[1.7.0]: https://github.com/GIScience/orstools-qgis-plugin/compare/v1.6.0...v1.7.0
[1.6.0]: https://github.com/GIScience/orstools-qgis-plugin/compare/v1.5.3...v1.6.0
Expand Down
3 changes: 2 additions & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
MIT License

Copyright (c) 2021 HeiGIT gGmbH
Copyright (c) 2017 Nils Nolde
Copyright (c) 2019 HeiGIT gGmbH

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
22 changes: 22 additions & 0 deletions ORStools/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
MIT License

Copyright (c) 2017 Nils Nolde
Copyright (c) 2019 HeiGIT gGmbH

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
36 changes: 22 additions & 14 deletions ORStools/ORStoolsPlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
***************************************************************************/
"""

from qgis.gui import QgisInterface
from qgis.core import QgsApplication, QgsSettings
from PyQt5.QtCore import QTranslator, qVersion, QCoreApplication
from qgis.PyQt.QtCore import QTranslator, qVersion, QCoreApplication, QLocale
import os.path

from .gui import ORStoolsDialog
Expand All @@ -40,7 +41,7 @@ class ORStools:

# noinspection PyTypeChecker,PyArgumentList,PyCallByClass

def __init__(self, iface):
def __init__(self, iface: QgisInterface) -> None:
"""Constructor.
:param iface: An interface instance that will be passed to this class
Expand All @@ -55,25 +56,32 @@ def __init__(self, iface):
self.plugin_dir = os.path.dirname(__file__)

# initialize locale
locale = QgsSettings().value("locale/userLocale")[0:2]
locale_path = os.path.join(self.plugin_dir, "i18n", "orstools_{}.qm".format(locale))

if os.path.exists(locale_path):
self.translator = QTranslator()
self.translator.load(locale_path)

if qVersion() > "4.3.3":
QCoreApplication.installTranslator(self.translator)

try:
locale = QgsSettings().value("locale/userLocale")
if not locale:
locale = QLocale().name()
locale = locale[0:2]

locale_path = os.path.join(self.plugin_dir, "i18n", "orstools_{}.qm".format(locale))

if os.path.exists(locale_path):
self.translator = QTranslator()
self.translator.load(locale_path)

if qVersion() > "4.3.3":
QCoreApplication.installTranslator(self.translator)
except TypeError:
pass

self.add_default_provider_to_settings()

def initGui(self):
def initGui(self) -> None:
"""Create the menu entries and toolbar icons inside the QGIS GUI."""

QgsApplication.processingRegistry().addProvider(self.provider)
self.dialog.initGui()

def unload(self):
def unload(self) -> None:
"""remove menu entry and toolbar icons"""
QgsApplication.processingRegistry().removeProvider(self.provider)
self.dialog.unload()
Expand Down
20 changes: 20 additions & 0 deletions ORStools/common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,26 @@
"INPUT_AVOID_COUNTRIES",
"INPUT_AVOID_POLYGONS",
"INPUT_SMOOTHING",
"EXTRA_INFO",
"CSV_FACTOR",
"CSV_COLUMN",
]

LOCATION_TYPES = ["start", "destination"]

EXTRA_INFOS = [
"steepness",
"suitability",
"surface",
"waytype",
"waycategory",
"tollways",
"traildifficulty",
"osmid",
"roadaccessrestrictions",
"countryinfo",
"green",
"noise",
"csv",
"shadow",
]
18 changes: 13 additions & 5 deletions ORStools/common/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@
import random
import time
from datetime import datetime, timedelta
from typing import Union, Dict, List, Optional
from urllib.parse import urlencode

from PyQt5.QtCore import QObject, pyqtSignal
from qgis.PyQt.QtCore import QObject, pyqtSignal
from requests.utils import unquote_unreserved

from ORStools import __version__
Expand All @@ -48,7 +49,7 @@
class Client(QObject):
"""Performs requests to the ORS API services."""

def __init__(self, provider=None, agent=None):
def __init__(self, provider: Optional[dict] = None, agent: Optional[str] = None) -> None:
"""
:param provider: A openrouteservice provider from config.yml
:type provider: dict
Expand Down Expand Up @@ -87,7 +88,14 @@ def __init__(self, provider=None, agent=None):

overQueryLimit = pyqtSignal()

def request(self, url, params, first_request_time=None, retry_counter=0, post_json=None):
def request(
self,
url: str,
params: dict,
first_request_time: Optional[datetime.time] = None,
retry_counter: int = 0,
post_json: Optional[dict] = None,
):
"""Performs HTTP GET/POST with credentials, returning the body as
JSON.
Expand Down Expand Up @@ -194,7 +202,7 @@ def request(self, url, params, first_request_time=None, retry_counter=0, post_js

return json.loads(content.decode("utf-8"))

def _check_status(self):
def _check_status(self) -> None:
"""
Casts JSON response to dict
Expand Down Expand Up @@ -231,7 +239,7 @@ def _check_status(self):
elif status_code != 200:
raise exceptions.GenericServerError(str(status_code), message)

def _generate_auth_url(self, path, params):
def _generate_auth_url(self, path: str, params: Union[Dict, List]) -> str:
"""Returns the path and query string portion of the request URL, first
adding any necessary parameters.
Expand Down
Loading

0 comments on commit 3bdc804

Please sign in to comment.