Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Commit

Permalink
simplify footprints
Browse files Browse the repository at this point in the history
  • Loading branch information
dwastberg committed May 3, 2024
1 parent 7d30404 commit df7be1f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/dtcc_builder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
build_lod1_buildings,
)

from .building.modify import merge_building_footprints
from .building.modify import merge_building_footprints, simplify_building_footprints


from .geometry_builders.meshes import build_surface_mesh
Expand All @@ -46,5 +46,6 @@
"build_terrain_mesh",
"build_terrain_raster",
"flat_terrain",
"merge_building_footprints"
"merge_building_footprints",
"simplify_building_footprints"
]
18 changes: 18 additions & 0 deletions src/dtcc_builder/building/modify.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,21 @@ def merge_building_footprints(
building.add_geometry(building_surface, GeometryType.LOD0)
merged_buildings.append(building)
return merged_buildings

def simplify_building_footprints(
buildings: List[Building], tolerance: float = 0.5, lod: GeometryType = GeometryType.LOD0
) -> List[Building]:
simplified_buildings = []
for building in buildings:
lod0 = building.lod0
if lod0 is None:
continue
footprint = lod0.to_polygon()
footprint = footprint.simplify(tolerance, True)
building_surface = Surface()
building_surface.from_polygon(footprint, lod0.zmax)
simplified_building = building.copy()
simplified_building.add_geometry(building_surface, GeometryType.LOD0)
simplified_building.calculate_bounds()
simplified_buildings.append(simplified_building)
return simplified_buildings

0 comments on commit df7be1f

Please sign in to comment.