add name field to geojson
This commit is contained in:
parent
4ca8975e18
commit
af0e2a7c69
|
@ -29,6 +29,7 @@ class Geojson:
|
|||
|
||||
def __init__(self,
|
||||
path,
|
||||
name_field=None,
|
||||
extrusion_height_field=None,
|
||||
year_of_construction_field=None,
|
||||
function_field=None,
|
||||
|
@ -41,6 +42,7 @@ class Geojson:
|
|||
self._max_y = cte.MIN_FLOAT
|
||||
self._max_z = 0
|
||||
self._city = None
|
||||
self._name_field = name_field
|
||||
self._extrusion_height_field = extrusion_height_field
|
||||
self._year_of_construction_field = year_of_construction_field
|
||||
self._function_field = function_field
|
||||
|
@ -209,10 +211,12 @@ class Geojson:
|
|||
else:
|
||||
building_name = f'building_{building_id}'
|
||||
building_id += 1
|
||||
if self._name_field is not None:
|
||||
building_name = feature['properties'][self._name_field]
|
||||
polygons = []
|
||||
for part, coordinates in enumerate(geometry['coordinates']):
|
||||
polygons = self._get_polygons(polygons, coordinates)
|
||||
for zone, polygon in enumerate(polygons):
|
||||
for polygon in polygons:
|
||||
if extrusion_height == 0:
|
||||
buildings = buildings + Geojson._create_buildings_lod0(f'{building_name}_part_{part}',
|
||||
year_of_construction,
|
||||
|
|
|
@ -23,6 +23,7 @@ class GeometryFactory:
|
|||
def __init__(self, file_type,
|
||||
path=None,
|
||||
data_frame=None,
|
||||
name_field=None,
|
||||
height_field=None,
|
||||
year_of_construction_field=None,
|
||||
function_field=None,
|
||||
|
@ -35,6 +36,7 @@ class GeometryFactory:
|
|||
raise Exception(err_msg)
|
||||
self._path = path
|
||||
self._data_frame = data_frame
|
||||
self._name_field = name_field
|
||||
self._height_field = height_field
|
||||
self._year_of_construction_field = year_of_construction_field
|
||||
self._function_field = function_field
|
||||
|
@ -77,6 +79,7 @@ class GeometryFactory:
|
|||
:return: City
|
||||
"""
|
||||
return Geojson(self._path,
|
||||
self._name_field,
|
||||
self._height_field,
|
||||
self._year_of_construction_field,
|
||||
self._function_field,
|
||||
|
|
|
@ -139,9 +139,12 @@ class TestGeometryFactory(TestCase):
|
|||
path=(self._example_path / file).resolve(),
|
||||
height_field='building_height',
|
||||
year_of_construction_field='ANNEE_CONS',
|
||||
name_field='ID_UEV',
|
||||
function_field='CODE_UTILI',
|
||||
function_to_hub=MontrealFunctionToHubFunction().dictionary).city
|
||||
# include 25 square meter condition for a building reduces buildings number from 2289 to 2057
|
||||
for building in city.buildings:
|
||||
print(building.name)
|
||||
self.assertEqual(2057, len(city.buildings), 'wrong number of buildings')
|
||||
|
||||
def test_map_neighbours(self):
|
||||
|
|
Loading…
Reference in New Issue
Block a user