# Main Include file
SET(INC_DIR
- inc
+ inc
inc/engine
)
src/here_geocode.cpp
src/here_place.cpp
src/here_revgeocode.cpp
+ src/here_multirevgeocode.cpp
src/here_route.cpp
src/here_utils.cpp
)
CLEAN_DIRECT_OUTPUT 1
)
-TARGET_LINK_LIBRARIES(${pkg_name} ${pkgs_LDFLAGS})
+FIND_LIBRARY(HERE_ENGINE heremaps-engine lib/${ARCH})
+
+TARGET_LINK_LIBRARIES(${pkg_name} ${HERE_ENGINE} ${pkgs_LDFLAGS})
# Install
INSTALL(TARGETS ${pkg_name} DESTINATION ${LIBDIR}/maps/plugins)
GIOChannel* __pChannel;
GMainContext* __pGmainContext;
- int __WorkingThreadNum;
- bool __WaitingForJoin;
- pthread_cond_t __join_condition;
- pthread_mutex_t __join_mutex;
-
- class ThreadArg
- {
- public:
- int requestType;
- void* pArg;
- void* ReqInstance;
- };
-
FireArg_List FireArgs;
pthread_mutex_t FireArgsLock;
-
- static void* EventDrivenThreadHandler(void* thread_arg);
static gboolean OnEventReceived(GIOChannel* pChannel, GIOCondition condition, gpointer data);
- static gboolean __stopWaitingForJoin(gpointer data);
-
+ static void __flush(EventDrivenThread *pArg);
}; // EventDrivenThread
TIZEN_MAPS_END_NAMESPACE
TIZEN_MAPS_END_NAMESPACE
#endif /* HERE_CONFIG_H */
-
#ifndef HEREMAPS_GLOBAL_H
#define HEREMAPS_GLOBAL_H
-#ifndef TIZEN_MIGRATION // Migration for Tizen 2.4
#define TIZEN_MIGRATION
-#endif
-#ifndef TIZEN_CUSTOMIZATION
+#ifdef TIZEN_MIGRATION
+/* enhancement for updated HERE APIs */
#define TIZEN_CUSTOMIZATION
+
+/* sub-features */
+#define TIZEN_SUPPORT_POST_METHOD
+#define TIZEN_SUPPORT_CRYPTO_LOCK /* mutex locking system for SSL */
+
+/* configuration */
+#define TIZEN_CFG_CURL_TIMEOUT 20 /* seconds */
+#define TIZEN_CFG_CURL_MULTITHREADS 8 /* the limit of multi-threads for CURL */
+
+/* for debugging */
+//#define TIZEN_PROFILING_CURL_TIME
+//#define TIZEN_PROFILING_MEMLEAK
#endif
#endif
+
/*
* Note: DEBUG variable should be set from the outside.
* Currently done in CMAKE file
#endif
#define LOG_TAG "HERE_PLUGIN"
-#define MAPS_LOGD(fmt,args...) LOGD(fmt, ##args)
-#define MAPS_LOGW(fmt,args...) LOGW(fmt, ##args)
-#define MAPS_LOGI(fmt,args...) LOGI(fmt, ##args)
-#define MAPS_LOGE(fmt,args...) LOGE(fmt, ##args)
-#define MAPS_SECLOG(fmt,args...) SECURE_LOGD(fmt, ##args)
-
#define HERE_MAPS_LOG_DBG_INFO(fmt,args...) LOGD(fmt, ##args);
#define HERE_MAPS_LOG_ERROR(fmt,args...) LOGE(fmt, ##args);
#define HERE_MAPS_LOG_WARNING(fmt,args...) LOGW(fmt, ##args);
+#define HERE_MAPS_SECLOG(fmt,args...) SECURE_LOGD(fmt, ##args)
#define HERE_MAPS_RETURN_RESULT(cond,ret,fmt,args...)\
if (!cond) {\
--- /dev/null
+/*
+ * Copyright (C) 2013 HERE Global B.V. All rights reserved.
+ * This software, including documentation, is protected by copyright controlled by
+ * HERE Global B.V. (“Software”). All rights are reserved. Copying, including reproducing,
+ * storing, adapting or translating, any or all of this material requires the prior
+ * written consent of HERE Global B.V. You may use this
+ * Software in accordance with the terms and conditions defined in the
+ * HERE Location Platform Services Terms and Conditions, available at
+ * http://developer.here.com/terms-conditions-base
+ *
+ * As an additional permission to the above, you may distribute Software,
+ * in object code format as part of an Application, according to, and subject to, terms and
+ * conditions defined in the Tizen Software Development kit (“SDK”) License Agreement.
+ * You may distribute such object code format Application under terms of your choice,
+ * provided that the header and source files of the Software have not been modified.
+ */
+
+#ifndef MULTIREVERSEQUERY_H
+#define MULTIREVERSEQUERY_H
+
+#include "common/HereMaps_global.h"
+#include "common/GeoCoordinates.h"
+
+#include "geocoder/GeoCoderQueryBase.h"
+
+HERE_MAPS_BEGIN_NAMESPACE
+
+class MultiReverseReply;
+class GeoCoordinates;
+class MultiReverseQueryListener;
+
+/**
+ * This class represents a reverse geocoding query.
+ *
+ * Instances of the class are used to obtain an address (or a set of addresses)
+ * corresponding to a set of geographic coordinates.
+ *
+ * @ingroup geocoding
+ */
+class EXPORT_API MultiReverseQuery : public GeoCoderQueryBase
+{
+public:
+ /**
+ * This enumeration defines identifiers for reverse geocoding modes. A mode
+ * indicates whether addresses are to be returned or
+ * administrative area names (such as city, county, state, country).
+ */
+ enum ReverseMode
+ {
+ RM_RetrieveAreas, ///< Indicates that administrative area names are to be retrieved.
+ RM_RetrieveAddresses ///< Indicates that addresses are to be retrieved.
+ };
+
+ /**
+ * This method is the default constructor.
+ */
+ MultiReverseQuery();
+
+ /**
+ * This method is a constructor that initializes the query with the location
+ * to reverse-geocode and the mode.
+ *
+ * @param rCoordinate A constant reference to an object containing the geographic
+ * coordinates of the location to reverse-geocode.
+ *
+ * @param aMode A value indicating the reverse geocoding mode to use.
+ */
+ MultiReverseQuery(const GeoCoordinates& rCoordinate, ReverseMode aMode);
+
+ /**
+ * This method is a constructor that initializes the query with the location
+ * to reverse-geocode, the mode and the radius within which to conduct the
+ * search.
+ *
+ * @param rCoordinate A constant reference to an object containing the geographic
+ * coordinates of the location to reverse-geocode.
+ *
+ * @param aMode A value indicating the reverse geocoding mode to use.
+ *
+ * @param fRadius A float value indicating the radius (in meters) within
+ * which to search.
+ */
+ MultiReverseQuery(const GeoCoordinates& rCoordinate, ReverseMode aMode, float fRadius);
+
+ /**
+ * This method is the (virtual) destructor.
+ */
+ virtual ~MultiReverseQuery();
+
+ /**
+ * This method sets the properties defining a circular area within which a
+ * search is to be conducted. The area is defined in terms of its center and
+ * radius.
+ *
+ * @param rCoord A constant reference to an object containing the latitude
+ * and longitude of the center of the proximity area (search center).
+ *
+ * @param rRadius A value specifying the radius of the search area in meters.
+ */
+ void SetProximity(const GeoCoordinates& rCoord, float fRadius = 0);
+
+ /**
+ * This method detects whether coordinates/proximity (the center of search area
+ * set or not).
+ *
+ * @return <code>true</code> if the proximity was set,
+ * otherwise <code>false</code>
+ */
+ bool HasProximity() const;
+
+ /**
+ * This method sets the reverse geocoding mode to apply to the query.
+ *
+ * @param aMode A value indicating the reverse geocoding mode to use.
+ */
+ void SetMode(ReverseMode aMode);
+
+ void SetGeocodeList(const GeoCoordinateList& rGeocodeList);
+ /**
+ * This method attempts to establish a connection
+ * with the server and then, if the connection has been established, it
+ * builds and submits a query.
+ *
+ * @param rListener A shared pointer to an object that is to be notified when
+ * the reply to the query has arrived from the server.
+ *
+ * @param pUserData A pointer to user data to be echoed in the reply object.
+ *
+ * @return A value representing the identifier of the issued request.
+ */
+ RestItemHandle::RequestId Execute(MultiReverseQueryListener& rListener, Tizen::Maps::HereObject* pUserData = NULL) const;
+
+ /**
+ * This method returns the base URI to be used for all subsequent
+ * reverse geocoder queries.
+ *
+ * @return A string containing the base URI.
+ */
+ String GetBaseUri() const;
+
+ /**
+ * This method returns the base URI to be used for all subsequent
+ * reverse geocoder queries.
+ *
+ * @param sUri A constant reference to a string containing the base URI.
+ */
+ void SetBaseUri(const String& sUri);
+
+private:
+ /**
+ * This method creates the URI for the request.
+ *
+ * @return URI request string.
+ */
+ String CreateUri() const;
+
+#ifdef TIZEN_MIGRATION_TO_SUPPORT_POST_METHOD
+ /**
+ * This method creates the URI for the request.
+ *
+ * @return URI request string.
+ */
+ String CreatePostData() const;
+#endif
+
+private:
+ HERE_MAPS_NO_COPY_NO_ASSIGN(MultiReverseQuery);
+
+ class MultiReverseQueryImpl;
+ MultiReverseQueryImpl* m_pImpl;
+};
+
+HERE_MAPS_END_NAMESPACE
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 2013 HERE Global B.V. All rights reserved.
+ * This software, including documentation, is protected by copyright controlled by
+ * HERE Global B.V. (“Software”). All rights are reserved. Copying, including reproducing,
+ * storing, adapting or translating, any or all of this material requires the prior
+ * written consent of HERE Global B.V. You may use this
+ * Software in accordance with the terms and conditions defined in the
+ * HERE Location Platform Services Terms and Conditions, available at
+ * http://developer.here.com/terms-conditions-base
+ *
+ * As an additional permission to the above, you may distribute Software,
+ * in object code format as part of an Application, according to, and subject to, terms and
+ * conditions defined in the Tizen Software Development kit (“SDK”) License Agreement.
+ * You may distribute such object code format Application under terms of your choice,
+ * provided that the header and source files of the Software have not been modified.
+ */
+
+#ifndef MULTIREVERSEQUERYLISTENER_H
+#define MULTIREVERSEQUERYLISTENER_H
+
+#include "common/HereMaps_global.h"
+
+#include "common/QueryListener.h"
+
+HERE_MAPS_BEGIN_NAMESPACE
+
+class MultiReverseReply;
+
+/**
+ * This class encapsulates a listener facility that is informed when the results
+ * of a query become available.
+ *
+ * The class exposes a callback method that must be implemented by the derived
+ * classes to process the data received from the server.
+ *
+ * @ingroup geocoding
+ */
+class EXPORT_API MultiReverseQueryListener : public QueryListener
+{
+public:
+ /**
+ * This method is the default constructor.
+ */
+ MultiReverseQueryListener();
+
+ /**
+ * This method is the destructor.
+ */
+ ~MultiReverseQueryListener();
+
+ /**
+ * This method is a callback invoked when data have arrived in response to a
+ * geocoding request.
+ *
+ * @param rReply A Constant reference to an object containing the response data.
+ */
+ virtual void OnMultiReverseReply(const MultiReverseReply& rReply) = 0;
+
+ #ifdef TIZEN_MIGRATION
+ /**
+ * This method is a callback invoked when geocoding request is failed.
+ *
+ * @param rReply A Constant reference to an object containing the response data.
+ */
+ virtual void OnMultiReverseFailure(const MultiReverseReply& rReply) = 0;
+ #endif
+
+private:
+
+ void OnReplySuccess(BaseReply& rReply);
+
+ #ifdef TIZEN_MIGRATION
+ void OnFailure(const BaseReply& rReply);
+ #endif
+
+};
+
+HERE_MAPS_END_NAMESPACE
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 2013 HERE Global B.V. All rights reserved.
+ * This software, including documentation, is protected by copyright controlled by
+ * HERE Global B.V. (“Software”). All rights are reserved. Copying, including reproducing,
+ * storing, adapting or translating, any or all of this material requires the prior
+ * written consent of HERE Global B.V. You may use this
+ * Software in accordance with the terms and conditions defined in the
+ * HERE Location Platform Services Terms and Conditions, available at
+ * http://developer.here.com/terms-conditions-base
+ *
+ * As an additional permission to the above, you may distribute Software,
+ * in object code format as part of an Application, according to, and subject to, terms and
+ * conditions defined in the Tizen Software Development kit (“SDK”) License Agreement.
+ * You may distribute such object code format Application under terms of your choice,
+ * provided that the header and source files of the Software have not been modified.
+ */
+
+#ifndef MULTIREVERSEREPLY_H_
+#define MULTIREVERSEREPLY_H_
+
+#include "common/HereMaps_global.h"
+#include "common/BaseReply.h"
+
+HERE_MAPS_BEGIN_NAMESPACE
+
+class Result;
+class MetaInfo;
+
+
+/**
+ * This class encapsulates a reply to a geocoding query.
+ *
+ * The class receives the response data returned by the server in reply to a
+ * query asynchronously. Notification that the data is available comes via a
+ * listener object registered on the class by calling <code>AddListener()</code>.
+ *
+ * @ingroup geocoding
+ */
+class EXPORT_API MultiReverseReply : public BaseReply
+{
+public:
+
+ /**
+ * This is the default constructor.
+ */
+ MultiReverseReply();
+
+ /**
+ * This is a destructor.
+ */
+ virtual ~MultiReverseReply();
+
+ /**
+ * This method retrieves a value indicating the number of results in the
+ * reply to the query.
+ *
+ * @return An integer value indicating the number of results.
+ */
+ size_t GetNumResults() const;
+
+ /**
+ * This method retrieves a result at the index specified by the caller.
+ *
+ * @param A value indicating the index of the result to retrieve.
+ *
+ * @return A constant pointer to an instance of <code>Result</code>.
+ */
+ const Result* GetResult(size_t idx) const;
+
+ /**
+ * This method retrieves the reply meta information.
+ *
+ * @return A constant pointer to an instance of <code>MetaInfo</code>.
+ */
+ const MetaInfo* GetMetaInfo() const;
+
+private:
+ HERE_MAPS_NO_COPY_NO_ASSIGN(MultiReverseReply);
+ friend class TestGeoCoderParser;
+
+ virtual bool OnDataReceived(const unsigned char* pBuffer, size_t uSize);
+
+ class MultiReverseReplyImpl;
+ MultiReverseReplyImpl* m_pImpl;
+};
+
+HERE_MAPS_END_NAMESPACE
+
+#endif /* MULTIREVERSEREPLY_H_ */
#include "base/BaseByteBuffer.h"
#include "base/EventDrivenThread.h"
-#define RESTCURL_CRYPTO_LOCK
-
TIZEN_MAPS_BEGIN_NAMESPACE
using namespace Tizen::Maps;
typedef struct MemoryStruct {
+ MemoryStruct() : memory(NULL), size(0), http_code(0), error(0) {};
+
char *memory;
size_t size;
long http_code;
+ int error;
} MemoryStruct_s;
class RestCurl
public:
RestCurl();
virtual ~RestCurl();
+
+ static RestCurl& GetInstance();
bool Commit(void *pArgs);
+ void Abort(const Here::Maps::RestItemHandle::RequestId aRequestId);
void Clear();
+ void Join();
void Shutdown();
- void Abort(const Here::Maps::RestItemHandle::RequestId aRequestId);
- int EasyCurl(String sUrl, MemoryStruct_s* pChunk);
- String UrlEncode(String sStr);
- static RestCurl& GetInstance();
-
private:
- static size_t WriteMemoryCallback(void *contents, size_t size, size_t nmemb, void *userp);
+ int EasyCurl(String sUrl, MemoryStruct_s* pChunk
+ #ifdef TIZEN_SUPPORT_POST_METHOD
+ , bool bPost = false, String sPostData = ""
+ #endif
+ );
static void *ThreadFunc(void *pArgs);
+ static size_t WriteMemoryCb(void *pContents, size_t nSize, size_t nNmemb, void *pUser);
+ static int XferInfoCb(void *pUser, curl_off_t dlTotal, curl_off_t dlNow,
+ curl_off_t ulTotal, curl_off_t ulNow);
+ String UrlEncode(String sStr);
+ bool CreateDetachedThread(void* (*pFunc)(void*), void *pArgs);
+
+ #ifdef TIZEN_SUPPORT_CRYPTO_LOCK
+ static void CRYPTO_MutexLock(int mode, int type, char *file, int line);
+ static void CRYPTO_InitMutexLocks(void);
+ static void CRYPTO_KillMutexLocks(void);
+ static unsigned long CRYPTO_ThreadId(void);
+ #endif
class RestCurlImpl;
RestCurlImpl* m_pImpl;
: public Tizen::Maps::Object
{
public:
+#ifdef TIZEN_SUPPORT_POST_METHOD
+ RestEngineArgument(const String& sUrl, RestItem* pRestItem,
+ bool bPost = false, const String& sPostData = "")
+ : m_sUrl(sUrl)
+ , m_pRestItem(pRestItem)
+ , m_bPost(bPost)
+ , m_sPostData(sPostData)
+#else
RestEngineArgument(const String& sUrl, RestItem* pRestItem)
: m_sUrl(sUrl)
, m_pRestItem(pRestItem)
+#endif
{
}
String m_sUrl;
RestItem* m_pRestItem;
RestItemHandle::RequestId m_aRequestId;
- #ifdef TIZEN_MIGRATION
+#ifdef TIZEN_MIGRATION
Tizen::Maps::MemoryStruct_s m_Chunk;
- #endif
+#endif
+#ifdef TIZEN_SUPPORT_POST_METHOD
+ bool m_bPost;
+ String m_sPostData;
+#endif
};
//this is an internal class and should not be used outside
public:
static RestEngine& GetInstance();
+#ifdef TIZEN_SUPPORT_POST_METHOD
+ RestItemHandle::RequestId OpenRequest(const String& sUrl, QueryListener* pListener, BaseReplyPtr pReply,
+ bool bPost = false, const String& sPostData = "");
+#else
RestItemHandle::RequestId OpenRequest(const String& sUrl, QueryListener* pListener, BaseReplyPtr pReply);
+#endif
size_t GetNumPendingRequests() const;
void ShutdownEngine();
void AbortRequest(RestItemHandle::RequestId aRequestId);
RT_CloseRestItem,
RT_DeleteRestItem
};
+
bool CheckRequestIn(RestItem* pRestItem);
RestItem* GetChechedInRequest(RestItemHandle::RequestId aRequestId) const;
void RegisterListener(QueryListener* rListener);
+#ifdef TIZEN_SUPPORT_POST_METHOD
+ bool DoOpenRequest(const String& sUrl, RestItem* pRestItem,
+ bool bPost = false, const String& sPostData = "");
+#else
bool DoOpenRequest(const String& sUrl, RestItem* pRestItem);
+#endif
void DoCloseRestItemLater(RestItemHandle::RequestId aRequestId);
void DoDeleteRestItemLater(RestItem* pRestItem);
RestItem(QueryListener* rListener, BaseReplyPtr pBaseReply);
~RestItem();
+#ifdef TIZEN_SUPPORT_POST_METHOD
+ bool Run(const String& rUri, bool bPost = false, const String& rPostData = "");
+#else
bool Run(const String& rUri);
+#endif
void Stop();
void OnError(ErrorBase& rError);
maps_item_hashtable_h hPref, maps_service_reverse_geocode_cb pCbFunc,
void *pUserData, int *nReqId);
+int HerePluginMultiReverseGeocode(const maps_coordinates_list_h hGeocodeList,
+ maps_item_hashtable_h hPref, maps_service_multi_reverse_geocode_cb pCbFunc,
+ void *pUserData, int *nReqId);
+
int HerePluginSearchPlace(maps_coordinates_h hPos, int nDistance,
maps_item_hashtable_h hPref, maps_place_filter_h hFilter, maps_service_search_place_cb pCbFunc,
void * pUserData, int *nReqId);
HERE_SVC_GEOCODE,
HERE_SVC_REV_GEOCODE,
HERE_SVC_PLACE,
- HERE_SVC_ROUTE
+ HERE_SVC_ROUTE,
+ HERE_SVC_MULTI_REV_GEOCODE
};
void* CreateInstance(HereSvcType nHereSvc, void* pCbFunc, void* pUserData, int *nReqId);
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _LOCATION_HERE_MULTI_REV_GEOCODER_H_
+#define _LOCATION_HERE_MULTI_REV_GEOCODER_H_
+
+//plug-in header
+#include "here_manager.h"
+
+#include <maps_coordinates.h>
+
+//map engine header
+#include <geocoder/MultiReverseQuery.h>
+#include <geocoder/MultiReverseReply.h>
+#include <geocoder/MultiReverseQueryListener.h>
+#include <geocoder/Result.h>
+#include <common/GeoLocation.h>
+#include <common/Address.h>
+
+HERE_PLUGIN_BEGIN_NAMESPACE
+
+using namespace HERE_MAPS_NAMESPACE_PREFIX;
+
+class HereMultiRevGeocode
+: public HereBase
+, public MultiReverseQueryListener
+{
+public:
+ /**
+ *This is the default constructor for reverse Geocoder.
+ */
+
+ HereMultiRevGeocode(void *pCbFunc, void *pUserData, int nReqId);
+
+ /**
+ *This is the default destructor for reverse Geocoder.
+ */
+
+ ~HereMultiRevGeocode();
+
+
+ here_error_e PrepareQuery();
+ here_error_e PreparePositionList(const maps_coordinates_list_h hGeocodeList);
+ here_error_e StartMultiReverse(maps_item_hashtable_h hPref);
+
+ virtual void OnMultiReverseReply(const MultiReverseReply& Reply);
+ virtual void OnMultiReverseFailure(const MultiReverseReply& Reply);
+
+private:
+ MultiReverseQuery* m_pQuery;
+ GeoCoordinates m_geoCoord;
+};
+
+HERE_PLUGIN_END_NAMESPACE
+
+#endif //_LOCATION_HERE_MULTI_REV_GEOCODER_H_
void ProcessPlaceRated(PlaceDetails herePlace, maps_place_h mapsPlace);
void __sortList(PlaceList &list);
+ void __flushReplies(int error);
static bool __compareWithTitle(const maps_place_h &item1, const maps_place_h &item2);
static bool __compareWithId(const maps_place_h &item1, const maps_place_h &item2);
static bool __compareWithType(const maps_place_h &item1, const maps_place_h &item2);
int m_nReplyCnt;
int m_nReplyIdx;
char *m_szSortBy;
+ bool m_bPlaceDetailsInternal;
PlaceList m_PlaceList;
//plug-in header
#include "here_manager.h"
-#include <maps_extra_types.h>
#include <maps_coordinates.h>
//map engine header
#include <vector>
//maps-service header
-#include <maps_extra_types.h>
-#include <maps_plugin_types.h>
#include <maps_area.h>
#include <maps_preference.h>
#include <maps_route_maneuver.h>
-libheremaps-engine.so.1.0.6_7
\ No newline at end of file
+libheremaps-engine.so.1.0.6_8
\ No newline at end of file
-libheremaps-engine.so.1.0.6_7
\ No newline at end of file
+libheremaps-engine.so.1.0.6_8
\ No newline at end of file
-libheremaps-engine.so.1.0.6_7
\ No newline at end of file
+libheremaps-engine.so.1.0.6_8
\ No newline at end of file
-libheremaps-engine.so.1.0.6_7
\ No newline at end of file
+libheremaps-engine.so.1.0.6_8
\ No newline at end of file
+[Version] maps-plugin-here_0.1.7
+[Date] 19 Nov 2015
+[Title] Support multi reverse geocode
+[Developer] Kyoungjun Sung <kj7.sung@samsung.com>
+
+[Version] maps-plugin-here_0.1.6
+[Date] 10 Nov 2015
+[Title] Fixed to manage dropped requests of PlaceDetails
+[Developer] Seechan Kim <cbible.kim@samsung.com>
+
[Version] maps-plugin-here_0.1.5
[Date] 06 Oct 2015
[Title] Fixed to return more proper error codes
Name: maps-plugin-here
Summary: Tizen HERE Maps Plug-in Library
-Version: 0.1.6
+Version: 0.1.7
Release: 1
Group: Location/Libraries
License: Apache-2.0 and HERE
%endif
MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
-cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DMAJORVER=${MAJORVER} -DFULLVER=%{version} -DLIBDIR=%{_libdir} -DARCH=%{ARCH}
+cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DMAJORVER=${MAJORVER} -DFULLVER=%{version} -DLIBDIR=lib -DARCH=%{ARCH}
make %{?jobs:-j%jobs}
%install
%files
%manifest maps-plugin-here.manifest
%defattr(-,root,root,-)
-%{_libdir}/maps/plugins/libmaps-plugin-here.so*
+%{_prefix}/lib/maps/plugins/libmaps-plugin-here.so*
%{_prefix}/lib/libheremaps-engine.so*
/usr/share/license/maps-plugin-here
#include "here_types.h"
#include "here_geocode.h"
#include "here_revgeocode.h"
+#include "here_multirevgeocode.h"
#include "here_place.h"
#include "here_route.h"
#include <common/HereConfig.h>
return error;
}
+int HerePluginMultiReverseGeocode(const maps_coordinates_list_h hGeocodeList,
+ maps_item_hashtable_h hPref, maps_service_multi_reverse_geocode_cb pCbFunc,
+ void *pUserData, int *nReqId)
+{
+ /* checking parmaters */
+ if (!hGeocodeList || !pCbFunc || !nReqId)
+ return HERE_ERROR_INVALID_PARAMETER;
+
+ if (!HereManager::GetHandler())
+ return HERE_ERROR_INVALID_OPERATION;
+
+ /* creating instance */
+ HereMultiRevGeocode *pMultiRevGeocode =
+ (HereMultiRevGeocode*)(HereManager::GetHandler()->CreateInstance(HereManager::HERE_SVC_MULTI_REV_GEOCODE,
+ (void*)pCbFunc, pUserData, nReqId));
+
+ if(!pMultiRevGeocode)
+ return HERE_ERROR_SERVICE_NOT_AVAILABLE;
+
+ /* sending request */
+ here_error_e error = HERE_ERROR_UNKNOWN;
+
+ do {
+ error = pMultiRevGeocode->PrepareQuery();
+ if (error != HERE_ERROR_NONE) break;
+
+ error = pMultiRevGeocode->PreparePositionList(hGeocodeList);
+ if (error != HERE_ERROR_NONE) break;
+
+ error = pMultiRevGeocode->StartMultiReverse(hPref);
+ } while(0);
+
+ /* finishing task */
+ if(error != HERE_ERROR_NONE)
+ pMultiRevGeocode->TerminateService();
+
+ return error;
+}
+
int HerePluginSearchPlace(maps_coordinates_h hPos, int nDistance,
maps_item_hashtable_h hPref, maps_place_filter_h hFilter, maps_service_search_place_cb pCbFunc,
void *pUserData, int *nReqId)
* limitations under the License.
*/
-#include <sys/types.h>
#include <unistd.h>
#include <libxml/xpath.h>
#include "here_base.h"
#include "here_geocode.h"
#include "here_revgeocode.h"
+#include "here_multirevgeocode.h"
#include "here_place.h"
#include "here_route.h"
#include "here_utils.h"
void HereManager::Close()
{
pthread_mutex_lock(&g_mtxRef);
- if (--m_nRefCnt == 0 && m_pHereManager)
+ bool terminate = (--m_nRefCnt == 0 && m_pHereManager);
+ pthread_mutex_unlock(&g_mtxRef);
+
+ if (terminate)
{
m_pHereManager->TerminateAllServices();
HereConfig::Shutdown();
m_pHereManager = NULL;
}
MAPS_LOGD("Closed a HereManager instance (%d).", m_nRefCnt);
- pthread_mutex_unlock(&g_mtxRef);
}
HereManager* HereManager::GetHandler()
pHere = (HereBase*)new HereRoute(pCbFunc, pUserData, *nReqId);
break;
+ case HERE_SVC_MULTI_REV_GEOCODE:
+ pHere = (HereBase*)new HereMultiRevGeocode(pCbFunc, pUserData, *nReqId);
+ break;
+
default:
return NULL;
}
}
}
pthread_mutex_unlock(&m_mtxHereList);
-
+
return HERE_ERROR_NONE;
}
m_HereList.erase(it);
}
catch (std::exception &e) {
+ MAPS_LOGD("Exception caught: %s", e.what());
}
};
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "here_multirevgeocode.h"
+
+HERE_PLUGIN_BEGIN_NAMESPACE
+
+HereMultiRevGeocode::HereMultiRevGeocode(void* pCbFunc, void* pUserData, int nReqId)
+: m_geoCoord(0,0,0)
+{
+ m_pQuery = NULL;
+ m_pCbFunc = pCbFunc;
+ m_pUserData = pUserData;
+ m_nReqId = nReqId;
+}
+
+HereMultiRevGeocode::~HereMultiRevGeocode()
+{
+ if (m_pQuery)
+ {
+ delete m_pQuery;
+ m_pQuery = NULL;
+ }
+}
+
+here_error_e HereMultiRevGeocode::PrepareQuery()
+{
+ if (m_pQuery)
+ return HERE_ERROR_PERMISSION_DENIED;
+
+ m_pQuery = new MultiReverseQuery();
+
+ if (!m_pQuery)
+ return HERE_ERROR_OUT_OF_MEMORY;
+ else
+ return HERE_ERROR_NONE;
+}
+
+static bool geocoder_coordinates_cb(int index, maps_coordinates_h coordinates, void *user_data)
+{
+ double dLatitude = 0.0;
+ double dLongitude = 0.0;
+ GeoCoordinates hereCoord;
+ maps_coordinates_get_latitude(coordinates, &dLatitude);
+ maps_coordinates_get_longitude(coordinates, &dLongitude);
+ hereCoord = GeoCoordinates(dLatitude, dLongitude);
+
+ if (!HereUtils::IsValid(hereCoord))
+ return HERE_ERROR_INVALID_PARAMETER;
+
+ GeoCoordinateList *pList =(GeoCoordinateList *) user_data;
+ pList->push_back(hereCoord);
+
+ return true;
+}
+
+here_error_e HereMultiRevGeocode::PreparePositionList(const maps_coordinates_list_h hGeocodeList)
+{
+ if (!m_pQuery)
+ return HERE_ERROR_OUT_OF_MEMORY;
+
+ if (!hGeocodeList)
+ return HERE_ERROR_INVALID_PARAMETER;
+
+ GeoCoordinateList hereCoordList;
+ maps_coordinates_list_foreach(hGeocodeList, geocoder_coordinates_cb, &hereCoordList);
+
+ m_pQuery->SetMode(MultiReverseQuery::RM_RetrieveAddresses);
+ m_pQuery->SetGeocodeList(hereCoordList);
+ m_pQuery->SetMaxResults(1);
+ m_pQuery->SetGenParameter(8);
+
+ return HERE_ERROR_NONE;
+}
+
+here_error_e HereMultiRevGeocode::StartMultiReverse(maps_item_hashtable_h hPref)
+{
+ if (!m_pQuery)
+ return HERE_ERROR_OUT_OF_MEMORY;
+
+ m_nRestReqId = m_pQuery->Execute(*this, NULL);
+
+ return (m_nRestReqId > 0 ? HERE_ERROR_NONE : HERE_ERROR_CANCELED);
+}
+
+void HereMultiRevGeocode::OnMultiReverseReply(const MultiReverseReply& Reply)
+{
+ if (m_bCanceled) // ignore call back if it was cancelled.
+ {
+ delete this;
+ return;
+ }
+
+ int nResults = Reply.GetNumResults();
+ Result* pResult;
+
+ maps_address_list_h address_list;
+ maps_address_list_create(&address_list);
+ maps_address_h pAddr = NULL;
+
+ for (size_t i = 0; i < (size_t)nResults; i++)
+ {
+ maps_error_e error = (maps_error_e)maps_address_create(&pAddr);
+
+ if(error == MAPS_ERROR_NONE)
+ {
+ pResult = (Result*)Reply.GetResult(i);
+
+ if (pResult)
+ {
+ Address tmpAddr = (pResult->GetLocation()).GetAddress();
+
+ if(!tmpAddr.GetHouseNumber().empty())
+ maps_address_set_building_number(pAddr, tmpAddr.GetHouseNumber().c_str());
+
+ if(!tmpAddr.GetStreet().empty())
+ maps_address_set_street(pAddr, tmpAddr.GetStreet().c_str());
+
+ if(!tmpAddr.GetDistrict().empty())
+ maps_address_set_district(pAddr, tmpAddr.GetDistrict().c_str());
+
+ if(!tmpAddr.GetCity().empty())
+ maps_address_set_city(pAddr, tmpAddr.GetCity().c_str());
+
+ if(!tmpAddr.GetCounty().empty())
+ maps_address_set_county(pAddr, tmpAddr.GetCounty().c_str());
+
+ if(!tmpAddr.GetState().empty())
+ maps_address_set_state(pAddr, tmpAddr.GetState().c_str());
+
+ if(!tmpAddr.GetCountry().empty())
+ maps_address_set_country(pAddr, tmpAddr.GetCountry().c_str());
+
+ if(!tmpAddr.GetCountryCode().empty())
+ maps_address_set_country_code(pAddr, tmpAddr.GetCountryCode().c_str());
+
+ if(!tmpAddr.GetPostalCode().empty())
+ maps_address_set_postal_code(pAddr, tmpAddr.GetPostalCode().c_str());
+
+ if(!tmpAddr.GetLabel().empty())
+ maps_address_set_freetext(pAddr, tmpAddr.GetLabel().c_str());
+ }
+ }
+ maps_address_list_append(address_list, pAddr);
+ }
+
+ if (m_bCanceled)
+ {
+ maps_address_list_destroy(address_list);
+ }
+ else
+ {
+ ((maps_service_multi_reverse_geocode_cb)m_pCbFunc)(MAPS_ERROR_NONE, m_nReqId, nResults, address_list, m_pUserData);
+ }
+
+ delete this;
+}
+
+void HereMultiRevGeocode::OnMultiReverseFailure(const MultiReverseReply& Reply)
+{
+ if (!m_bCanceled)
+ ((maps_service_multi_reverse_geocode_cb)m_pCbFunc)((maps_error_e)GetErrorCode(Reply), m_nReqId, 0, NULL, m_pUserData);
+ delete this;
+}
+
+HERE_PLUGIN_END_NAMESPACE
+
m_nReplyCnt = 0;
m_nReplyIdx = 0;
m_szSortBy = NULL;
+ m_bPlaceDetailsInternal = false;
}
HerePlace::~HerePlace()
std::unique_ptr<PlaceDetailsQuery> pPlaceDetailsQuery (new (std::nothrow)PlaceDetailsQuery());
-
bool bExcuted = (int)(pPlaceDetailsQuery->Execute(*this, NULL, szUrl) > 0);
return (bExcuted ? HERE_ERROR_NONE : HERE_ERROR_INVALID_OPERATION);
hereLinkObj = herePlaceIt->GetLinkObject();
if (!hereLinkObj.GetHref().empty() && !hereLinkObj.GetId().empty())
{
- m_PlaceList.push_back(mapsPlace);
- isPending = true;
- StartPlaceDetailsInternal(hereLinkObj.GetHref().c_str());
- MAPS_LOGD("Add maps_place_h to the pending list. id=%s", hereLinkObj.GetId().data());
+ if (StartPlaceDetailsInternal(hereLinkObj.GetHref().c_str()) == HERE_ERROR_NONE)
+ {
+ m_PlaceList.push_back(mapsPlace);
+ isPending = true;
+ m_bPlaceDetailsInternal = true;
+ MAPS_LOGD("Add maps_place_h to the pending list. id=%s", hereLinkObj.GetId().data());
+ }
}
}
}
if (m_nReplyIdx == m_nReplyCnt)
{
- m_nReplyIdx = 0;
- __sortList(m_PlaceList);
-
- while (m_nReplyIdx < m_nReplyCnt && !m_bCanceled && !m_PlaceList.empty())
- {
- 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;
- }
- }
+ __flushReplies(error);
delete this;
}
}
void HerePlace::OnDiscoverFailure(const DiscoveryReply& Reply)
{
- if (!m_bCanceled)
- ((maps_service_search_place_cb)m_pCbFunc)((maps_error_e)GetErrorCode(Reply), m_nReqId, 0, 1, NULL, m_pUserData);
- delete this;
+ if (++m_nReplyIdx == m_nReplyCnt)
+ {
+ __flushReplies((maps_error_e)GetErrorCode(Reply));
+ delete this;
+ }
}
void HerePlace::OnPlaceDetailsReply (const PlaceDetailsReply &Reply)
if (!isPending)
m_PlaceList.push_back(mapsPlace);
- m_nReplyIdx++;
-
- if (m_nReplyIdx == m_nReplyCnt)
+ if (++m_nReplyIdx == m_nReplyCnt)
{
- m_nReplyIdx = 0;
- __sortList(m_PlaceList);
-
- while (m_nReplyIdx < m_nReplyCnt && !m_bCanceled && !m_PlaceList.empty())
- {
- 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;
- }
- }
+ __flushReplies(error);
delete this;
}
}
void HerePlace::OnPlaceDetailsFailure(const PlaceDetailsReply& Reply)
{
- if (!m_bCanceled)
- ((maps_service_search_place_cb)m_pCbFunc)((maps_error_e)GetErrorCode(Reply), m_nReqId, 0, 1, NULL, m_pUserData);
- delete this;
+ if (++m_nReplyIdx == m_nReplyCnt)
+ {
+ __flushReplies(m_bPlaceDetailsInternal ? MAPS_ERROR_NONE : GetErrorCode(Reply));
+ delete this;
+ }
}
void HerePlace::ProcessPlaceLocation(PlaceDetails herePlace, maps_place_h mapsPlace)
maps_place_link_object_destroy(mapsRelated);
}
+void HerePlace::__flushReplies(int error)
+{
+ maps_place_h mapsPlace;
+
+ m_nReplyIdx = 0;
+ __sortList(m_PlaceList);
+
+ while (m_nReplyIdx < m_nReplyCnt && !m_bCanceled && !m_PlaceList.empty())
+ {
+ 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;
+ }
+ }
+}
+
bool HerePlace::__compareWithTitle(const maps_place_h &item1, const maps_place_h &item2)
{
bool result = false;
case MAPS_SERVICE_SEARCH_ROUTE:
case MAPS_SERVICE_SEARCH_ROUTE_WAYPOINTS:
case MAPS_SERVICE_CANCEL_REQUEST:
+ case MAPS_SERVICE_MULTI_REVERSE_GEOCODE:
*supported = TRUE;
return MAPS_ERROR_NONE;
default:
return ConvertToMapsError(ret);
}
+EXPORT_API int maps_plugin_multi_reverse_geocode(const maps_coordinates_list_h geocode_list,
+ const maps_preference_h preference, maps_service_multi_reverse_geocode_cb callback,
+ void *user_data, int *request_id)
+{
+ if (!callback || !request_id)
+ return MAPS_ERROR_INVALID_PARAMETER;
+
+ int ret = HerePluginMultiReverseGeocode(geocode_list, preference, callback, user_data, request_id);
+
+ MAPS_LOGD("here_error_e = %d", ret);
+
+ return ConvertToMapsError(ret);
+}
+
EXPORT_API int maps_plugin_search_place(const maps_coordinates_h position, int distance,
const maps_place_filter_h filter, maps_preference_h preference, maps_service_search_place_cb callback,
void* user_data, int* request_id)