|
|
|
|
@@ -16,14 +16,14 @@ namespace Floorplan {
|
|
|
|
|
/** possible issue types */
|
|
|
|
|
enum class Type {
|
|
|
|
|
WARN,
|
|
|
|
|
ERROR,
|
|
|
|
|
ERR,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** type -> string */
|
|
|
|
|
static std::string getTypeStr(const Type t) {
|
|
|
|
|
switch(t) {
|
|
|
|
|
case Type::WARN: return "WARNING";
|
|
|
|
|
case Type::ERROR: return "ERROR";
|
|
|
|
|
case Type::ERR: return "ERROR";
|
|
|
|
|
default: throw Exception("code error. invalid type. todo!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -57,7 +57,7 @@ namespace Floorplan {
|
|
|
|
|
int err = 0;
|
|
|
|
|
for (const Issue& i : issues) {
|
|
|
|
|
std::cout << i.asString() << std::endl;
|
|
|
|
|
if (i.type == Type::ERROR) {++err;}
|
|
|
|
|
if (i.type == Type::ERR) {++err;}
|
|
|
|
|
}
|
|
|
|
|
if (err > 0) {
|
|
|
|
|
// throw Exception("detected floorplan errors");
|
|
|
|
|
@@ -74,7 +74,7 @@ namespace Floorplan {
|
|
|
|
|
|
|
|
|
|
// outline present?
|
|
|
|
|
if (floor->outline.empty()) {
|
|
|
|
|
res.push_back(Issue(Type::ERROR, floor, "has no outline"));
|
|
|
|
|
res.push_back(Issue(Type::ERR, floor, "has no outline"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// check outline
|
|
|
|
|
@@ -115,14 +115,14 @@ namespace Floorplan {
|
|
|
|
|
static void checkOutline(Issues& res, const Floor* floor, const FloorOutlinePolygon* poly) {
|
|
|
|
|
|
|
|
|
|
// number of points valid?
|
|
|
|
|
if (poly->poly.points.size() < 3) {res.push_back(Issue(Type::ERROR, floor, "' outline '" + poly->name + "' needs at least 3 edges"));}
|
|
|
|
|
if (poly->poly.points.size() > 1024) {res.push_back(Issue(Type::ERROR, floor, "' outline '" + poly->name + "' has too many edges"));}
|
|
|
|
|
if (poly->poly.points.size() < 3) {res.push_back(Issue(Type::ERR, floor, "' outline '" + poly->name + "' needs at least 3 edges"));}
|
|
|
|
|
if (poly->poly.points.size() > 1024) {res.push_back(Issue(Type::ERR, floor, "' outline '" + poly->name + "' has too many edges"));}
|
|
|
|
|
|
|
|
|
|
// outline size [bbox] valid?
|
|
|
|
|
BBox2 outline;
|
|
|
|
|
for (const Point2 pt : poly->poly.points) { outline.add(pt); }
|
|
|
|
|
const Point2 size = outline.getSize();
|
|
|
|
|
if (size.x < 1.0 || size.y < 1.0) {res.push_back(Issue(Type::ERROR, floor, "' outline '" + poly->name + "' seems too small"));}
|
|
|
|
|
if (size.x < 1.0 || size.y < 1.0) {res.push_back(Issue(Type::ERR, floor, "' outline '" + poly->name + "' seems too small"));}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -143,7 +143,7 @@ namespace Floorplan {
|
|
|
|
|
if (door) {
|
|
|
|
|
const float len_m = door->from.getDistance(door->to);
|
|
|
|
|
if (len_m < 0.40) {
|
|
|
|
|
res.push_back(Issue(Type::ERROR, floor, "' door is too narrow: " + std::to_string(len_m) + " meter from " + door->from.asString() + " to " + door->to.asString()));
|
|
|
|
|
res.push_back(Issue(Type::ERR, floor, "' door is too narrow: " + std::to_string(len_m) + " meter from " + door->from.asString() + " to " + door->to.asString()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -152,7 +152,7 @@ namespace Floorplan {
|
|
|
|
|
if (circle) {
|
|
|
|
|
const float len_m = circle->radius;
|
|
|
|
|
if (len_m < 0.20) {
|
|
|
|
|
res.push_back(Issue(Type::ERROR, floor, "' pillar is too narrow: " + std::to_string(len_m) + " meter at " + circle->center.asString()));
|
|
|
|
|
res.push_back(Issue(Type::ERR, floor, "' pillar is too narrow: " + std::to_string(len_m) + " meter at " + circle->center.asString()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -162,7 +162,7 @@ namespace Floorplan {
|
|
|
|
|
|
|
|
|
|
const std::string note = "does it belong to a stair? if so: fine! Note: fingerprints are currently measured using smartphones and smartphone are held by the pedestian. thus: fingerprints are ~1.3 meter above ground";
|
|
|
|
|
if (fpl->heightAboveFloor < 0.8) {
|
|
|
|
|
res.push_back(Issue(Type::ERROR, floor, std::string() + "fingerprint " + fpl->name + " @ " + fpl->getPosition(*floor).asString() + " is too near to the floor. " + note));
|
|
|
|
|
res.push_back(Issue(Type::ERR, floor, std::string() + "fingerprint " + fpl->name + " @ " + fpl->getPosition(*floor).asString() + " is too near to the floor. " + note));
|
|
|
|
|
} else if (fpl->heightAboveFloor > 2.0) {
|
|
|
|
|
res.push_back(Issue(Type::WARN, floor, std::string() + "fingerprint " + fpl->name + " @ " + fpl->getPosition(*floor).asString() + " is too high above the floor. " + note));
|
|
|
|
|
}
|
|
|
|
|
@@ -179,7 +179,7 @@ namespace Floorplan {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (stair->getParts().empty()) {
|
|
|
|
|
res.push_back(Issue(Type::ERROR, floor, "stair does not contain any parts! [empty stair]"));
|
|
|
|
|
res.push_back(Issue(Type::ERR, floor, "stair does not contain any parts! [empty stair]"));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -191,19 +191,19 @@ namespace Floorplan {
|
|
|
|
|
|
|
|
|
|
// start == end?
|
|
|
|
|
if (quadS.p1.z == quadE.p3.z) {
|
|
|
|
|
res.push_back(Issue(Type::ERROR, floor, "stair start and end must not belong to the same floor!"));
|
|
|
|
|
res.push_back(Issue(Type::ERR, floor, "stair start and end must not belong to the same floor!"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// disconnected start? (MUST belong to the floor the stair is attached to)
|
|
|
|
|
if (quadS.p1.z != floor->getStartingZ()) {
|
|
|
|
|
res.push_back(Issue(Type::ERROR, floor, "stair is not connected to the starting floor's ground! [open stair start]"));
|
|
|
|
|
res.push_back(Issue(Type::ERR, floor, "stair is not connected to the starting floor's ground! [open stair start]"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// disconnected end? (must be long to ANY other floor within the map)
|
|
|
|
|
//if (quadE.p3.z != floor->getEndingZ()) {
|
|
|
|
|
const int stairEndingZ_cm = std::round( quadE.p3.z * 100 );
|
|
|
|
|
if(std::find(floorAtHeight_cm.begin(), floorAtHeight_cm.end(), stairEndingZ_cm) == floorAtHeight_cm.end()) {
|
|
|
|
|
res.push_back(Issue(Type::ERROR, floor, "stair is not connected to the ending floor's ground! [open stair end]"));
|
|
|
|
|
res.push_back(Issue(Type::ERR, floor, "stair is not connected to the ending floor's ground! [open stair end]"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -214,7 +214,7 @@ namespace Floorplan {
|
|
|
|
|
// disconnected within?
|
|
|
|
|
if (i > 0) {
|
|
|
|
|
if (quads[i-1].p4.z != quads[i-0].p1.z) {
|
|
|
|
|
res.push_back(Issue(Type::ERROR, floor, "stair is disconnected within!"));
|
|
|
|
|
res.push_back(Issue(Type::ERR, floor, "stair is disconnected within!"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -225,15 +225,15 @@ namespace Floorplan {
|
|
|
|
|
static void checkElevator(Issues& res, const IndoorMap* map, const Floor* floor, const Elevator* e) {
|
|
|
|
|
|
|
|
|
|
if (e->depth < 0.5) {
|
|
|
|
|
res.push_back(Issue(Type::ERROR, floor, "elevator's @" + e->center.asString() + ": depth is too small: " + std::to_string(e->depth) + "m"));
|
|
|
|
|
res.push_back(Issue(Type::ERR, floor, "elevator's @" + e->center.asString() + ": depth is too small: " + std::to_string(e->depth) + "m"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (e->width < 0.5) {
|
|
|
|
|
res.push_back(Issue(Type::ERROR, floor, "elevator's @" + e->center.asString() + ": width is too small: " + std::to_string(e->width) + "m"));
|
|
|
|
|
res.push_back(Issue(Type::ERR, floor, "elevator's @" + e->center.asString() + ": width is too small: " + std::to_string(e->width) + "m"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (e->height_m < 0.1) {
|
|
|
|
|
res.push_back(Issue(Type::ERROR, floor, "elevator's @" + e->center.asString() + ": height is too small: " + std::to_string(e->height_m) + "m"));
|
|
|
|
|
res.push_back(Issue(Type::ERR, floor, "elevator's @" + e->center.asString() + ": height is too small: " + std::to_string(e->height_m) + "m"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// list of all heights where there is a floor;
|
|
|
|
|
@@ -246,7 +246,7 @@ namespace Floorplan {
|
|
|
|
|
// disconnected end? (must be long to ANY other floor within the map)
|
|
|
|
|
const int elevEndZ_cm = std::round( (floor->getStartingZ() + e->height_m) * 100 );
|
|
|
|
|
if(std::find(floorAtHeight_cm.begin(), floorAtHeight_cm.end(), elevEndZ_cm) == floorAtHeight_cm.end()) {
|
|
|
|
|
res.push_back(Issue(Type::ERROR, floor, "elevator @" + e->center.asString() + " is not connected to the ending floor's ground! [open elevator end]"));
|
|
|
|
|
res.push_back(Issue(Type::ERR, floor, "elevator @" + e->center.asString() + " is not connected to the ending floor's ground! [open elevator end]"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|