From: Marcin Masternak Date: Fri, 27 May 2016 17:31:29 +0000 (+0200) Subject: [my-place] Move Place print2Stream to DebugUtils X-Git-Tag: submit/tizen/20160622.045445~1^2~15 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F35%2F71935%2F1;p=platform%2Fcore%2Fcontext%2Fcontext-provider.git [my-place] Move Place print2Stream to DebugUtils Change-Id: I940190b13719fe1bc5283232b5bba9bc75bc326d Signed-off-by: Marcin Masternak --- diff --git a/src/my-place/user_places/debug_utils.cpp b/src/my-place/user_places/debug_utils.cpp index 48b9cd9..bb03751 100644 --- a/src/my-place/user_places/debug_utils.cpp +++ b/src/my-place/user_places/debug_utils.cpp @@ -16,6 +16,12 @@ #include "debug_utils.h" #include +#include + +/* + * 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; +} diff --git a/src/my-place/user_places/debug_utils.h b/src/my-place/user_places/debug_utils.h index 4651dfc..1e0965d 100644 --- a/src/my-place/user_places/debug_utils.h +++ b/src/my-place/user_places/debug_utils.h @@ -19,6 +19,8 @@ #include #include +#include +#include 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 */ diff --git a/src/my-place/user_places/places_detector.cpp b/src/my-place/user_places/places_detector.cpp index a324984..95585d5 100644 --- a/src/my-place/user_places/places_detector.cpp +++ b/src/my-place/user_places/places_detector.cpp @@ -29,6 +29,7 @@ #include #include #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); diff --git a/src/my-place/user_places/user_places_params.h b/src/my-place/user_places/user_places_params.h index 262e7ed..e08f20c 100644 --- a/src/my-place/user_places/user_places_params.h +++ b/src/my-place/user_places/user_places_params.h @@ -67,11 +67,6 @@ #define PLACES_DETECTOR_RETENTION_DAYS 30 #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 */ diff --git a/src/my-place/user_places/user_places_types.cpp b/src/my-place/user_places/user_places_types.cpp index f3faa37..7a9768d 100644 --- a/src/my-place/user_places/user_places_types.cpp +++ b/src/my-place/user_places/user_places_types.cpp @@ -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; -} diff --git a/src/my-place/user_places/user_places_types.h b/src/my-place/user_places/user_places_types.h index 508e889..7c20d97 100644 --- a/src/my-place/user_places/user_places_types.h +++ b/src/my-place/user_places/user_places_types.h @@ -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 */