1.Updated heremaps-uc app. 77/56677/1
authorchanywa <cbible.kim@samsung.com>
Tue, 12 Jan 2016 02:38:20 +0000 (11:38 +0900)
committerchanywa <cbible.kim@samsung.com>
Tue, 12 Jan 2016 02:55:51 +0000 (11:55 +0900)
2.Fixed to convert distance values with the distance unit in preference.
3.Rearranged some apis for search_place.
4.Updated engine libraries to heremaps-engine_1.0.6_9

Change-Id: I2d772991d63be8f9d6c375faa9d75c1ceae45c1b

21 files changed:
heremaps-uc/src/heremaps-uc.c
inc/engine/routes/GeoRouteQuery.h
inc/here_place.h
inc/here_route.h
inc/here_utils.h
lib/aarch64/libheremaps-engine.so.1
lib/aarch64/libheremaps-engine.so.1.0.6_8 [deleted file]
lib/aarch64/libheremaps-engine.so.1.0.6_9 [new file with mode: 0755]
lib/arm/libheremaps-engine.so.1
lib/arm/libheremaps-engine.so.1.0.6_8 [deleted file]
lib/arm/libheremaps-engine.so.1.0.6_9 [new file with mode: 0755]
lib/i586/libheremaps-engine.so.1
lib/i586/libheremaps-engine.so.1.0.6_8 [deleted file]
lib/i586/libheremaps-engine.so.1.0.6_9 [new file with mode: 0755]
lib/x86_64/libheremaps-engine.so.1
lib/x86_64/libheremaps-engine.so.1.0.6_8 [deleted file]
lib/x86_64/libheremaps-engine.so.1.0.6_9 [new file with mode: 0755]
src/here_api.cpp
src/here_place.cpp
src/here_route.cpp
src/here_utils.cpp

index f4bde7733bfda77677c9e13c23ce6d7b94dd3360..2621092a7a7811fbe5ff7190f002e8a7564f93e2 100644 (file)
@@ -60,6 +60,43 @@ static void win_del(void *data, Evas_Object * obj, void *event)
        elm_exit();
 }
 
+static void read_file(heremaps_uc_app_data *ad)
+{
+       LS_FUNC_ENTER
+       FILE *fp = fopen(UC_FILE, "r");
+       char buf[15] = {};
+       char *data = NULL, *save_token = NULL;
+       app_control_h reply;
+       int ret = 0;
+
+       if (fp == NULL)
+               LS_LOGE("UC_FILE open fail");
+       else {
+               ret = fread(buf, 15, 1, fp);
+               fclose(fp);
+
+               if (ret > 0)
+               {
+                       data = strtok_r(buf, "=", &save_token);
+                       data = strtok_r(NULL, "=", &save_token);
+               }
+               else
+                       LS_LOGE("UC_FILE read fail");
+       }
+
+       app_control_create(&reply);
+       if (data == NULL)
+               app_control_add_extra_data(reply, "result", "No");
+       else if ((strcmp(data, "Yes") == 0) || (strcmp(data, "No") == 0))
+               app_control_add_extra_data(reply, "result", data);
+       else
+               app_control_add_extra_data(reply, "result", "No");
+       ret = app_control_reply_to_launch_request(reply, ad->app_control, APP_CONTROL_RESULT_SUCCEEDED);
+       if (ret != APP_CONTROL_ERROR_NONE)
+               LS_LOGE("app_control_reply_to_launch_request fail. err=%d", ret);
+       app_control_destroy(reply);
+}
+
 static void save_file(char *data, heremaps_uc_app_data *ad)
 {
        FILE *fp = fopen(UC_FILE, "w+");
@@ -67,12 +104,20 @@ static void save_file(char *data, heremaps_uc_app_data *ad)
        app_control_h reply;
        int ret = 0;
 
-       snprintf(buf, sizeof(buf)-1, "Agree=%s", data);
-       fwrite(buf, strlen(buf), 1, fp);
+       app_control_create(&reply);
 
-       fclose(fp);
+       if (fp == NULL) {
+               LS_LOGE("UC_FILE open fail");
+               app_control_add_extra_data(reply, "result", "No");
+       } else {
+               snprintf(buf, sizeof(buf)-1, "Agree=%s", data);
+               fwrite(buf, strlen(buf), 1, fp);
+               fclose(fp);
+               LS_LOGE("result of save_file() is %s", data);
+
+               app_control_add_extra_data(reply, "result", strdup(data));
+       }
 
-       app_control_create(&reply);
        ret = app_control_reply_to_launch_request(reply, ad->app_control, APP_CONTROL_RESULT_SUCCEEDED);
        if (ret != APP_CONTROL_ERROR_NONE)
                LS_LOGE("app_control_reply_to_launch_request fail. err=%d", ret);
@@ -99,6 +144,15 @@ static void agree_btn_cb(void *data, Evas_Object * obj, void *event)
        elm_exit();
 }
 
+static void back_btn_cb(void *data, Evas_Object * obj, void *event)
+{
+       LS_FUNC_ENTER
+       heremaps_uc_app_data *ad = (heremaps_uc_app_data *) data;
+
+       read_file(ad);
+       elm_exit();
+}
+
 static Evas_Object *create_win(const char *name)
 {
        LS_FUNC_ENTER
@@ -126,7 +180,7 @@ static Evas_Object *create_popup(Evas_Object *layout, heremaps_uc_app_data *ad)
        /* popup */
        popup = elm_popup_add(layout);
        elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
-       eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, win_del, layout);
+       eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, back_btn_cb, ad);
        evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
 
        elm_object_part_text_set(popup, "title,text", P_("IDS_POSITIONING_CONSENT_TITLE"));
@@ -181,20 +235,29 @@ static void _app_control_cb(app_control_h app_control, void *user_data)
 
        gboolean ret = FALSE;
        heremaps_uc_app_data *ad = (heremaps_uc_app_data *) user_data;
+       char *action = NULL;
        char *data = NULL;
        LS_RETURN_IF_FAILED(ad);
 
-       app_control_get_extra_data(app_control, "value", &data);
-       LS_LOGE("DATA = %s", data);
-
        ret = app_control_clone(&(ad->app_control), app_control);
        if (ret == FALSE)
                LS_LOGE("app_control_clone. err=%d", ret);
 
-       if (data != NULL) {
-               if ((strcmp(data, "Yes") == 0) || (strcmp(data, "No") == 0)) {
-                       save_file(data, ad);
+       app_control_get_extra_data(app_control, "action", &action);
+       if (action != NULL) {
+               if (strcmp(action, "Get") == 0) {
+                       read_file(ad);
                        elm_exit();
+               } else if (strcmp(action, "Set") == 0) {
+                       app_control_get_extra_data(app_control, "value", &data);
+                       LS_LOGE("DATA = %s", data);
+
+                        if (data != NULL) {
+                               if ((strcmp(data, "Yes") == 0) || (strcmp(data, "No") == 0)) {
+                                       save_file(data, ad);
+                                       elm_exit();
+                               }
+                       }
                }
        }
 
index f3af23293054b0c3885d6a842aa20c247af12e7f..e9ed4151f5869d164baefd8954f5d6808b6a2385 100755 (executable)
@@ -119,8 +119,8 @@ public:
      * This enumeration defines identifiers for route MetricSystem specifiers.
      */
     enum MetricSystem {
-        DIST_imperial = 0x0000,      ///< Indicates that MetricSystem is miles
-        DIST_metric = 0x0001         ///< Indicates that MetricSystem is m & km
+        DIST_metric = 0x0000,        ///< Indicates that MetricSystem is m & km
+        DIST_imperial = 0x0001       ///< Indicates that MetricSystem is miles
     };
 #endif
 
index 0cc4338331d96ee77d510d844a9ad9e868f11f23..8a62ab9dfbb15e833c1db6b9ccb98d6497e3b401 100644 (file)
@@ -74,13 +74,12 @@ public:
        here_error_e PrepareDiscoveryFilter(maps_place_filter_h hFilter);
 
        here_error_e StartDiscoveryPlace(maps_coordinates_h hCoord, int nDistance);
-       here_error_e StartDiscoveryPlaceByArea(maps_area_h hArea);
-       here_error_e StartDiscoveryPlaceByAddress(const char *szAddr, maps_area_h hArea);
+       here_error_e StartDiscoveryPlace(maps_area_h hArea, const char *szAddr = "");
 
        here_error_e PreparePlaceDetailsQuery();
        here_error_e PreparePlaceDetailsPreference(maps_preference_h hPref);
-       
-       here_error_e StartPlaceDetails(const char* szPlaceId);
+
+       here_error_e StartPlaceDetails(const char* szUrl);
        here_error_e StartPlaceDetailsInternal(const char* szUrl);
 
        virtual void OnDiscoverReply(const DiscoveryReply &Reply);
@@ -117,6 +116,7 @@ private:
        bool m_bReplyFlushed;
        char *m_szSortBy;
        bool m_bPlaceDetailsInternal;
+       maps_distance_unit_e m_eDistanceUnit;
 
        PlaceList m_PlaceList;
 
index 0aab6097b9f9d09921e2c4ff85e3b3bca947faa5..8c352e1d5d0f125139babe1c50f71ef1c77e8623 100644 (file)
@@ -64,7 +64,9 @@ public:
 private:
        maps_error_e ProcessSegments(maps_route_h mapsRoute, const RouteSegmentList& hereSegmList);
        maps_error_e ProcessManeuver(maps_route_segment_h mapsSegm, const ManeuverList& hereManeList);
+       const double __convertDistanceUnit(const double dValue);
 
+       maps_distance_unit_e m_eDistanceUnit;
        GeoRouteQuery* m_pQuery;
 };
 
index 3a54031271996b5068175af0ab38318c4103b028..c46e64ddda4a69fdfca1416eb7fb1fd5e8022e0b 100644 (file)
@@ -40,6 +40,8 @@
 #include <routes/GeoRouteQuery.h>
 #include <routes/Maneuver.h>
 #include <common/GeoCoordinates.h>
+#include <common/GeoBoundingBox.h>
+#include <common/GeoBoundingCircle.h>
 
 #define HERE_PLUGIN_BEGIN_NAMESPACE  namespace Here { namespace PlugIn {
 #define HERE_PLUGIN_END_NAMESPACE    }}
@@ -128,10 +130,13 @@ public:
        static maps_route_turn_type_e Convert(Maneuver::InstructionDirection nVal);
        static GeoBoundingBox& Convert(maps_area_h hArea, GeoBoundingBox& Box);
        static maps_area_h& Convert(GeoBoundingBox Box, maps_area_h& hArea);
+       static GeoBoundingCircle& Convert(maps_area_h hArea, GeoBoundingCircle& circle);
        static void Convert(String strUtf8, WString& strUtf16);
        static void Convert(WString strUtf16, String& strUtf8);
        static GeoBoundingBox& Convert(const char *src, GeoBoundingBox &box);
        static maps_error_e ConvertHttpCodeToMapsError(int nVal);
+       static const double ConvertDistance(const double originValue, maps_distance_unit_e destUnit);
+       static const double ConvertDistance(const double originValue, maps_distance_unit_e originUnit, maps_distance_unit_e destUnit);
 
        static bool IsValid(GeoCoordinates geoCoord);
        static bool IsValid(maps_coordinates_s geoCoord);
index e36a8f887fe1ebe6615ea2412fb37bb27b6d82af..ece39bdaa903e7ca070e5e77fb2b4fbfec5b71ee 120000 (symlink)
@@ -1 +1 @@
-libheremaps-engine.so.1.0.6_8
\ No newline at end of file
+libheremaps-engine.so.1.0.6_9
\ No newline at end of file
diff --git a/lib/aarch64/libheremaps-engine.so.1.0.6_8 b/lib/aarch64/libheremaps-engine.so.1.0.6_8
deleted file mode 100755 (executable)
index d2446f5..0000000
Binary files a/lib/aarch64/libheremaps-engine.so.1.0.6_8 and /dev/null differ
diff --git a/lib/aarch64/libheremaps-engine.so.1.0.6_9 b/lib/aarch64/libheremaps-engine.so.1.0.6_9
new file mode 100755 (executable)
index 0000000..dec06a3
Binary files /dev/null and b/lib/aarch64/libheremaps-engine.so.1.0.6_9 differ
index e36a8f887fe1ebe6615ea2412fb37bb27b6d82af..ece39bdaa903e7ca070e5e77fb2b4fbfec5b71ee 120000 (symlink)
@@ -1 +1 @@
-libheremaps-engine.so.1.0.6_8
\ No newline at end of file
+libheremaps-engine.so.1.0.6_9
\ No newline at end of file
diff --git a/lib/arm/libheremaps-engine.so.1.0.6_8 b/lib/arm/libheremaps-engine.so.1.0.6_8
deleted file mode 100755 (executable)
index 33a0c4f..0000000
Binary files a/lib/arm/libheremaps-engine.so.1.0.6_8 and /dev/null differ
diff --git a/lib/arm/libheremaps-engine.so.1.0.6_9 b/lib/arm/libheremaps-engine.so.1.0.6_9
new file mode 100755 (executable)
index 0000000..bb449cb
Binary files /dev/null and b/lib/arm/libheremaps-engine.so.1.0.6_9 differ
index e36a8f887fe1ebe6615ea2412fb37bb27b6d82af..ece39bdaa903e7ca070e5e77fb2b4fbfec5b71ee 120000 (symlink)
@@ -1 +1 @@
-libheremaps-engine.so.1.0.6_8
\ No newline at end of file
+libheremaps-engine.so.1.0.6_9
\ No newline at end of file
diff --git a/lib/i586/libheremaps-engine.so.1.0.6_8 b/lib/i586/libheremaps-engine.so.1.0.6_8
deleted file mode 100755 (executable)
index 4ab209d..0000000
Binary files a/lib/i586/libheremaps-engine.so.1.0.6_8 and /dev/null differ
diff --git a/lib/i586/libheremaps-engine.so.1.0.6_9 b/lib/i586/libheremaps-engine.so.1.0.6_9
new file mode 100755 (executable)
index 0000000..46f5e30
Binary files /dev/null and b/lib/i586/libheremaps-engine.so.1.0.6_9 differ
index e36a8f887fe1ebe6615ea2412fb37bb27b6d82af..ece39bdaa903e7ca070e5e77fb2b4fbfec5b71ee 120000 (symlink)
@@ -1 +1 @@
-libheremaps-engine.so.1.0.6_8
\ No newline at end of file
+libheremaps-engine.so.1.0.6_9
\ No newline at end of file
diff --git a/lib/x86_64/libheremaps-engine.so.1.0.6_8 b/lib/x86_64/libheremaps-engine.so.1.0.6_8
deleted file mode 100755 (executable)
index 3dda9f2..0000000
Binary files a/lib/x86_64/libheremaps-engine.so.1.0.6_8 and /dev/null differ
diff --git a/lib/x86_64/libheremaps-engine.so.1.0.6_9 b/lib/x86_64/libheremaps-engine.so.1.0.6_9
new file mode 100755 (executable)
index 0000000..7f478d9
Binary files /dev/null and b/lib/x86_64/libheremaps-engine.so.1.0.6_9 differ
index 194d050bdbd9857ccca106687c12765cfd30fc30..fdcc8ada796f1f929bc98f664b76de94fa4a22ca 100644 (file)
@@ -385,7 +385,7 @@ int HerePluginSearchPlaceByArea(maps_area_h hArea,
                error = pPlace->PrepareDiscoveryFilter(hFilter);
                if (error != HERE_ERROR_NONE) break;
 
-               error = pPlace->StartDiscoveryPlaceByArea(hArea);
+               error = pPlace->StartDiscoveryPlace(hArea);
        } while(0);
 
        /* finishing task */
@@ -430,7 +430,7 @@ int HerePluginSearchPlaceByAddress(const char* szAddr, maps_area_h hArea,
                error = pPlace->PrepareDiscoveryFilter(hFilter);
                if (error != HERE_ERROR_NONE) break;
 
-               error = pPlace->StartDiscoveryPlaceByAddress(szAddr, hArea);
+               error = pPlace->StartDiscoveryPlace(hArea, szAddr);
        } while(0);
 
        /* finishing task */
index 51c1a06d520345e5c7e082644f8169800730e872..6ce63447d5f26effbc2443cf5c20e1430f33d780 100644 (file)
@@ -32,6 +32,7 @@ HerePlace::HerePlace(void *pCbFunc, void *pUserData, int nReqId)
        m_bReplyFlushed = false;
        m_szSortBy = NULL;
        m_bPlaceDetailsInternal = false;
+       m_eDistanceUnit = MAPS_DISTANCE_UNIT_M;
 }
 
 HerePlace::~HerePlace()
@@ -89,6 +90,11 @@ here_error_e HerePlace::PrepareDiscoveryPreference(maps_preference_h hPref)
        if (ret == MAPS_ERROR_NONE)
                m_pDiscoveryQuery->SetMaxResults((size_t)nMaxResults);
 
+       maps_distance_unit_e eUnit;
+       ret = maps_preference_get_distance_unit(hPref, &eUnit);
+       if (ret == MAPS_ERROR_NONE)
+               m_eDistanceUnit = eUnit;
+
        char *szSortBy;
        ret = maps_preference_get(hPref, MAPS_PLACE_FILTER_SORT_BY, &szSortBy);
        if (ret == MAPS_ERROR_NONE)
@@ -146,130 +152,126 @@ here_error_e HerePlace::PrepareDiscoveryFilter(maps_place_filter_h hFilter)
 
 here_error_e HerePlace::StartDiscoveryPlace(maps_coordinates_h hCoord, int nDistance)
 {
+       if (!hCoord || nDistance < 0)
+               return HERE_ERROR_INVALID_PARAMETER;
+
+       maps_area_h area = NULL;
+       maps_area_create_circle(hCoord, nDistance, &area);
+       here_error_e error = StartDiscoveryPlace(area);
+       maps_area_destroy(area);
+       return error;
+}
+
+here_error_e HerePlace::StartDiscoveryPlace(maps_area_h hArea, const char *szAddr)
+{
+       if (!hArea)
+               return HERE_ERROR_INVALID_PARAMETER;
+
        if (!m_pDiscoveryQuery)
                return HERE_ERROR_OUT_OF_MEMORY;
 
-       if (!hCoord)
-               return HERE_ERROR_INVALID_PARAMETER;
 
 
-       if (m_pDiscoveryQuery->GetSearchText().empty())
-       {
-               m_pDiscoveryQuery->SetType(DiscoveryQuery::QT_EXPLORE);
+       typedef enum {
+               PLACE_CMD_TEXT,
+               PLACE_CMD_CENTER,
+               PLACE_CMD_AREA,
+       } PlaceCmdType;
 
-               double dLat, dLon;
-               maps_coordinates_get_latitude(hCoord, &dLat);
-               maps_coordinates_get_longitude(hCoord, &dLon);
-               GeoCoordinates geoCoord(dLat, dLon);
+       PlaceCmdType cmdType;
+       maps_area_s *pArea = (maps_area_s*)hArea;
+       GeoCoordinates geoCoord;
+       GeoBoundingArea *geoArea = NULL;
+       GeoBoundingBox geoBox;
+       GeoBoundingCircle geoCircle;
 
-               if (nDistance > 0)
-               {
-                       GeoBoundingCircle geoCircle(geoCoord, nDistance);
-                       m_pDiscoveryQuery->SetArea(geoCircle);
-               }
-               else if (nDistance == 0)
-               {
-                       m_pDiscoveryQuery->SetProximity(geoCoord);
-               }
-               else
-                       return HERE_ERROR_INVALID_PARAMETER;
+       /* Merge search text with other search text being in preference */
+       String szSearchText = szAddr;
+       if (m_pDiscoveryQuery->GetSearchText().size() > 0 &&
+               szSearchText != m_pDiscoveryQuery->GetSearchText())
+       {
+               szSearchText += " " + m_pDiscoveryQuery->GetSearchText();
+       }
+       m_pDiscoveryQuery->SetSearchText(szSearchText);
 
-               m_nRestReqId = m_pDiscoveryQuery->Execute(*this, NULL);
 
-               return (m_nRestReqId > 0 ? HERE_ERROR_NONE : HERE_ERROR_INVALID_OPERATION);
+       /* Decide command type */
+       if (!szSearchText.empty())
+       {
+               cmdType = PLACE_CMD_TEXT;
+       }
+       else if (pArea->type == MAPS_AREA_CIRCLE && pArea->circle.radius == 0)
+       {
+               cmdType = PLACE_CMD_CENTER;
        }
        else
        {
-               here_error_e error;
-               maps_area_h hArea = NULL;
-               maps_area_create_circle(hCoord, nDistance, &hArea);
-               error = StartDiscoveryPlaceByAddress(m_pDiscoveryQuery->GetSearchText().data(), hArea);
-               maps_area_destroy(hArea);
-               return error;
+               cmdType = PLACE_CMD_AREA;
        }
-}
-
-here_error_e HerePlace::StartDiscoveryPlaceByArea(maps_area_h hArea)
-{
-       if (!m_pDiscoveryQuery)
-               return HERE_ERROR_OUT_OF_MEMORY;
-
-       if (!hArea)
-               return HERE_ERROR_INVALID_PARAMETER;
 
 
-       if (m_pDiscoveryQuery->GetSearchText().empty())
+       /* Get proximity with area */
+       if (cmdType == PLACE_CMD_TEXT || cmdType == PLACE_CMD_CENTER)
        {
-               m_pDiscoveryQuery->SetType(DiscoveryQuery::QT_EXPLORE);
-
-               maps_area_s *pArea = (maps_area_s*)hArea;
                if (pArea->type == MAPS_AREA_RECTANGLE)
                {
-                       GeoBoundingBox box(pArea->rect.top_left.longitude, pArea->rect.bottom_right.longitude,
-                                          pArea->rect.bottom_right.latitude, pArea->rect.top_left.latitude);
-                       m_pDiscoveryQuery->SetArea(box);
+                       double dLat1 = pArea->rect.top_left.latitude;
+                       double dLng1 = pArea->rect.top_left.longitude;
+                       double dLat2 = pArea->rect.bottom_right.latitude;
+                       double dLng2 = pArea->rect.bottom_right.longitude;
+                       double dLat = (dLat1 + dLat2) / 2;
+                       double dLng = (dLng1 + dLng2) / 2;
+
+                       geoCoord.SetLatitude(dLat);
+                       geoCoord.SetLongitude(dLng);
                }
-               else if (pArea->type == MAPS_AREA_CIRCLE)
+               else if(pArea->type == MAPS_AREA_CIRCLE)
                {
-                       GeoCoordinates coord(pArea->circle.center.latitude, pArea->circle.center.longitude);
-                       GeoBoundingCircle circle(coord, pArea->circle.radius);
-                       m_pDiscoveryQuery->SetArea(circle);
+                       double dLat = pArea->circle.center.latitude;
+                       double dLng = pArea->circle.center.longitude;
+
+                       geoCoord.SetLatitude(dLat);
+                       geoCoord.SetLongitude(dLng);
                }
                else
                        return HERE_ERROR_INVALID_PARAMETER;
-
-
-               m_nRestReqId = m_pDiscoveryQuery->Execute(*this, NULL);
-
-               return (m_nRestReqId > 0 ? HERE_ERROR_NONE : HERE_ERROR_INVALID_OPERATION);
        }
-       else
+       else if (cmdType == PLACE_CMD_AREA)
        {
-               return StartDiscoveryPlaceByAddress(m_pDiscoveryQuery->GetSearchText().data(), hArea);
+               if (pArea->type == MAPS_AREA_RECTANGLE)
+               {
+                       HereUtils::Convert(hArea, geoBox);
+                       geoArea = &geoBox;
+               }
+               else if (pArea->type == MAPS_AREA_CIRCLE)
+               {
+                       HereUtils::Convert(hArea, geoCircle);
+                       geoArea = &geoCircle;
+               }
+               else
+                       return HERE_ERROR_INVALID_PARAMETER;
        }
-}
-
-here_error_e HerePlace::StartDiscoveryPlaceByAddress(const char *szAddr, maps_area_h hArea)
-{
-       if (!m_pDiscoveryQuery)
-               return HERE_ERROR_OUT_OF_MEMORY;
-
-       if (!szAddr || (szAddr && strlen(szAddr) <= 0) || !hArea)
-               return HERE_ERROR_INVALID_PARAMETER;
 
 
-       m_pDiscoveryQuery->SetType(DiscoveryQuery::QT_SEARCH);
-
-       String szSearchText = szAddr;
-       if (m_pDiscoveryQuery->GetSearchText().size() > 0 &&
-               szSearchText != m_pDiscoveryQuery->GetSearchText())
+       /* Set properties */
+       if (cmdType == PLACE_CMD_TEXT)
        {
-               szSearchText += " " + m_pDiscoveryQuery->GetSearchText();
+               m_pDiscoveryQuery->SetType(DiscoveryQuery::QT_SEARCH);
+               m_pDiscoveryQuery->SetProximity(geoCoord);
        }
-       m_pDiscoveryQuery->SetSearchText(szSearchText);
-
-       maps_area_s *pArea = (maps_area_s*)hArea;
-       if (pArea->type == MAPS_AREA_RECTANGLE)
+       else if (cmdType == PLACE_CMD_CENTER)
        {
-               double dLat1 = pArea->rect.top_left.latitude;
-               double dLng1 = pArea->rect.top_left.longitude;
-               double dLat2 = pArea->rect.bottom_right.latitude;
-               double dLng2 = pArea->rect.bottom_right.longitude;
-               double dLat = (dLat1 + dLat2) / 2;
-               double dLng = (dLng1 + dLng2) / 2;
-
-               GeoCoordinates geoCoord(dLat, dLng);
+               m_pDiscoveryQuery->SetType(DiscoveryQuery::QT_EXPLORE);
                m_pDiscoveryQuery->SetProximity(geoCoord);
        }
-       else if(pArea->type == MAPS_AREA_CIRCLE)
+       else
        {
-               double dLat = pArea->circle.center.latitude;
-               double dLng = pArea->circle.center.longitude;
-               GeoCoordinates geoCoord(dLat, dLng);
-               m_pDiscoveryQuery->SetProximity(geoCoord);
+               m_pDiscoveryQuery->SetType(DiscoveryQuery::QT_EXPLORE);
+               if (geoArea)
+                       m_pDiscoveryQuery->SetArea(*geoArea);
        }
 
-
+       /* Execute query */
        m_nRestReqId = m_pDiscoveryQuery->Execute(*this, NULL);
 
        return (m_nRestReqId > 0 ? HERE_ERROR_NONE : HERE_ERROR_INVALID_OPERATION);
@@ -303,22 +305,24 @@ here_error_e HerePlace::PreparePlaceDetailsPreference(maps_preference_h hPref)
                m_pPlaceDetailsQuery->SetLanguage(szLanguage);
        g_free(szLanguage);
 
+       maps_distance_unit_e eUnit;
+       ret = maps_preference_get_distance_unit(hPref, &eUnit);
+       if (ret == MAPS_ERROR_NONE)
+               m_eDistanceUnit = eUnit;
+
        return HERE_ERROR_NONE;
 }
 
-here_error_e HerePlace::StartPlaceDetails(const char *szPlaceId)
+here_error_e HerePlace::StartPlaceDetails(const char *szUrl)
 {
        if (!m_pPlaceDetailsQuery)
                return HERE_ERROR_OUT_OF_MEMORY;
 
-       if (!szPlaceId || (szPlaceId && strlen(szPlaceId) <= 0))
+       if (!szUrl || (szUrl && strlen(szUrl) <= 0))
                return HERE_ERROR_INVALID_PARAMETER;
 
 
-       m_pPlaceDetailsQuery->SetPlaceId(szPlaceId);
-
-
-       m_nRestReqId = m_pPlaceDetailsQuery->Execute(*this, NULL);
+       m_nRestReqId = m_pPlaceDetailsQuery->Execute(*this, NULL, szUrl);
 
        return (m_nRestReqId > 0 ? HERE_ERROR_NONE : HERE_ERROR_INVALID_OPERATION);
 }
@@ -445,7 +449,7 @@ void HerePlace::OnDiscoverReply (const DiscoveryReply &Reply)
                        }
 
                        /* distance */
-                       maps_place_set_distance(mapsPlace, (int)herePlaceIt->GetDistance());
+                       maps_place_set_distance(mapsPlace, HereUtils::ConvertDistance((int)herePlaceIt->GetDistance(), m_eDistanceUnit));
 
                        /* sponser */
                        /* herePlaceList.GetIsSponsored() */
@@ -905,7 +909,7 @@ void HerePlace::ProcessPlaceCategory(PlaceDetails herePlace, maps_place_h mapsPl
 }
 
 void HerePlace::ProcessPlaceImage(PlaceDetails herePlace, maps_place_h mapsPlace)
-{ 
+{
        ImageContentList hereImageList = herePlace.GetImageContent();
        ImageContentList::iterator hereImage;
        maps_item_list_h mapsImageList;
index cdb2e0dba931c511d74988793a69f659503c40ff..0a537a58590b572981e4183f537d961573016b6d 100644 (file)
@@ -25,6 +25,8 @@ HereRoute::HereRoute(void *pCbFunc, void *pUserData, int nReqId)
        m_pCbFunc = pCbFunc;
        m_pUserData = pUserData;
        m_nReqId = nReqId;
+
+       m_eDistanceUnit = MAPS_DISTANCE_UNIT_M;
 }
 
 HereRoute::~HereRoute()
@@ -169,6 +171,7 @@ here_error_e HereRoute::PreparePreference(maps_preference_h hPref)
                case MAPS_DISTANCE_UNIT_KM: eMetric = GeoRouteQuery::DIST_metric;   break;
                default:                    eMetric = GeoRouteQuery::DIST_imperial; break;
                }
+               m_eDistanceUnit = eUnit;
                m_pQuery->SetMetricSystem(eMetric);
        }
 
@@ -227,7 +230,11 @@ void HereRoute::OnRouteReply(const GeoRouteReply& Reply)
                                maps_route_set_route_id(mapsRoute, (char*)hereRoute->GetRouteId().c_str());
 
                        /* distance */
-                       maps_route_set_total_distance(mapsRoute, hereRoute->GetDistance());
+                       maps_route_set_total_distance(mapsRoute,
+                               HereUtils::ConvertDistance(hereRoute->GetDistance(), m_eDistanceUnit));
+
+                       /* distance unit */
+                       maps_route_set_distance_unit(mapsRoute, m_eDistanceUnit);
 
                        /* duration */
                        maps_route_set_total_duration(mapsRoute, hereRoute->GetTravelTime());
@@ -329,7 +336,8 @@ maps_error_e HereRoute::ProcessSegments(maps_route_h mapsRoute, const RouteSegme
                if (maps_route_segment_create(&mapsSegm) != MAPS_ERROR_NONE) continue;
 
                /* distance */
-               maps_route_segment_set_distance(mapsSegm, hereSegm->GetDistance());
+               maps_route_segment_set_distance(mapsSegm,
+                       HereUtils::ConvertDistance(hereSegm->GetDistance(), m_eDistanceUnit));
 
                /* tranvel time */
                maps_route_segment_set_duration(mapsSegm, hereSegm->GetTravelTime());
@@ -403,7 +411,7 @@ maps_error_e HereRoute::ProcessManeuver(maps_route_segment_h mapsSegm, const Man
 
                /* length */
                maps_route_maneuver_set_distance_to_next_instruction(mapsManeuver,
-                       hereMane->GetDistanceToNextInstruction());
+                       HereUtils::ConvertDistance(hereMane->GetDistanceToNextInstruction(), m_eDistanceUnit));
 
                /* travel time */
                maps_route_maneuver_set_time_to_next_instruction(mapsManeuver,
index 60f1fb90daddd355c7fcaf554713da8e46ebd666..07680b8bf2075877defa35293b19f39487a9b384 100644 (file)
@@ -297,6 +297,20 @@ maps_area_h& HereUtils::Convert(GeoBoundingBox Box, maps_area_h& hArea)
        return hArea;
 }
 
+GeoBoundingCircle& HereUtils::Convert(maps_area_h hArea, GeoBoundingCircle& circle)
+{
+       maps_area_s* area_s = (maps_area_s*)hArea;
+
+       if (!area_s || area_s->type != MAPS_AREA_CIRCLE) return circle;
+
+       GeoCoordinates hereCoord(area_s->circle.center.latitude, area_s->circle.center.longitude);
+
+       circle.SetCenter(hereCoord);
+       circle.SetRadius(area_s->circle.radius);
+
+       return circle;
+}
+
 void HereUtils::Convert(String strUtf8, WString& strUtf16)
 {
        strUtf16.assign(strUtf8.begin(), strUtf8.end());
@@ -355,5 +369,15 @@ bool HereUtils::IsValid(maps_area_s hArea)
                return false;
 }
 
+const double HereUtils::ConvertDistance(const double originValue, maps_distance_unit_e destUnit)
+{
+       return ConvertDistance(originValue, MAPS_DISTANCE_UNIT_M, destUnit);
+}
+
+const double HereUtils::ConvertDistance(const double originValue, maps_distance_unit_e originUnit, maps_distance_unit_e destUnit)
+{
+       double meterConstant[MAPS_DISTANCE_UNIT_YD+1] = { 1.0, 0.001, 3.2808399, 1.0936133 };
+       return originValue / meterConstant[originUnit] * meterConstant[destUnit];
+}
 
 HERE_PLUGIN_END_NAMESPACE