Skip to content

Commit 8d57326

Browse files
author
Lars van Blokland
committed
Merge branch 'main' of github.com:alexandre-bry/Inclusive-TU-Delft-Map
2 parents 4103250 + 0245c1e commit 8d57326

File tree

15 files changed

+287
-141
lines changed

15 files changed

+287
-141
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ You can also find more information about it in the [about page of the website](h
1010

1111
## Documentation
1212

13-
The documentation is hosted at: <https://alexandre-bry.github.io/Inclusive-TU-Delft-Map/>.
13+
The documentation is hosted at: <https://tudelft3d.github.io/Inclusive-TU-Delft-Map/>.

mkdocs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
site_name: Inclusive 3D Campus Map of TU Delft
22

3-
repo_name: alexandre-bry/Inclusive-TU-Delft-Map
4-
repo_url: https://github.com/alexandre-bry/Inclusive-TU-Delft-Map
3+
repo_name: tudelft3d/Inclusive-TU-Delft-Map
4+
repo_url: https://github.com/tudelft3d/Inclusive-TU-Delft-Map
55
edit_uri: edit/main/docs/
66

77
theme:

python/src/data_pipeline/cj_helpers/cj_attributes.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,10 @@ def __init__(
246246
if len(self.unit_storeys) == 0:
247247
unit_storeys_set: set[str] = set()
248248
for space in self.unit_spaces:
249-
storey = ".".join(space.split(".")[:-1])
249+
space_split = space.split(".")
250+
if len(space.split(".")) < 3:
251+
continue
252+
storey = ".".join(space_split[:3])
250253
unit_storeys_set.add(storey)
251254
self.unit_storeys = list(unit_storeys_set)
252255

python/src/data_pipeline/cj_writing/bag_to_cj.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,6 @@ def _process_bag_element(
207207
):
208208
space_id = bdg_attributes.space_id
209209
obj_key = Building.key_to_cj_key(key=bdg_attributes.cj_key)
210-
print(f"{space_id = }")
211-
print(f"{bdg_attributes.bag_ids = }")
212210

213211
geoms = _process_bag_element(
214212
obj_key=obj_key,
@@ -255,11 +253,11 @@ def _process_bag_element(
255253
CityJSONObject.add_parent_child(parent=bdg_obj, child=main_container)
256254

257255
z_container_id = BuildingUnitContainer.unit_code_to_cj_key(
258-
code="BS", prefix=prefix
256+
code="BS-SP", prefix=prefix
259257
)
260258
if z_container_id not in all_objects_cj:
261259
z_container = BuildingUnitContainer(
262-
cj_key=z_container_id, unit_code="BS"
260+
cj_key=z_container_id, unit_code="BS-SP"
263261
)
264262
all_objects_cj[z_container_id] = z_container
265263
CityJSONObject.add_parent_child(
@@ -272,12 +270,12 @@ def _process_bag_element(
272270
units_same_code = len(z_container.children_ids)
273271

274272
obj_key = BuildingUnit.unit_code_to_cj_key(
275-
code="BS", prefix=prefix, index=units_same_code
273+
code="BS-SP", prefix=prefix, index=units_same_code
276274
)
277275

278276
unit = BuildingUnit(
279277
cj_key=obj_key,
280-
unit_code="BS",
278+
unit_code="BS-SP",
281279
unit_storeys=[],
282280
icon_position=bdgs_sub_attributes.icon_position,
283281
)
@@ -292,7 +290,6 @@ def _process_bag_element(
292290
for bag_2d_id in tqdm(
293291
unprocessed_bag_ids, desc="Processing the remaining buildings"
294292
):
295-
print(bag_2d_id)
296293
# Skip the children
297294
if bag_2d_id[-2] == "-":
298295
continue

python/src/data_pipeline/cj_writing/gltf_to_cj.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,16 @@ def load_units_from_csv(
231231
cj_file_pos = spaces_ids_to_pos[space_id]
232232
space = cj_file.city_objects[cj_file_pos]
233233
assert isinstance(space, CityJSONSpaceSubclass)
234-
if space.geometries is None:
234+
if space.geometries is None or len(space.geometries) == 0:
235235
continue
236-
best_idx = 0
237-
for idx in range(1, len(space.geometries)):
238-
if space.geometries[idx].lod > space.geometries[best_idx].lod:
236+
best_idx = -1
237+
best_lod = -1
238+
for idx in range(0, len(space.geometries)):
239+
if space.geometries[idx].lod > best_lod:
239240
best_idx = idx
240-
meshes.append(space.geometries[best_idx].to_trimesh())
241+
best_lod = space.geometries[best_idx].lod
242+
if best_idx >= 0:
243+
meshes.append(space.geometries[best_idx].to_trimesh())
241244

242245
if len(meshes) == 0:
243246
continue

python/src/data_pipeline/cli.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,9 @@ def format_codelist(
519519
f"There is already a file at {output_json_path.absolute()}. Set `overwrite` to True to overwrite it."
520520
)
521521

522-
format_codelist(input_csv_path=input_csv_path, output_json_path=output_json_path)
522+
format_codelist_json(
523+
input_csv_path=input_csv_path, output_json_path=output_json_path
524+
)
523525

524526

525527
def setup_logging(verbose: int):

threejs/index.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<link href="./styles/location.css" rel="stylesheet" type="text/css">
2020
<link href="./styles/infoPane.css" rel="stylesheet" type="text/css">
2121
<link href="./styles/storeyManager.css" rel="stylesheet" type="text/css">
22+
<link href="./styles/attribution.css" rel="stylesheet" type="text/css">
2223

2324
<script type="module" src="./src/header.js" defer></script>
2425
<script type="module" src="./src/main.js"></script>
@@ -176,7 +177,13 @@
176177
<div id="basemap-aerial"></div>
177178

178179
<!-- overlay used to dim background when sheet is open -->
179-
<div id="layers-overlay" aria-hidden="true"></div>
180+
<div id="layers-overlay" aria-hidden="true"> </div>
181+
182+
<div id="attribution">
183+
<p>
184+
<a href="https://www.pdok.nl/">PDOK</a> | <a href="https://docs.3dbag.nl/en/copyright">© 3DBAG by tudelft3d and 3DGI</a>
185+
</p>
186+
</div>
180187

181188
</body>
182189

threejs/src/cjHelper.js

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ export class CjHelper {
6565
return type == "Building";
6666
}
6767

68+
isBuildingStorey(key) {
69+
const type = this.getType(key);
70+
return type == "BuildingStorey";
71+
}
72+
6873
isBuildingRoom(key) {
6974
const type = this.getType(key);
7075
return type == "BuildingRoom";
@@ -264,25 +269,6 @@ export class CjHelper {
264269
);
265270
}
266271

267-
/**
268-
* Get the object keys of all the objects of one of the given types.
269-
*
270-
* @param {string[]} objectTypes
271-
* @returns
272-
*/
273-
_getAllObjectKeysFilter(objectTypes) {
274-
const allObjectKeys = [];
275-
for (const [objectKey, object] of Object.entries(
276-
cityjson.CityObjects
277-
)) {
278-
const objectType = this.getType(objectKey);
279-
if (objectTypes.includes(objectType)) {
280-
allObjectKeys.push(objectKey);
281-
}
282-
}
283-
return allObjectKeys;
284-
}
285-
286272
/**
287273
* @param {key} buildingKey: The cityjson key of the building object from which the keys of the building unit groups need to be extracted.
288274
*
@@ -305,6 +291,32 @@ export class CjHelper {
305291
return this.getChildrenObjectKeys(buildingUnitMainGroup);
306292
}
307293

294+
/**
295+
* Get the object keys of all the objects of one of the given types.
296+
* Returns all objects if the list is empty.
297+
*
298+
* @param {string[]} objectTypes
299+
* @returns
300+
*/
301+
_getAllObjectKeysFilter(objectTypes) {
302+
const allObjectKeys = [];
303+
for (const [objectKey, object] of Object.entries(
304+
cityjson.CityObjects
305+
)) {
306+
const objectType = this.getType(objectKey);
307+
if (objectTypes.length == 0) {
308+
allObjectKeys.push(objectKey);
309+
} else if (objectTypes.includes(objectType)) {
310+
allObjectKeys.push(objectKey);
311+
}
312+
}
313+
return allObjectKeys;
314+
}
315+
316+
getAllObjectKeys() {
317+
return this._getAllObjectKeysFilter([]);
318+
}
319+
308320
getAllBuildingsObjectKeys() {
309321
return this._getAllObjectKeysFilter(["Building"]);
310322
}

threejs/src/objectPicker.js

Lines changed: 44 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -531,50 +531,64 @@ export class ObjectPicker {
531531
if (unitSpacesObjectKeys.length != 0) {
532532
// Case where the unit links to spaces
533533

534-
unitSpacesMeshes = unitSpacesObjectKeys.map((objectKey) => {
535-
return this.cjHelper.getMesh(objectKey);
536-
});
537-
const unitSpacesBuildingObjectKeys = unitSpacesObjectKeys.map(
538-
(objectKey) => {
539-
return this.cjHelper.findParentBuildingObjectKey(
534+
// unitSpacesMeshes = unitSpacesObjectKeys.map((objectKey) => {
535+
// if (this.cjHelper.isBuildingRoom(objectKey)) {
536+
// return this.cjHelper.getMesh(objectKey);
537+
// } else if (this.cjHelper.isBuildingStorey(objectKey)) {
538+
// const rooms = this.cjHelper.getChildrenObjectKeys(objectKey);
539+
// return rooms.map((roomKey) => {
540+
// return this.cjHelper.getMesh(roomKey);
541+
// });
542+
// } else {
543+
// console.error("The specified object is not a BuildingRoom or BuildingStorey.")
544+
// }
545+
// });
546+
547+
// Find the spaces of the unit and their parent building
548+
unitSpacesMeshes = [];
549+
const unitSpacesBuildingKeys = [];
550+
for (const objectKey of unitSpacesObjectKeys) {
551+
if (this.cjHelper.isBuildingRoom(objectKey)) {
552+
unitSpacesMeshes.push(this.cjHelper.getMesh(objectKey));
553+
unitSpacesBuildingKeys.push(this.cjHelper.findParentBuildingObjectKey(
540554
objectKey
541-
);
555+
));
556+
} else if (this.cjHelper.isBuildingStorey(objectKey)) {
557+
const rooms = this.cjHelper.getChildrenObjectKeys(objectKey);
558+
rooms.forEach((roomKey) => {
559+
unitSpacesMeshes.push(this.cjHelper.getMesh(roomKey));
560+
unitSpacesBuildingKeys.push(this.cjHelper.findParentBuildingObjectKey(
561+
roomKey
562+
));
563+
564+
});
565+
} else {
566+
console.error("The specified object is not a BuildingRoom or BuildingStorey.")
542567
}
543-
);
568+
}
569+
570+
// const unitSpacesBuildingKeys = unitSpacesObjectKeys.map(
571+
// (objectKey) => {
572+
// return this.cjHelper.findParentBuildingObjectKey(
573+
// objectKey
574+
// );
575+
// }
576+
// );
544577

545578
// Check if all the unit spaces are in the same building
546579
if (
547-
!unitSpacesBuildingObjectKeys.every(
548-
(v) => v === unitSpacesBuildingObjectKeys[0]
580+
!unitSpacesBuildingKeys.every(
581+
(v) => v === unitSpacesBuildingKeys[0]
549582
)
550583
) {
551584
console.error(
552585
"A unit with spaces in multiple buildings is not supported."
553586
);
554587
return;
555588
}
556-
buildingObjectKey = unitSpacesBuildingObjectKeys[0];
589+
buildingObjectKey = unitSpacesBuildingKeys[0];
557590
buildingMesh = this.cjHelper.getMesh(buildingObjectKey);
558591

559-
// // Find the most frequent storey code
560-
// const unitSpacesStoreyCodes = unitSpacesObjectKeys.map(
561-
// (objectKey) => {
562-
// return this.cjHelper.getStoreyCode(objectKey);
563-
// }
564-
// );
565-
// var counts = {};
566-
// var compare = 0;
567-
// for (const spaceStoreyCode of unitSpacesStoreyCodes) {
568-
// if (counts[spaceStoreyCode] === undefined) {
569-
// counts[spaceStoreyCode] = 1;
570-
// } else {
571-
// counts[spaceStoreyCode] += 1;
572-
// }
573-
// if (counts[spaceStoreyCode] > compare) {
574-
// compare = counts[spaceStoreyCode];
575-
// storeyCode = spaceStoreyCode;
576-
// }
577-
// }
578592
} else {
579593
// Case where the unit has no spaces
580594

@@ -597,7 +611,6 @@ export class ObjectPicker {
597611
storeyCode = this.cjHelper.getUnitMainStoreyCode(pickedObjectKey);
598612
}
599613

600-
601614
// Highlight the meshes
602615
this.pickHighlighter.highlight(unitSpacesMeshes);
603616

0 commit comments

Comments
 (0)