From 8fe8a66c308c623f4057120b745cf9f20287f3f2 Mon Sep 17 00:00:00 2001 From: Till Frankenbach Date: Wed, 9 Jul 2025 12:50:16 +0200 Subject: [PATCH 1/5] fix: set url slashes correctly with optimization requests in procs --- ORStools/proc/directions_lines_proc.py | 2 +- ORStools/proc/directions_points_layer_proc.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ORStools/proc/directions_lines_proc.py b/ORStools/proc/directions_lines_proc.py index 4d6436cb..f81b5467 100644 --- a/ORStools/proc/directions_lines_proc.py +++ b/ORStools/proc/directions_lines_proc.py @@ -190,7 +190,7 @@ def processAlgorithm( endpoint = self.get_endpoint_names_from_provider(parameters[self.IN_PROVIDER])[ "optimization" ] - response = ors_client.request(f"{endpoint}/", {}, post_json=params) + response = ors_client.request(f"/{endpoint}/", {}, post_json=params) sink.addFeature( directions_core.get_output_features_optimization( diff --git a/ORStools/proc/directions_points_layer_proc.py b/ORStools/proc/directions_points_layer_proc.py index 41c8d5cf..0f3310eb 100644 --- a/ORStools/proc/directions_points_layer_proc.py +++ b/ORStools/proc/directions_points_layer_proc.py @@ -231,7 +231,7 @@ def sort(f): endpoint = self.get_endpoint_names_from_provider(parameters[self.IN_PROVIDER])[ "optimization" ] - response = ors_client.request(f"{endpoint}/", {}, post_json=params) + response = ors_client.request(f"/{endpoint}/", {}, post_json=params) sink.addFeature( directions_core.get_output_features_optimization( From 74268c0a7d2f35cc184ff87be0223f85b0da357e Mon Sep 17 00:00:00 2001 From: Till Frankenbach Date: Wed, 24 Sep 2025 10:14:07 +0200 Subject: [PATCH 2/5] docs: add to changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 379d593c..70c2c151 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,7 @@ RELEASING: ### Fixed - Delete annotations when plugin is uninstalled ([#346](https://github.com/GIScience/orstools-qgis-plugin/issues/346)) - Reset hand cursor after deactivating line tool ([#342](https://github.com/GIScience/orstools-qgis-plugin/issues/342)) +- Set url slashes correctly with optimization requests in procs ([#347](https://github.com/GIScience/orstools-qgis-plugin/issues/347)) ## [2.0.1] - 2025-06-01 ### Added From 781685af2ad5b17ab73d89c4a8e4c058a7d8cb94 Mon Sep 17 00:00:00 2001 From: Till Frankenbach Date: Wed, 1 Oct 2025 13:32:49 +0200 Subject: [PATCH 3/5] test: add tests for directions lines and points layers optimization requests --- tests/test_proc.py | 53 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/tests/test_proc.py b/tests/test_proc.py index c13fc807..2e504fbe 100644 --- a/tests/test_proc.py +++ b/tests/test_proc.py @@ -81,6 +81,32 @@ def test_directions_lines(self): feat_length = next(processed_layer.getFeatures()).geometry().length() self.assertTrue(feat_length > 0) + def test_directions_lines_opti(self): + parameters = { + "INPUT_AVOID_BORDERS": None, + "INPUT_AVOID_COUNTRIES": "", + "INPUT_AVOID_FEATURES": [], + "INPUT_AVOID_POLYGONS": None, + "INPUT_LAYER_FIELD": None, + "INPUT_LINE_LAYER": self.line_layer, + "INPUT_OPTIMIZE": 0, + "INPUT_PREFERENCE": 0, + "INPUT_PROFILE": 0, + "INPUT_PROVIDER": 0, + "INPUT_METRIC": 0, + "LOCATION_TYPE": 0, + "OUTPUT": "TEMPORARY_OUTPUT", + } + + directions = ORSDirectionsLinesAlgo().create() + dest_id = directions.processAlgorithm(parameters, self.context, self.feedback) + processed_layer = QgsProcessingUtils.mapLayerFromString(dest_id["OUTPUT"], self.context) + + self.assertEqual(type(processed_layer), QgsVectorLayer) + + feat_length = next(processed_layer.getFeatures()).geometry().length() + self.assertTrue(feat_length > 0) + def test_directions_points_layer(self): parameters = { "INPUT_AVOID_BORDERS": None, @@ -108,6 +134,33 @@ def test_directions_points_layer(self): return processed_layer + def test_directions_points_layer_optimization(self): + parameters = { + "INPUT_AVOID_BORDERS": None, + "INPUT_AVOID_COUNTRIES": "", + "INPUT_AVOID_FEATURES": [], + "INPUT_AVOID_POLYGONS": None, + "INPUT_LAYER_FIELD": None, + "INPUT_OPTIMIZE": 1, + "INPUT_POINT_LAYER": self.point_layer_1, + "INPUT_PREFERENCE": 0, + "INPUT_PROFILE": 0, + "INPUT_PROVIDER": 0, + "INPUT_SORTBY": None, + "OUTPUT": "TEMPORARY_OUTPUT", + } + + directions = ORSDirectionsPointsLayerAlgo().create() + dest_id = directions.processAlgorithm(parameters, self.context, self.feedback) + processed_layer = QgsProcessingUtils.mapLayerFromString(dest_id["OUTPUT"], self.context) + + self.assertEqual(type(processed_layer), QgsVectorLayer) + + feat_length = next(processed_layer.getFeatures()).geometry().length() + self.assertTrue(feat_length > 0) + + return processed_layer + def test_directions_points_layers(self): parameters = { "INPUT_AVOID_BORDERS": None, From 36bd2ce159feb737033e965e7434286277c1b864 Mon Sep 17 00:00:00 2001 From: Till Frankenbach Date: Wed, 1 Oct 2025 14:17:36 +0200 Subject: [PATCH 4/5] refactor: correct test method name Co-authored-by: Jakob Schnell --- tests/test_proc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_proc.py b/tests/test_proc.py index 2e504fbe..dfb7c5ef 100644 --- a/tests/test_proc.py +++ b/tests/test_proc.py @@ -81,7 +81,7 @@ def test_directions_lines(self): feat_length = next(processed_layer.getFeatures()).geometry().length() self.assertTrue(feat_length > 0) - def test_directions_lines_opti(self): + def test_directions_lines_layer_optimize(self): parameters = { "INPUT_AVOID_BORDERS": None, "INPUT_AVOID_COUNTRIES": "", From cc800bca1b9a1abea49f3232506d34ce4eac778c Mon Sep 17 00:00:00 2001 From: Till Frankenbach Date: Wed, 1 Oct 2025 14:18:39 +0200 Subject: [PATCH 5/5] fix: set correct optimization parameter value in test Co-authored-by: Jakob Schnell --- tests/test_proc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_proc.py b/tests/test_proc.py index dfb7c5ef..0cbd3c92 100644 --- a/tests/test_proc.py +++ b/tests/test_proc.py @@ -89,7 +89,7 @@ def test_directions_lines_layer_optimize(self): "INPUT_AVOID_POLYGONS": None, "INPUT_LAYER_FIELD": None, "INPUT_LINE_LAYER": self.line_layer, - "INPUT_OPTIMIZE": 0, + "INPUT_OPTIMIZE": 1, "INPUT_PREFERENCE": 0, "INPUT_PROFILE": 0, "INPUT_PROVIDER": 0,