Building constructor
Building({
- required String key,
- required WorldLocation location,
- required List<
Floor> floors, - required PolygonalArea area,
Implementation
Building(
{required this.key,
required this.location,
required this.floors,
required this.area}) {
//list of room keys
List<String> keys = [];
for (var floor in floors) {
for (var room in floor.rooms) {
keys.add(room.key);
}
}
//check for duplicate room keys if building has rooms
if (keys.isNotEmpty) {
final duplicateKeys = keys.toSet().toList();
assert(listEquals(duplicateKeys, keys),
'Identical Room keys or on the same floor cannot exist!');
}
//list of beacon ids
List<String> ids = [];
for (var floor in floors) {
for (var beacon in floor.beacons) {
ids.add(beacon.id);
}
}
//check for duplicate beacon ids
final check = ids.toSet().toList();
assert(listEquals(check, ids),
'Identical Beacon ids or mac adresses in the same building cannot exist!');
for (var floor in floors) {
for (var floorPoints in floor.area.points) {
assert(area.pointInArea(floorPoints),
'$floorPoints:All points of floors need to be in the Area of the building');
}
}
}