Skip to content

Commit

Permalink
feat: add support for csv_column
Browse files Browse the repository at this point in the history
  • Loading branch information
merydian committed May 3, 2024
1 parent f616734 commit aa52090
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
9 changes: 9 additions & 0 deletions ORStools/proc/directions_lines_proc.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
QgsProcessingParameterEnum,
QgsPointXY,
QgsProcessingParameterNumber,
QgsProcessingParameterString,
)

from ORStools.common import directions_core, PROFILES, PREFERENCES, OPTIMIZATION_MODES, EXTRA_INFOS
Expand All @@ -59,6 +60,7 @@ def __init__(self):
self.IN_MODE = "INPUT_MODE"
self.EXTRA_INFO = "EXTRA_INFO"
self.CSV_FACTOR = "CSV_FACTOR"
self.CSV_COLUMN = "CSV_COLUMN"
self.PARAMETERS = [
QgsProcessingParameterFeatureSource(
name=self.IN_LINES,
Expand Down Expand Up @@ -98,6 +100,13 @@ def __init__(self):
type=QgsProcessingParameterNumber.Double,
minValue=0,
maxValue=1,
defaultValue=None,
optional=True,
),
QgsProcessingParameterString(
self.CSV_COLUMN,
self.tr("Csv Column"),
optional=True,
),
]

Expand Down
15 changes: 14 additions & 1 deletion ORStools/proc/directions_points_layer_proc.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
QgsProcessingParameterEnum,
QgsPointXY,
QgsProcessingParameterNumber,
QgsProcessingParameterString,
)

from ORStools.common import directions_core, PROFILES, PREFERENCES, OPTIMIZATION_MODES, EXTRA_INFOS
Expand All @@ -60,6 +61,7 @@ def __init__(self):
self.IN_SORTBY = "INPUT_SORTBY"
self.EXTRA_INFO = "EXTRA_INFO"
self.CSV_FACTOR = "CSV_FACTOR"
self.CSV_COLUMN = "CSV_COLUMN"
self.PARAMETERS = [
QgsProcessingParameterFeatureSource(
name=self.IN_POINTS,
Expand Down Expand Up @@ -106,6 +108,13 @@ def __init__(self):
type=QgsProcessingParameterNumber.Double,
minValue=0,
maxValue=1,
defaultValue=None,
optional=True,
),
QgsProcessingParameterString(
self.CSV_COLUMN,
self.tr("Csv Column"),
optional=True,
),
]

Expand All @@ -120,9 +129,13 @@ def processAlgorithm(self, parameters, context, feedback):

options = self.parseOptions(parameters, context)

csv_column = self.parameterAsString(parameters, self.CSV_COLUMN, context)

csv_factor = self.parameterAsDouble(parameters, self.CSV_FACTOR, context)
if csv_factor > 0:
options["profile_params"] = {"weightings": {"csv_factor": csv_factor}}
options["profile_params"] = {
"weightings": {"csv_factor": round(csv_factor, 2), "csv_column": csv_column}
}

extra_info = self.parameterAsEnums(parameters, self.EXTRA_INFO, context)
extra_info = [EXTRA_INFOS[i] for i in extra_info]
Expand Down
9 changes: 9 additions & 0 deletions ORStools/proc/directions_points_layers_proc.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
QgsProcessingParameterFeatureSource,
QgsProcessingParameterEnum,
QgsProcessingParameterNumber,
QgsProcessingParameterString,
)

from ORStools.common import directions_core, PROFILES, PREFERENCES, EXTRA_INFOS
Expand All @@ -59,6 +60,7 @@ def __init__(self):
self.IN_MODE = "INPUT_MODE"
self.EXTRA_INFO = "EXTRA_INFO"
self.CSV_FACTOR = "CSV_FACTOR"
self.CSV_COLUMN = "CSV_COLUMN"
self.PARAMETERS = [
QgsProcessingParameterFeatureSource(
name=self.IN_START,
Expand Down Expand Up @@ -123,6 +125,13 @@ def __init__(self):
type=QgsProcessingParameterNumber.Double,
minValue=0,
maxValue=1,
defaultValue=None,
optional=True,
),
QgsProcessingParameterString(
self.CSV_COLUMN,
self.tr("Csv Column"),
optional=True,
),
]

Expand Down

0 comments on commit aa52090

Please sign in to comment.