Skip to content

Commit

Permalink
feat: order extra_info according to fields order
Browse files Browse the repository at this point in the history
  • Loading branch information
koebi committed May 15, 2024
1 parent 15b4d0c commit 58b2848
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions ORStools/common/directions_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,14 +250,15 @@ def build_default_parameters(
return params


def get_extra_info_features_directions(response: dict):
def get_extra_info_features_directions(response: dict, extra_info_order: list[str]):
extra_info_order = [key if key != "waytype" else "waytypes" for key in extra_info_order] # inconsistency in API
response_mini = response["features"][0]
coordinates = response_mini["geometry"]["coordinates"]
feats = list()
extra_info = response_mini["properties"]["extras"]
logger.log(str(extra_info))
extras_list = {i: [] for i in extra_info}
for key in extra_info:
extras_list = {i: [] for i in extra_info_order}
for key in extra_info_order:
values = extra_info[key]["values"]
for val in values:
for i in range(val[0], val[1]):
Expand Down
3 changes: 2 additions & 1 deletion ORStools/proc/directions_points_layer_proc.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ def processAlgorithm(self, parameters, context, feedback):
**get_fields_options, line=True, extra_info=extra_info
)


(sink, dest_id) = self.parameterAsSink(
parameters,
self.OUT,
Expand Down Expand Up @@ -219,7 +220,7 @@ def sort(f):
)

if extra_info:
feats = directions_core.get_extra_info_features_directions(response)
feats = directions_core.get_extra_info_features_directions(response, extra_info)
for feat in feats:
sink.addFeature(feat)
else:
Expand Down

0 comments on commit 58b2848

Please sign in to comment.