Skip to content

Commit

Permalink
changed the osmid keys to be JInteger instead of Long, to save memory
Browse files Browse the repository at this point in the history
  • Loading branch information
roopehub committed Aug 29, 2024
1 parent 993a264 commit 365ff54
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/r5py/r5/custom_cost_transport_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def _validate_custom_cost_params(
len(custom_cost_segment_weight_factor) == 0
or not isinstance(custom_cost_segment_weight_factor, dict)
or not all(
isinstance(key, str) and isinstance(value, float)
isinstance(key, (str, int)) and isinstance(value, float)
for key, value in custom_cost_segment_weight_factor.items()
)
):
Expand Down
2 changes: 1 addition & 1 deletion src/r5py/r5/travel_time_matrix_computer.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def _parse_results(self, from_id, results):
# add OSM IDs if found in results
# osmIdsResults are generated when routing with custom_cost_transport_network
if hasattr(results, "osmIdResults") and results.osmIdResults:
od_matrix["osm_ids"] = results.osmIdResults
od_matrix["osm_ids"] = list(results.osmIdResults)

# R5’s NULL value is MAX_INT32
od_matrix = self._fill_nulls(od_matrix)
Expand Down
5 changes: 3 additions & 2 deletions src/r5py/util/custom_cost_conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ def convert_python_dict_to_java_hashmap(custom_cost_segment_weight_factors):
custom_cost_java_hashmap : jpype.java.util.HashMap
Custom cost factors in Java HashMap format.
"""
JInteger = jpype.JClass("java.lang.Integer")
custom_cost_java_hashmap = jpype.JClass("java.util.HashMap")()
for key, value_cost in custom_cost_segment_weight_factors.items():
long_key = jpype.JLong(key)
int_key = JInteger(int(key))
int_value = jpype.JDouble(value_cost)
custom_cost_java_hashmap.put(long_key, int_value)
custom_cost_java_hashmap.put(int_key, int_value)
return custom_cost_java_hashmap


Expand Down

0 comments on commit 365ff54

Please sign in to comment.