std::map<std::string, std::string> wifiAPsMap;
DatabaseManager dbManager;
bool ret = dbManager.executeSync(__GET_WIFI_APS_MAP_QUERY, &records);
- // TODO: add return statements if db fail
_D("load Wifi APs map (size = %d), result: %s", records.size(), ret ? "SUCCESS" : "FAIL");
std::string mac = "";
std::string networkName = "";
#define __DELETE_PLACES_QUERY "DELETE FROM " PLACE_TABLE
#ifdef DEBUG_MODE
-#define __USER_PLACES_FILE "/tmp/user_places.txt" // TODO: Only for debug purposes -> Remove in final solution
+#define __USER_PLACES_FILE "/tmp/user_places.txt"
#endif /* DEBUG_MODE */
#define __GET_VISITS_QUERY "SELECT "\
std::vector<std::shared_ptr<ctx::Place>> ctx::PlacesDetector::__processVisits(ctx::Visits &visits, bool testMode)
{
#ifdef DEBUG_MODE
- std::vector<Visits> placesVisits; // TODO: remove from final solution.
+ std::vector<Visits> placesVisits;
#endif /* DEBUG_MODE */
std::vector<std::shared_ptr<Place>> newDetectedPlaces;
__dbInsertPlace(*place);
#ifdef DEBUG_MODE
- { // TODO: Only for debug -> remove in final solution
+ {
Visits placeVisits;
for (graph::Node i : *component) {
placeVisits.push_back(visits[i]);
}
#ifdef DEBUG_MODE
- { // Print to file TODO: Only for debug -> remove in final solution
+ {
std::ofstream out(__USER_PLACES_FILE);
for (size_t i = 0; i < newDetectedPlaces.size(); i++) {
DebugUtils::printPlace2Stream(*newDetectedPlaces[i], out);
std::stringstream query;
query << "DELETE FROM " << VISIT_TABLE;
query << " WHERE " << VISIT_COLUMN_END_TIME << " < " << threshold;
- // query << " AND 0"; // XXX: Always false condition. Uncomment it for not deleting any visit during development.
std::vector<Json> records;
DatabaseManager dbManager;
bool ret = dbManager.executeSync(query.str().c_str(), &records);
/*
* Class for generating a HTML page with GoogleMaps with all user places.
- * This class is for test/demo purposes only. TODO: Remove this class from final solution.
+ * This class is for test/demo purposes only.
*/
class Gmap {
void ctx::LocationEvent::log()
{
std::string time_str = DebugUtils::humanReadableDateTime(timestamp, "%T", 9);
-#ifdef DEBUG_MODE
- _D("location lat=%.8f, lon=%.8f, acc=%.2f[m], time=%s, method=%d",
- coordinates.latitude,
- coordinates.longitude,
- coordinates.accuracy,
- time_str.c_str(),
- method);
-#else /* DEBUG_MODE */
_D("location lat=%.8f, lon=%.8f, acc=%.2f[m], time=%s",
coordinates.latitude,
coordinates.longitude,
coordinates.accuracy,
time_str.c_str());
-#endif /* DEBUG_MODE */
}
void ctx::Visit::setLocation(Location location_)
#define VISIT_COLUMN_END_TIME "end_time"
#define VISIT_COLUMN_WIFI_APS "wifi_aps"
#define VISIT_COLUMN_CATEGORY "category"
-#ifdef DEBUG_MODE
-#define VISIT_COLUMN_START_TIME_HUMAN "start_time_human" // only for debug: human readable time data:
-#define VISIT_COLUMN_END_TIME_HUMAN "end_time_human" // only for debug: human readable time data:
-#endif /* DEBUG_MODE */
#define VISIT_COLUMN_LOCATION_VALID "location_valid"
#define VISIT_COLUMN_LOCATION_LATITUDE "location_latitude"
#define VISIT_COLUMN_LOCATION_LONGITUDE "location_longitude"
#define LOCATION_COLUMN_LONGITUDE "longitude"
#define LOCATION_COLUMN_ACCURACY "accuracy"
#define LOCATION_COLUMN_TIMESTAMP "timestamp"
-#ifdef DEBUG_MODE
-#define LOCATION_COLUMN_TIMESTAMP_HUMAN "time_human" // only for debug: human readable time data:
-#define LOCATION_COLUMN_METHOD "method"
-#endif /* DEBUG_MODE */
#define MYPLACE_SETTINGS_TABLE "Myplace_Settings"
#define MYPLACE_SETTINGS_COLUMN_KEY "key"
typedef std::map<int, num_t> Categs; // scores of categories
-#ifdef DEBUG_MODE
- enum LocationSource {
- LOCATION_METHOD_REQUEST = 0,
- LOCATION_METHOD_GET_LOCATION = 1,
- LOCATION_METHOD_GET_LAST_LOCATION = 2
- };
-#endif /* DEBUG_MODE */
-
/*
* location + timestamp + method
*/
Location coordinates;
time_t timestamp;
-#ifdef DEBUG_MODE
- LocationSource method;
-
- LocationEvent(double latitude_, double longitude_, double accuracy_, time_t timestamp_, LocationSource method_) :
- coordinates(latitude_, longitude_, accuracy_),
- timestamp(timestamp_), method(method_) {}
-#else /* DEBUG_MODE */
LocationEvent(double latitude_, double longitude_, double accuracy_, time_t timestamp_) :
coordinates(latitude_, longitude_, accuracy_),
timestamp(timestamp_) {}
-#endif /* DEBUG_MODE */
void log();
#include <DebugUtils.h>
#include "LocationLogger.h"
-#ifdef DEBUG_MODE
-#define __LOCATION_CREATE_TABLE_COLUMNS \
- LOCATION_COLUMN_LATITUDE " REAL NOT NULL, "\
- LOCATION_COLUMN_LONGITUDE " REAL NOT NULL, "\
- LOCATION_COLUMN_ACCURACY " REAL, "\
- LOCATION_COLUMN_TIMESTAMP " timestamp NOT NULL, "\
- LOCATION_COLUMN_TIMESTAMP_HUMAN " TEXT, "\
- LOCATION_COLUMN_METHOD " INTEGER "
-#else /* DEBUG_MODE */
#define __LOCATION_CREATE_TABLE_COLUMNS \
LOCATION_COLUMN_LATITUDE " REAL NOT NULL, "\
LOCATION_COLUMN_LONGITUDE " REAL NOT NULL, "\
LOCATION_COLUMN_ACCURACY " REAL, "\
LOCATION_COLUMN_TIMESTAMP " timestamp NOT NULL "
-#endif /* DEBUG_MODE */
#define __LOCATION_ERROR_LOG(error) { \
if (error != LOCATIONS_ERROR_NONE) { \
_D("");
ctx::LocationLogger* locationLogger = (ctx::LocationLogger *)userData;
double horizontal = locationLogger->__locationManagerGetHorizontalAccuracy();
-#ifdef DEBUG_MODE
- ctx::LocationEvent location(latitude, longitude, horizontal, timestamp, LOCATION_METHOD_REQUEST);
-#else /* DEBUG_MODE */
ctx::LocationEvent location(latitude, longitude, horizontal, timestamp);
-#endif /* DEBUG_MODE */
locationLogger->__broadcast(location);
locationLogger->__onActiveRequestSucceeded();
}
data.set(NULL, LOCATION_COLUMN_LONGITUDE, locationEvent.coordinates.longitude);
data.set(NULL, LOCATION_COLUMN_ACCURACY, locationEvent.coordinates.accuracy);
data.set(NULL, LOCATION_COLUMN_TIMESTAMP, static_cast<int>(locationEvent.timestamp));
-#ifdef DEBUG_MODE
- std::string timeHuman = DebugUtils::humanReadableDateTime(locationEvent.timestamp, "%F %T", 80);
- data.set(NULL, LOCATION_COLUMN_TIMESTAMP_HUMAN, timeHuman);
- data.set(NULL, LOCATION_COLUMN_METHOD, static_cast<int>(locationEvent.method));
-#endif /* DEBUG_MODE */
DatabaseManager dbManager;
int64_t rowId;
__activeAttempts++;
__allAttempts++;
if (ret == LOCATIONS_ERROR_NONE) {
-#ifdef DEBUG_MODE
- ctx::LocationEvent location(latitude, longitude, horizontal, timestamp, LOCATION_METHOD_GET_LOCATION);
-#else /* DEBUG_MODE */
ctx::LocationEvent location(latitude, longitude, horizontal, timestamp);
-#endif /* DEBUG_MODE */
__broadcast(location);
__onActiveLocationSucceeded();
return true;
__LOCATION_ERROR_LOG(ret);
__allAttempts++;
if (ret == LOCATIONS_ERROR_NONE) {
-#ifdef DEBUG_MODE
- ctx::LocationEvent location(latitude, longitude, horizontal, timestamp, LOCATION_METHOD_GET_LAST_LOCATION);
-#else /* DEBUG_MODE */
ctx::LocationEvent location(latitude, longitude, horizontal, timestamp);
-#endif /* DEBUG_MODE */
__broadcast(location);
}
}
#include "LocationListenerIface.h"
/* Database usage flag */
-#define LOCATION_LOGGER_DATABASE false // TODO: false in final solution
+#define LOCATION_LOGGER_DATABASE false
/* Locations measure method */
#define LOCATION_LOGGER_METHOD LOCATIONS_METHOD_HYBRID
typedef void (*visit_categer_t)(ctx::Visit &visit);
-#ifdef DEBUG_MODE
#define __VISIT_TABLE_COLUMNS \
VISIT_COLUMN_WIFI_APS " TEXT, "\
VISIT_COLUMN_START_TIME " timestamp, "\
VISIT_COLUMN_END_TIME " timestamp, "\
- VISIT_COLUMN_START_TIME_HUMAN " TEXT, "\
- VISIT_COLUMN_END_TIME_HUMAN " TEXT, "\
VISIT_COLUMN_LOCATION_VALID " INTEGER, "\
VISIT_COLUMN_LOCATION_LATITUDE " REAL, "\
VISIT_COLUMN_LOCATION_LONGITUDE " REAL, "\
VISIT_COLUMN_CATEG_HOME " REAL, "\
VISIT_COLUMN_CATEG_WORK " REAL, "\
VISIT_COLUMN_CATEG_OTHER " REAL"
-#else /* DEBUG_MODE */
-#define __VISIT_TABLE_COLUMNS \
- VISIT_COLUMN_WIFI_APS " TEXT, "\
- VISIT_COLUMN_START_TIME " timestamp, "\
- VISIT_COLUMN_END_TIME " timestamp, "\
- VISIT_COLUMN_LOCATION_VALID " INTEGER, "\
- VISIT_COLUMN_LOCATION_LATITUDE " REAL, "\
- VISIT_COLUMN_LOCATION_LONGITUDE " REAL, "\
- VISIT_COLUMN_LOCATION_ACCURACY " REAL, "\
- VISIT_COLUMN_CATEG_HOME " REAL, "\
- VISIT_COLUMN_CATEG_WORK " REAL, "\
- VISIT_COLUMN_CATEG_OTHER " REAL"
-#endif /* DEBUG_MODE */
#define __WIFI_APS_MAP_TABLE_COLUMNS \
WIFI_APS_MAP_COLUMN_MAC " TEXT NOT NULL UNIQUE, "\
#ifdef DEBUG_MODE
std::string startTimeHuman = DebugUtils::humanReadableDateTime(visit.interval.start, "%F %T", 80);
std::string endTimeHuman = DebugUtils::humanReadableDateTime(visit.interval.end, "%F %T", 80);
- data.set(NULL, VISIT_COLUMN_START_TIME_HUMAN, startTimeHuman.c_str());
- data.set(NULL, VISIT_COLUMN_END_TIME_HUMAN, endTimeHuman.c_str());
_D("db: visit table insert interval: (%d, %d): (%s, %s)",
visit.interval.start, visit.interval.end, startTimeHuman.c_str(), endTimeHuman.c_str());
#else