1. [ACR-452] Added Place search APIs 52/57652/2 accepted/tizen/ivi/20160218.023944 accepted/tizen/mobile/20160122.081302 accepted/tizen/tv/20160122.081320 accepted/tizen/wearable/20160122.081343 submit/tizen/20160122.065659 submit/tizen_common/20160218.142243 submit/tizen_ivi/20160217.000000 submit/tizen_ivi/20160217.000003
authorkj7.sung <kj7.sung@samsung.com>
Thu, 21 Jan 2016 10:11:27 +0000 (19:11 +0900)
committerkj7.sung <kj7.sung@samsung.com>
Thu, 21 Jan 2016 10:13:39 +0000 (19:13 +0900)
2. Sync with latest codes

Change-Id: Ife5815c98edc86283ef76b4390ebf97e9dd65ba5
Signed-off-by: kj7.sung <kj7.sung@samsung.com>
inc/here_api.h
inc/here_manager.h
inc/here_place.h
inc/here_route.h
inc/here_utils.h
src/here_api.cpp
src/here_manager.cpp
src/here_place.cpp
src/here_plugin.cpp
src/here_route.cpp
src/here_utils.cpp

index 6c764ab..6a5280f 100644 (file)
@@ -62,9 +62,11 @@ int HerePluginSearchPlaceByAddress(const char* szAddr, maps_area_h hArea,
        maps_item_hashtable_h hPref, maps_place_filter_h hFilter, maps_service_search_place_cb pCbFunc,
        void * pUserData, int *nReqId);
 
+int HerePluginSearchPlaceList(maps_area_h hArea, maps_item_hashtable_h hPref,
+       maps_place_filter_h hFilter, maps_service_search_place_list_cb pCbFunc, void * pUserData, int *nReqId);
+
 int HerePluginSearchPlaceDetails(const char* szUrl,
-       maps_item_hashtable_h hPref, maps_service_search_place_cb pCbFunc,
-       void * pUserData, int *nReqId);
+       maps_service_get_place_details_cb pCbFunc, void * pUserData, int *nReqId);
 
 int HerePluginSearchRoute(maps_coordinates_h hOrigin, maps_coordinates_h hDestination,
        maps_item_hashtable_h hPref, maps_service_search_route_cb pCbFunc,
index b44bdd6..97da6a1 100644 (file)
@@ -70,7 +70,7 @@ public:
                HERE_SVC_MULTI_REV_GEOCODE
        };
 
-       void* CreateInstance(HereSvcType nHereSvc, void* pCbFunc, void* pUserData, int *nReqId);
+       void* CreateInstance(HereSvcType nHereSvc, void* pCbFunc = NULL, void* pUserData = NULL, int *nReqId = NULL);
        here_error_e CloseInstance(int nReqId);
        here_error_e CancelInstance(int nReqId);
        here_error_e SetCredentials(const char* provider_key);
index 0cc4338..229c969 100644 (file)
@@ -74,13 +74,13 @@ 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 StartDiscoveryPlaceList(maps_area_h hArea);
 
        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);
@@ -116,7 +116,10 @@ private:
        int m_nReplyIdx;
        bool m_bReplyFlushed;
        char *m_szSortBy;
+       bool m_bPlaceDetails;
        bool m_bPlaceDetailsInternal;
+       bool m_bReplyWithList;
+       maps_distance_unit_e m_eDistanceUnit;
 
        PlaceList m_PlaceList;
 
index 0aab609..8c352e1 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 3a54031..c46e64d 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 194d050..d3d2b39 100644 (file)
@@ -57,9 +57,7 @@ int HerePluginSetProviderKey(const char* szKey)
        if (!HereManager::GetHandler())
                return HERE_ERROR_INVALID_OPERATION;
 
-       here_error_e error = HereManager::GetHandler()->SetCredentials(szKey);
-
-       return error;
+       return HereManager::GetHandler()->SetCredentials(szKey);
 }
 
 int HerePluginGetProviderKey(char** szKey)
@@ -70,9 +68,7 @@ int HerePluginGetProviderKey(char** szKey)
        if (!HereManager::GetHandler())
                return HERE_ERROR_INVALID_OPERATION;
 
-       here_error_e error = HereManager::GetHandler()->GetCredentials(szKey);
-
-       return error;
+       return HereManager::GetHandler()->GetCredentials(szKey);
 }
 
 int HerePluginSetPreference(maps_preference_h hPref)
@@ -83,9 +79,7 @@ int HerePluginSetPreference(maps_preference_h hPref)
        if (!HereManager::GetHandler())
                return HERE_ERROR_INVALID_OPERATION;
 
-       here_error_e error = HereManager::GetHandler()->SetPreference(hPref);
-
-       return error;
+       return HereManager::GetHandler()->SetPreference(hPref);
 }
 
 int HerePluginGetPreference(maps_preference_h *hPref)
@@ -96,9 +90,7 @@ int HerePluginGetPreference(maps_preference_h *hPref)
        if (!HereManager::GetHandler())
                return HERE_ERROR_INVALID_OPERATION;
 
-       here_error_e error = HereManager::GetHandler()->GetPreference(hPref);
-
-       return error;
+       return HereManager::GetHandler()->GetPreference(hPref);
 }
 
 int HerePluginGeocode(const char* szAddr,
@@ -385,7 +377,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 +422,51 @@ 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 */
+       if(error != HERE_ERROR_NONE)
+               pPlace->TerminateService();
+
+       return error;
+}
+
+int HerePluginSearchPlaceList(maps_area_h hArea, maps_item_hashtable_h hPref,
+       maps_place_filter_h hFilter, maps_service_search_place_list_cb pCbFunc, void *pUserData, int *nReqId)
+{
+       /* checking parmaters */
+       if (!hFilter || !pCbFunc || !nReqId)
+               return HERE_ERROR_INVALID_PARAMETER;
+
+       if (!hArea || !HereUtils::IsValid(*(maps_area_s*)hArea))
+               return HERE_ERROR_INVALID_PARAMETER;
+
+       if (!HereManager::GetHandler())
+               return HERE_ERROR_INVALID_OPERATION;
+
+       /* creating instance */
+       HerePlace *pPlace =
+               (HerePlace*)(HereManager::GetHandler()->CreateInstance(HereManager::HERE_SVC_PLACE,
+               (void*)pCbFunc, pUserData, nReqId));
+
+       if(!pPlace)
+               return HERE_ERROR_SERVICE_NOT_AVAILABLE;
+
+       /* sending request */
+       here_error_e error = HERE_ERROR_NONE;
+
+       do {
+               error = pPlace->PrepareDiscoveryQuery();
+               if (error != HERE_ERROR_NONE) break;
+
+               error = pPlace->PrepareDiscoveryPreference(hPref);
+               if (error != HERE_ERROR_NONE) break;
+
+               error = pPlace->PrepareDiscoveryFilter(hFilter);
+               if (error != HERE_ERROR_NONE) break;
+
+               error = pPlace->StartDiscoveryPlaceList(hArea);
        } while(0);
 
        /* finishing task */
@@ -441,8 +477,7 @@ int HerePluginSearchPlaceByAddress(const char* szAddr, maps_area_h hArea,
 }
 
 int HerePluginSearchPlaceDetails(const char* szUrl,
-       maps_item_hashtable_h hPref, maps_service_search_place_cb pCbFunc,
-       void *pUserData, int *nReqId)
+       maps_service_get_place_details_cb pCbFunc, void *pUserData, int *nReqId)
 {
        /* checking parmaters */
        if (!szUrl || (szUrl && *szUrl == '\0') || !pCbFunc || !nReqId)
@@ -466,9 +501,6 @@ int HerePluginSearchPlaceDetails(const char* szUrl,
                error = pPlace->PreparePlaceDetailsQuery();
                if (error != HERE_ERROR_NONE) break;
 
-               error = pPlace->PreparePlaceDetailsPreference(hPref);
-               if (error != HERE_ERROR_NONE) break;
-
                error = pPlace->StartPlaceDetails(szUrl);
        } while(0);
 
index 50c256d..b8609f7 100644 (file)
@@ -112,28 +112,29 @@ void* HereManager::CreateInstance(HereSvcType nHereSvc, void* pCbFunc,
 {
        HereBase *pHere = NULL;
 
-       *nReqId = m_nNextReqId++;
+       int reqId = m_nNextReqId++;
+       if (nReqId) *nReqId = reqId;
 
        switch(nHereSvc)
        {
        case HERE_SVC_GEOCODE:
-               pHere = (HereBase*)new (std::nothrow) HereGeocode(pCbFunc, pUserData, *nReqId);
+               pHere = (HereBase*)new (std::nothrow) HereGeocode(pCbFunc, pUserData, reqId);
                break;
 
        case HERE_SVC_REV_GEOCODE:
-               pHere = (HereBase*)new (std::nothrow) HereRevGeocode(pCbFunc, pUserData, *nReqId);
+               pHere = (HereBase*)new (std::nothrow) HereRevGeocode(pCbFunc, pUserData, reqId);
                break;
 
        case HERE_SVC_PLACE:
-               pHere = (HereBase*)new (std::nothrow) HerePlace(pCbFunc, pUserData, *nReqId);
+               pHere = (HereBase*)new (std::nothrow) HerePlace(pCbFunc, pUserData, reqId);
                break;
 
        case HERE_SVC_ROUTE:
-               pHere = (HereBase*)new (std::nothrow) HereRoute(pCbFunc, pUserData, *nReqId);
+               pHere = (HereBase*)new (std::nothrow) HereRoute(pCbFunc, pUserData, reqId);
                break;
 
        case HERE_SVC_MULTI_REV_GEOCODE:
-               pHere = (HereBase*)new (std::nothrow) HereMultiRevGeocode(pCbFunc, pUserData, *nReqId);
+               pHere = (HereBase*)new (std::nothrow) HereMultiRevGeocode(pCbFunc, pUserData, reqId);
                break;
 
        default:
index 51c1a06..4bc9f39 100644 (file)
@@ -31,7 +31,10 @@ HerePlace::HerePlace(void *pCbFunc, void *pUserData, int nReqId)
        m_nReplyIdx = 0;
        m_bReplyFlushed = false;
        m_szSortBy = NULL;
+       m_bPlaceDetails = false;
        m_bPlaceDetailsInternal = false;
+       m_bReplyWithList = false;
+       m_eDistanceUnit = MAPS_DISTANCE_UNIT_M;
 }
 
 HerePlace::~HerePlace()
@@ -89,6 +92,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)
@@ -125,13 +133,16 @@ here_error_e HerePlace::PrepareDiscoveryFilter(maps_place_filter_h hFilter)
 
                ret = maps_place_category_get_id(mapsCate, &szId);
                if (ret == MAPS_ERROR_NONE && szId && *szId)
-               {
                        hereCate.SetCategoryId(CategoryId(szId));
-                       hereCateList.push_back(hereCate);
-                       m_pDiscoveryQuery->SetCategoriesFilter(hereCateList);
+               else if (hereCate.GetTitle().size() > 0)
+               {
+                       hereCate.SetCategoryId(CategoryId(hereCate.GetTitle()));
+                       hereCate.SetTitle("");
                }
                g_free(szId);
 
+               hereCateList.push_back(hereCate);
+               m_pDiscoveryQuery->SetCategoriesFilter(hereCateList);
                maps_place_category_destroy(mapsCate);
        }
 
@@ -141,140 +152,166 @@ here_error_e HerePlace::PrepareDiscoveryFilter(maps_place_filter_h hFilter)
                m_pDiscoveryQuery->SetSearchText(szName);
        g_free(szName);
 
+       char *szKeyword = NULL;
+       ret = maps_place_filter_get_keyword(hFilter, &szKeyword);
+       if (ret == MAPS_ERROR_NONE && szKeyword && *szKeyword)
+       {
+               String szSearchText = m_pDiscoveryQuery->GetSearchText();
+               if (szSearchText.size() > 0) szSearchText += " ";
+               szSearchText += szKeyword;
+               m_pDiscoveryQuery->SetSearchText(szSearchText);
+       }
+       g_free(szKeyword);
+
+       char *szAddress = NULL;
+       ret = maps_place_filter_get_place_address(hFilter, &szAddress);
+       if (ret == MAPS_ERROR_NONE && szAddress && *szAddress)
+       {
+               String szSearchText = szAddress;
+               if (m_pDiscoveryQuery->GetSearchText().size() > 0)
+               {
+                       szSearchText += " " + m_pDiscoveryQuery->GetSearchText();
+               }
+               m_pDiscoveryQuery->SetSearchText(szSearchText);
+       }
+       g_free(szAddress);
+
        return HERE_ERROR_NONE;
 }
 
 here_error_e HerePlace::StartDiscoveryPlace(maps_coordinates_h hCoord, int nDistance)
 {
-       if (!m_pDiscoveryQuery)
-               return HERE_ERROR_OUT_OF_MEMORY;
+       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;
+}
 
-       if (!hCoord)
+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 (m_pDiscoveryQuery->GetSearchText().empty())
-       {
-               m_pDiscoveryQuery->SetType(DiscoveryQuery::QT_EXPLORE);
 
-               double dLat, dLon;
-               maps_coordinates_get_latitude(hCoord, &dLat);
-               maps_coordinates_get_longitude(hCoord, &dLon);
-               GeoCoordinates geoCoord(dLat, dLon);
 
-               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;
+       typedef enum {
+               PLACE_CMD_TEXT,
+               PLACE_CMD_CENTER,
+               PLACE_CMD_AREA,
+       } PlaceCmdType;
+
+       PlaceCmdType cmdType;
+       maps_area_s *pArea = (maps_area_s*)hArea;
+       GeoCoordinates geoCoord;
+       GeoBoundingArea *geoArea = NULL;
+       GeoBoundingBox geoBox;
+       GeoBoundingCircle geoCircle;
+
+       /* Merge search text with other search text being in preference */
+       String szSearchText = (szAddr ? szAddr : "");
+       if (m_pDiscoveryQuery->GetSearchText().size() > 0)
+       {
+               if (szSearchText.size() > 0) szSearchText += " ";
+               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);
 }
 
+here_error_e HerePlace::StartDiscoveryPlaceList(maps_area_h hArea)
+{
+       m_bReplyWithList = true;
+       return StartDiscoveryPlace(hArea);
+}
+
 here_error_e HerePlace::PreparePlaceDetailsQuery()
 {
        if (m_pPlaceDetailsQuery)
@@ -303,22 +340,25 @@ 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_bPlaceDetails = true;
 
-       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);
 }
@@ -328,7 +368,6 @@ here_error_e HerePlace::StartPlaceDetailsInternal(const char *szUrl)
        if (!szUrl || (szUrl && strlen(szUrl) <= 0))
                return HERE_ERROR_INVALID_PARAMETER;
 
-
        std::unique_ptr<PlaceDetailsQuery> pPlaceDetailsQuery (new (std::nothrow)PlaceDetailsQuery());
 
        m_bPlaceDetailsInternal = true;
@@ -445,7 +484,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() */
@@ -453,7 +492,7 @@ void HerePlace::OnDiscoverReply (const DiscoveryReply &Reply)
                        /* vicinity */
 
                        /* If needed PlaceDetails information, postpone to send a reply */
-                       if(__sending_place_details_query_automatically)
+                       if(__sending_place_details_query_automatically && !m_bReplyWithList)
                        {
                                hereLinkObj = herePlaceIt->GetLinkObject();
                                if (!hereLinkObj.GetHref().empty() && !hereLinkObj.GetId().empty())
@@ -905,7 +944,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;
@@ -1214,35 +1253,57 @@ void HerePlace::ProcessPlaceRated(PlaceDetails herePlace, maps_place_h mapsPlace
 void HerePlace::__flushReplies(int error)
 {
        maps_place_h mapsPlace;
-       bool bCallbackCanceled = false;
-       int nReplyIdx = 0;
-
-       if (m_bReplyFlushed || m_bCanceled || !m_pCbFunc) return;
-       m_bReplyFlushed = true;
+       maps_item_list_h place_list;
 
+       m_nReplyIdx = 0;
        __sortList(m_PlaceList);
 
-       while ((nReplyIdx < m_nReplyCnt) ||
-               (error != MAPS_ERROR_NONE && nReplyIdx == 0 && m_nReplyCnt == 0) /* reply with only error */
-       )
+       if (m_bPlaceDetails)
        {
-               mapsPlace = NULL;
-               if (!m_PlaceList.empty())
+               if (error != MAPS_ERROR_NONE)
                {
+                       ((maps_service_get_place_details_cb)m_pCbFunc)((maps_error_e)error, m_nReqId, NULL, m_pUserData);
+                       return;
+               }
+
                        mapsPlace = m_PlaceList.front();
                        m_PlaceList.pop_front();
+
+               ((maps_service_get_place_details_cb)m_pCbFunc)((maps_error_e)error, m_nReqId, mapsPlace, m_pUserData);
+       }
+       else if (m_bReplyWithList)
+       {
+               int error = maps_item_list_create(&place_list);
+               if (error != MAPS_ERROR_NONE)
+               {
+                       ((maps_service_search_place_list_cb)m_pCbFunc)((maps_error_e)error, m_nReqId, NULL, m_pUserData);
+                       return;
                }
 
-               if (m_bCanceled || bCallbackCanceled)
+               while (m_nReplyIdx < m_nReplyCnt && !m_bCanceled && !m_PlaceList.empty())
                {
-                       maps_place_destroy(mapsPlace);
+                       mapsPlace = m_PlaceList.front();
+                       m_PlaceList.pop_front();
+
+                       maps_item_list_append(place_list, mapsPlace, maps_place_clone);
                }
-               else if (((maps_service_search_place_cb)m_pCbFunc)((maps_error_e)error, m_nReqId,
-                       nReplyIdx, m_nReplyCnt, mapsPlace, m_pUserData) == FALSE)
+
+               ((maps_service_search_place_list_cb)m_pCbFunc)((maps_error_e)error, m_nReqId, place_list, m_pUserData);
+       }
+       else
+       {
+               while (m_nReplyIdx < m_nReplyCnt && !m_bCanceled && !m_PlaceList.empty())
                {
-                       bCallbackCanceled = true;
+                       mapsPlace = m_PlaceList.front();
+                       m_PlaceList.pop_front();
+
+                       /* callback function */
+                       if (((maps_service_search_place_cb)m_pCbFunc)((maps_error_e)error, m_nReqId,
+                               m_nReplyIdx++, m_nReplyCnt, mapsPlace, m_pUserData) == FALSE)
+                       {
+                               break;
+                       }
                }
-               nReplyIdx++;
        }
 }
 
index 55898a3..8bd60e4 100644 (file)
@@ -107,6 +107,7 @@ EXPORT_API int maps_plugin_is_service_supported(maps_service_e service, bool *su
                case MAPS_SERVICE_SEARCH_ROUTE_WAYPOINTS:
                case MAPS_SERVICE_CANCEL_REQUEST:
                case MAPS_SERVICE_MULTI_REVERSE_GEOCODE:
+               case MAPS_SERVICE_SEARCH_PLACE_LIST:
                        *supported = TRUE;
                        return MAPS_ERROR_NONE;
                default:
@@ -230,6 +231,26 @@ EXPORT_API int maps_plugin_search_place_by_address(const char* address, const ma
        return ConvertToMapsError(ret);
 }
 
+EXPORT_API int maps_plugin_search_place_list(const maps_area_h boundary, const maps_place_filter_h filter,
+       maps_preference_h preference, maps_service_search_place_list_cb callback, void* user_data, int* request_id)
+{
+       int ret = HerePluginSearchPlaceList(boundary, preference, filter, callback, user_data, request_id);
+
+       MAPS_LOGD("here_error_e = %d", ret);
+
+       return ConvertToMapsError(ret);
+}
+
+EXPORT_API int maps_plugin_get_place_details(const char* url,
+       maps_service_get_place_details_cb callback, void* user_data, int* request_id)
+{
+       int ret = HerePluginSearchPlaceDetails(url, callback, user_data, request_id);
+
+       MAPS_LOGD("here_error_e = %d", ret);
+
+       return ConvertToMapsError(ret);
+}
+
 EXPORT_API int maps_plugin_search_route(const maps_coordinates_h origin, const maps_coordinates_h destination,
        maps_preference_h preference, maps_service_search_route_cb callback,
        void* user_data, int* request_id)
index cdb2e0d..0a537a5 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 60f1fb9..07680b8 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