From 707b35b767024b56c05c21eedc65e403157e6e1c Mon Sep 17 00:00:00 2001 From: Tim Sutton Date: Fri, 10 Jan 2025 13:07:50 +0000 Subject: [PATCH] Reduce the number of ORS API calls Defaults to 100 features per request now and makes it user configurable in settings. Fixes #732 --- .../multi_buffer_distances_workflow.py | 5 +- geest/gui/geest_settings.py | 3 + geest/ui/geest_settings_base.ui | 206 +++++++++++------- 3 files changed, 129 insertions(+), 85 deletions(-) diff --git a/geest/core/workflows/multi_buffer_distances_workflow.py b/geest/core/workflows/multi_buffer_distances_workflow.py index e1ac3b4c..34dbbdff 100644 --- a/geest/core/workflows/multi_buffer_distances_workflow.py +++ b/geest/core/workflows/multi_buffer_distances_workflow.py @@ -122,7 +122,10 @@ def __init__( else: self.measurement = "time" - self.subset_size = 5 # Process 5 features at a time - hardcoded for now + # How many features to pass with each ORS API call + # Managed in the settings panel + self.subset_size = setting(key="ors_request_size", default=30) + self.ors_client = ORSClient("https://api.openrouteservice.org/v2/isochrones") self.api_key = self.ors_client.check_api_key() # Create the masked API key for logging diff --git a/geest/gui/geest_settings.py b/geest/gui/geest_settings.py index d56c1066..23712382 100644 --- a/geest/gui/geest_settings.py +++ b/geest/gui/geest_settings.py @@ -59,6 +59,8 @@ def __init__(self, parent=None): self.ors_key_line_edit.setText(ors_key) else: self.ors_key_line_edit.setPlaceholderText("Enter your ORS API key here") + ors_request_size = int(setting(key="ors_request_size", default=100)) + self.ors_request_size.setValue(ors_request_size) def apply(self): """Process the animation sequence. @@ -81,6 +83,7 @@ def apply(self): set_setting(key="verbose_mode", value=0) set_setting(key="ors_key", value=self.ors_key_line_edit.text()) + set_setting(key="ors_request_size", value=self.ors_request_size.value()) class GeestOptionsFactory(QgsOptionsWidgetFactory): diff --git a/geest/ui/geest_settings_base.ui b/geest/ui/geest_settings_base.ui index 1832d62f..93e8de6d 100644 --- a/geest/ui/geest_settings_base.ui +++ b/geest/ui/geest_settings_base.ui @@ -13,22 +13,60 @@ Geest Settings - - - + + + - Your API Key for the Open Route Service + # Geest Settings + + + Qt::MarkdownText + + + Qt::AlignCenter - - - - Verbose logging mode - + + + + Open Route Service Options + + + + + + Your API Key for the Open Route Service + + + + + + + + + + Features per request + + + + + + + 10000 + + + 10 + + + 100 + + + + - + Qt::Vertical @@ -41,80 +79,80 @@ - - - - Enable developer mode - - - - - - - - - - - - Concurrent Tasks - - - - - - - - - - - - The maximum number of concurrent threads to allow during analysis. Setting to the same number of CPU cores you have would be a good conservative approach. If you want to produce your analysis faster, you could probably run 4 or more on a decently specced machine. - - - true - - - 0 - - - - - - - This is intended for developers to attach to the plugin using a remote debugger so that they can step through the code. Do not enable it if you do not have a remote debugger set up as it will block QGIS startup until a debugger is attached to the process. In addition, debug mode will enable a log tab in the dock. Requires restart after changing. - - - true - - - 0 - - - - - - - # Geest Settings - - - Qt::MarkdownText - - - Qt::AlignCenter - - - - - - - Adds verbose log message, useful for diagnostics. - - - true - - - 0 - + + + + Advanced Options + + + + + + + + Concurrent Tasks + + + + + + + + + + + + The maximum number of concurrent threads to allow during analysis. Setting to the same number of CPU cores you have would be a good conservative approach. If you want to produce your analysis faster, you could probably run 4 or more on a decently specced machine. + + + true + + + 0 + + + + + + + Enable developer mode + + + + + + + This is intended for developers to attach to the plugin using a remote debugger so that they can step through the code. Do not enable it if you do not have a remote debugger set up as it will block QGIS startup until a debugger is attached to the process. In addition, debug mode will enable a log tab in the dock. Requires restart after changing. + + + true + + + 0 + + + + + + + Verbose logging mode + + + + + + + Adds verbose log message, useful for diagnostics. + + + true + + + 0 + + + +