Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ RELEASING:
-->
## Unreleased

### Added
- warning and fix if deprecated URL is detected ([#389](https://github.com/GIScience/orstools-qgis-plugin/pull/388))

### Changed
- default base URL to api.heigit.org ([#388](https://github.com/GIScience/orstools-qgis-plugin/pull/388))

## [2.2.0] - 2026-10-02

### Added
Expand Down
2 changes: 2 additions & 0 deletions ORStools/gui/ORStoolsDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

from ..utils.router import route_as_layer, get_routing_parameters
from ORStools.gui import directions_gui
from ..utils.deprecation import check_provider_url

try:
import processing
Expand Down Expand Up @@ -272,6 +273,7 @@ def _init_gui_control(self) -> None:
for provider in providers:
self.dlg.provider_combo.addItem(provider["name"], provider)

check_provider_url()
self.dlg.show()

def handle_task_exception(self, exception: Exception) -> None:
Expand Down
2 changes: 2 additions & 0 deletions ORStools/proc/base_processing_algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
from ..common import client, PROFILES, AVOID_BORDERS, AVOID_FEATURES, ADVANCED_PARAMETERS
from ..utils.processing import read_help_file
from ..gui.directions_gui import _get_avoid_polygons
from ..utils.deprecation import check_provider_url


# noinspection PyPep8Naming
Expand Down Expand Up @@ -78,6 +79,7 @@ def createInstance(self) -> Any:
"""
Returns instance of any child class
"""
check_provider_url()
return self.__class__()

def group(self) -> str:
Expand Down
117 changes: 117 additions & 0 deletions ORStools/utils/deprecation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# -*- coding: utf-8 -*-
"""
/***************************************************************************
ORStools
A QGIS plugin
QGIS client to query openrouteservice
-------------------
begin : 2026-11-12
git sha : $Format:%H$
copyright : (C) 2026 by HeiGIT gGmbH
email : support@openrouteservice.heigit.org
***************************************************************************/

This plugin provides access to openrouteservice API functionalities
(https://openrouteservice.org), developed and
maintained by the openrouteservice team of HeiGIT gGmbH, Germany. By using
this plugin you agree to the ORS terms of service
(https://openrouteservice.org/terms-of-service/).

/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
"""

from . import configmanager
from qgis.PyQt.QtWidgets import QMessageBox
from ..proc import ENDPOINTS, DEFAULT_SETTINGS


class DeprecatedUrlDialog(QMessageBox):
"""Dialog informing the user that the configured URL is deprecated."""

def __init__(self, parent=None):
super().__init__(parent)

self.setIcon(QMessageBox.Icon.Warning)
self.setWindowTitle(self.tr("ORS Tools: Deprecated URL"))

self.setText(
self.tr(
"<b>ORSTools Plugin:</b> <br /><br />"
"The configured ORS provider URL <tt>https://api.openrouteservice.org</tt> is <a href='https://ask.openrouteservice.org/t/deprecating-api-openrouteservice-org-in-favour-of-api-heigit-org/7912'>deprecated</a>.<br />"
"Would you like to reset it to the new default URL <tt>https://api.heigit.org</tt>?"
)
)

self.reset_button = self.addButton(self.tr("Reset URL"), QMessageBox.ButtonRole.AcceptRole)

self.addButton(self.tr("Close"), QMessageBox.ButtonRole.RejectRole)


def url_dialog_reset_button(parent=None) -> bool:
"""Shows the deprecated URL dialog and returns bool."""

url_dlg = DeprecatedUrlDialog(parent)
url_dlg.exec()
return url_dlg.clickedButton() == url_dlg.reset_button


def add_default_provider_to_settings():
settings = configmanager.read_config()

settings_keys = ["ENV_VARS", "base_url", "key", "name", "endpoints"]

# Add any new settings here for backwards compatibility
if settings:
changed = False
for i, prov in enumerate(settings["providers"]):
if any([i not in prov for i in settings_keys]):
changed = True
# Add here, like the endpoints
prov["endpoints"] = ENDPOINTS
settings["providers"][i] = prov
if changed:
configmanager.write_config(settings)
else:
configmanager.write_config(DEFAULT_SETTINGS)


def url_is_deprecated() -> bool:
settings = configmanager.read_config()

if not settings:
return False

legacy_url = "https://api.openrouteservice.org"

return any(legacy_url in provider["base_url"] for provider in settings["providers"])


def reset_provider_url():
"""Reset the first provider URL to the default URL."""

settings = configmanager.read_config()

if not settings:
return

default_url = DEFAULT_SETTINGS["providers"][0]["base_url"]
legacy_url = "https://api.openrouteservice.org"

for provider_config in settings.get("providers", []):
if provider_config.get("base_url") == legacy_url:
provider_config["base_url"] = default_url

configmanager.write_config(settings)


def check_provider_url(parent=None):
if url_is_deprecated():
if url_dialog_reset_button(parent):
reset_provider_url()
Loading