2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef _CONTEXT_PLACE_RECOGNITION_PLACES_DETECTOR_
18 #define _CONTEXT_PLACE_RECOGNITION_PLACES_DETECTOR_
22 #include <UserPlacesTypes.h>
23 #include <MyPlaceTypes.h>
28 class PlacesDetector {
31 static double __doubleValueFromJson(Json &row, const char* key);
32 static Categs __visitCategsFromJson(Json &row);
33 static void __visitLocationFromJson(Json &row, ctx::Visit &visit);
34 static Visit __visitFromJson(Json &row);
35 static Visits __visitsFromJsons(std::vector<Json>& records);
37 static std::shared_ptr<graph::Graph> __graphFromVisits(const std::vector<Visit> &visits);
39 static void __dbCreateTable();
40 static void __dbDeletePlaces();
41 static void __dbDeleteOldEntries();
42 static void __dbDeleteOlderVisitsThan(time_t threshold);
43 static void __dbDeleteOlderWifiAPsThan(time_t threshold);
44 static std::vector<Json> __dbGetVisits();
45 static void __dbInsertPlace(const Place &place);
47 static std::shared_ptr<Place> __placeFromMergedVisits(Visits &mergedVisits);
48 static std::vector<std::shared_ptr<ctx::Place>> __processVisits(Visits &visits, bool testMode = false);
49 static void __mergeLocation(const Visits &mergedVisits, Place &place);
50 static std::shared_ptr<graph::Components> __mergeVisits(const std::vector<Visit> &visits);
51 static void __reduceOutliers(Visits &visits);
52 static void __reduceOutliers(std::shared_ptr<graph::Components> &cc);
57 static void detectPlaces();
59 }; /* class PlacesDetector */
63 #endif /* End of _CONTEXT_PLACE_RECOGNITION_PLACES_DETECTOR_ */