Skip to content

Commit

Permalink
Merge branch 'main' into feature/141-format-and-lint
Browse files Browse the repository at this point in the history
clean up issues from 774a6dd
  • Loading branch information
koebi committed Dec 6, 2023
2 parents 9824eca + 774a6dd commit 1959f23
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 22 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ RELEASING:
## Unreleased

### Added
- Additional parameter for the "smoothing factor" to isochrones processing algorithms ([#172](https://github.com/GIScience/orstools-qgis-plugin/issues/172))
- Mention omission of configuration options when using traveling salesman

## [1.6.0] - 2023-07-25
Expand All @@ -50,7 +51,6 @@ RELEASING:
- translation mechanism ([#183](https://github.com/GIScience/orstools-qgis-plugin/pull/183))
- german translation ([#183](https://github.com/GIScience/orstools-qgis-plugin/pull/183))


## [1.5.3] - 2023-03-30

### Fixed
Expand Down
1 change: 1 addition & 0 deletions ORStools/common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,5 @@
"INPUT_AVOID_BORDERS",
"INPUT_AVOID_COUNTRIES",
"INPUT_AVOID_POLYGONS",
"INPUT_SMOOTHING",
]
Binary file modified ORStools/i18n/orstools_de.qm
Binary file not shown.
32 changes: 21 additions & 11 deletions ORStools/i18n/orstools_de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,53 +165,63 @@
<context>
<name>ORSIsochronesLayerAlgo</name>
<message>
<location filename="../proc/isochrones_layer_proc.py" line="60"/>
<location filename="../proc/isochrones_layer_proc.py" line="64"/>
<source>Input Point layer</source>
<translation>Eingabelayer (Punkte)</translation>
</message>
<message>
<location filename="../proc/isochrones_layer_proc.py" line="69"/>
<location filename="../proc/isochrones_layer_proc.py" line="73"/>
<source>Input layer ID Field (mutually exclusive with Point option)</source>
<translation>ID-Attribut (schließt Punkt-Option aus)</translation>
</message>
<message>
<location filename="../proc/isochrones_layer_proc.py" line="75"/>
<location filename="../proc/isochrones_layer_proc.py" line="79"/>
<source>Dimension</source>
<translation>Dimension</translation>
</message>
<message>
<location filename="../proc/isochrones_layer_proc.py" line="81"/>
<location filename="../proc/isochrones_layer_proc.py" line="85"/>
<source>Comma-separated ranges [min or m]</source>
<translation>Komma-getrennte Reichweiten [min oder m]</translation>
</message>
<message>
<location filename="../proc/isochrones_layer_proc.py" line="203"/>
<location filename="../proc/isochrones_layer_proc.py" line="225"/>
<source>Isochrones from Point-Layer</source>
<translation>Isochronen aus Punkt-Layer</translation>
</message>
<message>
<location filename="../proc/isochrones_layer_proc.py" line="90"/>
<source>Smoothing factor between 0 [detailed] and 100 [generalized]</source>
<translation>Glättungsfaktor zwischen 0 [detailliert] und 100 [verallgemeinert]</translation>
</message>
</context>
<context>
<name>ORSIsochronesPointAlgo</name>
<message>
<location filename="../proc/isochrones_point_proc.py" line="55"/>
<location filename="../proc/isochrones_point_proc.py" line="58"/>
<source>Input Point from map canvas (mutually exclusive with layer option)</source>
<translation>Eingabepunkt aus Kartenansicht (schließt Ebenen-Option aus)</translation>
</message>
<message>
<location filename="../proc/isochrones_point_proc.py" line="60"/>
<location filename="../proc/isochrones_point_proc.py" line="63"/>
<source>Dimension</source>
<translation>Dimension</translation>
</message>
<message>
<location filename="../proc/isochrones_point_proc.py" line="66"/>
<location filename="../proc/isochrones_point_proc.py" line="69"/>
<source>Comma-separated ranges [min or m]</source>
<translation>Komma-getrennte Reichweiten [min oder m]</translation>
</message>
<message>
<location filename="../proc/isochrones_point_proc.py" line="144"/>
<location filename="../proc/isochrones_point_proc.py" line="163"/>
<source>Isochrones from Point</source>
<translation>Isochronen von einzelnem Punkt</translation>
</message>
<message>
<location filename="../proc/isochrones_point_proc.py" line="74"/>
<source>Smoothing factor between 0 [detailed] and 100 [generalized]</source>
<translation>Glättungsfaktor zwischen 0 [detailliert] und 100 [verallgemeinert]</translation>
</message>
</context>
<context>
<name>ORSMatrixAlgo</name>
Expand Down Expand Up @@ -244,12 +254,12 @@
<context>
<name>ORStoolsDialog</name>
<message>
<location filename="../gui/ORStoolsDialog.py" line="385"/>
<location filename="../gui/ORStoolsDialog.py" line="392"/>
<source>Apply</source>
<translation>Anwenden</translation>
</message>
<message>
<location filename="../gui/ORStoolsDialog.py" line="386"/>
<location filename="../gui/ORStoolsDialog.py" line="393"/>
<source>Close</source>
<translation>Schließen</translation>
</message>
Expand Down
37 changes: 27 additions & 10 deletions ORStools/proc/isochrones_layer_proc.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
QgsProcessingParameterFeatureSource,
QgsProcessingParameterString,
QgsProcessingParameterEnum,
QgsProcessingParameterNumber,
QgsProcessingParameterDefinition,
)

from ORStools.common import isochrones_core, PROFILES, DIMENSIONS
Expand All @@ -57,6 +59,7 @@ def __init__(self):
self.IN_RANGES = "INPUT_RANGES"
self.IN_KEY = "INPUT_APIKEY"
self.IN_DIFFERENCE = "INPUT_DIFFERENCE"
self.IN_SMOOTHING = "INPUT_SMOOTHING"
self.PARAMETERS = [
QgsProcessingParameterFeatureSource(
name=self.IN_POINTS,
Expand Down Expand Up @@ -84,6 +87,14 @@ def __init__(self):
description=self.tr("Comma-separated ranges [min or m]"),
defaultValue="5, 10",
),
QgsProcessingParameterNumber(
name=self.IN_SMOOTHING,
description=self.tr("Smoothing factor between 0 [detailed] and 100 [generalized]"),
defaultValue=None,
minValue=0,
maxValue=100,
optional=True,
),
]

# Save some important references
Expand All @@ -104,10 +115,12 @@ def processAlgorithm(self, parameters, context, feedback):
factor = 60 if dimension == "time" else 1
ranges_raw = parameters[self.IN_RANGES]
ranges_proc = [x * factor for x in map(int, ranges_raw.split(","))]
smoothing = parameters[self.IN_SMOOTHING]

# self.difference = self.parameterAsBool(parameters, self.IN_DIFFERENCE, context)
source = self.parameterAsSource(parameters, self.IN_POINTS, context)

# get smoothness parameter value
options = self.parseOptions(parameters, context)

# Make the actual requests
Expand All @@ -131,16 +144,20 @@ def processAlgorithm(self, parameters, context, feedback):
if feedback.isCanceled():
break

requests.append(
{
"locations": locations,
"range_type": dimension,
"range": ranges_proc,
"attributes": ["total_pop"],
"id": id_value,
"options": options,
}
)
params = {
"locations": locations,
"range_type": dimension,
"range": ranges_proc,
"attributes": ["total_pop"],
"id": id_value,
"options": options,
}

# only include smoothing if set
if smoothing is not None:
params["smoothing"] = smoothing

requests.append(params)

(sink, self.dest_id) = self.parameterAsSink(
parameters,
Expand Down
15 changes: 15 additions & 0 deletions ORStools/proc/isochrones_point_proc.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
QgsProcessingParameterString,
QgsProcessingParameterEnum,
QgsProcessingParameterPoint,
QgsProcessingParameterNumber,
QgsProcessingParameterDefinition,
)

from ORStools.common import isochrones_core, PROFILES, DIMENSIONS
Expand All @@ -52,6 +54,7 @@ def __init__(self):
self.IN_RANGES = "INPUT_RANGES"
self.IN_KEY = "INPUT_APIKEY"
self.IN_DIFFERENCE = "INPUT_DIFFERENCE"
self.IN_SMOOTHING = "INPUT_SMOOTHING"
self.PARAMETERS = [
QgsProcessingParameterPoint(
name=self.IN_POINT,
Expand All @@ -71,6 +74,14 @@ def __init__(self):
description=self.tr("Comma-separated ranges [min or m]"),
defaultValue="5, 10",
),
QgsProcessingParameterNumber(
name=self.IN_SMOOTHING,
description=self.tr("Smoothing factor between 0 [detailed] and 100 [generalized]"),
defaultValue=None,
minValue=0,
maxValue=100,
optional=True,
),
]

# Save some important references
Expand All @@ -91,6 +102,7 @@ def processAlgorithm(self, parameters, context, feedback):
factor = 60 if dimension == "time" else 1
ranges_raw = parameters[self.IN_RANGES]
ranges_proc = [x * factor for x in map(int, ranges_raw.split(","))]
smoothing = parameters[self.IN_SMOOTHING]

options = self.parseOptions(parameters, context)

Expand All @@ -108,6 +120,9 @@ def processAlgorithm(self, parameters, context, feedback):
"options": options,
}

if smoothing is not None:
params["smoothing"] = smoothing

(sink, self.dest_id) = self.parameterAsSink(
parameters,
self.OUT,
Expand Down

0 comments on commit 1959f23

Please sign in to comment.