|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| def check_area_constraints(floor_matrix, cell_area):
|
| """
|
| 檢查該層樓是否符合免計面積相關建築法規
|
| 傳入參數:
|
| - floor_matrix: 該層樓的空間矩陣(數字代表各空間)
|
| - cell_area: 每一格(cell)所代表的面積(單位 m²)
|
| 回傳:
|
| - warnings: 不符合限制的警告清單(list)
|
| """
|
| from collections import Counter
|
|
|
|
|
| flat = [cell for row in floor_matrix for cell in row]
|
| count = Counter(flat)
|
|
|
|
|
| total_cells = len(flat)
|
| total_area = total_cells * cell_area
|
|
|
|
|
| balcony_area = count.get(5, 0) * cell_area
|
| stair_lobby_area = (count.get(6, 0) + count.get(8, 0)) * cell_area
|
| me_area = (count.get(3, 0) + count.get(7, 0)) * cell_area
|
|
|
| warnings = []
|
|
|
|
|
| if stair_lobby_area > 0.10 * total_area:
|
| warnings.append("❌ 梯廳面積超過該層樓地板面積的 10%")
|
|
|
|
|
| if (balcony_area + stair_lobby_area) > 0.15 * total_area:
|
| warnings.append("❌ 陽台與梯廳合計面積超過該層樓地板面積的 15%")
|
|
|
|
|
| if (me_area + stair_lobby_area) > 0.15 * total_area:
|
| warnings.append("❌ 機電空間與梯廳合計面積超過該層樓地板面積的 15%")
|
|
|
| return warnings |