Merge branch 'master' into workingToni
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "../../geo/Point3.h"
|
||||
#include "../../geo/Point2.h"
|
||||
#include "../../geo/EarthPos.h"
|
||||
|
||||
namespace Floorplan {
|
||||
|
||||
@@ -21,20 +22,86 @@ namespace Floorplan {
|
||||
/** a free key-value meta element */
|
||||
struct Meta {
|
||||
|
||||
struct KeyVal {
|
||||
std::string key;
|
||||
std::string val;
|
||||
KeyVal() {;}
|
||||
KeyVal(const std::string& key, const std::string& val) : key(key), val(val) {;}
|
||||
};
|
||||
|
||||
const std::string EMPTY = "";
|
||||
std::unordered_map<std::string, std::string> params;
|
||||
|
||||
// std::unordered_map<std::string, std::string> params;
|
||||
// const std::string& getVal(const std::string& key) const {
|
||||
// const auto it = params.find(key);
|
||||
// return (it == params.end()) ? (EMPTY) : (it->second);
|
||||
// }
|
||||
|
||||
std::vector<KeyVal> params;
|
||||
|
||||
KeyVal* getKV(const std::string& key) {
|
||||
for (KeyVal& kv : params) {
|
||||
if (kv.key == key) {return &kv;}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const KeyVal* getKV(const std::string& key) const {
|
||||
for (const KeyVal& kv : params) {
|
||||
if (kv.key == key) {return &kv;}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const std::string& getVal(const std::string& key) const {
|
||||
const auto it = params.find(key);
|
||||
return (it == params.end()) ? (EMPTY) : (it->second);
|
||||
static const std::string EMPTY = "";
|
||||
const KeyVal* kv = getKV(key);
|
||||
return (kv) ? (kv->val) : (EMPTY);
|
||||
}
|
||||
void setVal(const std::string& key, const std::string& val) {(*this)[key] = val;}
|
||||
|
||||
void add(const std::string& key, const std::string& val) {params.push_back(KeyVal(key,val));}
|
||||
|
||||
std::string& operator [] (const std::string& key) {
|
||||
KeyVal* kv = getKV(key);
|
||||
if (!kv) {params.push_back(KeyVal(key, ""));}
|
||||
return getKV(key)->val;
|
||||
}
|
||||
void setVal(const std::string& key, const std::string& val) {params[key] = val;}
|
||||
|
||||
float getFloat(const std::string& key) const { return std::stof(getVal(key)); }
|
||||
void setFloat(const std::string& key, const float val) { params[key] = std::to_string(val); }
|
||||
void setFloat(const std::string& key, const float val) { (*this)[key] = std::to_string(val); }
|
||||
|
||||
int getInt(const std::string& key) const { return std::stoi(getVal(key)); }
|
||||
void setInt(const std::string& key, const int val) { params[key] = std::to_string(val); }
|
||||
void setInt(const std::string& key, const int val) { (*this)[key] = std::to_string(val); }
|
||||
|
||||
|
||||
|
||||
size_t size() const {return params.size();}
|
||||
|
||||
const std::string& getKey(const int idx) const {return params[idx].key;}
|
||||
const std::string& getVal(const int idx) const {return params[idx].val;}
|
||||
|
||||
void set(const int idx, const KeyVal& kv) {params[idx] = kv;}
|
||||
void setKey(const int idx, const std::string& key) {params[idx].key = key;}
|
||||
void setVal(const int idx, const std::string& val) {params[idx].val = val;}
|
||||
|
||||
/** delete the idx-th entry */
|
||||
void deleteEntry(const int idx) {params.erase(params.begin()+idx);}
|
||||
|
||||
};
|
||||
|
||||
class HasMeta {
|
||||
|
||||
Meta* meta = nullptr;
|
||||
|
||||
public:
|
||||
|
||||
Meta* getMeta() const {return meta;}
|
||||
|
||||
void setMeta(Meta* meta) {
|
||||
if (this->meta) {delete this->meta;}
|
||||
this->meta = meta;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -180,14 +247,14 @@ namespace Floorplan {
|
||||
};
|
||||
|
||||
/** an AccessPoint located somewhere on a floor */
|
||||
struct AccessPoint {
|
||||
struct AccessPoint : public HasMeta {
|
||||
std::string name;
|
||||
std::string mac;
|
||||
Point3 pos; // z is relative to the floor's height
|
||||
struct Model {
|
||||
float txp;
|
||||
float exp;
|
||||
float waf;
|
||||
float txp = 0;
|
||||
float exp = 0;
|
||||
float waf = 0;
|
||||
} model;
|
||||
AccessPoint() : name(), mac(), pos() {;}
|
||||
AccessPoint(const std::string& name, const std::string& mac, const Point3& pos) : name(name), mac(toUpperCase(mac)), pos(pos) {;}
|
||||
@@ -401,8 +468,7 @@ namespace Floorplan {
|
||||
|
||||
|
||||
/** base-class for stairs */
|
||||
struct Stair {
|
||||
Meta* meta = nullptr;
|
||||
struct Stair : public HasMeta {
|
||||
virtual std::vector<StairPart> getParts() const = 0;
|
||||
};
|
||||
|
||||
@@ -453,7 +519,7 @@ namespace Floorplan {
|
||||
|
||||
|
||||
/** an image file that can be added to the map */
|
||||
struct UnderlayImage {
|
||||
struct UnderlayImage {
|
||||
std::string name;
|
||||
std::string filename;
|
||||
Point2 anchor;
|
||||
@@ -463,16 +529,44 @@ namespace Floorplan {
|
||||
|
||||
|
||||
|
||||
/** one correspondence point: earth <-> map */
|
||||
struct EarthPosMapPos {
|
||||
|
||||
EarthPos posOnEarth;
|
||||
|
||||
Point3 posOnMap_m;
|
||||
|
||||
/** ctor */
|
||||
EarthPosMapPos(const EarthPos posOnEarth, const Point3 posOnMap_m) : posOnEarth(posOnEarth), posOnMap_m(posOnMap_m) {;}
|
||||
|
||||
};
|
||||
|
||||
|
||||
/** describe the floorplan's location on earth */
|
||||
struct EarthRegistration {
|
||||
|
||||
/** all available correspondences: earth <-> map */
|
||||
std::vector<EarthPosMapPos> correspondences;
|
||||
|
||||
};
|
||||
|
||||
/** describes the whole indoor map */
|
||||
struct IndoorMap {
|
||||
|
||||
float width;
|
||||
float depth;
|
||||
|
||||
std::vector<Floor*> floors;
|
||||
|
||||
/** mapping: floorplan <-> earth */
|
||||
EarthRegistration earthReg;
|
||||
|
||||
IndoorMap() {;}
|
||||
|
||||
/** no copy */
|
||||
IndoorMap(const IndoorMap& o) = delete;
|
||||
|
||||
/** no copy assign */
|
||||
void operator = (const IndoorMap& o) = delete;
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user