SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
AppWAISlamParamHelper.h
Go to the documentation of this file.
1 #ifndef APP_WAI_SLAM_PARAM_HELPER_H
2 #define APP_WAI_SLAM_PARAM_HELPER_H
3 
4 #include <Utils.h>
5 #include <string>
6 
8 {
9  std::string dateTime;
10  std::string weatherConditions;
11  std::string deviceString;
12  std::string purpose;
13  std::string resolution;
14 };
15 
17 {
18  std::string dateTime;
19  std::string location;
20  std::string area;
21  std::string extractorType;
22  int nLevels;
23 };
24 
25 static bool extractSlamVideoInfosFromFileName(std::string fileName,
26  SlamVideoInfos* slamVideoInfos)
27 {
28  bool result = false;
29 
30  std::vector<std::string> stringParts;
31  Utils::splitString(fileName, '_', stringParts);
32 
33  if (stringParts.size() == 5)
34  {
35  slamVideoInfos->dateTime = stringParts[0];
36  slamVideoInfos->weatherConditions = stringParts[1];
37  slamVideoInfos->deviceString = stringParts[2];
38  slamVideoInfos->purpose = stringParts[3];
39  slamVideoInfos->resolution = stringParts[4];
40 
41  result = true;
42  }
43 
44  return result;
45 }
46 
47 static std::string constructSlamMapIdentifierString(std::string location,
48  std::string area,
49  std::string extractorType,
50  int nLevels,
51  std::string dateTime = "")
52 {
53  if (dateTime.empty())
54  {
55  dateTime = Utils::getDateTime2String();
56  }
57 
58  std::string result = "DEVELOPMENT-map_" + dateTime + "_" + location + "_" + area + "_" + extractorType + "_" + std::to_string(nLevels);
59 
60  return result;
61 }
62 
63 static bool extractSlamMapInfosFromFileName(std::string fileName,
64  SlamMapInfos* slamMapInfos)
65 {
66  bool result = false;
67 
68  *slamMapInfos = {};
69 
70  fileName = Utils::getFileNameWOExt(fileName);
71 
72  std::vector<std::string> stringParts;
73  Utils::splitString(fileName, '_', stringParts);
74 
75  if (stringParts.size() >= 4)
76  {
77  slamMapInfos->dateTime = stringParts[1];
78  slamMapInfos->location = stringParts[2];
79  slamMapInfos->area = stringParts[3];
80 
81  result = true;
82  }
83 
84  if (stringParts.size() >= 5)
85  {
86  slamMapInfos->extractorType = stringParts[4];
87  }
88 
89  if (stringParts.size() >= 6)
90  {
91  slamMapInfos->nLevels = std::stoi(stringParts[5]);
92  }
93  return result;
94 }
95 
96 static std::string constructSlamLocationDir(std::string locationsRootDir, std::string location)
97 {
98  std::string result = Utils::unifySlashes(locationsRootDir) + location + "/";
99 
100  return result;
101 }
102 
103 static std::string constructSlamAreaDir(std::string locationsRootDir, std::string location, std::string area)
104 {
105  std::string result = constructSlamLocationDir(locationsRootDir, location) + Utils::getFileNameWOExt(area) + "/";
106 
107  return result;
108 }
109 
110 static std::string constructSlamMapDir(std::string locationsRootDir, std::string location, std::string area)
111 {
112  std::string result = constructSlamAreaDir(locationsRootDir, location, area) + "maps/";
113 
114  return result;
115 }
116 
117 static std::string constructSlamMapImgDir(std::string mapDir, std::string mapFileName)
118 {
119  SlamMapInfos mapInfos;
120 
121  std::string result = Utils::unifySlashes(mapDir + Utils::getFileNameWOExt(mapFileName));
122 
123  return result;
124 }
125 
126 static std::string constructSlamVideoDir(std::string locationsRootDir, std::string location, std::string area)
127 {
128  std::string result = constructSlamAreaDir(locationsRootDir, location, area) + "videos/";
129 
130  return result;
131 }
132 
133 static std::string constructSlamMapFileName(std::string location,
134  std::string area,
135  std::string extractorType,
136  int nLevels,
137  std::string dateTime = "",
138  bool binaryMap = false)
139 {
140  std::string result = constructSlamMapIdentifierString(location, area, extractorType, nLevels, dateTime);
141  if (binaryMap)
142  result += ".waimap";
143  else
144  result += ".json.gz";
145  return result;
146 }
147 
148 static std::string constructBinarySlamMapFileName(std::string location,
149  std::string area,
150  std::string extractorType,
151  int nLevels,
152  std::string dateTime = "")
153 {
154  std::string result = constructSlamMapIdentifierString(location, area, extractorType, nLevels, dateTime) + ".waimap";
155 
156  return result;
157 }
158 
159 static std::string constructSlamMarkerDir(std::string locationsRootDir, std::string location, std::string area)
160 {
161  std::string result = constructSlamAreaDir(locationsRootDir, location, area) + "markers/";
162 
163  return result;
164 }
165 
166 #endif
static std::string constructSlamVideoDir(std::string locationsRootDir, std::string location, std::string area)
static bool extractSlamMapInfosFromFileName(std::string fileName, SlamMapInfos *slamMapInfos)
static std::string constructBinarySlamMapFileName(std::string location, std::string area, std::string extractorType, int nLevels, std::string dateTime="")
static bool extractSlamVideoInfosFromFileName(std::string fileName, SlamVideoInfos *slamVideoInfos)
static std::string constructSlamMarkerDir(std::string locationsRootDir, std::string location, std::string area)
static std::string constructSlamMapFileName(std::string location, std::string area, std::string extractorType, int nLevels, std::string dateTime="", bool binaryMap=false)
static std::string constructSlamMapIdentifierString(std::string location, std::string area, std::string extractorType, int nLevels, std::string dateTime="")
static std::string constructSlamMapDir(std::string locationsRootDir, std::string location, std::string area)
static std::string constructSlamMapImgDir(std::string mapDir, std::string mapFileName)
static std::string constructSlamLocationDir(std::string locationsRootDir, std::string location)
static std::string constructSlamAreaDir(std::string locationsRootDir, std::string location, std::string area)
string getDateTime2String()
Returns local time as string like "20190213-154611".
Definition: Utils.cpp:289
string unifySlashes(const string &inputDir, bool withTrailingSlash)
Returns the inputDir string with unified forward slashes, e.g.: "dirA/dirB/".
Definition: Utils.cpp:368
string getFileNameWOExt(const string &pathFilename)
Returns the filename without extension.
Definition: Utils.cpp:616
void splitString(const string &s, char delimiter, vector< string > &splits)
Splits an input string at a delimiter character into a string vector.
Definition: Utils.cpp:152
std::string location
std::string dateTime
std::string extractorType
std::string weatherConditions
std::string deviceString