Geojson class modified for the geojson format Guille suggested

This commit is contained in:
Saeed Ranjbar 2024-07-24 10:26:45 -04:00 committed by majidrezaei93
parent 47810737fa
commit df2d7a3054

View File

@ -3,7 +3,6 @@ Geojson module parses geojson files and import the geometry into the city model
SPDX - License - Identifier: LGPL - 3.0 - or -later SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2022 Concordia CERC group Copyright © 2022 Concordia CERC group
Project Coder Guillermo Gutierrez Guillermo.GutierrezMorote@concordia.ca Project Coder Guillermo Gutierrez Guillermo.GutierrezMorote@concordia.ca
Project Collaborator Saeed Ranjbar saeed.ranjbar@concordia.ca
""" """
import uuid import uuid
@ -130,16 +129,24 @@ class Geojson:
function = str(feature['properties'][self._function_field]) function = str(feature['properties'][self._function_field])
if function == 'Mixed use' or function == 'mixed use': if function == 'Mixed use' or function == 'mixed use':
function_parts = [] function_parts = []
for key, value in feature['properties'].items(): if 'usages' in feature['properties']:
if key.startswith("mixed_type_") and not key.endswith("_percentage"): usages = feature['properties']['usages']
type_key = key for usage in usages:
percentage_key = f"{key}_percentage" if self._function_to_hub is not None and usage['usage'] in self._function_to_hub:
if percentage_key in feature['properties']: function_parts.append(f"{usage['percentage']}-{self._function_to_hub[usage['usage']]}")
if self._function_to_hub is not None and feature['properties'][type_key] in self._function_to_hub: else:
usage_function = self._function_to_hub[feature['properties'][type_key]] function_parts.append(f"{usage['percentage']}-{usage['usage']}")
function_parts.append(f"{feature['properties'][percentage_key]}-{usage_function}") else:
else: for key, value in feature['properties'].items():
function_parts.append(f"{feature['properties'][percentage_key]}-{feature['properties'][type_key]}") if key.startswith("mixed_type_") and not key.endswith("_percentage"):
type_key = key
percentage_key = f"{key}_percentage"
if percentage_key in feature['properties']:
if self._function_to_hub is not None and feature['properties'][type_key] in self._function_to_hub:
usage_function = self._function_to_hub[feature['properties'][type_key]]
function_parts.append(f"{feature['properties'][percentage_key]}-{usage_function}")
else:
function_parts.append(f"{feature['properties'][percentage_key]}-{feature['properties'][type_key]}")
function = "_".join(function_parts) function = "_".join(function_parts)
if self._function_to_hub is not None: if self._function_to_hub is not None:
# use the transformation dictionary to retrieve the proper function # use the transformation dictionary to retrieve the proper function