Stashing changes
This commit is contained in:
parent
a1bc4bc33e
commit
43cb1e5612
|
@ -18,6 +18,8 @@ from hub.city_model_structure.attributes.polygon import Polygon
|
||||||
from hub.city_model_structure.building import Building
|
from hub.city_model_structure.building import Building
|
||||||
from hub.city_model_structure.building_demand.surface import Surface
|
from hub.city_model_structure.building_demand.surface import Surface
|
||||||
from hub.city_model_structure.city import City
|
from hub.city_model_structure.city import City
|
||||||
|
from typing import Dict, Tuple
|
||||||
|
from shapely.geometry import Polygon
|
||||||
|
|
||||||
|
|
||||||
class Geojson:
|
class Geojson:
|
||||||
|
@ -78,7 +80,6 @@ class Geojson:
|
||||||
lod0_buildings = Geojson._create_buildings_lod0(name, year_of_construction, function, surface_coordinates)
|
lod0_buildings = Geojson._create_buildings_lod0(name, year_of_construction, function, surface_coordinates)
|
||||||
surfaces = []
|
surfaces = []
|
||||||
buildings = []
|
buildings = []
|
||||||
|
|
||||||
for zone, lod0_building in enumerate(lod0_buildings):
|
for zone, lod0_building in enumerate(lod0_buildings):
|
||||||
for surface in lod0_building.grounds:
|
for surface in lod0_building.grounds:
|
||||||
|
|
||||||
|
@ -175,6 +176,19 @@ class Geojson:
|
||||||
percentage += percentage_ground * percentage_height
|
percentage += percentage_ground * percentage_height
|
||||||
wall.percentage_shared = percentage
|
wall.percentage_shared = percentage
|
||||||
|
|
||||||
|
'''def _remove_sub_polygons(self, building_coordinates: Dict, new_coordinate: Tuple) -> Dict:
|
||||||
|
new_polygon = Polygon(new_coordinate[1])
|
||||||
|
is_sub_polygon = False
|
||||||
|
for coordinates in building_coordinates['coords']:
|
||||||
|
if Polygon(coordinates).contains(new_polygon):
|
||||||
|
is_sub_polygon = True
|
||||||
|
|
||||||
|
if not is_sub_polygon:
|
||||||
|
building_coordinates['coords'].append(new_coordinate[1])
|
||||||
|
building_coordinates['parts'].append(new_coordinate[0])
|
||||||
|
|
||||||
|
return building_coordinates'''
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def city(self) -> City:
|
def city(self) -> City:
|
||||||
"""
|
"""
|
||||||
|
@ -210,6 +224,11 @@ class Geojson:
|
||||||
building_name = f'building_{building_id}'
|
building_name = f'building_{building_id}'
|
||||||
building_id += 1
|
building_id += 1
|
||||||
polygons = []
|
polygons = []
|
||||||
|
'''building_coordinates = {'coords': [], 'parts': []}
|
||||||
|
for part, coordinates in enumerate(geometry['coordinates']):
|
||||||
|
building_coordinates = self._remove_sub_polygons(building_coordinates, (part, coordinates))
|
||||||
|
# remove polygon inside other polygons
|
||||||
|
print(building_coordinates)'''
|
||||||
for part, coordinates in enumerate(geometry['coordinates']):
|
for part, coordinates in enumerate(geometry['coordinates']):
|
||||||
polygons = self._get_polygons(polygons, coordinates)
|
polygons = self._get_polygons(polygons, coordinates)
|
||||||
for zone, polygon in enumerate(polygons):
|
for zone, polygon in enumerate(polygons):
|
||||||
|
|
|
@ -141,9 +141,23 @@ class TestGeometryFactory(TestCase):
|
||||||
year_of_construction_field='ANNEE_CONS',
|
year_of_construction_field='ANNEE_CONS',
|
||||||
function_field='CODE_UTILI',
|
function_field='CODE_UTILI',
|
||||||
function_to_hub=MontrealFunctionToHubFunction().dictionary).city
|
function_to_hub=MontrealFunctionToHubFunction().dictionary).city
|
||||||
# include 25 square meter condition for a building reduces buildings number from 2289 to 2057
|
# including 25 square meter condition for a building reduces buildings number from 2289 to 2057
|
||||||
self.assertEqual(2057, len(city.buildings), 'wrong number of buildings')
|
self.assertEqual(2057, len(city.buildings), 'wrong number of buildings')
|
||||||
|
|
||||||
|
def test_import_geojson_2(self):
|
||||||
|
"""
|
||||||
|
Test geojson import
|
||||||
|
"""
|
||||||
|
file = 'test.geojson'
|
||||||
|
city = GeometryFactory('geojson',
|
||||||
|
path=(self._example_path / file).resolve(),
|
||||||
|
height_field='citygml_me',
|
||||||
|
year_of_construction_field='ANNEE_CONS',
|
||||||
|
function_field='CODE_UTILI',
|
||||||
|
function_to_hub=MontrealFunctionToHubFunction().dictionary).city
|
||||||
|
for building in city.buildings:
|
||||||
|
print(building.floor_area)
|
||||||
|
|
||||||
def test_map_neighbours(self):
|
def test_map_neighbours(self):
|
||||||
"""
|
"""
|
||||||
Test neighbours map creation
|
Test neighbours map creation
|
||||||
|
|
209
hub/unittests/tests_data/test.geojson
Normal file
209
hub/unittests/tests_data/test.geojson
Normal file
|
@ -0,0 +1,209 @@
|
||||||
|
{
|
||||||
|
"type":"FeatureCollection",
|
||||||
|
"features":[
|
||||||
|
{
|
||||||
|
"type":"Feature",
|
||||||
|
"id":164,
|
||||||
|
"geometry":{
|
||||||
|
"type":"Polygon",
|
||||||
|
"coordinates":[
|
||||||
|
[
|
||||||
|
[
|
||||||
|
-73.577465563026294,
|
||||||
|
45.495808553995417
|
||||||
|
],
|
||||||
|
[
|
||||||
|
-73.577627737571262,
|
||||||
|
45.49588695081647
|
||||||
|
],
|
||||||
|
[
|
||||||
|
-73.577789912566104,
|
||||||
|
45.4959653474059
|
||||||
|
],
|
||||||
|
[
|
||||||
|
-73.577897155727669,
|
||||||
|
45.495855628290393
|
||||||
|
],
|
||||||
|
[
|
||||||
|
-73.578004398472899,
|
||||||
|
45.49574590907234
|
||||||
|
],
|
||||||
|
[
|
||||||
|
-73.577709868721371,
|
||||||
|
45.495603565479428
|
||||||
|
],
|
||||||
|
[
|
||||||
|
-73.577680024034251,
|
||||||
|
45.495589134278653
|
||||||
|
],
|
||||||
|
[
|
||||||
|
-73.577465563026294,
|
||||||
|
45.495808553995417
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"properties":{
|
||||||
|
"OBJECTID_12":164,
|
||||||
|
"gml_id":"1066826",
|
||||||
|
"gml_parent":"fme-gen-57964590-baa9-48a7-99b0-fa11ca012d7c",
|
||||||
|
"citygml_ta":"http://www.opengis.net/citygml/building/2.0",
|
||||||
|
"citygml_fe":"cityObjectMember",
|
||||||
|
"citygml__1":" ",
|
||||||
|
"citygml__2":" ",
|
||||||
|
"gml_descri":" ",
|
||||||
|
"gml_name":" ",
|
||||||
|
"citygml_cr":" ",
|
||||||
|
"citygml_te":" ",
|
||||||
|
"externalRe":" ",
|
||||||
|
"external_1":" ",
|
||||||
|
"external_2":" ",
|
||||||
|
"citygml_ge":" ",
|
||||||
|
"citygml_re":" ",
|
||||||
|
"citygml__3":" ",
|
||||||
|
"citygml_ap":" ",
|
||||||
|
"citygml_cl":" ",
|
||||||
|
"citygml__4":" ",
|
||||||
|
"citygml_fu":" ",
|
||||||
|
"citygml__5":" ",
|
||||||
|
"citygml_us":" ",
|
||||||
|
"citygml__6":" ",
|
||||||
|
"citygml_ye":" ",
|
||||||
|
"citygml__7":" ",
|
||||||
|
"citygml_ro":" ",
|
||||||
|
"citygml__8":" ",
|
||||||
|
"citygml_me":65.929000000000002,
|
||||||
|
"citygml__9":"#m",
|
||||||
|
"citygml_st":" ",
|
||||||
|
"citygml_10":" ",
|
||||||
|
"citygml_11":" ",
|
||||||
|
"citygml_12":" ",
|
||||||
|
"citygml_13":" ",
|
||||||
|
"citygml_14":" ",
|
||||||
|
"citygml_ou":" ",
|
||||||
|
"citygml_in":" ",
|
||||||
|
"citygml_bo":" ",
|
||||||
|
"citygml_le":" ",
|
||||||
|
"citygml_15":" ",
|
||||||
|
"citygml_co":" ",
|
||||||
|
"citygml_ad":" ",
|
||||||
|
"Volume":"52877.804",
|
||||||
|
"parcelle":" ",
|
||||||
|
"OBJECTID":7589,
|
||||||
|
"gml_id_1":"46c9507d-33c9-40e9-9bda-00ad6fa8cd8f",
|
||||||
|
"gml_pare_1":"1066826",
|
||||||
|
"citygml_16":"http://www.opengis.net/citygml/building/2.0",
|
||||||
|
"citygml_17":"boundedBy",
|
||||||
|
"citygml_18":" ",
|
||||||
|
"citygml_19":" ",
|
||||||
|
"gml_desc_1":" ",
|
||||||
|
"gml_name_1":" ",
|
||||||
|
"citygml_20":" ",
|
||||||
|
"citygml_21":" ",
|
||||||
|
"external_3":" ",
|
||||||
|
"external_4":" ",
|
||||||
|
"external_5":" ",
|
||||||
|
"citygml_22":" ",
|
||||||
|
"citygml_23":" ",
|
||||||
|
"citygml_24":" ",
|
||||||
|
"citygml_25":" ",
|
||||||
|
"citygml_26":" ",
|
||||||
|
"citygml_op":" ",
|
||||||
|
"Area":"911.899",
|
||||||
|
"FID_":0,
|
||||||
|
"Join_Count":1,
|
||||||
|
"TARGET_FID":7594,
|
||||||
|
"gml_id_12":"1066826",
|
||||||
|
"gml_pare_2":"fme-gen-57964590-baa9-48a7-99b0-fa11ca012d7c",
|
||||||
|
"citygml_27":"http://www.opengis.net/citygml/building/2.0",
|
||||||
|
"citygml_28":"cityObjectMember",
|
||||||
|
"citygml_29":" ",
|
||||||
|
"citygml_30":" ",
|
||||||
|
"gml_desc_2":" ",
|
||||||
|
"gml_name_2":" ",
|
||||||
|
"citygml_31":" ",
|
||||||
|
"citygml_32":" ",
|
||||||
|
"external_6":" ",
|
||||||
|
"external_7":" ",
|
||||||
|
"external_8":" ",
|
||||||
|
"citygml_33":" ",
|
||||||
|
"citygml_34":" ",
|
||||||
|
"citygml_35":" ",
|
||||||
|
"citygml_36":" ",
|
||||||
|
"citygml_37":" ",
|
||||||
|
"citygml_38":" ",
|
||||||
|
"citygml_39":" ",
|
||||||
|
"citygml_40":" ",
|
||||||
|
"citygml_41":" ",
|
||||||
|
"citygml_42":" ",
|
||||||
|
"citygml_43":" ",
|
||||||
|
"citygml_44":" ",
|
||||||
|
"citygml_45":" ",
|
||||||
|
"citygml_46":" ",
|
||||||
|
"citygml_47":65.929000000000002,
|
||||||
|
"citygml_48":"#m",
|
||||||
|
"citygml_49":" ",
|
||||||
|
"citygml_50":" ",
|
||||||
|
"citygml_51":" ",
|
||||||
|
"citygml_52":" ",
|
||||||
|
"citygml_53":" ",
|
||||||
|
"citygml_54":" ",
|
||||||
|
"citygml_55":" ",
|
||||||
|
"citygml_56":" ",
|
||||||
|
"citygml_57":" ",
|
||||||
|
"citygml_58":" ",
|
||||||
|
"citygml_59":" ",
|
||||||
|
"citygml_60":" ",
|
||||||
|
"citygml_61":" ",
|
||||||
|
"Volume_1":"52877.804",
|
||||||
|
"Field":0,
|
||||||
|
"Field1":0,
|
||||||
|
"OBJECTID_1":7589,
|
||||||
|
"gml_id_12_":"46c9507d-33c9-40e9-9bda-00ad6fa8cd8f",
|
||||||
|
"gml_pare_3":"1066826",
|
||||||
|
"citygml_62":"http://www.opengis.net/citygml/building/2.0",
|
||||||
|
"citygml_63":"boundedBy",
|
||||||
|
"citygml_64":" ",
|
||||||
|
"citygml_65":" ",
|
||||||
|
"gml_desc_3":" ",
|
||||||
|
"gml_name_3":" ",
|
||||||
|
"citygml_66":" ",
|
||||||
|
"citygml_67":" ",
|
||||||
|
"external_9":" ",
|
||||||
|
"externa_10":" ",
|
||||||
|
"externa_11":" ",
|
||||||
|
"citygml_68":" ",
|
||||||
|
"citygml_69":" ",
|
||||||
|
"citygml_70":" ",
|
||||||
|
"citygml_71":" ",
|
||||||
|
"citygml_72":" ",
|
||||||
|
"citygml_73":" ",
|
||||||
|
"Area_1":"911.899",
|
||||||
|
"cityGML_hi":0,
|
||||||
|
"Z_Min":41.631399999999999,
|
||||||
|
"Z_Max":107.56,
|
||||||
|
"Shape_Leng":120.703852102,
|
||||||
|
"ID_UEV":"01111020",
|
||||||
|
"CIVIQUE_DE":" 1515",
|
||||||
|
"CIVIQUE_FI":" 1515",
|
||||||
|
"NOM_RUE":"rue Sainte-Catherine Ouest (MTL+WMT)",
|
||||||
|
"MUNICIPALI":"50",
|
||||||
|
"ETAGE_HORS":17,
|
||||||
|
"NOMBRE_LOG":1,
|
||||||
|
"ANNEE_CONS":2005,
|
||||||
|
"CODE_UTILI":"6821",
|
||||||
|
"LIBELLE_UT":"Université",
|
||||||
|
"CATEGORIE_":"Régulier",
|
||||||
|
"MATRICULE8":"9839-75-0526-8-000-0000",
|
||||||
|
"SUPERFICIE":5949,
|
||||||
|
"SUPERFIC_1":259,
|
||||||
|
"NO_ARROND_":"REM19",
|
||||||
|
"Shape_Le_1":0.0037693215640499998,
|
||||||
|
"Shape_Ar_1":6.8474298198599997e-07,
|
||||||
|
"Z_Min_1":null,
|
||||||
|
"Z_Max_1":null,
|
||||||
|
"Shape_Length":120.70385210151841,
|
||||||
|
"Shape_Area":910.23684745179321
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]}
|
Loading…
Reference in New Issue
Block a user