Skip to content

Commit

Permalink
Merge branch 'main' into 277-error-with-canvas-scenes-when-deleting-s…
Browse files Browse the repository at this point in the history
…elected-vertices-in-list
  • Loading branch information
koebi authored Oct 29, 2024
2 parents 7d2b484 + 8687fe3 commit 58d6be0
Show file tree
Hide file tree
Showing 18 changed files with 405 additions and 83 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,15 @@ RELEASING:
-->

## Unreleased

### Fixed
#### Minor Fixes
- Error with canvas scenes when deleting selected vertices in list ([#278](https://github.com/GIScience/orstools-qgis-plugin/pull/278))
-
### Added
- Processing algorithms for the Network Export endpoint ([#210](https://github.com/GIScience/orstools-qgis-plugin/issues/210))

### 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

Expand Down
22 changes: 22 additions & 0 deletions ORStools/ORStoolsPlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ def __init__(self, iface: QgisInterface) -> None:
except TypeError:
pass

self.add_default_provider_to_settings()

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

Expand All @@ -83,3 +85,23 @@ def unload(self) -> None:
"""remove menu entry and toolbar icons"""
QgsApplication.processingRegistry().removeProvider(self.provider)
self.dialog.unload()

def add_default_provider_to_settings(self):
s = QgsSettings()
settings = s.value("ORStools/config")
if not settings:
def_settings = {
"providers": [
{
"ENV_VARS": {
"ORS_QUOTA": "X-Ratelimit-Limit",
"ORS_REMAINING": "X-Ratelimit-Remaining",
},
"base_url": "https://api.openrouteservice.org",
"key": "",
"name": "openrouteservice",
"timeout": 60,
}
]
}
s.setValue("ORStools/config", def_settings)
8 changes: 0 additions & 8 deletions ORStools/config.yml

This file was deleted.

52 changes: 50 additions & 2 deletions ORStools/gui/ORStoolsDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
from qgis.gui import QgsMapCanvasAnnotationItem

from qgis.PyQt.QtCore import QSizeF, QPointF, QCoreApplication
from qgis.PyQt.QtGui import QIcon, QTextDocument
from qgis.PyQt.QtGui import QIcon, QTextDocument, QColor
from qgis.PyQt.QtWidgets import (
QAction,
QDialog,
Expand Down Expand Up @@ -106,6 +106,8 @@ def on_help_click() -> None:
def on_about_click(parent: QWidget) -> None:
"""Slot for click event of About button/menu entry."""

# ruff will add trailing comma to last string line which breaks pylupdate5
# fmt: off
info = QCoreApplication.translate(
"@default",
'<b>ORS Tools</b> provides access to <a href="https://openrouteservice.org"'
Expand All @@ -120,8 +122,9 @@ def on_about_click(parent: QWidget) -> None:
'Web: <a href="{2}">{2}</a><br>'
'Repo: <a href="https://github.com/GIScience/orstools-qgis-plugin">'
"github.com/GIScience/orstools-qgis-plugin</a><br>"
"Version: {3}",
"Version: {3}"
).format(DEFAULT_COLOR, __email__, __web__, __version__)
# fmt: on

QMessageBox.information(
parent, QCoreApplication.translate("@default", "About {}").format(PLUGIN_NAME), info
Expand Down Expand Up @@ -324,6 +327,27 @@ def run_gui_control(self) -> None:
try:
params = directions.get_parameters()
if self.dlg.optimization_group.isChecked():
# check for duplicate points
points = [
self.dlg.routing_fromline_list.item(x).text()
for x in range(self.dlg.routing_fromline_list.count())
]
if len(points) != len(set(points)):
QMessageBox.warning(
self.dlg,
self.tr("Duplicates"),
self.tr(
"""
There are duplicate points in the input layer. Traveling Salesman Optimization does not allow this.
Either remove the duplicates or deselect Traveling Salesman.
"""
),
)
msg = self.tr("The request has been aborted!")
logger.log(msg, 0)
self.dlg.debug_text.setText(msg)
return

if len(params["jobs"]) <= 1: # Start/end locations don't count as job
QMessageBox.critical(
self.dlg,
Expand Down Expand Up @@ -494,6 +518,14 @@ def __init__(self, iface: QgisInterface, parent=None) -> None:
self.routing_fromline_list.model().rowsMoved.connect(self._reindex_list_items)
self.routing_fromline_list.model().rowsRemoved.connect(self._reindex_list_items)

# Connect signals to the color_duplicate_items function
self.routing_fromline_list.model().rowsRemoved.connect(
lambda: self.color_duplicate_items(self.routing_fromline_list)
)
self.routing_fromline_list.model().rowsInserted.connect(
lambda: self.color_duplicate_items(self.routing_fromline_list)
)

self.annotation_canvas = self._iface.mapCanvas()

def _save_vertices_to_layer(self) -> None:
Expand Down Expand Up @@ -637,3 +669,19 @@ def _on_linetool_map_doubleclick(self) -> None:
QApplication.restoreOverrideCursor()
self._iface.mapCanvas().setMapTool(self.last_maptool)
self.show()

def color_duplicate_items(self, list_widget):
item_dict = {}
for index in range(list_widget.count()):
item = list_widget.item(index)
text = item.text()
if text in item_dict:
item_dict[text].append(index)
else:
item_dict[text] = [index]

for indices in item_dict.values():
if len(indices) > 1:
for index in indices:
item = list_widget.item(index)
item.setBackground(QColor("lightsalmon"))
9 changes: 9 additions & 0 deletions ORStools/help/export_network_from_map.help
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Export the base graph for different modes of transport.

You need to have a valid API key ('Web' menu ► 'ORS Tools' ► 'Configuration') or sign up at <a href="https://openrouteservice.org/sign-up/">https://openrouteservice.org/sign-up/</a>.
Current <a href="https://openrouteservice.org/restrictions/">restriction limits</a> for the openrouteservice API apply.

<i>Travel Mode</i>: determines the profile used.

<i>Input Extent</i>: Choose an extent, the content of which will be exported.

7 changes: 7 additions & 0 deletions ORStools/help/export_network_from_map_de.help
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Das Basisgraph für verschiedene Verkehrsmittel exportieren.

Ein gültiger API-Schlüssel ist erforderlich ('Web'-Menü ► 'ORS Tools' ► 'Konfiguration') oder eine Anmeldung unter <a href="https://openrouteservice.org/sign-up/">https://openrouteservice.org/sign-up/</a>. Aktuelle <a href="https://openrouteservice.org/restrictions/">Beschränkungslimits</a> für die openrouteservice API gelten.

<i>Verkehrsmittel</i>: bestimmt das genutzte Reise-Profil

<i>Input-Extent</i>: Es ist ein Bereich auszuwählen, dessen Inhalt exportiert wird.
103 changes: 58 additions & 45 deletions ORStools/i18n/orstools_de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
<context>
<name>@default</name>
<message>
<location filename="../gui/ORStoolsDialog.py" line="79"/>
<source>&lt;b&gt;ORS Tools&lt;/b&gt; provides access to &lt;a href=&quot;https://openrouteservice.org&quot; style=&quot;color: {0}&quot;&gt;openrouteservice&lt;/a&gt; routing functionalities.&lt;br&gt;&lt;br&gt;&lt;center&gt;&lt;a href=&quot;https://heigit.org/de/willkommen&quot;&gt;&lt;img src=&quot;:/plugins/ORStools/img/logo_heigit_300.png&quot;/&gt;&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;/center&gt;Author: HeiGIT gGmbH&lt;br&gt;Email: &lt;a href=&quot;mailto:Openrouteservice &lt;{1}&gt;&quot;&gt;{1}&lt;/a&gt;&lt;br&gt;Web: &lt;a href=&quot;{2}&quot;&gt;{2}&lt;/a&gt;&lt;br&gt;Repo: &lt;a href=&quot;https://github.com/GIScience/orstools-qgis-plugin&quot;&gt;github.com/GIScience/orstools-qgis-plugin&lt;/a&gt;&lt;br&gt;Version: {3}</source>
<translation type="obsolete">&lt;b&gt;ORS Tools&lt;/b&gt; bietet Zugriff auf &lt;a href=&quot;https://openrouteservice.org&quot; style=&quot;color: {0}&quot;&gt;openrouteservice&lt;/a&gt; Berechnungen.&lt;br&gt;&lt;br&gt;&lt;center&gt;&lt;a href=&quot;https://heigit.org/de/willkommen&quot;&gt;&lt;img src=&quot;:/plugins/ORStools/img/logo_heigit_300.png&quot;/&gt;&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;/center&gt;Author: HeiGIT gGmbH&lt;br&gt;Email: &lt;a href=&quot;mailto:Openrouteservice &lt;{1}&gt;&quot;&gt;{1}&lt;/a&gt;&lt;br&gt;Web: &lt;a href=&quot;{2}&quot;&gt;{2}&lt;/a&gt;&lt;br&gt;Repo: &lt;a href=&quot;https://github.com/GIScience/orstools-qgis-plugin&quot;&gt;github.com/GIScience/orstools-qgis-plugin&lt;/a&gt;&lt;br&gt;Version: {3}</translation>
</message>
<message>
<location filename="../gui/ORStoolsDialog.py" line="122"/>
<location filename="../gui/ORStoolsDialog.py" line="129"/>
<source>About {}</source>
<translation>Über {}</translation>
</message>
<message>
<location filename="../gui/ORStoolsDialog.py" line="111"/>
<source>&lt;b&gt;ORS Tools&lt;/b&gt; provides access to &lt;a href=&quot;https://openrouteservice.org&quot; style=&quot;color: {0}&quot;&gt;openrouteservice&lt;/a&gt; routing functionalities.&lt;br&gt;&lt;br&gt;&lt;center&gt;&lt;a href=&quot;https://heigit.org/de/willkommen&quot;&gt;&lt;img src=&quot;:/plugins/ORStools/img/logo_heigit_300.png&quot;/&gt;&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;/center&gt;Author: HeiGIT gGmbH&lt;br&gt;Email: &lt;a href=&quot;mailto:Openrouteservice &lt;{1}&gt;&quot;&gt;{1}&lt;/a&gt;&lt;br&gt;Web: &lt;a href=&quot;{2}&quot;&gt;{2}&lt;/a&gt;&lt;br&gt;Repo: &lt;a href=&quot;https://github.com/GIScience/orstools-qgis-plugin&quot;&gt;github.com/GIScience/orstools-qgis-plugin&lt;/a&gt;&lt;br&gt;Version: {3}</source>
<translation>&lt;b&gt;ORS Tools&lt;/b&gt; bietet Zugriff auf &lt;a href=&quot;https://openrouteservice.org&quot; style=&quot;color: {0}&quot;&gt;openrouteservice&lt;/a&gt; Berechnungen.&lt;br&gt;&lt;br&gt;&lt;center&gt;&lt;a href=&quot;https://heigit.org/de/willkommen&quot;&gt;&lt;img src=&quot;:/plugins/ORStools/img/logo_heigit_300.png&quot;/&gt;&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;/center&gt;Author: HeiGIT gGmbH&lt;br&gt;Email: &lt;a href=&quot;mailto:Openrouteservice &lt;{1}&gt;&quot;&gt;{1}&lt;/a&gt;&lt;br&gt;Web: &lt;a href=&quot;{2}&quot;&gt;{2}&lt;/a&gt;&lt;br&gt;Repo: &lt;a href=&quot;https://github.com/GIScience/orstools-qgis-plugin&quot;&gt;github.com/GIScience/orstools-qgis-plugin&lt;/a&gt;&lt;br&gt;Version: {3}</translation>
</message>
</context>
<context>
<name>ORSBaseProcessingAlgorithm</name>
Expand Down Expand Up @@ -79,7 +79,7 @@
<translation>Wegpunktoptimierung (sonstige Konfiguration wird nicht berücksichtigt)</translation>
</message>
<message>
<location filename="../proc/directions_lines_proc.py" line="286"/>
<location filename="../proc/directions_lines_proc.py" line="288"/>
<source>Directions from 1 Polyline-Layer</source>
<translation>Routenberechnung aus einem Polyline-Layer</translation>
</message>
Expand All @@ -104,34 +104,6 @@
<translation>Csv Spalte (benötigt Csv Faktor und csv in Extra Info)</translation>
</message>
</context>
<context>
<name>ORSDirectionsLinesAlgorithm</name>
<message>
<location filename="../proc/directions_lines_proc.py" line="60"/>
<source>Input Line layer</source>
<translation type="obsolete">Eingabelayer (Linien)</translation>
</message>
<message>
<location filename="../proc/directions_lines_proc.py" line="65"/>
<source>Layer ID Field</source>
<translation type="obsolete">ID-Attribut</translation>
</message>
<message>
<location filename="../proc/directions_lines_proc.py" line="72"/>
<source>Travel preference</source>
<translation type="obsolete">Routenpräferenz</translation>
</message>
<message>
<location filename="../proc/directions_lines_proc.py" line="78"/>
<source>Traveling Salesman (omits other configurations)</source>
<translation type="obsolete">Wegpunktoptimierung (sonstige Konfiguration wird nicht berücksichtigt)</translation>
</message>
<message>
<location filename="../proc/directions_lines_proc.py" line="207"/>
<source>Directions from 1 Polyline-Layer</source>
<translation type="obsolete">Routenberechnung aus einem Polyline-Layer</translation>
</message>
</context>
<context>
<name>ORSDirectionsPointsLayerAlgo</name>
<message>
Expand All @@ -155,7 +127,7 @@
<translation>Wegpunktoptimierung (sonstige Konfiguration wird nicht berücksichtigt)</translation>
</message>
<message>
<location filename="../proc/directions_points_layer_proc.py" line="289"/>
<location filename="../proc/directions_points_layer_proc.py" line="297"/>
<source>Directions from 1 Point-Layer</source>
<translation>Routenberechnung aus einem Punkt-Layer</translation>
</message>
Expand All @@ -165,7 +137,7 @@
<translation>ID-Attribut (zum Beispiel für joins)</translation>
</message>
<message>
<location filename="../proc/directions_points_layer_proc.py" line="133"/>
<location filename="../proc/directions_points_layer_proc.py" line="132"/>
<source>Export order of jobs</source>
<translation>Reihenfolge exportieren</translation>
</message>
Expand All @@ -175,15 +147,24 @@
<translation>Extra Info</translation>
</message>
<message>
<location filename="../proc/directions_points_layer_proc.py" line="119"/>
<location filename="../proc/directions_points_layer_proc.py" line="118"/>
<source>Csv Factor (needs Csv Column and csv in Extra Info)</source>
<translation>Csv Faktor (benötigt Csv Spalte und csv in Extra Info)</translation>
</message>
<message>
<location filename="../proc/directions_points_layer_proc.py" line="128"/>
<location filename="../proc/directions_points_layer_proc.py" line="127"/>
<source>Csv Column (needs Csv Factor and csv in Extra Info)</source>
<translation>Csv Spalte (benötigt Csv Faktor und csv in Extra Info)</translation>
</message>
<message>
<location filename="../proc/directions_points_layer_proc.py" line="223"/>
<source>
There are duplicate points in the input layer. Traveling Salesman Optimization does not allow this.
Either remove the duplicates or deselect Traveling Salesman.
</source>
<translation>Das Eingabelayer enthält duplizierte Punkte. Dies ist mit der Wegpunktoptimierung nicht erlaubt.
Duplikate entfernen oder Wegpunktoptimierung abwählen.</translation>
</message>
</context>
<context>
<name>ORSDirectionsPointsLayersAlgo</name>
Expand Down Expand Up @@ -228,7 +209,7 @@
<translation>Zuordnungs-Verfahren</translation>
</message>
<message>
<location filename="../proc/directions_points_layers_proc.py" line="319"/>
<location filename="../proc/directions_points_layers_proc.py" line="326"/>
<source>Directions from 2 Point-Layers</source>
<translation>Routenberechnung aus zwei Punkt-Layern</translation>
</message>
Expand All @@ -248,6 +229,19 @@
<translation>Csv Spalte (benötigt Csv Faktor und csv in Extra Info)</translation>
</message>
</context>
<context>
<name>ORSExportAlgo</name>
<message>
<location filename="../proc/export_proc.py" line="67"/>
<source>Input Extent</source>
<translation>Ausdehnung</translation>
</message>
<message>
<location filename="../proc/export_proc.py" line="179"/>
<source>Export Network from Map</source>
<translation>Netzwerk von Karte exportieren</translation>
</message>
</context>
<context>
<name>ORSIsochronesLayerAlgo</name>
<message>
Expand Down Expand Up @@ -350,12 +344,12 @@
<context>
<name>ORStoolsDialog</name>
<message>
<location filename="../gui/ORStoolsDialog.py" line="453"/>
<location filename="../gui/ORStoolsDialog.py" line="481"/>
<source>Apply</source>
<translation>Anwenden</translation>
</message>
<message>
<location filename="../gui/ORStoolsDialog.py" line="454"/>
<location filename="../gui/ORStoolsDialog.py" line="482"/>
<source>Close</source>
<translation>Schließen</translation>
</message>
Expand Down Expand Up @@ -715,19 +709,38 @@ p, li { white-space: pre-wrap; }
<context>
<name>ORStoolsDialogMain</name>
<message>
<location filename="../gui/ORStoolsDialog.py" line="178"/>
<location filename="../gui/ORStoolsDialog.py" line="185"/>
<source>Help</source>
<translation>Hilfe</translation>
</message>
<message>
<location filename="../gui/ORStoolsDialog.py" line="170"/>
<location filename="../gui/ORStoolsDialog.py" line="177"/>
<source>Provider Settings</source>
<translation>Dienst-Einstellungen</translation>
</message>
<message>
<location filename="../gui/ORStoolsDialog.py" line="176"/>
<location filename="../gui/ORStoolsDialog.py" line="183"/>
<source>About</source>
<translation>Über</translation>
</message>
<message>
<location filename="../gui/ORStoolsDialog.py" line="336"/>
<source>Duplicates</source>
<translation>Duplikate</translation>
</message>
<message>
<location filename="../gui/ORStoolsDialog.py" line="336"/>
<source>
There are duplicate points in the input layer. Traveling Salesman Optimization does not allow this.
Either remove the duplicates or deselect Traveling Salesman.
</source>
<translation>Das Eingabelayer enthält duplizierte Punkte. Dies ist mit der Wegpunktoptimierung nicht erlaubt.
Duplikate entfernen oder Wegpunktoptimierung abwählen.</translation>
</message>
<message>
<location filename="../gui/ORStoolsDialog.py" line="346"/>
<source>The request has been aborted!</source>
<translation>Die Anfrage wurde abgebrochen!</translation>
</message>
</context>
</TS>
1 change: 1 addition & 0 deletions ORStools/i18n/translate.pro
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ SOURCES = ../common/directions_core.py \
../proc/isochrones_layer_proc.py \
../proc/isochrones_point_proc.py \
../proc/matrix_proc.py \
../proc/export_proc.py \
../gui/ORStoolsDialog.py \
../gui/ORStoolsDialogConfig.py

Expand Down
Loading

0 comments on commit 58d6be0

Please sign in to comment.