Skip to content

Commit

Permalink
feat: add necessary fields to output layer
Browse files Browse the repository at this point in the history
  • Loading branch information
merydian committed Apr 26, 2024
1 parent 92f79bd commit 729a0da
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions ORStools/common/directions_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def get_fields(
from_name="FROM_ID",
to_name="TO_ID",
line=False,
extra_info: list = []
):
"""
Builds output fields for directions response layer.
Expand Down Expand Up @@ -112,6 +113,8 @@ def get_fields(
fields.append(QgsField(from_name, from_type))
if not line:
fields.append(QgsField(to_name, to_type))
for info in extra_info:
fields.append(QgsField(info.upper(), QVariant.String))

return fields

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 @@ -123,7 +123,7 @@ def processAlgorithm(self, parameters, context, feedback):
from_name=source_field_name,
)

sink_fields = directions_core.get_fields(**get_fields_options, line=True)
sink_fields = directions_core.get_fields(**get_fields_options, line=True, extra_info=extra_info)

(sink, dest_id) = self.parameterAsSink(
parameters,
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 @@ -124,7 +124,7 @@ def processAlgorithm(self, parameters, context, feedback):
from_name=source_field_name,
)

sink_fields = directions_core.get_fields(**get_fields_options, line=True)
sink_fields = directions_core.get_fields(**get_fields_options, line=True, extra_info=extra_info)

(sink, dest_id) = self.parameterAsSink(
parameters,
Expand Down
2 changes: 1 addition & 1 deletion ORStools/proc/directions_points_layers_proc.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def sort_end(f):
field_types.update({"from_type": source_field.type()})
if destination_field:
field_types.update({"to_type": destination_field.type()})
sink_fields = directions_core.get_fields(**field_types)
sink_fields = directions_core.get_fields(**field_types, extra_info=extra_info)

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

0 comments on commit 729a0da

Please sign in to comment.