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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ORStools/proc/directions_lines_proc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion ORStools/proc/directions_points_layer_proc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
53 changes: 53 additions & 0 deletions tests/test_proc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_layer_optimize(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": 1,
"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,
Expand Down Expand Up @@ -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,
Expand Down