[my-place] Move Place print2Stream to DebugUtils 35/71935/1
authorMarcin Masternak <m.masternak@samsung.com>
Fri, 27 May 2016 17:31:29 +0000 (19:31 +0200)
committerMarcin Masternak <m.masternak@samsung.com>
Fri, 27 May 2016 17:40:35 +0000 (19:40 +0200)
Change-Id: I940190b13719fe1bc5283232b5bba9bc75bc326d
Signed-off-by: Marcin Masternak <m.masternak@samsung.com>
src/my-place/user_places/debug_utils.cpp
src/my-place/user_places/debug_utils.h
src/my-place/user_places/places_detector.cpp
src/my-place/user_places/user_places_params.h
src/my-place/user_places/user_places_types.cpp
src/my-place/user_places/user_places_types.h

index 48b9cd9..bb03751 100644 (file)
 
 #include "debug_utils.h"
 #include <Types.h>
+#include <iomanip>
+
+/*
+ * Number of digits after decimal point used in geo coordinates.
+ */
+#define GEO_LOCATION_PRECISION 7
 
 std::string ctx::DebugUtils::humanReadableDateTime(time_t timestamp, std::string format, size_t size, bool utc)
 {
@@ -37,3 +43,15 @@ std::string ctx::DebugUtils::humanReadableDateTime(time_t timestamp, std::string
        }
        return std::string(buffer);
 }
+
+void ctx::DebugUtils::printPlace2Stream(const Place &place, std::ostream &out)
+{
+       out << "PLACE:" << std::endl;
+       out << "__CATEGORY: " << place.name << std::endl;
+       if (place.locationValid) {
+               out << "__LOCATION: lat=" << std::setprecision(GEO_LOCATION_PRECISION + 2) << place.location.latitude;
+               out << ", lon=" << place.location.longitude << std::setprecision(5) << std::endl;
+       }
+       out << "__WIFI:" << place.wifiAps << std::endl;
+       out << "__CREATE_DATE: " << humanReadableDateTime(place.createDate, "%F %T", 80) << std::endl;
+}
index 4651dfc..1e0965d 100644 (file)
@@ -19,6 +19,8 @@
 
 #include <string>
 #include <ctime>
+#include <iostream>
+#include <user_places_types.h>
 
 namespace ctx {
 
@@ -26,6 +28,7 @@ namespace ctx {
 
        public:
                static std::string humanReadableDateTime(time_t timestamp, std::string format, size_t size, bool utc = false);
+               static void printPlace2Stream(const Place &place, std::ostream &out);
 
        };      /* class DebugUtils */
 
index a324984..95585d5 100644 (file)
@@ -29,6 +29,7 @@
 #include <fstream>
 #include <algorithm>
 #include "user_places_params.h"
+#include "debug_utils.h"
 
 #define __DELETE_PLACES_QUERY "DELETE FROM " PLACE_TABLE
 
@@ -261,7 +262,7 @@ void ctx::PlacesDetector::__processVisits(ctx::Visits &visits)
        { // 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++) {
-                       newDetectedPlaces[i]->print2Stream(out);
+                       DebugUtils::printPlace2Stream(*newDetectedPlaces[i], out);
                        Visits placeVisits = placesVisits[i];
                        for (Visit visit : placeVisits) {
                                visit.printShort2Stream(out);
index 262e7ed..e08f20c 100644 (file)
 #define PLACES_DETECTOR_RETENTION_SECONDS 24 * 60 * 60 * PLACES_DETECTOR_RETENTION_DAYS
 
 /*
- * Number of digits after decimal point used in geo coordinates.
- */
-#define GEO_LOCATION_PRECISION 7
-
-/*
  * Minimal duration of visit (in minutes) taking into account for place detection
  */
 #define PLACES_DETECTOR_MIN_VISIT_DURATION_MINUTES 15
index f3faa37..7a9768d 100644 (file)
@@ -248,15 +248,3 @@ ctx::Interval::Interval(time_t start_, time_t end_) : start(start_), end(end_) {
                _E("Negative interval, start=%d, end=%d", start_, end_);
        }
 }
-
-void ctx::Place::print2Stream(std::ostream &out) const
-{
-       out << "PLACE:" << std::endl;
-       out << "__CATEGORY: " << name << std::endl;
-       if (locationValid) {
-               out << "__LOCATION: lat=" << std::setprecision(GEO_LOCATION_PRECISION + 2) << location.latitude;
-               out << ", lon=" << location.longitude << std::setprecision(5) << std::endl;
-       }
-       out << "__WIFI:" << wifiAps << std::endl;
-       out << "__CREATE_DATE: " << DebugUtils::humanReadableDateTime(createDate, "%F %T", 80) << std::endl;
-}
index 508e889..7c20d97 100644 (file)
@@ -215,8 +215,6 @@ namespace ctx {
                std::string wifiAps; // WiFi APs MAC addresses separated by ","
                time_t createDate; // The last update time of this place
 
-               void print2Stream(std::ostream &out) const;
-
        };      /* class Place */
 
 }      /* namespace ctx */