Skip to content
Open
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
17 changes: 12 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,20 @@ RELEASING:
13. Upload the package to https://plugins.qgis.org/plugins/ORStools/ (Manage > Add Version)
14. Create new release in GitHub with tag version and release title of `vX.X.X`
-->

## Unreleased
## Unrealeased
### Added
- Depiction of live preview route statistics

## [2.1.0] - 2025-12-09

### Added
- pre-commit configuration with Ruff linter for code quality enforcement
- Improve cursor behaviour during digitization
- tooltip hints in processing algorithms ([#196](https://github.com/GIScience/orstools-qgis-plugin/issues/196))
- Improve isochrone color ramp with many ranges
- Improve isochrone color ramp with many ranges ([#264](https://github.com/GIScience/orstools-qgis-plugin/issues/264))
- Enabled usage of custom endpoints in main application

### Changed
- Improve cursor behaviour during digitization ([#357](https://github.com/GIScience/orstools-qgis-plugin/pull/357))

### Fixed
- Delete annotations when plugin is uninstalled ([#346](https://github.com/GIScience/orstools-qgis-plugin/issues/346))
Expand Down Expand Up @@ -324,7 +330,8 @@ RELEASING:
- first working version of ORS Tools, after replacing OSM Tools plugin


[unreleased]: https://github.com/GIScience/orstools-qgis-plugin/compare/v2.0.1...HEAD
[unreleased]: https://github.com/GIScience/orstools-qgis-plugin/compare/v2.1.0...HEAD
[2.1.0]: https://github.com/GIScience/orstools-qgis-plugin/compare/v2.0.1...v2.1.0
[2.0.1]: https://github.com/GIScience/orstools-qgis-plugin/compare/v2.0.0...v2.0.1
[2.0.0]: https://github.com/GIScience/orstools-qgis-plugin/compare/v1.10.0...v2.0.0
[1.10.0]: https://github.com/GIScience/orstools-qgis-plugin/compare/v1.9.0...v1.10.0
Expand Down
1 change: 1 addition & 0 deletions ORStools/common/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from typing import Union, Dict, List, Optional
from urllib.parse import urlencode


from qgis.PyQt.QtCore import QObject, pyqtSignal, QUrl, QTimer, QEventLoop
from qgis.PyQt.QtNetwork import QNetworkRequest, QNetworkReply
from qgis.core import QgsSettings, QgsBlockingNetworkRequest
Expand Down
42 changes: 38 additions & 4 deletions ORStools/gui/ORStoolsDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
***************************************************************************/
"""

import json
import os
import json
from datetime import datetime
from typing import Optional

Expand Down Expand Up @@ -58,7 +58,11 @@
QgsAnnotation,
QgsCoordinateTransform,
)
from qgis.gui import QgsMapCanvasAnnotationItem, QgsCollapsibleGroupBox, QgisInterface
from qgis.gui import (
QgsMapCanvasAnnotationItem,
QgsCollapsibleGroupBox,
QgisInterface,
)
from qgis.PyQt.QtCore import QSizeF, QPointF, QCoreApplication
from qgis.PyQt.QtGui import QTextDocument
from qgis.PyQt.QtWidgets import QAction, QDialog, QApplication, QMenu, QMessageBox, QDialogButtonBox
Expand Down Expand Up @@ -291,11 +295,23 @@ def run_gui_control(self) -> None:

except exceptions.ApiError as e:
# Error thrown by ORStools/common/client.py, line 243, in _check_status
parsed = json.loads(e.message)
error_code = int(parsed["error"]["code"])
try:
parsed = json.loads(e.message)
error_code = int(parsed["error"]["code"])
except KeyError:
error_code = e.status

if error_code == 2010:
maptools.LineTool(self.dlg).radius_message_box(e)
return
elif error_code == "404":
self.iface.messageBar().pushMessage(
"Error 404: Not Found",
"Are your endpoints set correctly in the Provider Settings?",
level=Qgis.MessageLevel.Warning,
)
else:
raise e

def tr(self, string: str) -> str:
return QCoreApplication.translate(str(self.__class__.__name__), string)
Expand Down Expand Up @@ -412,6 +428,7 @@ def __init__(self, iface: QgisInterface, parent=None) -> None:
child.toggled.connect(self.reload_rubber_band)

self.rubber_band = None
self.set_live_preview_stats_visibility(False)

def _save_vertices_to_layer(self) -> None:
"""Saves the vertices list to a temp layer"""
Expand Down Expand Up @@ -441,6 +458,22 @@ def _save_vertices_to_layer(self) -> None:
self.tr("Success"), self.tr("Vertices saved to layer."), level=Qgis.MessageLevel.Success
)

def set_live_preview_stats_visibility(self, visible: bool) -> None:
self.label_distance.setVisible(visible)
self.live_distance.setVisible(visible)
self.label_duration.setVisible(visible)
self.live_duration.setVisible(visible)

def set_live_preview_stats(self, duration: float, distance: float) -> None:
def format_duration(hours: float) -> str:
h = int(hours)
m = int((hours - h) * 60)
return f"{h:02d}:{m:02d}"

self.set_live_preview_stats_visibility(self.toggle_preview.isChecked())
self.live_duration.setText(f"{format_duration(duration)} h")
self.live_distance.setText(f"{distance} km")

def _on_prov_refresh_click(self) -> None:
"""Populates provider dropdown with fresh list from config.yml"""

Expand Down Expand Up @@ -471,6 +504,7 @@ def _clear_listwidget(self) -> None:
self.rubber_band.reset()
del self.line_tool
self.line_tool = maptools.LineTool(self)
self.set_live_preview_stats(0, 0)

def _linetool_annotate_point(
self, point: QgsPointXY, idx: int, crs: Optional[QgsCoordinateReferenceSystem] = None
Expand Down
Loading