[my-place] Output JSON places fix. 01/72601/1
authorMarcin Masternak <m.masternak@samsung.com>
Wed, 1 Jun 2016 11:47:24 +0000 (13:47 +0200)
committerMarcin Masternak <m.masternak@samsung.com>
Wed, 1 Jun 2016 18:16:52 +0000 (20:16 +0200)
Change-Id: I66fd171c20ff6a3de47ec0c342e472578384c915
Signed-off-by: Marcin Masternak <m.masternak@samsung.com>
src/my-place/user_places/user_places.cpp

index a2a129a..621a40a 100755 (executable)
@@ -122,17 +122,22 @@ ctx::Json ctx::UserPlaces::__composeJson(std::vector<std::shared_ptr<Place>> pla
                placeJson.set(NULL, PLACE_CATEG_CONFIDENCE, static_cast<double>(place->categConfidence));
                placeJson.set(NULL, PLACE_NAME, place->name);
                if (place->locationValid) {
-                       placeJson.set(NULL, PLACE_LOCATION_LATITUDE, static_cast<double>(place->location.latitude));
-                       placeJson.set(NULL, PLACE_LOCATION_LONGITUDE, static_cast<double>(place->location.longitude));
+                       ctx::Json locationJson;
+                       locationJson.set(NULL, PLACE_LOCATION_LATITUDE, static_cast<double>(place->location.latitude));
+                       locationJson.set(NULL, PLACE_LOCATION_LONGITUDE, static_cast<double>(place->location.longitude));
+                       locationJson.set(NULL, PLACE_LOCATION_ACCURACY, static_cast<double>(place->location.accuracy));
+                       placeJson.set(NULL, PLACE_LOCATION, locationJson);
                }
-               ctx::Json wifiApsListJson;
-               for (std::pair<std::string, std::string> ap : place->wifiAps) {
-                       ctx::Json wifiApJson;
-                       wifiApJson.set(NULL, PLACE_WIFI_AP_MAC, ap.first);
-                       wifiApJson.set(NULL, PLACE_WIFI_AP_NETWORK_NAME, ap.second);
-                       wifiApsListJson.append(NULL, PLACE_WIFI_APS, wifiApJson);
+               if (place->wifiAps.size()) {
+                       ctx::Json wifiApsListJson;
+                       for (std::pair<std::string, std::string> ap : place->wifiAps) {
+                               ctx::Json wifiApJson;
+                               wifiApJson.set(NULL, PLACE_WIFI_AP_MAC, ap.first);
+                               wifiApJson.set(NULL, PLACE_WIFI_AP_NETWORK_NAME, ap.second);
+                               wifiApsListJson.append(NULL, PLACE_WIFI_APS, wifiApJson);
+                       }
+                       placeJson.set(NULL, PLACE_WIFI_APS, wifiApsListJson);
                }
-               placeJson.set(NULL, PLACE_WIFI_APS, wifiApsListJson);
                placeJson.set(NULL, PLACE_CREATE_DATE, static_cast<int64_t>(place->createDate));
                data.append(NULL, PLACE_DATA_READ, placeJson);
        }