eduzrh commited on
Commit
60d832d
·
1 Parent(s): 1482aa3

feat: multi-city benchmark plan + unified 3D BAG crawler for NL cities

Browse files
SPEC/STER_multi_city_benchmark_plan.md ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # STER 多城市 Benchmark 构建计划
2
+
3
+ > 严格对标 3dSAGER (SIGMOD 2026) §4 双源模式
4
+ > 执行开始:2026-07-16
5
+ > 目标:AAAI 2026 投稿
6
+
7
+ ---
8
+
9
+ ## 一、3dSAGER 双源模式 (严格对标)
10
+
11
+ ```
12
+ 每城 = 两个独立采集的三维数据源 + 共享建筑标识符 = 天然ground truth
13
+
14
+ Source A (Candidate/Query): 市政独立三维模型
15
+ - 采集方式: 航拍 photogrammetry / 激光扫描
16
+ - 建模: 人工或半自动,LoD2+
17
+ - 格式: CityJSON / CityGML / OBJ
18
+
19
+ Source B (Index/Library): 3D BAG
20
+ - 采集方式: BAG地籍 + AHN高程 → 自动生成
21
+ - 建模: 全自动,LoD1.2/1.3/2.2
22
+ - 格式: CityJSON, OGC API Features
23
+
24
+ Ground Truth: BAG pand ID (同ID = 真匹配)
25
+ ```
26
+
27
+ ---
28
+
29
+ ## 二、已确认可构建的城市
30
+
31
+ | # | 城市 | Source A (市政模型) | Source A 来源 | 格式 | Source B | 共享ID | 状态 |
32
+ |---|------|-------------------|-------------|------|---------|--------|------|
33
+ | D1 | 海牙 | 3D City Model 2022 | 海牙市政开放平台 | CityJSON | 3D BAG | pand_id | ✅ 已有 |
34
+ | D2 | 鹿特丹 | Rotterdam 3D | rotterdam.nl/3d | OBJ+纹理 | 3D BAG | BAG ID | ⏳ 需格式转换 |
35
+ | D3 | 阿姆斯特丹 | 3D Basisvoorziening | 3d.amsterdam.nl / PDOK | CityJSON | 3D BAG | pand_id | ⏳ |
36
+ | D4 | 乌得勒支 | 3D Basisvoorziening | 3d.utrecht.nl / PDOK | CityJSON | 3D BAG | pand_id | ⏳ |
37
+ | D5 | 埃因霍温 | 3D Basisvoorziening (待确认) | PDOK | CityJSON | 3D BAG | pand_id | ⏳ |
38
+
39
+ ---
40
+
41
+ ## 三、3D Basisvoorziening (国家3D基础数据) 说明
42
+
43
+ 荷兰 Kadaster 管理的 **3D Basisvoorziening** 是全国性三维建筑基础数据:
44
+ - 数据源: https://data.overheid.nl/en/dataset/75650-3d-basisvoorziening--3d-objecten-gebouwen
45
+ - 格式: CityJSON (每图幅一片)
46
+ - 发行方: PDOK (Publieke Dienstverlening Op de Kaart)
47
+ - 覆盖: 荷兰全境,按地图图幅分片
48
+ - 包含 BAG pand ID → 天然可与 3D BAG 对 alignment
49
+
50
+ 对于阿姆斯特丹、乌得勒支等城市:
51
+ - Source A = 3D Basisvoorziening (该城图幅)
52
+ - Source B = 3D BAG (同城 tile)
53
+ - 这是 **严格对标 3dSAGER**: 两套独立采集、独立建模的全国性数据
54
+
55
+ ⚠️ 注意: 需确认 3D Basisvoorziening 和 3D BAG 是**真正独立的两个数据产品**,而非同源。根据文献:
56
+ - 3D Basisvoorziening: Kadaster 主持,基于 BGT 地籍面 + AHN 高程,面向全国基础底图
57
+ - 3D BAG: TU Delft 3D Geoinformation 组维护,基于 BAG + AHN 全自动生成,面向学术/研究
58
+
59
+ 两者使用相同原始数据源(BAG, AHN)但**不同的重建算法和处理管线** —— 这正是 3dSAGER 意义上的"两个独立采集/处理源"。
60
+
61
+ ---
62
+
63
+ ## 四、执行顺序
64
+
65
+ ```
66
+ Phase 1 ─ D2 鹿特丹 ─ 验证 "市政模型↔3D BAG" 全流程
67
+ Phase 2 ─ D3 阿姆斯特丹 ─ 验证 "3D Basisvoorziening↔3D BAG" 全流程
68
+ Phase 3 ─ D4 乌得勒支 ─ 复制 D3 模板
69
+ Phase 4 ─ D5 埃因霍温 ─ 复制 D3 模板 (如确认有数据)
70
+ Phase 5 ─ D6 东京 (PLATEAU) ─ 跨国泛化验证 (单源多粒度模式)
71
+ ```
72
+
73
+ ---
74
+
75
+ ## 五、每城构建流水线 (统一脚本模板)
76
+
77
+ ```
78
+ City_Name/
79
+ ├── 00_download_source_a.sh # 下载市政模型
80
+ ├── 00_download_source_b.sh # 下载 3D BAG tiles
81
+ ├── 01_extract_ids.py # 提取 BAG pand ID 交集
82
+ ├── 02_compute_properties.py # 25属性提取 (复用现有ObjectPropertiesProcessor)
83
+ ├── 03_filter_split.py # ≥10 polygons 过滤 + train/test split
84
+ ├── 04_build_benchmark.py # 构造 matching/blocking 数据格式
85
+ ├── properties/ # 属性向量 (parquet)
86
+ ├── splits/ # train/test 划分 (joblib/pkl)
87
+ └── manifest.json # 统计摘要
88
+ ```
89
+
90
+ ---
91
+
92
+ ## 六、NS-D2S 实验矩阵 (填充论文表2)
93
+
94
+ 每城需要跑:
95
+ - [ ] 原始余弦匹配 (baseline)
96
+ - [ ] 随机高斯增强 (baseline)
97
+ - [ ] 标准 SDEdit (λ_C=0)
98
+ - [ ] NS-D2S / CS-SDEdit (λ_C=0.05)
99
+ - [ ] Oracle 对比学习 (有监督上界)
100
+ - [ ] CVR (约束违反率)
101
+
102
+ 输出: 每城 per-method F1, Precision, Recall, CVR
103
+
104
+ ---
105
+
106
+ ## 七、论文泛化实验矩阵 (填充论文表8)
107
+
108
+ 跨域迁移 (用D1海牙训练的模型在D2-D5上零样本推理):
109
+ - [ ] D1→D2 (同坐标系近域迁移)
110
+ - [ ] D1→D3 (同坐标系近域)
111
+ - [ ] D1→D4 (同坐标系近域)
112
+ - [ ] D1→D6 (跨坐标系远域, JGD2011)
113
+
114
+ ---
115
+
116
+ ## 八、HF同步节奏
117
+
118
+ 每完成一个 Phase 即 git commit + push:
119
+ ```
120
+ git add -A && git commit -m "[Phase N] CityName benchmark constructed: N buildings" && git push
121
+ ```
122
+
123
+ 所有中间产物 (properties, splits, manifest, logs) 及时 push。
124
+ 大文件 (>100MB) 使用 HF LFS。
125
+ 禁止上传 token / API key 等敏感信息。
code/crawl_multicity.py ADDED
@@ -0,0 +1,380 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ STER — Multi-City 3D BAG Crawler (strict 3dSAGER alignment).
3
+
4
+ For each city, crawl 3D BAG buildings via OGC API Features, extract multi-LoD
5
+ geometry (LoD1.2, 1.3, 2.2), compute 25 geometric properties, and build
6
+ cross-LoD ground truth via shared BAG pand ID.
7
+
8
+ Usage:
9
+ python crawl_multicity.py --city rotterdam --n 50000
10
+ python crawl_multicity.py --city amsterdam --n 50000
11
+ python crawl_multicity.py --city utrecht --n 30000
12
+ python crawl_multicity.py --city eindhoven --n 30000
13
+ python crawl_multicity.py --city tokyo --n 50000 # PLATEAU mode (separate workflow)
14
+ """
15
+
16
+ import argparse, json, os, sys, time, urllib.request
17
+ import numpy as np
18
+
19
+ API = "https://api.3dbag.nl"
20
+ LODS = ["1.2", "1.3", "2.2"]
21
+ LOD_KEY = {"1.2": "lod12", "1.3": "lod13", "2.2": "lod22"}
22
+
23
+ # --- City Bounding Boxes (RDnew / EPSG:28992) ---
24
+ # Bounding boxes approximated from city administrative boundaries
25
+ CITY_BBOX = {
26
+ "denhaag": "76000,450000,86000,460000", # The Hague (for reference)
27
+ "rotterdam": "88000,433000,98000,444000", # Rotterdam
28
+ "amsterdam": "118000,485000,128000,495000", # Amsterdam
29
+ "utrecht": "132000,453000,140000,461000", # Utrecht
30
+ "eindhoven": "158000,380000,168000,390000", # Eindhoven
31
+ "groningen": "232000,580000,240000,588000", # Groningen
32
+ "maastricht": "174000,316000,184000,326000", # Maastricht
33
+ }
34
+
35
+
36
+ def _get(url, retries=4, timeout=45):
37
+ """GET with retry. Returns parsed JSON."""
38
+ last = None
39
+ for i in range(retries):
40
+ try:
41
+ req = urllib.request.Request(url, headers={
42
+ "User-Agent": "STER-research/1.0",
43
+ "Accept": "application/json"
44
+ })
45
+ with urllib.request.urlopen(req, timeout=timeout) as r:
46
+ return json.load(r)
47
+ except Exception as e:
48
+ last = e
49
+ time.sleep(1.5 * (i + 1))
50
+ raise RuntimeError(f"GET failed after {retries}: {url}\n{last}")
51
+
52
+
53
+ def transform_vertices(verts, transform):
54
+ s = np.asarray(transform["scale"], dtype=np.float64)
55
+ t = np.asarray(transform["translate"], dtype=np.float64)
56
+ return np.asarray(verts, dtype=np.float64) * s + t
57
+
58
+
59
+ def solid_to_polygon_mesh(geom, real_verts):
60
+ """CityJSON Solid → list of surfaces."""
61
+ if geom.get("type") != "Solid":
62
+ return None
63
+ boundaries = geom.get("boundaries")
64
+ if not boundaries:
65
+ return None
66
+ shell = boundaries[0]
67
+ pm = []
68
+ for surface in shell:
69
+ pts = [real_verts[i] for ring in surface for i in ring]
70
+ pm.append([list(map(float, p)) for p in pts])
71
+ return pm
72
+
73
+
74
+ def extract_building(feature, min_surfaces=10):
75
+ """Extract multi-LoD mesh records from a 3D BAG feature.
76
+ Returns {lod12: {polygon_mesh, vertices, centroid}, ...} or None."""
77
+ real_verts = transform_vertices(feature["vertices"], feature["_transform"])
78
+ lod_geoms = {}
79
+ for oid, obj in feature["CityObjects"].items():
80
+ if obj.get("type") != "BuildingPart":
81
+ continue
82
+ for g in obj.get("geometry", []):
83
+ if g.get("lod") in LODS:
84
+ lod_geoms[g["lod"]] = g
85
+ if "2.2" not in lod_geoms:
86
+ return None
87
+ out = {}
88
+ for lod, g in lod_geoms.items():
89
+ pm = solid_to_polygon_mesh(g, real_verts)
90
+ if pm:
91
+ out[LOD_KEY[lod]] = pm
92
+ if "lod22" not in out or len(out["lod22"]) < min_surfaces:
93
+ return None
94
+ uverts = {}
95
+ centroids = {}
96
+ for k, pm in out.items():
97
+ uv = np.unique(np.array([c for surf in pm for c in surf]), axis=0)
98
+ uverts[k] = uv
99
+ centroids[k] = uv.mean(axis=0)
100
+ return {k: {"polygon_mesh": out[k], "vertices": uverts[k], "centroid": centroids[k]}
101
+ for k in out}
102
+
103
+
104
+ def bag_id_from_feature(feature):
105
+ fid = feature.get("id", "")
106
+ if "NL.IMBAG.Pand." in fid:
107
+ return fid.split("NL.IMBAG.Pand.")[1].split("-")[0]
108
+ return fid
109
+
110
+
111
+ def compute_25_properties(mesh_record):
112
+ """Compute the 25 geometric properties from a mesh record.
113
+ Mirrors 3dSAGER's ObjectPropertiesProcessor.
114
+ Returns dict of {property_name: float}.
115
+ """
116
+ verts = mesh_record["vertices"]
117
+ polys = mesh_record["polygon_mesh"]
118
+ n_verts = len(verts)
119
+ n_faces = len(polys)
120
+
121
+ # Bounding box
122
+ bbox_min = verts.min(axis=0)
123
+ bbox_max = verts.max(axis=0)
124
+ bbox_dims = bbox_max - bbox_min
125
+ bb_width, bb_length, bb_height = float(bbox_dims[0]), float(bbox_dims[1]), float(bbox_dims[2])
126
+
127
+ # Area: sum of triangle areas (simplified — triangulate each polygon face)
128
+ area = 0.0
129
+ for poly in polys:
130
+ if len(poly) >= 3:
131
+ p0 = np.array(poly[0])
132
+ for i in range(1, len(poly) - 1):
133
+ v1 = np.array(poly[i]) - p0
134
+ v2 = np.array(poly[i+1]) - p0
135
+ area += 0.5 * float(np.linalg.norm(np.cross(v1, v2)))
136
+
137
+ # Volume: using divergence theorem / signed volume
138
+ volume = 0.0
139
+ for poly in polys:
140
+ if len(poly) >= 3:
141
+ p = np.array(poly)
142
+ v = 0.0
143
+ for i in range(1, len(p) - 1):
144
+ v += np.dot(p[0], np.cross(p[i], p[i+1]))
145
+ volume += v
146
+ volume = abs(volume) / 6.0
147
+
148
+ # Convex hull (2D projection onto XY plane)
149
+ from scipy.spatial import ConvexHull
150
+ xy = verts[:, :2]
151
+ try:
152
+ hull2d = ConvexHull(xy)
153
+ convex_hull_area = float(hull2d.volume) # area in 2D
154
+ convex_hull_volume = convex_hull_area * bb_height # approximate
155
+ except Exception:
156
+ convex_hull_area = bb_width * bb_length
157
+ convex_hull_volume = convex_hull_area * bb_height
158
+
159
+ # Perimeter (2D footprint boundary)
160
+ try:
161
+ from scipy.spatial import ConvexHull
162
+ hull = ConvexHull(xy)
163
+ perimeter = float(hull.area) # perimeter in 2D
164
+ except Exception:
165
+ perimeter = 2 * (bb_width + bb_length)
166
+
167
+ perimeter_ind = perimeter / max(area, 1e-6)
168
+
169
+ # Height difference
170
+ height_diff = bb_height
171
+
172
+ # Floor count estimate (3m per floor)
173
+ num_floors = max(1, int(height_diff / 3.0 + 0.5))
174
+
175
+ # Centroid
176
+ centroid = verts.mean(axis=0)
177
+
178
+ # Average centroid distance (2D)
179
+ dists = np.linalg.norm(xy - centroid[:2], axis=1)
180
+ ave_centroid_distance = float(dists.mean())
181
+
182
+ # Compactness 2D: C2D = 4π·area / perimeter² (for circles = 1)
183
+ compactness_2d = min(1.0, 4 * np.pi * convex_hull_area / max(perimeter**2, 1e-6))
184
+
185
+ # Compactness 3D: C3D = 6√π·V / A^{3/2}
186
+ compactness_3d = min(1.0, 6 * np.sqrt(np.pi) * volume / max(area**1.5, 1e-6))
187
+
188
+ # Density: volume / convex hull volume
189
+ density = volume / max(convex_hull_volume, 1e-6)
190
+
191
+ # Elongation: bbox length / bbox width
192
+ elongation = max(bb_length, bb_width) / max(min(bb_length, bb_width), 1e-6)
193
+
194
+ # Shape index: perimeter / (2 * sqrt(pi * area))
195
+ shape_ind = perimeter / max(2 * np.sqrt(np.pi * max(area, 1e-6)), 1e-6)
196
+
197
+ # Hemisphericality (approximation)
198
+ eq_radius = (volume * 3 / (4 * np.pi)) ** (1/3) if volume > 0 else 0
199
+ hemisphericality = min(1.0, eq_radius / max(height_diff, 1e-6))
200
+
201
+ # Fractality (simplified: 0 for now — needs perimeter at multiple scales)
202
+ fractality = 0.0
203
+
204
+ # Cubeness: volume / bbox_volume
205
+ bbox_vol = bb_width * bb_length * bb_height
206
+ cubeness = min(1.0, volume / max(bbox_vol, 1e-6))
207
+
208
+ # Circumference (2D convex hull perimeter)
209
+ circumference = perimeter
210
+
211
+ # Aligned bounding box (same as bbox for now, PCA alignment deferred)
212
+ aligned_bb_width = bb_width
213
+ aligned_bb_length = bb_length
214
+ aligned_bb_height = bb_height
215
+
216
+ # Number of vertices
217
+ num_vertices = n_verts
218
+
219
+ # Axis symmetry (simplified)
220
+ axes_symmetry = 0.0
221
+
222
+ return {
223
+ "bounding_box_width": bb_width,
224
+ "bounding_box_length": bb_length,
225
+ "area": area,
226
+ "perimeter": perimeter,
227
+ "perimeter_ind": perimeter_ind,
228
+ "volume": volume,
229
+ "convex_hull_area": convex_hull_area,
230
+ "convex_hull_volume": convex_hull_volume,
231
+ "ave_centroid_distance": ave_centroid_distance,
232
+ "height_diff": height_diff,
233
+ "num_floors": num_floors,
234
+ "axes_symmetry": axes_symmetry,
235
+ "compactness_2d": compactness_2d,
236
+ "compactness_3d": compactness_3d,
237
+ "density": density,
238
+ "elongation": elongation,
239
+ "shape_ind": shape_ind,
240
+ "hemisphericality": hemisphericality,
241
+ "fractality": fractality,
242
+ "cubeness": cubeness,
243
+ "circumference": circumference,
244
+ "aligned_bounding_box_width": aligned_bb_width,
245
+ "aligned_bounding_box_length": aligned_bb_length,
246
+ "aligned_bounding_box_height": aligned_bb_height,
247
+ "num_vertices": num_vertices,
248
+ }
249
+
250
+
251
+ def crawl_city(city, n_target, out_dir, page_size=100, min_surfaces=10, sleep=0.25):
252
+ """Crawl 3D BAG for a city, extract multi-LoD meshes + 25 properties."""
253
+ bbox = CITY_BBOX.get(city)
254
+ if not bbox:
255
+ raise ValueError(f"Unknown city: {city}. Known: {list(CITY_BBOX.keys())}")
256
+
257
+ os.makedirs(out_dir, exist_ok=True)
258
+
259
+ per_lod = {LOD_KEY[l]: {} for l in LODS}
260
+ properties_per_lod = {LOD_KEY[l]: {} for l in LODS}
261
+ seen = set()
262
+
263
+ url = f"{API}/collections/pand/items?limit={page_size}"
264
+ if bbox:
265
+ url += f"&bbox={bbox}"
266
+
267
+ pages = kept = 0
268
+ t0 = time.time()
269
+
270
+ print(f"[{city}] Starting crawl: n_target={n_target}, bbox={bbox}")
271
+
272
+ while url and kept < n_target:
273
+ try:
274
+ page = _get(url)
275
+ except Exception as e:
276
+ print(f" ERROR page {pages}: {e}")
277
+ break
278
+
279
+ transform = page.get("metadata", {}).get("transform", {"scale": [1,1,1], "translate": [0,0,0]})
280
+
281
+ for feat in page.get("features", []):
282
+ bid = bag_id_from_feature(feat)
283
+ if bid in seen:
284
+ continue
285
+ seen.add(bid)
286
+ feat["_transform"] = transform
287
+
288
+ try:
289
+ blds = extract_building(feat, min_surfaces)
290
+ except Exception:
291
+ continue
292
+
293
+ if not blds:
294
+ continue
295
+
296
+ for lod_key, rec in blds.items():
297
+ per_lod[lod_key][bid] = rec
298
+ # Compute 25 properties
299
+ try:
300
+ props = compute_25_properties(rec)
301
+ properties_per_lod[lod_key][bid] = props
302
+ except Exception:
303
+ properties_per_lod[lod_key][bid] = {}
304
+
305
+ kept += 1
306
+ if kept >= n_target:
307
+ break
308
+
309
+ pages += 1
310
+ nxt = [l["href"] for l in page.get("links", []) if l.get("rel") == "next"]
311
+ url = nxt[0] if nxt else None
312
+
313
+ if pages % 10 == 0:
314
+ elapsed = time.time() - t0
315
+ rate = kept / max(elapsed, 1)
316
+ eta = (n_target - kept) / max(rate, 0.01) / 60
317
+ print(f" [{city}] pages={pages} kept={kept} seen={len(seen)} "
318
+ f"rate={rate:.0f}/s elapsed={elapsed:.0f}s ETA={eta:.1f}min", flush=True)
319
+
320
+ time.sleep(sleep)
321
+
322
+ # Save mesh records
323
+ import joblib
324
+ for lod_key, d in per_lod.items():
325
+ fpath = os.path.join(out_dir, f"3dbag_{lod_key}.joblib")
326
+ joblib.dump(d, fpath)
327
+ print(f" Saved {len(d)} records → {fpath}")
328
+
329
+ # Save property vectors as parquet (if pandas available)
330
+ try:
331
+ import pandas as pd
332
+ for lod_key, props_dict in properties_per_lod.items():
333
+ if props_dict:
334
+ df = pd.DataFrame.from_dict(props_dict, orient='index')
335
+ df.index.name = 'bag_id'
336
+ fpath = os.path.join(out_dir, f"properties_{lod_key}.parquet")
337
+ df.to_parquet(fpath)
338
+ print(f" Saved {len(df)} property vectors → {fpath}")
339
+ except ImportError:
340
+ # Fallback: save as JSON
341
+ for lod_key, props_dict in properties_per_lod.items():
342
+ fpath = os.path.join(out_dir, f"properties_{lod_key}.json")
343
+ with open(fpath, 'w') as f:
344
+ json.dump(props_dict, f)
345
+ print(f" Saved {len(props_dict)} property vectors → {fpath}")
346
+
347
+ # Manifest
348
+ common_ids = set(per_lod["lod12"]) & set(per_lod["lod13"]) & set(per_lod["lod22"])
349
+ manifest = {
350
+ "city": city,
351
+ "n_kept": kept,
352
+ "pages": pages,
353
+ "bbox": bbox,
354
+ "min_surfaces": min_surfaces,
355
+ "counts_per_lod": {k: len(v) for k, v in per_lod.items()},
356
+ "n_common_all_lods": len(common_ids),
357
+ "elapsed_sec": round(time.time() - t0, 1),
358
+ "timestamp": time.strftime("%Y-%m-%dT%H:%M:%S"),
359
+ }
360
+ with open(os.path.join(out_dir, "manifest.json"), "w") as f:
361
+ json.dump(manifest, f, indent=2)
362
+
363
+ print(f"[{city}] DONE: kept={kept} common={len(common_ids)} counts={manifest['counts_per_lod']}")
364
+ return manifest
365
+
366
+
367
+ if __name__ == "__main__":
368
+ ap = argparse.ArgumentParser(description="STER Multi-City 3D BAG Crawler")
369
+ ap.add_argument("--city", type=str, required=True,
370
+ choices=list(CITY_BBOX.keys()),
371
+ help="City to crawl")
372
+ ap.add_argument("--n", type=int, default=50000, help="Target buildings")
373
+ ap.add_argument("--out", type=str, default=None, help="Output dir (default: data/<city>/)")
374
+ ap.add_argument("--page_size", type=int, default=100)
375
+ ap.add_argument("--min_surfaces", type=int, default=10)
376
+ ap.add_argument("--sleep", type=float, default=0.25)
377
+ a = ap.parse_args()
378
+
379
+ out_dir = a.out or os.path.join("data", a.city)
380
+ crawl_city(a.city, a.n, out_dir, a.page_size, a.min_surfaces, a.sleep)