forked from s_ranjbar/city_retrofit
added shared walls to geojson. geojson importer test raises an error because the surfaces are triangulated. It should be solved when extrusion is finished
This commit is contained in:
parent
d198ac9141
commit
a0e52b3e8d
|
@ -120,12 +120,6 @@ class Geojson:
|
|||
def _store_shared_percentage_to_walls(self, city, city_mapped):
|
||||
for building in city.buildings:
|
||||
building_mapped = city_mapped[building.name]
|
||||
for entry in building_mapped:
|
||||
if building_mapped[entry]['shared_points'] <= 3:
|
||||
continue
|
||||
line = [building_mapped[entry]['line_start'], building_mapped[entry]['line_end']]
|
||||
neighbour_line = [building_mapped[entry]['neighbour_line_start'], building_mapped[entry]['neighbour_line_end']]
|
||||
neighbour_height = city.city_object(building_mapped[entry]['neighbour_name']).max_height
|
||||
for wall in building.walls:
|
||||
percentage = 0
|
||||
ground_line = []
|
||||
|
@ -136,16 +130,23 @@ class Geojson:
|
|||
if len(ground_line) < 2:
|
||||
continue
|
||||
# todo: erase down to here
|
||||
for entry in building_mapped:
|
||||
if building_mapped[entry]['shared_points'] <= 5:
|
||||
continue
|
||||
line = [building_mapped[entry]['line_start'], building_mapped[entry]['line_end']]
|
||||
neighbour_line = [building_mapped[entry]['neighbour_line_start'],
|
||||
building_mapped[entry]['neighbour_line_end']]
|
||||
neighbour_height = city.city_object(building_mapped[entry]['neighbour_name']).max_height
|
||||
if self._find_wall(line, ground_line):
|
||||
line_shared = (GeometryHelper.distance_between_points(line[0], line[1]) +
|
||||
GeometryHelper.distance_between_points(neighbour_line[0], neighbour_line[1]) -
|
||||
GeometryHelper.distance_between_points(line[1], neighbour_line[0]) -
|
||||
GeometryHelper.distance_between_points(line[0], neighbour_line[1])) / 2
|
||||
percentage = line_shared / GeometryHelper.distance_between_points(line[0], line[1])
|
||||
percentage_ground = line_shared / GeometryHelper.distance_between_points(line[0], line[1])
|
||||
percentage_height = neighbour_height / building.max_height
|
||||
if percentage_height > 1:
|
||||
percentage_height = 1
|
||||
percentage = percentage * percentage_height
|
||||
percentage += percentage_ground * percentage_height
|
||||
wall.percentage_shared = percentage
|
||||
|
||||
@property
|
||||
|
@ -157,6 +158,7 @@ class Geojson:
|
|||
missing_functions = []
|
||||
buildings = []
|
||||
building_id = 0
|
||||
lod = 1
|
||||
for feature in self._geojson['features']:
|
||||
extrusion_height = 0
|
||||
if self._extrusion_height_field is not None:
|
||||
|
@ -182,7 +184,6 @@ class Geojson:
|
|||
building_name = f'building_{building_id}'
|
||||
building_id += 1
|
||||
polygons = []
|
||||
lod = 1
|
||||
for part, coordinates in enumerate(geometry['coordinates']):
|
||||
polygons = self._get_polygons(polygons, coordinates)
|
||||
for zone, polygon in enumerate(polygons):
|
||||
|
@ -205,6 +206,9 @@ class Geojson:
|
|||
for building in buildings:
|
||||
self._city.add_city_object(building)
|
||||
self._city.level_of_detail.geometry = lod
|
||||
if lod == 1:
|
||||
lines_information = GeometryHelper.city_mapping(self._city)
|
||||
self._store_shared_percentage_to_walls(self._city, lines_information)
|
||||
if len(missing_functions) > 0:
|
||||
print(f'There are unknown functions {missing_functions}')
|
||||
return self._city
|
||||
|
|
|
@ -9,8 +9,6 @@ from pathlib import Path
|
|||
from unittest import TestCase
|
||||
from hub.helpers.geometry_helper import GeometryHelper
|
||||
|
||||
from numpy import inf
|
||||
|
||||
import hub.exports.exports_factory
|
||||
from hub.imports.construction_factory import ConstructionFactory
|
||||
from hub.imports.geometry_factory import GeometryFactory
|
||||
|
@ -135,7 +133,7 @@ class TestGeometryFactory(TestCase):
|
|||
"""
|
||||
Test geojson import
|
||||
"""
|
||||
file = 'concordia.geojson'
|
||||
file = 'neighbours.geojson'
|
||||
city = self._get_city(file, 'geojson',
|
||||
height_field='citygml_me',
|
||||
year_of_construction_field='ANNEE_CONS',
|
||||
|
@ -144,6 +142,9 @@ class TestGeometryFactory(TestCase):
|
|||
hub.exports.exports_factory.ExportsFactory('obj', city, self._output_path).export()
|
||||
self.assertEqual(207, len(city.buildings), 'wrong number of buildings')
|
||||
self._check_buildings(city)
|
||||
for building in city.buildings:
|
||||
for wall in building.walls:
|
||||
self.assertIsNotNone(wall.percentage_shared, 'wall percentage shared is not assigned')
|
||||
|
||||
def test_map_neighbours(self):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue
Block a user