Merge pull request 'Add crs to the geometry importer as a parameter' (#51) from geojson_exporter into main

Reviewed-on: https://nextgenerations-cities.encs.concordia.ca/gitea/CERC/hub/pulls/51
This commit is contained in:
Guille Gutierrez 2023-10-24 10:03:49 -04:00
commit 3512d4b1e4
3 changed files with 21 additions and 11 deletions

View File

@ -26,13 +26,16 @@ class CityGml:
extrusion_height_field=None, extrusion_height_field=None,
year_of_construction_field=None, year_of_construction_field=None,
function_field=None, function_field=None,
function_to_hub=None): function_to_hub=None,
hub_crs=None):
self._city = None self._city = None
self._lod = None self._lod = None
self._lod1_tags = ['lod1Solid', 'lod1MultiSurface'] self._lod1_tags = ['lod1Solid', 'lod1MultiSurface']
self._lod2_tags = ['lod2Solid', 'lod2MultiSurface', 'lod2MultiCurve'] self._lod2_tags = ['lod2Solid', 'lod2MultiSurface', 'lod2MultiCurve']
self._extrusion_height_field = extrusion_height_field self._extrusion_height_field = extrusion_height_field
self._function_to_hub = function_to_hub self._function_to_hub = function_to_hub
if hub_crs is None:
hub_crs = 'EPSG:26911'
if function_field is None: if function_field is None:
function_field = 'function' function_field = 'function'
if year_of_construction_field is None: if year_of_construction_field is None:
@ -80,8 +83,8 @@ class CityGml:
self._srs_name = envelope['@srsName'] self._srs_name = envelope['@srsName']
else: else:
# If not coordinate system given assuming hub standard # If not coordinate system given assuming hub standard
logging.warning('gml file contains no coordinate system assuming EPSG:26911 (North america with 4m error)') logging.warning(f'gml file contains no coordinate system assuming {hub_crs}')
self._srs_name = "EPSG:26911" self._srs_name = hub_crs
else: else:
# get the boundary from the city objects instead # get the boundary from the city objects instead
for city_object_member in self._gml['CityModel']['cityObjectMember']: for city_object_member in self._gml['CityModel']['cityObjectMember']:

View File

@ -34,9 +34,13 @@ class Geojson:
extrusion_height_field=None, extrusion_height_field=None,
year_of_construction_field=None, year_of_construction_field=None,
function_field=None, function_field=None,
function_to_hub=None): function_to_hub=None,
# todo: destination epsg should change according actual the location hub_crs=None
self._transformer = Transformer.from_crs('epsg:4326', 'epsg:26911') ):
self._hub_crs = hub_crs
if hub_crs is None :
self._hub_crs = 'epsg:26911'
self._transformer = Transformer.from_crs('epsg:4326', self._hub_crs)
self._min_x = cte.MAX_FLOAT self._min_x = cte.MAX_FLOAT
self._min_y = cte.MAX_FLOAT self._min_y = cte.MAX_FLOAT
self._max_x = cte.MIN_FLOAT self._max_x = cte.MIN_FLOAT
@ -155,7 +159,7 @@ class Geojson:
extrusion_height)) extrusion_height))
else: else:
raise NotImplementedError(f'Geojson geometry type [{geometry["type"]}] unknown') raise NotImplementedError(f'Geojson geometry type [{geometry["type"]}] unknown')
self._city = City([self._min_x, self._min_y, 0.0], [self._max_x, self._max_y, self._max_z], 'epsg:26911') self._city = City([self._min_x, self._min_y, 0.0], [self._max_x, self._max_y, self._max_z], self._hub_crs)
for building in buildings: for building in buildings:
# Do not include "small building-like structures" to buildings # Do not include "small building-like structures" to buildings
if building.floor_area >= 25: if building.floor_area >= 25:
@ -166,7 +170,6 @@ class Geojson:
if lod > 0: if lod > 0:
lines_information = GeometryHelper.city_mapping(self._city, plot=False) lines_information = GeometryHelper.city_mapping(self._city, plot=False)
self._store_shared_percentage_to_walls(self._city, lines_information) self._store_shared_percentage_to_walls(self._city, lines_information)
return self._city return self._city
def _polygon_coordinates_to_3d(self, polygon_coordinates): def _polygon_coordinates_to_3d(self, polygon_coordinates):

View File

@ -23,7 +23,8 @@ class GeometryFactory:
height_field=None, height_field=None,
year_of_construction_field=None, year_of_construction_field=None,
function_field=None, function_field=None,
function_to_hub=None): function_to_hub=None,
hub_crs=None):
self._file_type = '_' + file_type.lower() self._file_type = '_' + file_type.lower()
validate_import_export_type(GeometryFactory, file_type) validate_import_export_type(GeometryFactory, file_type)
self._path = path self._path = path
@ -33,6 +34,7 @@ class GeometryFactory:
self._year_of_construction_field = year_of_construction_field self._year_of_construction_field = year_of_construction_field
self._function_field = function_field self._function_field = function_field
self._function_to_hub = function_to_hub self._function_to_hub = function_to_hub
self._hub_crs = hub_crs
@property @property
def _citygml(self) -> City: def _citygml(self) -> City:
@ -44,7 +46,8 @@ class GeometryFactory:
self._height_field, self._height_field,
self._year_of_construction_field, self._year_of_construction_field,
self._function_field, self._function_field,
self._function_to_hub).city self._function_to_hub,
self._hub_crs).city
@property @property
def _obj(self) -> City: def _obj(self) -> City:
@ -65,7 +68,8 @@ class GeometryFactory:
self._height_field, self._height_field,
self._year_of_construction_field, self._year_of_construction_field,
self._function_field, self._function_field,
self._function_to_hub).city self._function_to_hub,
self._hub_crs).city
@property @property
def city(self) -> City: def city(self) -> City: