From: chanywa Date: Wed, 8 Jun 2016 06:47:11 +0000 (+0900) Subject: Tizen C++ Coding Rules X-Git-Tag: accepted/tizen/common/20160614.144241~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F42%2F73442%2F1;p=platform%2Fcore%2Flocation%2Fmaps-plugin-here.git Tizen C++ Coding Rules Change-Id: I271e2460ec6fa8ff3af08a4101186dad1922c6fd --- diff --git a/CMakeLists.txt b/CMakeLists.txt index ff858d8..b5b0751 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ SET(PREFIX ${CMAKE_INSTALL_PREFIX}) SET(LIBDIR ${LIBDIR}) # Dependencies -SET(dependents +SET(dependents glib-2.0 gmodule-2.0 libxml-2.0 diff --git a/heremaps-uc/src/heremaps-uc-common.h b/heremaps-uc/src/heremaps-uc-common.h index edf0e89..82349a2 100644 --- a/heremaps-uc/src/heremaps-uc-common.h +++ b/heremaps-uc/src/heremaps-uc-common.h @@ -37,7 +37,6 @@ extern "C" { #include #endif #include -#include #include #include #include diff --git a/inc/here_api.h b/inc/here_api.h index 3d6440a..7ad11ef 100755 --- a/inc/here_api.h +++ b/inc/here_api.h @@ -95,8 +95,6 @@ int HerePluginSetScalebar(maps_view_h hView, bool enable); int HerePluginGetScalebar(maps_view_h hView, bool *enabled); -int HerePluginDrawMap(maps_view_h hView, Evas* pCanvas, int x, int y, int w, int h); - int HerePluginGetCenter(maps_view_h hView, maps_coordinates_h *center); int HerePluginScreenToGeography(maps_view_h hView, int x, int y, maps_coordinates_h *mapsCoord); diff --git a/inc/here_utils.h b/inc/here_utils.h index d9e8b35..d016639 100644 --- a/inc/here_utils.h +++ b/inc/here_utils.h @@ -57,11 +57,11 @@ /* * Internal Macros */ -#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 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 MAPS_CHECK_CONDITION(condition, error, msg) \ do { \ @@ -81,7 +81,7 @@ } while (0) #define MAPS_NULL_ARG_CHECK(arg) \ - MAPS_CHECK_CONDITION(arg != NULL,MAPS_ERROR_INVALID_PARAMETER,"MAPS_ERROR_INVALID_PARAMETER") + MAPS_CHECK_CONDITION(arg != NULL, MAPS_ERROR_INVALID_PARAMETER, "MAPS_ERROR_INVALID_PARAMETER") #define MAPS_PRINT_ERROR_CODE_RETURN(code) \ do{ \ diff --git a/inc/here_view.h b/inc/here_view.h index 587fa1c..1bc024a 100644 --- a/inc/here_view.h +++ b/inc/here_view.h @@ -49,32 +49,30 @@ public: HereView(); ~HereView(); - here_error_e Init(maps_view_h hView, maps_plugin_map_view_ready_cb pCbFunc); - here_error_e Close(maps_view_h hView); - here_error_e RenderMap(maps_view_h hView, const maps_coordinates_h mapsCoord, double dZoom, double dAngle); - here_error_e RenderMapByArea(maps_view_h hView, const maps_area_h hArea, double dZoom, double dAngle); - here_error_e DrawMap(maps_view_h hView, Evas* pCanvas, int x, int y, int nWidth, int nHeight); - here_error_e MoveCenter(maps_view_h hView, int delta_x, int delta_y); - here_error_e GetCenter(maps_view_h hView, maps_coordinates_h *center); - here_error_e SetScalebar(maps_view_h hView, bool enable); - here_error_e GetScalebar(maps_view_h hView, bool *enabled); - here_error_e ScreenToGeolocation(maps_view_h hView, int x, int y, maps_coordinates_h *mapsCoord); - here_error_e GeolocationToScreen(maps_view_h hView, const maps_coordinates_h mapsCoord, int *x, int *y); - - here_error_e GetMinZoomLevel(maps_view_h hView, int *nMinZoomLevel); - here_error_e GetMaxZoomLevel(maps_view_h hView, int *nMaxZoomLevel); - here_error_e OnViewObject(maps_view_h hView, const maps_view_object_h object, maps_view_object_operation_e operation); + here_error_e init(maps_view_h view, maps_plugin_map_view_ready_cb callback); + here_error_e close(maps_view_h view); + here_error_e renderMap(maps_view_h view, const maps_coordinates_h coord, double zoom, double angle); + here_error_e moveCenter(maps_view_h view, int delta_x, int delta_y); + here_error_e getCenter(maps_view_h view, maps_coordinates_h *center); + here_error_e setScalebarEnabled(maps_view_h view, bool enable); + here_error_e getScalebarEnabled(maps_view_h view, bool *enabled); + here_error_e convertScreenToGeolocation(maps_view_h view, int x, int y, maps_coordinates_h *coord); + here_error_e convertGeolocationToScreen(maps_view_h view, const maps_coordinates_h coord, int *x, int *y); + + here_error_e getMinZoomLevel(maps_view_h view, int *zoom); + here_error_e getMaxZoomLevel(maps_view_h view, int *zoom); + here_error_e onViewObject(maps_view_h view, const maps_view_object_h object, maps_view_object_operation_e operation); private: - here_error_e __initOpenGL(); - here_error_e __initOpenGLSurface(maps_view_h hView); - here_error_e __initMap(maps_view_h hView, maps_plugin_map_view_ready_cb pCbFunc); - static void __readyMapCb(maps_view_h hView); + here_error_e initOpenGL(); + here_error_e initOpenGLSurface(maps_view_h view); + here_error_e initMap(maps_view_h view, maps_plugin_map_view_ready_cb callback); + void setMapType(maps_view_h view); + static void __readyMapCb(maps_view_h view); static Eina_Bool __idlerCb(void *data); static void __renderingCb(void *data); static void __pixelGetCb(void *data, Evas_Object *obj); - static void __processViewObject(maps_view_h hView, const maps_view_object_h object, maps_view_object_operation_e operation); - void __setMapType(maps_view_h hView); + static void __processViewObject(maps_view_h view, const maps_view_object_h object, maps_view_object_operation_e operation); private: Here::Maps::GeoTiledMap *__map; diff --git a/src/here_api.cpp b/src/here_api.cpp index 592e53d..912641f 100644 --- a/src/here_api.cpp +++ b/src/here_api.cpp @@ -133,7 +133,7 @@ int HerePluginGeocode(const char* szAddr, if (error != HERE_ERROR_NONE) break; error = pGeocode->StartGeocode(szAddr); - } while(0); + } while (0); /* finishing task */ if(error != HERE_ERROR_NONE) @@ -175,7 +175,7 @@ int HerePluginGeocodeByStructuredAddress(const maps_address_h hAddr, if (error != HERE_ERROR_NONE) break; error = pGeocode->StartGeocodeByStructuredAddress(hAddr); - } while(0); + } while (0); /* finishing task */ if(error != HERE_ERROR_NONE) @@ -220,7 +220,7 @@ int HerePluginGeocodeInsideArea(const char* szAddr, maps_area_h hArea, if (error != HERE_ERROR_NONE) break; error = pGeocode->StartGeocodeInsideArea(szAddr, hArea); - } while(0); + } while (0); /* finishing task */ if(error != HERE_ERROR_NONE) @@ -268,7 +268,7 @@ int HerePluginReverseGeocode(double dLatitude, double dLongitude, if (error != HERE_ERROR_NONE) break; error = pRevGeocode->StartRevGeocode(hPref); - } while(0); + } while (0); /* finishing task */ if(error != HERE_ERROR_NONE) @@ -310,7 +310,7 @@ int HerePluginMultiReverseGeocode(const maps_coordinates_list_h hGeocodeList, if (error != HERE_ERROR_NONE) break; error = pMultiRevGeocode->StartMultiReverse(hPref); - } while(0); + } while (0); /* finishing task */ if(error != HERE_ERROR_NONE) @@ -358,7 +358,7 @@ int HerePluginSearchPlace(maps_coordinates_h hPos, int nDistance, if (error != HERE_ERROR_NONE) break; error = pPlace->StartDiscoveryPlace(hPos, nDistance); - } while(0); + } while (0); /* finishing task */ if(error != HERE_ERROR_NONE) @@ -406,7 +406,7 @@ int HerePluginSearchPlaceByArea(maps_area_h hArea, if (error != HERE_ERROR_NONE) break; error = pPlace->StartDiscoveryPlace(hArea); - } while(0); + } while (0); /* finishing task */ if(error != HERE_ERROR_NONE) @@ -454,7 +454,7 @@ int HerePluginSearchPlaceByAddress(const char* szAddr, maps_area_h hArea, if (error != HERE_ERROR_NONE) break; error = pPlace->StartDiscoveryPlace(hArea, szAddr); - } while(0); + } while (0); /* finishing task */ if(error != HERE_ERROR_NONE) @@ -502,7 +502,7 @@ int HerePluginSearchPlaceList(maps_area_h hArea, maps_item_hashtable_h hPref, if (error != HERE_ERROR_NONE) break; error = pPlace->StartDiscoveryPlaceList(hArea); - } while(0); + } while (0); /* finishing task */ if(error != HERE_ERROR_NONE) @@ -541,7 +541,7 @@ int HerePluginSearchPlaceDetails(const char* szUrl, if (error != HERE_ERROR_NONE) break; error = pPlace->StartPlaceDetails(szUrl); - } while(0); + } while (0); /* finishing task */ if(error != HERE_ERROR_NONE) @@ -590,7 +590,7 @@ int HerePluginSearchRoute(maps_coordinates_h hOrigin, maps_coordinates_h hDestin if (error != HERE_ERROR_NONE) break; error = pRoute->StartRoute(); - } while(0); + } while (0); /* finishing task */ if(error != HERE_ERROR_NONE) @@ -607,7 +607,7 @@ int HerePluginSearchRouteWaypoints(const maps_coordinates_h* hWaypointList, int if (!hWaypointList || nWaypointNum < 2 || !pCbFunc || !nReqId) return HERE_ERROR_INVALID_PARAMETER; - for (int i=0; iStartRoute(); - } while(0); + } while (0); /* finishing task */ if(error != HERE_ERROR_NONE) @@ -661,6 +661,8 @@ int HerePluginCancelRequest(int nReqId) return (HereManager::GetHandler()->CancelInstance(nReqId)); } + + /*****************************************************************************/ /* */ /* Maps Widget */ @@ -676,7 +678,7 @@ int HerePluginCreateMapView(maps_view_h hView, maps_plugin_map_view_ready_cb pCb maps_view_set_maps_plugin_view_handle(hView, vh); if (ovh) delete ovh; - return vh->Init(hView, pCbFunc); + return vh->init(hView, pCbFunc); } int HerePluginDestroyMapView(maps_view_h hView) @@ -686,19 +688,20 @@ int HerePluginDestroyMapView(maps_view_h hView) here_error_e error = (here_error_e)ConvertToHereError(maps_error); if (error == HERE_ERROR_NONE && vh) { maps_view_set_maps_plugin_view_handle(hView, NULL); - error = vh->Close(hView); + error = vh->close(hView); delete vh; } return error; } -int HerePluginRenderMap(maps_view_h hView, const maps_coordinates_h mapsCoord, double dZoom, double dAngle) +int HerePluginRenderMap(maps_view_h hView, const maps_coordinates_h mapsCoord, + double dZoom, double dAngle) { HereView *vh = NULL; int maps_error = maps_view_get_maps_plugin_view_handle(hView, (void**)&vh); here_error_e error = (here_error_e)ConvertToHereError(maps_error); if (error == HERE_ERROR_NONE && vh) - error = vh->RenderMap(hView, mapsCoord, dZoom, dAngle); + error = vh->renderMap(hView, mapsCoord, dZoom, dAngle); return error; } @@ -708,7 +711,7 @@ int HerePluginMoveCenter(maps_view_h hView, int delta_x, int delta_y) int maps_error = maps_view_get_maps_plugin_view_handle(hView, (void**)&vh); here_error_e error = (here_error_e)ConvertToHereError(maps_error); if (error == HERE_ERROR_NONE && vh) - error = vh->MoveCenter(hView, delta_x, delta_y); + error = vh->moveCenter(hView, delta_x, delta_y); return error; } @@ -718,7 +721,7 @@ int HerePluginSetScalebar(maps_view_h hView, bool enable) int maps_error = maps_view_get_maps_plugin_view_handle(hView, (void**)&vh); here_error_e error = (here_error_e)ConvertToHereError(maps_error); if (error == HERE_ERROR_NONE && vh) - error = vh->SetScalebar(hView, enable); + error = vh->setScalebarEnabled(hView, enable); return error; } @@ -728,22 +731,17 @@ int HerePluginGetScalebar(maps_view_h hView, bool *enabled) int maps_error = maps_view_get_maps_plugin_view_handle(hView, (void**)&vh); here_error_e error = (here_error_e)ConvertToHereError(maps_error); if (error == HERE_ERROR_NONE && vh) - error = vh->GetScalebar(hView, enabled); + error = vh->getScalebarEnabled(hView, enabled); return error; } -int HerePluginDrawMap(maps_view_h hView, Evas* pCanvas, int x, int y, int w, int h) -{ - return HERE_ERROR_NONE; -} - int HerePluginGetCenter(maps_view_h hView, maps_coordinates_h *center) { HereView *vh = NULL; int maps_error = maps_view_get_maps_plugin_view_handle(hView, (void**)&vh); here_error_e error = (here_error_e)ConvertToHereError(maps_error); if (error == HERE_ERROR_NONE && vh) - error = vh->GetCenter(hView, center); + error = vh->getCenter(hView, center); return error; } @@ -753,7 +751,7 @@ int HerePluginScreenToGeography(maps_view_h hView, int x, int y, maps_coordinate int maps_error = maps_view_get_maps_plugin_view_handle(hView, (void**)&vh); here_error_e error = (here_error_e)ConvertToHereError(maps_error); if (error == HERE_ERROR_NONE && vh) - error = vh->ScreenToGeolocation(hView, x, y, mapsCoord); + error = vh->convertScreenToGeolocation(hView, x, y, mapsCoord); return error; } @@ -763,7 +761,7 @@ int HerePluginGeographyToScreen(maps_view_h hView, const maps_coordinates_h maps int maps_error = maps_view_get_maps_plugin_view_handle(hView, (void**)&vh); here_error_e error = (here_error_e)ConvertToHereError(maps_error); if (error == HERE_ERROR_NONE && vh) - error = vh->GeolocationToScreen(hView, mapsCoord, x, y); + error = vh->convertGeolocationToScreen(hView, mapsCoord, x, y); return error; } @@ -773,7 +771,7 @@ int HerePluginGetMinZoomLevel(maps_view_h hView, int *nMinZoomLevel) int maps_error = maps_view_get_maps_plugin_view_handle(hView, (void**)&vh); here_error_e error = (here_error_e)ConvertToHereError(maps_error); if (error == HERE_ERROR_NONE && vh) - error = vh->GetMinZoomLevel(hView, nMinZoomLevel); + error = vh->getMinZoomLevel(hView, nMinZoomLevel); return error; } @@ -783,16 +781,17 @@ int HerePluginGetMaxZoomLevel(maps_view_h hView, int *nMaxZoomLevel) int maps_error = maps_view_get_maps_plugin_view_handle(hView, (void**)&vh); here_error_e error = (here_error_e)ConvertToHereError(maps_error); if (error == HERE_ERROR_NONE && vh) - error = vh->GetMaxZoomLevel(hView, nMaxZoomLevel); + error = vh->getMaxZoomLevel(hView, nMaxZoomLevel); return error; } -int HerePluginOnViewObject(maps_view_h hView, const maps_view_object_h object, maps_view_object_operation_e operation) +int HerePluginOnViewObject(maps_view_h hView, const maps_view_object_h object, + maps_view_object_operation_e operation) { HereView *vh = NULL; int maps_error = maps_view_get_maps_plugin_view_handle(hView, (void**)&vh); here_error_e error = (here_error_e)ConvertToHereError(maps_error); if (error == HERE_ERROR_NONE && vh) - error = vh->OnViewObject(hView, object, operation); + error = vh->onViewObject(hView, object, operation); return error; } diff --git a/src/here_geocode.cpp b/src/here_geocode.cpp index 80f11b5..4fbb0e0 100644 --- a/src/here_geocode.cpp +++ b/src/here_geocode.cpp @@ -107,8 +107,7 @@ here_error_e HereGeocode::StartGeocodeInsideArea(const char* szAddr, const maps_ m_pQuery->SetSearchtext(sSearch); maps_area_s *pArea = (maps_area_s *)hArea; - if (pArea->type == MAPS_AREA_RECTANGLE) - { + if (pArea->type == MAPS_AREA_RECTANGLE) { double dLatTL = pArea->rect.top_left.latitude; double dLngTL = pArea->rect.top_left.longitude; GeoCoordinates geoCoordTL(dLatTL, dLngTL); @@ -120,13 +119,10 @@ here_error_e HereGeocode::StartGeocodeInsideArea(const char* szAddr, const maps_ GeoBoundingBox BoundingBox(geoCoordTL, geoCoordBR); m_pQuery->SetBoundingBox(BoundingBox); - } - else if (pArea->type == MAPS_AREA_CIRCLE) - { + } else if (pArea->type == MAPS_AREA_CIRCLE) { MAPS_LOGD("HERE Maps is not supported circle type in GeocoderQuery"); return HERE_ERROR_NOT_SUPPORTED; - } - else { + } else { return HERE_ERROR_INVALID_PARAMETER; } @@ -229,8 +225,7 @@ void HereGeocode::OnGeoCoderReply(const GeoCoderReply& Reply) GeoCoordinates hereCoord; maps_coordinates_h mapsCoord; - if (nResults == 0) - { + if (nResults == 0) { ((maps_service_geocode_cb)m_pCbFunc)(MAPS_ERROR_NOT_FOUND, m_nReqId, 0, 0, NULL, m_pUserData); delete this; @@ -241,12 +236,9 @@ void HereGeocode::OnGeoCoderReply(const GeoCoderReply& Reply) { pResult = (Result*)Reply.GetResult(i); - if (pResult) - { + if (pResult) { hereCoord = (pResult->GetLocation()).GetDisplayPosition(); - } - else - { + } else { hereCoord.SetLatitude(0.0); hereCoord.SetLongitude(0.0); } @@ -254,16 +246,12 @@ void HereGeocode::OnGeoCoderReply(const GeoCoderReply& Reply) maps_error_e error = (maps_error_e)maps_coordinates_create( hereCoord.GetLatitude(), hereCoord.GetLongitude(), &mapsCoord); - if (m_bCanceled || !m_pCbFunc) - { + if (m_bCanceled || !m_pCbFunc) { if (mapsCoord) maps_coordinates_destroy(mapsCoord); break; - } - else - { + } else { if (((maps_service_geocode_cb)m_pCbFunc)(error, m_nReqId, i, - nResults, mapsCoord, m_pUserData) == FALSE) - { + nResults, mapsCoord, m_pUserData) == FALSE) { delete this; return; } diff --git a/src/here_manager.cpp b/src/here_manager.cpp index ab04411..0d9f592 100644 --- a/src/here_manager.cpp +++ b/src/here_manager.cpp @@ -77,8 +77,7 @@ bool HereManager::Create() m_pHereManager = new (std::nothrow) HereManager(); pthread_mutex_lock(&g_mtxRef); - if (m_pHereManager) - { + if (m_pHereManager) { m_nRefCnt++; result = true; MAPS_LOGD("Created a HereManager instance (%d).", m_nRefCnt); @@ -96,8 +95,7 @@ void HereManager::Close() bool terminate = (--m_nRefCnt == 0 && m_pHereManager); pthread_mutex_unlock(&g_mtxRef); - if (terminate) - { + if (terminate) { m_pHereManager->TerminateAllServices(); HereConfig::Shutdown(); @@ -163,10 +161,8 @@ here_error_e HereManager::CloseInstance(int nReqId) HereSvcList::iterator it; pthread_mutex_lock(&m_mtxHereList); - for (it = m_HereList.begin(); it != m_HereList.end(); it++) - { - if ((*it)->GetReqId() == nReqId) - { + for (it = m_HereList.begin(); it != m_HereList.end(); it++) { + if ((*it)->GetReqId() == nReqId) { m_HereList.erase(it); break; } @@ -181,10 +177,8 @@ here_error_e HereManager::CancelInstance(int nReqId) HereSvcList::iterator it; pthread_mutex_lock(&m_mtxHereList); - for (it = m_HereList.begin(); it != m_HereList.end(); it++) - { - if ((*it)->GetReqId() == nReqId) - { + for (it = m_HereList.begin(); it != m_HereList.end(); it++) { + if ((*it)->GetReqId() == nReqId) { m_HereList.erase(it); RestItemHandle::Cancel((*it)->GetRestReqId()); (*it)->TerminateService(); @@ -202,12 +196,9 @@ bool HereManager::AppInfoMetadataCb(const char *metadata_key, const char *metada if (!metadata_key || !metadata_value) return false; - if (!strncmp(metadata_key, "http://tizen.org/metadata/here_key", 35) && strlen(metadata_value) > 0 ) - { + if (!strncmp(metadata_key, "http://tizen.org/metadata/here_key", 35) && strlen(metadata_value) > 0) { if (m_pHereManager->SetCredentials(metadata_value) == HERE_ERROR_NONE) - { MAPS_LOGD("Succeeded getting credential from metadata"); - } return false; } @@ -224,15 +215,13 @@ here_error_e HereManager::SetCredentials(void) nProcessId = getpid(); nRet = app_manager_get_app_id(nProcessId, &strAppId); - if (nRet != APP_MANAGER_ERROR_NONE) - { + if (nRet != APP_MANAGER_ERROR_NONE) { MAPS_LOGI("Get app_id [%ld]. nRet[%d]", nProcessId, nRet); return HERE_ERROR_NONE; } nRet = app_info_create(strAppId, &hAppInfo); - if (nRet != APP_MANAGER_ERROR_NONE) - { + if (nRet != APP_MANAGER_ERROR_NONE) { MAPS_LOGI("Get appinfo of [%s]. nRet[%d]", strAppId, nRet); if (strAppId) free(strAppId); return HERE_ERROR_NONE; @@ -242,15 +231,11 @@ here_error_e HereManager::SetCredentials(void) nRet = app_info_foreach_metadata(hAppInfo, AppInfoMetadataCb, NULL); if (nRet != APP_MANAGER_ERROR_NONE) - { MAPS_LOGI("Get metadata. nRet[%d]", nRet); - } nRet = app_info_destroy(hAppInfo); if (nRet != APP_MANAGER_ERROR_NONE) - { MAPS_LOGI("Destroy app_info. nRet[%d]", nRet); - } return HERE_ERROR_NONE; } @@ -266,8 +251,7 @@ here_error_e HereManager::SetCredentials(const char *szKey) nCodeStart = strKey.find("/"); - if(nCodeStart == 0 || nCodeStart >= (strKey.length()-1)) - { + if(nCodeStart == 0 || nCodeStart >= (strKey.length()-1)) { MAPS_LOGE("[error] Key type fault : Key type should be as like XXXXX/YYYYY"); return HERE_ERROR_INVALID_PARAMETER; } @@ -285,8 +269,9 @@ here_error_e HereManager::SetCredentials(const char *szKey) strRequestAppId.append(strAppId); g_free(strAppId); } - } else + } else { strRequestAppId = ApplicationContext::GetInstance().GetRequestAppId(); + } if(!ApplicationContext::GetInstance().Initialize(strAppCode, strAppId, strRequestAppId)) return HERE_ERROR_INVALID_OPERATION; @@ -324,8 +309,7 @@ here_error_e HereManager::SetPreference(maps_preference_h hPref) if (!hPref) return HERE_ERROR_INVALID_PARAMETER; - if (m_hPref) - { + if (m_hPref) { if (maps_preference_destroy(m_hPref) != MAPS_ERROR_NONE) return HERE_ERROR_INVALID_OPERATION; } @@ -338,7 +322,7 @@ here_error_e HereManager::SetPreference(maps_preference_h hPref) error = maps_preference_get_language(hPref, &szLanguage); if (error == MAPS_ERROR_NONE && szLanguage && strlen(szLanguage) > 0) ApplicationContext::GetInstance().SetPreferredLanguage(String(szLanguage)); - } while(0); + } while (0); return (here_error_e)ConvertToHereError(error); } @@ -367,11 +351,9 @@ void HereManager::TerminateAllServices(void) { HereSvcList::iterator it; - while (1) - { + while (1) { pthread_mutex_lock(&m_mtxHereList); - if (m_HereList.empty()) - { + if (m_HereList.empty()) { pthread_mutex_unlock(&m_mtxHereList); break; } @@ -381,14 +363,12 @@ void HereManager::TerminateAllServices(void) try { if (*it) (*it)->TerminateService(); m_HereList.erase(it); - } - catch (std::exception &e) { + } catch (std::exception &e) { MAPS_LOGD("Exception caught: %s", e.what()); } }; - if (m_hPref) - { + if (m_hPref) { maps_preference_destroy(m_hPref); m_hPref = NULL; } @@ -398,8 +378,7 @@ here_error_e HereManager::ConvertNetworkErrorCode(const int nErrorCode) { here_error_e err = HERE_ERROR_NONE; - switch (nErrorCode) - { + switch (nErrorCode) { case CONNECTION_ERROR_NONE: //MAPS_LOGD("No error"); err = HERE_ERROR_NONE; @@ -476,21 +455,16 @@ here_error_e HereManager::SetProxyAddress() char *proxy_address = NULL; - if (!m_hConnection) - { + if (!m_hConnection) { errorCode = connection_create(&m_hConnection); if (errorCode == CONNECTION_ERROR_NONE) - { errorCode = connection_set_type_changed_cb(m_hConnection, NetworkStateChangedIndCb, this); - - } } if (errorCode != CONNECTION_ERROR_NONE) return ConvertNetworkErrorCode(errorCode); errorCode = connection_get_proxy(m_hConnection, CONNECTION_ADDRESS_FAMILY_IPV4, &proxy_address); - if (errorCode == CONNECTION_ERROR_NONE) - { + if (errorCode == CONNECTION_ERROR_NONE) { MAPS_LOGD("Proxy = %s", (proxy_address ? proxy_address : "(null)")); Tizen::Maps::HereConfig::SetProxyAddress(proxy_address); } diff --git a/src/here_multirevgeocode.cpp b/src/here_multirevgeocode.cpp index fb73077..2bc9dda 100755 --- a/src/here_multirevgeocode.cpp +++ b/src/here_multirevgeocode.cpp @@ -19,7 +19,7 @@ HERE_PLUGIN_BEGIN_NAMESPACE HereMultiRevGeocode::HereMultiRevGeocode(void* pCbFunc, void* pUserData, int nReqId) -: m_geoCoord(0,0,0) + : m_geoCoord(0, 0, 0) { m_pQuery = NULL; m_pCbFunc = pCbFunc; @@ -29,8 +29,7 @@ HereMultiRevGeocode::HereMultiRevGeocode(void* pCbFunc, void* pUserData, int nRe HereMultiRevGeocode::~HereMultiRevGeocode() { - if (m_pQuery) - { + if (m_pQuery) { delete m_pQuery; m_pQuery = NULL; } @@ -116,12 +115,10 @@ void HereMultiRevGeocode::OnMultiReverseReply(const MultiReverseReply& Reply) { maps_error_e error = (maps_error_e)maps_address_create(&pAddr); - if(error == MAPS_ERROR_NONE) - { + if(error == MAPS_ERROR_NONE) { pResult = (Result*)Reply.GetResult(i); - if (pResult) - { + if (pResult) { Address tmpAddr = (pResult->GetLocation()).GetAddress(); if(!tmpAddr.GetHouseNumber().empty()) @@ -167,16 +164,11 @@ void HereMultiRevGeocode::OnMultiReverseReply(const MultiReverseReply& Reply) maps_address_list_append(address_list, pAddr); } - if (m_bCanceled || !m_pCbFunc) - { + if (m_bCanceled || !m_pCbFunc) { maps_address_list_destroy(address_list); - } - else if (nResults <= 0) - { + } else if (nResults <= 0) { ((maps_service_multi_reverse_geocode_cb)m_pCbFunc)(MAPS_ERROR_NOT_FOUND, m_nReqId, 0, NULL, m_pUserData); - } - else - { + } else { ((maps_service_multi_reverse_geocode_cb)m_pCbFunc)(MAPS_ERROR_NONE, m_nReqId, nResults, address_list, m_pUserData); } diff --git a/src/here_place.cpp b/src/here_place.cpp index 6473425..16359e5 100644 --- a/src/here_place.cpp +++ b/src/here_place.cpp @@ -39,20 +39,17 @@ HerePlace::HerePlace(void *pCbFunc, void *pUserData, int nReqId) HerePlace::~HerePlace() { - if (m_pDiscoveryQuery) - { + if (m_pDiscoveryQuery) { delete m_pDiscoveryQuery; m_pDiscoveryQuery = NULL; } - if (m_pPlaceDetailsQuery) - { + if (m_pPlaceDetailsQuery) { delete m_pPlaceDetailsQuery; m_pPlaceDetailsQuery = NULL; } - while(!m_PlaceList.empty()) - { + while (!m_PlaceList.empty()) { maps_place_destroy(m_PlaceList.front()); m_PlaceList.pop_front(); } @@ -115,8 +112,7 @@ here_error_e HerePlace::PrepareDiscoveryFilter(maps_place_filter_h hFilter) int ret; maps_place_category_h mapsCate = NULL; - if (maps_place_filter_get_category(hFilter, &mapsCate) == MAPS_ERROR_NONE) - { + if (maps_place_filter_get_category(hFilter, &mapsCate) == MAPS_ERROR_NONE) { CategoryList hereCateList; Category hereCate; char *szId = NULL, *szName = NULL, *szUrl = NULL; @@ -132,10 +128,9 @@ here_error_e HerePlace::PrepareDiscoveryFilter(maps_place_filter_h hFilter) g_free(szUrl); ret = maps_place_category_get_id(mapsCate, &szId); - if (ret == MAPS_ERROR_NONE && szId && *szId) + if (ret == MAPS_ERROR_NONE && szId && *szId) { hereCate.SetCategoryId(CategoryId(szId)); - else if (hereCate.GetTitle().size() > 0) - { + } else if (hereCate.GetTitle().size() > 0) { hereCate.SetCategoryId(CategoryId(hereCate.GetTitle())); hereCate.SetTitle(""); } @@ -154,8 +149,7 @@ here_error_e HerePlace::PrepareDiscoveryFilter(maps_place_filter_h hFilter) char *szKeyword = NULL; ret = maps_place_filter_get_keyword(hFilter, &szKeyword); - if (ret == MAPS_ERROR_NONE && szKeyword && *szKeyword) - { + if (ret == MAPS_ERROR_NONE && szKeyword && *szKeyword) { String szSearchText = m_pDiscoveryQuery->GetSearchText(); if (szSearchText.size() > 0) szSearchText += " "; szSearchText += szKeyword; @@ -165,13 +159,10 @@ here_error_e HerePlace::PrepareDiscoveryFilter(maps_place_filter_h hFilter) char *szAddress = NULL; ret = maps_place_filter_get_place_address(hFilter, &szAddress); - if (ret == MAPS_ERROR_NONE && szAddress && *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); @@ -216,32 +207,24 @@ here_error_e HerePlace::StartDiscoveryPlace(maps_area_h hArea, const char *szAdd /* Merge search text with other search text being in preference */ String szSearchText = (szAddr ? szAddr : ""); - if (m_pDiscoveryQuery->GetSearchText().size() > 0) - { + if (m_pDiscoveryQuery->GetSearchText().size() > 0) { if (szSearchText.size() > 0) szSearchText += " "; szSearchText += m_pDiscoveryQuery->GetSearchText(); } m_pDiscoveryQuery->SetSearchText(szSearchText); /* Decide command type */ - if (!szSearchText.empty()) - { + if (!szSearchText.empty()) { cmdType = PLACE_CMD_TEXT; - } - else if (pArea->type == MAPS_AREA_CIRCLE && pArea->circle.radius == 0) - { + } else if (pArea->type == MAPS_AREA_CIRCLE && pArea->circle.radius == 0) { cmdType = PLACE_CMD_CENTER; - } - else - { + } else { cmdType = PLACE_CMD_AREA; } /* Get proximity with area */ - if (cmdType == PLACE_CMD_TEXT || cmdType == PLACE_CMD_CENTER) - { - if (pArea->type == MAPS_AREA_RECTANGLE) - { + if (cmdType == PLACE_CMD_TEXT || cmdType == PLACE_CMD_CENTER) { + if (pArea->type == MAPS_AREA_RECTANGLE) { double dLat1 = pArea->rect.top_left.latitude; double dLng1 = pArea->rect.top_left.longitude; double dLat2 = pArea->rect.bottom_right.latitude; @@ -251,47 +234,35 @@ here_error_e HerePlace::StartDiscoveryPlace(maps_area_h hArea, const char *szAdd geoCoord.SetLatitude(dLat); geoCoord.SetLongitude(dLng); - } - else if(pArea->type == MAPS_AREA_CIRCLE) - { + } else if (pArea->type == MAPS_AREA_CIRCLE) { double dLat = pArea->circle.center.latitude; double dLng = pArea->circle.center.longitude; geoCoord.SetLatitude(dLat); geoCoord.SetLongitude(dLng); - } - else + } else { return HERE_ERROR_INVALID_PARAMETER; - } - else if (cmdType == PLACE_CMD_AREA) - { - if (pArea->type == MAPS_AREA_RECTANGLE) - { + } + } else if (cmdType == PLACE_CMD_AREA) { + if (pArea->type == MAPS_AREA_RECTANGLE) { HereUtils::Convert(hArea, geoBox); geoArea = &geoBox; - } - else if (pArea->type == MAPS_AREA_CIRCLE) - { + } else if (pArea->type == MAPS_AREA_CIRCLE) { HereUtils::Convert(hArea, geoCircle); geoArea = &geoCircle; - } - else + } else { return HERE_ERROR_INVALID_PARAMETER; + } } /* Set properties */ - if (cmdType == PLACE_CMD_TEXT) - { + if (cmdType == PLACE_CMD_TEXT) { m_pDiscoveryQuery->SetType(DiscoveryQuery::QT_SEARCH); m_pDiscoveryQuery->SetProximity(geoCoord); - } - else if (cmdType == PLACE_CMD_CENTER) - { + } else if (cmdType == PLACE_CMD_CENTER) { m_pDiscoveryQuery->SetType(DiscoveryQuery::QT_EXPLORE); m_pDiscoveryQuery->SetProximity(geoCoord); - } - else - { + } else { m_pDiscoveryQuery->SetType(DiscoveryQuery::QT_EXPLORE); if (geoArea) m_pDiscoveryQuery->SetArea(*geoArea); @@ -373,7 +344,7 @@ here_error_e HerePlace::StartPlaceDetailsInternal(const char *szUrl) return (bExcuted ? HERE_ERROR_NONE : HERE_ERROR_INVALID_OPERATION); } -void HerePlace::OnDiscoverReply (const DiscoveryReply &Reply) +void HerePlace::OnDiscoverReply(const DiscoveryReply &Reply) { maps_place_h mapsPlace; PlaceItemList herePlaceList = Reply.GetPlaceItems(); @@ -389,8 +360,7 @@ void HerePlace::OnDiscoverReply (const DiscoveryReply &Reply) int error = MAPS_ERROR_UNKNOWN, sub_error; bool is_valid, isPending; - if (m_bCanceled || !m_pCbFunc) - { + if (m_bCanceled || !m_pCbFunc) { delete this; return; } @@ -400,10 +370,8 @@ void HerePlace::OnDiscoverReply (const DiscoveryReply &Reply) for (herePlaceIt = herePlaceList.begin(); herePlaceIt != herePlaceList.end(); - herePlaceIt++) - { - if ((error = maps_place_create(&mapsPlace)) == MAPS_ERROR_NONE) - { + herePlaceIt++) { + if ((error = maps_place_create(&mapsPlace)) == MAPS_ERROR_NONE) { isPending = false; /* title, uri, id */ @@ -424,15 +392,13 @@ void HerePlace::OnDiscoverReply (const DiscoveryReply &Reply) /* position */ hereCoord = herePlaceIt->GetPosition(); if (maps_coordinates_create(hereCoord.GetLatitude(), hereCoord.GetLongitude(), - &mapsCoord) == MAPS_ERROR_NONE) - { + &mapsCoord) == MAPS_ERROR_NONE) { maps_place_set_location(mapsPlace, mapsCoord); maps_coordinates_destroy(mapsCoord); } /* rating (optional) */ - if (maps_place_rating_create(&mapsRating) == MAPS_ERROR_NONE) - { + if (maps_place_rating_create(&mapsRating) == MAPS_ERROR_NONE) { maps_place_rating_set_average(mapsRating, herePlaceIt->GetAverageRating()); maps_place_set_rating(mapsPlace, mapsRating); maps_place_rating_destroy(mapsRating); @@ -442,35 +408,29 @@ void HerePlace::OnDiscoverReply (const DiscoveryReply &Reply) hereCate = herePlaceIt->GetCategory(); maps_item_list_h mapsCateList; - if (maps_item_list_create(&mapsCateList) == MAPS_ERROR_NONE) - { - if (maps_place_category_create(&mapsCate) == MAPS_ERROR_NONE) - { + if (maps_item_list_create(&mapsCateList) == MAPS_ERROR_NONE) { + if (maps_place_category_create(&mapsCate) == MAPS_ERROR_NONE) { is_valid = false; - if (!hereCate.GetCategoryId().ToString().empty()) - { + if (!hereCate.GetCategoryId().ToString().empty()) { sub_error = maps_place_category_set_id(mapsCate, (char*)hereCate.GetCategoryId().ToString().c_str()); is_valid |= (sub_error == MAPS_ERROR_NONE); } - if (!hereCate.GetTitle().empty()) - { + if (!hereCate.GetTitle().empty()) { sub_error = maps_place_category_set_name(mapsCate, (char*)hereCate.GetTitle().c_str()); is_valid |= (sub_error == MAPS_ERROR_NONE); } - if (!hereCate.GetHref().empty()) - { + if (!hereCate.GetHref().empty()) { sub_error = maps_place_category_set_url(mapsCate, (char*)hereCate.GetHref().c_str()); is_valid |= (sub_error == MAPS_ERROR_NONE); } - if (is_valid) - { + if (is_valid) { maps_item_list_append(mapsCateList, mapsCate, maps_place_category_clone); maps_place_set_categories(mapsPlace, mapsCateList); maps_item_list_remove_all(mapsCateList, maps_place_category_destroy); @@ -490,13 +450,10 @@ void HerePlace::OnDiscoverReply (const DiscoveryReply &Reply) /* vicinity */ /* If needed PlaceDetails information, postpone to send a reply */ - if(__sending_place_details_query_automatically && !m_bReplyWithList) - { + if(__sending_place_details_query_automatically && !m_bReplyWithList) { hereLinkObj = herePlaceIt->GetLinkObject(); - if (!hereLinkObj.GetHref().empty() && !hereLinkObj.GetId().empty()) - { - if (StartPlaceDetailsInternal(hereLinkObj.GetHref().c_str()) == HERE_ERROR_NONE) - { + if (!hereLinkObj.GetHref().empty() && !hereLinkObj.GetId().empty()) { + if (StartPlaceDetailsInternal(hereLinkObj.GetHref().c_str()) == HERE_ERROR_NONE) { m_PlaceList.push_back(mapsPlace); isPending = true; MAPS_LOGD("Add maps_place_h to the pending list. id=%s", hereLinkObj.GetId().data()); @@ -508,42 +465,35 @@ void HerePlace::OnDiscoverReply (const DiscoveryReply &Reply) m_nReplyIdx++; m_PlaceList.push_back(mapsPlace); } - } - else - { + } else { m_nReplyCnt--; } } for (hereSearchIt = hereSearchList.begin(); hereSearchIt != hereSearchList.end(); - hereSearchIt++) - { + hereSearchIt++) { error = maps_place_create(&mapsPlace); - if(error == MAPS_ERROR_NONE) - { + if(error == MAPS_ERROR_NONE) { is_valid = false; // title, uri, szId hereLinkObj = hereSearchIt->GetLinkObject(); - if (!hereLinkObj.GetTitle().empty()) - { + if (!hereLinkObj.GetTitle().empty()) { sub_error = maps_place_set_name(mapsPlace, (char*)hereLinkObj.GetTitle().c_str()); is_valid |= (sub_error == MAPS_ERROR_NONE); } - if (!hereLinkObj.GetHref().empty()) - { + if (!hereLinkObj.GetHref().empty()) { sub_error = maps_place_set_uri(mapsPlace, (char*)hereLinkObj.GetHref().c_str()); is_valid |= (sub_error == MAPS_ERROR_NONE); } - if (!hereLinkObj.GetId().empty()) - { + if (!hereLinkObj.GetId().empty()) { sub_error = maps_place_set_id(mapsPlace, (char*)hereLinkObj.GetId().c_str()); is_valid |= (sub_error == MAPS_ERROR_NONE); @@ -551,28 +501,22 @@ void HerePlace::OnDiscoverReply (const DiscoveryReply &Reply) /* icon */ /* type */ - if (!is_valid) - { + if (!is_valid) { m_nReplyCnt--; error = MAPS_ERROR_NOT_FOUND; maps_place_destroy(mapsPlace); mapsPlace = NULL; - } - else - { + } else { m_PlaceList.push_back(mapsPlace); m_nReplyIdx++; } - } - else - { + } else { m_nReplyCnt--; } } - if (!m_bReplyFlushed && (m_nReplyCnt == 0 || m_nReplyIdx == m_nReplyCnt)) - { + if (!m_bReplyFlushed && (m_nReplyCnt == 0 || m_nReplyIdx == m_nReplyCnt)) { if (m_nReplyCnt == 0) error = MAPS_ERROR_NOT_FOUND; @@ -583,8 +527,7 @@ void HerePlace::OnDiscoverReply (const DiscoveryReply &Reply) void HerePlace::OnDiscoverFailure(const DiscoveryReply& Reply) { - if (!m_bReplyFlushed) - { + if (!m_bReplyFlushed) { m_nReplyIdx = 0; m_nReplyCnt = 0; __flushReplies((maps_error_e)GetErrorCode(Reply)); @@ -592,12 +535,10 @@ void HerePlace::OnDiscoverFailure(const DiscoveryReply& Reply) } } -void HerePlace::OnPlaceDetailsReply (const PlaceDetailsReply &Reply) +void HerePlace::OnPlaceDetailsReply(const PlaceDetailsReply &Reply) { - if (m_nReplyCnt == 0) - { - if (m_bCanceled || !m_pCbFunc) - { + if (m_nReplyCnt == 0) { + if (m_bCanceled || !m_pCbFunc) { delete this; return; } @@ -613,13 +554,10 @@ void HerePlace::OnPlaceDetailsReply (const PlaceDetailsReply &Reply) /* Finding maps_place_h which is already pending since DiscoverReply */ PlaceList::iterator it; - for (it = m_PlaceList.begin(); it != m_PlaceList.end(); it++) - { - if (maps_place_get_id(*it, &placeId) == MAPS_ERROR_NONE) - { + for (it = m_PlaceList.begin(); it != m_PlaceList.end(); it++) { + if (maps_place_get_id(*it, &placeId) == MAPS_ERROR_NONE) { placeIdLen = strlen(placeId); - if(!herePlace.GetPlaceId().compare(0, placeIdLen, placeId)) - { + if(!herePlace.GetPlaceId().compare(0, placeIdLen, placeId)) { mapsPlace = *it; isPending = true; MAPS_LOGD("Found maps_place_h in the pending list. id=%s", placeId); @@ -634,33 +572,28 @@ void HerePlace::OnPlaceDetailsReply (const PlaceDetailsReply &Reply) if (!mapsPlace) error = maps_place_create(&mapsPlace); - if (error == MAPS_ERROR_NONE) - { + if (error == MAPS_ERROR_NONE) { is_valid = false; /* name */ - if (!herePlace.GetName().empty()) - { + if (!herePlace.GetName().empty()) { sub_error = maps_place_set_name(mapsPlace, (char*)herePlace.GetName().c_str()); is_valid |= (sub_error == MAPS_ERROR_NONE); } /* id */ - if (!herePlace.GetPlaceId().empty()) - { + if (!herePlace.GetPlaceId().empty()) { sub_error = maps_place_set_id(mapsPlace, (char*)herePlace.GetPlaceId().c_str()); is_valid |= (sub_error == MAPS_ERROR_NONE); } /* view */ - if (!herePlace.GetView().empty()) - { + if (!herePlace.GetView().empty()) { sub_error = maps_place_set_uri(mapsPlace, (char*)herePlace.GetView().c_str()); is_valid |= (sub_error == MAPS_ERROR_NONE); } - if (is_valid) - { + if (is_valid) { /* icon */ /* maps not supported // herePlace.GetIconPath(); */ @@ -688,22 +621,17 @@ void HerePlace::OnPlaceDetailsReply (const PlaceDetailsReply &Reply) m_PlaceList.push_back(mapsPlace); m_nReplyIdx++; - } - else - { + } else { m_nReplyCnt--; error = MAPS_ERROR_NOT_FOUND; maps_place_destroy(mapsPlace); mapsPlace = NULL; } - } - else - { + } else { m_nReplyCnt--; } - if (!m_bReplyFlushed && (m_nReplyCnt == 0 || m_nReplyIdx == m_nReplyCnt)) - { + if (!m_bReplyFlushed && (m_nReplyCnt == 0 || m_nReplyIdx == m_nReplyCnt)) { if (m_nReplyCnt == 0) error = MAPS_ERROR_NOT_FOUND; @@ -714,18 +642,14 @@ void HerePlace::OnPlaceDetailsReply (const PlaceDetailsReply &Reply) void HerePlace::OnPlaceDetailsFailure(const PlaceDetailsReply& Reply) { - if (!m_bPlaceDetailsInternal) - { - if (!m_bReplyFlushed) - { + if (!m_bPlaceDetailsInternal) { + if (!m_bReplyFlushed) { m_nReplyIdx = 0; m_nReplyCnt = 0; __flushReplies(GetErrorCode(Reply)); delete this; } - } - else - { + } else { m_nReplyIdx++; MAPS_LOGD("Internal error during updating detailed information for the place. (%d/%d)", m_nReplyIdx, m_nReplyCnt); if (!m_bReplyFlushed && (m_nReplyIdx == m_nReplyCnt)) @@ -745,8 +669,7 @@ void HerePlace::ProcessPlaceLocation(PlaceDetails herePlace, maps_place_h mapsPl maps_coordinates_h mapsCoord; if (maps_coordinates_create(hereCoord.GetLatitude(), - hereCoord.GetLongitude(), &mapsCoord) == MAPS_ERROR_NONE) - { + hereCoord.GetLongitude(), &mapsCoord) == MAPS_ERROR_NONE) { maps_place_set_location(mapsPlace, mapsCoord); maps_coordinates_destroy(mapsCoord); } @@ -757,75 +680,63 @@ void HerePlace::ProcessPlaceLocation(PlaceDetails herePlace, maps_place_h mapsPl int error; bool is_valid; - if (maps_address_create(&mapsAddr) == MAPS_ERROR_NONE) - { + if (maps_address_create(&mapsAddr) == MAPS_ERROR_NONE) { is_valid = false; - if (!hereAddr.GetHouseNumber().empty()) - { + if (!hereAddr.GetHouseNumber().empty()) { error = maps_address_set_building_number(mapsAddr, hereAddr.GetHouseNumber().c_str()); is_valid |= (error == MAPS_ERROR_NONE); } - if (!hereAddr.GetStreet().empty()) - { + if (!hereAddr.GetStreet().empty()) { error = maps_address_set_street(mapsAddr, hereAddr.GetStreet().c_str()); is_valid |= (error == MAPS_ERROR_NONE); } - if (!hereAddr.GetDistrict().empty()) - { + if (!hereAddr.GetDistrict().empty()) { error = maps_address_set_district(mapsAddr, hereAddr.GetDistrict().c_str()); is_valid |= (error == MAPS_ERROR_NONE); } - if (!hereAddr.GetCity().empty()) - { + if (!hereAddr.GetCity().empty()) { error = maps_address_set_city(mapsAddr, hereAddr.GetCity().c_str()); is_valid |= (error == MAPS_ERROR_NONE); } - if (!hereAddr.GetState().empty()) - { + if (!hereAddr.GetState().empty()) { error = maps_address_set_state(mapsAddr, hereAddr.GetState().c_str()); is_valid |= (error == MAPS_ERROR_NONE); } - if (!hereAddr.GetCountry().empty()) - { + if (!hereAddr.GetCountry().empty()) { error = maps_address_set_country(mapsAddr, hereAddr.GetCountry().c_str()); is_valid |= (error == MAPS_ERROR_NONE); } - if (!hereAddr.GetCountryCode().empty()) - { + if (!hereAddr.GetCountryCode().empty()) { error = maps_address_set_country_code(mapsAddr, hereAddr.GetCountryCode().c_str()); is_valid |= (error == MAPS_ERROR_NONE); } - if (!hereAddr.GetCounty().empty()) - { + if (!hereAddr.GetCounty().empty()) { error = maps_address_set_county(mapsAddr, hereAddr.GetCounty().c_str()); is_valid |= (error == MAPS_ERROR_NONE); } - if (!hereAddr.GetPostalCode().empty()) - { + if (!hereAddr.GetPostalCode().empty()) { error = maps_address_set_postal_code(mapsAddr, hereAddr.GetPostalCode().c_str()); is_valid |= (error == MAPS_ERROR_NONE); } - if (!hereAddr.GetLabel().empty()) - { + if (!hereAddr.GetLabel().empty()) { error = maps_address_set_freetext(mapsAddr, hereAddr.GetLabel().c_str()); is_valid |= (error == MAPS_ERROR_NONE); } if (is_valid) - { maps_place_set_address(mapsPlace, mapsAddr); - } + maps_address_destroy(mapsAddr); } } @@ -845,43 +756,37 @@ void HerePlace::ProcessPlaceContact(PlaceDetails herePlace, maps_place_h mapsPla if (maps_item_list_create(&mapsContList) != MAPS_ERROR_NONE) return; - for (hereCont = hereContList.begin(); hereCont != hereContList.end(); hereCont++) - { + for (hereCont = hereContList.begin(); hereCont != hereContList.end(); hereCont++) { if (maps_place_contact_create(&mapsCont) != MAPS_ERROR_NONE) continue; is_valid = false; - if (!hereCont->GetLabel().empty()) - { + if (!hereCont->GetLabel().empty()) { error = maps_place_contact_set_label(mapsCont, (char*)hereCont->GetLabel().c_str()); is_valid |= (error == MAPS_ERROR_NONE); } - if (!hereCont->GetValue().empty()) - { + if (!hereCont->GetValue().empty()) { error = maps_place_contact_set_value(mapsCont, (char*)hereCont->GetValue().c_str()); is_valid |= (error == MAPS_ERROR_NONE); } - if (!hereCont->GetContactType().empty()) - { + if (!hereCont->GetContactType().empty()) { error = maps_place_contact_set_type(mapsCont, (char*)hereCont->GetContactType().c_str()); is_valid |= (error == MAPS_ERROR_NONE); } if (is_valid) - { maps_item_list_append(mapsContList, mapsCont, maps_place_contact_clone); - } + maps_place_contact_destroy(mapsCont); } - if (maps_item_list_items(mapsContList)) - { + if (maps_item_list_items(mapsContList)) { maps_place_set_contacts(mapsPlace, mapsContList); maps_item_list_remove_all(mapsContList, maps_place_contact_destroy); } @@ -905,36 +810,31 @@ void HerePlace::ProcessPlaceCategory(PlaceDetails herePlace, maps_place_h mapsPl hereCate = hereCateList.begin(); if (maps_place_category_create(&mapsCate) == MAPS_ERROR_NONE) { - if (!hereCate->GetCategoryId().ToString().empty()) - { + if (!hereCate->GetCategoryId().ToString().empty()) { error = maps_place_category_set_id(mapsCate, hereCate->GetCategoryId().ToString().c_str()); is_valid |= (error == MAPS_ERROR_NONE); } - if (!hereCate->GetTitle().empty()) - { + if (!hereCate->GetTitle().empty()) { error = maps_place_category_set_name(mapsCate, hereCate->GetTitle().c_str()); is_valid |= (error == MAPS_ERROR_NONE); } - if (!hereCate->GetHref().empty()) - { + if (!hereCate->GetHref().empty()) { error = maps_place_category_set_url(mapsCate, hereCate->GetHref().c_str()); is_valid |= (error == MAPS_ERROR_NONE); } - if (is_valid) - { + if (is_valid) { maps_item_list_append(mapsCateList, mapsCate, maps_place_category_clone); } maps_place_category_destroy(mapsCate); } - if (maps_item_list_items(mapsCateList)) - { + if (maps_item_list_items(mapsCateList)) { maps_place_set_categories(mapsPlace, mapsCateList); maps_item_list_remove_all(mapsCateList, maps_place_category_destroy); } @@ -956,8 +856,7 @@ void HerePlace::ProcessPlaceImage(PlaceDetails herePlace, maps_place_h mapsPlace if (maps_item_list_create(&mapsImageList) != MAPS_ERROR_NONE) return; - for (hereImage = hereImageList.begin(); hereImage != hereImageList.end(); hereImage++) - { + for (hereImage = hereImageList.begin(); hereImage != hereImageList.end(); hereImage++) { if (maps_place_image_create(&mapsImage) != MAPS_ERROR_NONE) continue; is_valid = false; @@ -968,53 +867,45 @@ void HerePlace::ProcessPlaceImage(PlaceDetails herePlace, maps_place_h mapsPlace /* here not supported // maps_place_image_set_media(maps_place_image_h mapsPlace, maps_place_media_h media); */ - if (!hereImage->GetSource().empty()) - { + if (!hereImage->GetSource().empty()) { error = maps_place_image_set_url(mapsImage, (char*)hereImage->GetSource().c_str()); is_valid |= (error == MAPS_ERROR_NONE); } - if (!hereImage->GetImageId().empty()) - { + if (!hereImage->GetImageId().empty()) { error = maps_place_image_set_id(mapsImage, (char*)hereImage->GetImageId().c_str()); is_valid |= (error == MAPS_ERROR_NONE); } hereImageUser = hereImage->GetUser(); - if (maps_place_link_object_create(&mapsImageUser) == MAPS_ERROR_NONE) - { + if (maps_place_link_object_create(&mapsImageUser) == MAPS_ERROR_NONE) { is_valid2 = false; - if (!hereImageUser.GetId().empty()) - { + if (!hereImageUser.GetId().empty()) { error = maps_place_link_object_set_id(mapsImageUser, (char*)hereImageUser.GetId().c_str()); is_valid2 |= (error == MAPS_ERROR_NONE); } - if (!hereImageUser.GetTitle().empty()) - { + if (!hereImageUser.GetTitle().empty()) { error = maps_place_link_object_set_name(mapsImageUser, (char*)hereImageUser.GetTitle().c_str()); is_valid2 |= (error == MAPS_ERROR_NONE); } - if (!hereImageUser.GetHref().empty()) - { + if (!hereImageUser.GetHref().empty()) { error = maps_place_link_object_set_string(mapsImageUser, (char*)hereImageUser.GetHref().c_str()); is_valid2 |= (error == MAPS_ERROR_NONE); } - if (!hereImageUser.GetType().empty()) - { + if (!hereImageUser.GetType().empty()) { error = maps_place_link_object_set_type(mapsImageUser, (char*)hereImageUser.GetType().c_str()); is_valid2 |= (error == MAPS_ERROR_NONE); } - if (is_valid2) - { + if (is_valid2) { maps_place_image_set_user_link(mapsImage, mapsImageUser); is_valid |= is_valid2; } @@ -1022,14 +913,12 @@ void HerePlace::ProcessPlaceImage(PlaceDetails herePlace, maps_place_h mapsPlace } if (is_valid) - { maps_item_list_append(mapsImageList, mapsImage, maps_place_image_clone); - } + maps_place_image_destroy(mapsImage); } - if (maps_item_list_items(mapsImageList)) - { + if (maps_item_list_items(mapsImageList)) { maps_place_set_images(mapsPlace, mapsImageList); maps_item_list_remove_all(mapsImageList, maps_place_image_destroy); } @@ -1049,21 +938,18 @@ void HerePlace::ProcessPlaceDetails(PlaceDetails herePlace, maps_place_h mapsPla if (maps_item_list_create(&mapsEditList) != MAPS_ERROR_NONE) return; - for (hereEdit = hereEditList.begin(); hereEdit != hereEditList.end(); hereEdit++) - { + for (hereEdit = hereEditList.begin(); hereEdit != hereEditList.end(); hereEdit++) { if (maps_place_editorial_create(&mapsEdit) != MAPS_ERROR_NONE) continue; is_valid = false; - if (!hereEdit->GetDescription().empty()) - { + if (!hereEdit->GetDescription().empty()) { error = maps_place_editorial_set_description(mapsEdit, (char*)hereEdit->GetDescription().c_str()); is_valid |= (error == MAPS_ERROR_NONE); } - if (!hereEdit->GetLanguage().empty()) - { + if (!hereEdit->GetLanguage().empty()) { error = maps_place_editorial_set_language(mapsEdit, (char*)hereEdit->GetLanguage().c_str()); is_valid |= (error == MAPS_ERROR_NONE); @@ -1072,14 +958,12 @@ void HerePlace::ProcessPlaceDetails(PlaceDetails herePlace, maps_place_h mapsPla /* maps_place_editorial_set_media(mapsEdit, maps_place_media_h media); */ if (is_valid) - { maps_item_list_append(mapsEditList, mapsEdit, maps_place_editorial_clone); - } + maps_place_editorial_destroy(mapsEdit); } - if (maps_item_list_items(mapsEditList)) - { + if (maps_item_list_items(mapsEditList)) { maps_place_set_editorials(mapsPlace, mapsEditList); maps_item_list_remove_all(mapsEditList, maps_place_editorial_destroy); } @@ -1101,28 +985,24 @@ void HerePlace::ProcessPlaceReviews(PlaceDetails herePlace, maps_place_h mapsPla if (maps_item_list_create(&mapsReviewList) != MAPS_ERROR_NONE) return; - for (hereReview = hereReviewList.begin(); hereReview != hereReviewList.end(); hereReview++) - { + for (hereReview = hereReviewList.begin(); hereReview != hereReviewList.end(); hereReview++) { if (maps_place_review_create(&mapsReview) != MAPS_ERROR_NONE) continue; is_valid = false; - if (!hereReview->GetDateTime().empty()) - { + if (!hereReview->GetDateTime().empty()) { error = maps_place_review_set_date(mapsReview, (char*)hereReview->GetDateTime().c_str()); is_valid |= (error == MAPS_ERROR_NONE); } - if (!hereReview->GetDescription().empty()) - { + if (!hereReview->GetDescription().empty()) { error = maps_place_review_set_description(mapsReview, (char*)hereReview->GetDescription().c_str()); is_valid |= (error == MAPS_ERROR_NONE); } - if (!hereReview->GetLanguage().empty()) - { + if (!hereReview->GetLanguage().empty()) { error = maps_place_review_set_language(mapsReview, (char*)hereReview->GetLanguage().c_str()); is_valid |= (error == MAPS_ERROR_NONE); @@ -1132,63 +1012,55 @@ void HerePlace::ProcessPlaceReviews(PlaceDetails herePlace, maps_place_h mapsPla maps_place_review_set_rating(mapsReview, hereReview->GetRating()); - if (!hereReview->GetTitle().empty()) - { + if (!hereReview->GetTitle().empty()) { error = maps_place_review_set_title(mapsReview, (char*)hereReview->GetTitle().c_str()); is_valid |= (error == MAPS_ERROR_NONE); } hereReviewUser = hereReview->GetUser(); - if (maps_place_link_object_create(&mapsReviewUser) == MAPS_ERROR_NONE) - { + if (maps_place_link_object_create(&mapsReviewUser) == MAPS_ERROR_NONE) { is_valid2 = false; - if (!hereReviewUser.GetId().empty()) - { + if (!hereReviewUser.GetId().empty()) { error = maps_place_link_object_set_id(mapsReviewUser, (char*)hereReviewUser.GetId().c_str()); is_valid2 |= (error == MAPS_ERROR_NONE); } - if (!hereReviewUser.GetTitle().empty()) - { + if (!hereReviewUser.GetTitle().empty()) { error = maps_place_link_object_set_name(mapsReviewUser, (char*)hereReviewUser.GetTitle().c_str()); is_valid2 |= (error == MAPS_ERROR_NONE); } - if (!hereReviewUser.GetHref().empty()) - { + if (!hereReviewUser.GetHref().empty()) { error = maps_place_link_object_set_string(mapsReviewUser, (char*)hereReviewUser.GetHref().c_str()); is_valid2 |= (error == MAPS_ERROR_NONE); } - if (!hereReviewUser.GetType().empty()) - { + if (!hereReviewUser.GetType().empty()) { error = maps_place_link_object_set_type(mapsReviewUser, (char*)hereReviewUser.GetType().c_str()); is_valid2 |= (error == MAPS_ERROR_NONE); } - if (is_valid2) - { + if (is_valid2) { maps_place_review_set_user_link(mapsReview, mapsReviewUser); is_valid |= is_valid2; } + maps_place_link_object_destroy(mapsReviewUser); } if (is_valid) - { maps_item_list_append(mapsReviewList, mapsReview, maps_place_review_clone); - } + maps_place_review_destroy(mapsReview); } - if (maps_item_list_items(mapsReviewList)) - { + if (maps_item_list_items(mapsReviewList)) { maps_place_set_reviews(mapsPlace, mapsReviewList); maps_item_list_remove_all(mapsReviewList, maps_place_review_destroy); } @@ -1220,31 +1092,27 @@ void HerePlace::ProcessPlaceRated(PlaceDetails herePlace, maps_place_h mapsPlace //need to check if GetId() exist //maps_place_link_object_set_id(mapsRelated, hereRelated.GetId()); - if (!hereRelated.GetTitle().empty()) - { + if (!hereRelated.GetTitle().empty()) { error = maps_place_link_object_set_name(mapsRelated, (char*)hereRelated.GetTitle().c_str()); is_valid |= (error == MAPS_ERROR_NONE); } - if (!hereRelated.GetHref().empty()) - { + if (!hereRelated.GetHref().empty()) { error = maps_place_link_object_set_string(mapsRelated, (char*)hereRelated.GetHref().c_str()); is_valid |= (error == MAPS_ERROR_NONE); } - if (!hereRelated.GetType().empty()) - { + if (!hereRelated.GetType().empty()) { error = maps_place_link_object_set_type(mapsRelated, (char*)hereRelated.GetType().c_str()); is_valid |= (error == MAPS_ERROR_NONE); } if (is_valid) - { maps_place_set_related_link(mapsPlace, mapsRelated); - } + maps_place_link_object_destroy(mapsRelated); } @@ -1256,10 +1124,8 @@ void HerePlace::__flushReplies(int error) m_nReplyIdx = 0; __sortList(m_PlaceList); - if (m_bPlaceDetails) - { - if (error != MAPS_ERROR_NONE) - { + if (m_bPlaceDetails) { + if (error != MAPS_ERROR_NONE) { ((maps_service_get_place_details_cb)m_pCbFunc)((maps_error_e)error, m_nReqId, NULL, m_pUserData); return; } @@ -1268,22 +1134,18 @@ void HerePlace::__flushReplies(int error) 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) - { + } else if (m_bReplyWithList) { if (error == MAPS_ERROR_NONE) error = maps_place_list_create(&placeList); - if (error != MAPS_ERROR_NONE) - { + if (error != MAPS_ERROR_NONE) { if (placeList) maps_place_list_destroy(placeList); ((maps_service_search_place_list_cb)m_pCbFunc)((maps_error_e)error, m_nReqId, 0, NULL, m_pUserData); return; } - while (m_nReplyIdx < m_nReplyCnt && !m_bCanceled && !m_PlaceList.empty()) - { + while (m_nReplyIdx < m_nReplyCnt && !m_bCanceled && !m_PlaceList.empty()) { mapsPlace = m_PlaceList.front(); m_PlaceList.pop_front(); @@ -1294,26 +1156,20 @@ void HerePlace::__flushReplies(int error) ((maps_service_search_place_list_cb)m_pCbFunc)((maps_error_e)error, m_nReqId, maps_item_list_items(placeList), placeList, m_pUserData); else maps_place_list_destroy(placeList); - } - else - { - if (error != MAPS_ERROR_NONE) - { + } else { + if (error != MAPS_ERROR_NONE) { ((maps_service_search_place_cb)m_pCbFunc)((maps_error_e)error, m_nReqId, 0, 0, NULL, m_pUserData); return; } - while (m_nReplyIdx < m_nReplyCnt && !m_bCanceled && !m_PlaceList.empty()) - { + 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; - } } } m_bReplyFlushed = true; @@ -1326,9 +1182,8 @@ bool HerePlace::__compareWithTitle(const maps_place_h &item1, const maps_place_h if (maps_place_get_name(item1, &str1) == MAPS_ERROR_NONE && maps_place_get_name(item2, &str2) == MAPS_ERROR_NONE) - { result = (strcmp(str1, str2) < 0); - } + g_free(str1); g_free(str2); return result; @@ -1341,9 +1196,8 @@ bool HerePlace::__compareWithId(const maps_place_h &item1, const maps_place_h &i if (maps_place_get_id(item1, &str1) == MAPS_ERROR_NONE && maps_place_get_id(item2, &str2) == MAPS_ERROR_NONE) - { result = (strcmp(str1, str2) < 0); - } + g_free(str1); g_free(str2); return result; @@ -1356,9 +1210,8 @@ bool HerePlace::__compareWithDistance(const maps_place_h &item1, const maps_plac if (maps_place_get_distance(item1, &num1) == MAPS_ERROR_NONE && maps_place_get_distance(item2, &num2) == MAPS_ERROR_NONE) - { result = (num1 < num2); - } + return result; } @@ -1366,16 +1219,13 @@ bool HerePlace::__compareWithRating(const maps_place_h &item1, const maps_place_ { bool result = false; maps_place_rating_h rat1 = NULL, rat2 = NULL; - double num1 = 0, num2 = 0; + double num1 = 0, num2 = 0; if (maps_place_get_rating(item1, &rat1) == MAPS_ERROR_NONE && - maps_place_get_rating(item2, &rat2) == MAPS_ERROR_NONE) - { + maps_place_get_rating(item2, &rat2) == MAPS_ERROR_NONE) { if (maps_place_rating_get_average(rat1, &num1) == MAPS_ERROR_NONE && maps_place_rating_get_average(rat2, &num2) == MAPS_ERROR_NONE) - { result = (num1 > num2); - } } maps_place_rating_destroy(rat1); maps_place_rating_destroy(rat2); @@ -1401,9 +1251,8 @@ bool HerePlace::__compareWithCategory(const maps_place_h &item1, const maps_plac if (maps_place_category_get_id(item1, &str1) == MAPS_ERROR_NONE && maps_place_category_get_id(item2, &str2) == MAPS_ERROR_NONE) - { result = (strcmp(str1, str2) < 0); - } + maps_place_category_destroy(item1); maps_place_category_destroy(item2); g_free(str1); @@ -1415,24 +1264,15 @@ void HerePlace::__sortList(PlaceList &list) { if (!m_szSortBy) return; - if (!strcmp(m_szSortBy, "name") || !strcmp(m_szSortBy, "title")) - { + if (!strcmp(m_szSortBy, "name") || !strcmp(m_szSortBy, "title")) { std::sort(list.begin(), list.end(), __compareWithTitle); - } - else if (!strcmp(m_szSortBy, "id")) - { + } else if (!strcmp(m_szSortBy, "id")) { std::sort(list.begin(), list.end(), __compareWithId); - } - else if (!strcmp(m_szSortBy, "distance")) - { + } else if (!strcmp(m_szSortBy, "distance")) { std::sort(list.begin(), list.end(), __compareWithDistance); - } - else if (!strcmp(m_szSortBy, "rate") || !strcmp(m_szSortBy, "rating")) - { + } else if (!strcmp(m_szSortBy, "rate") || !strcmp(m_szSortBy, "rating")) { std::sort(list.begin(), list.end(), __compareWithRating); - } - else if (!strcmp(m_szSortBy, "category")) - { + } else if (!strcmp(m_szSortBy, "category")) { std::sort(list.begin(), list.end(), __compareWithCategory); } } diff --git a/src/here_plugin.cpp b/src/here_plugin.cpp index 7502475..076dad8 100644 --- a/src/here_plugin.cpp +++ b/src/here_plugin.cpp @@ -24,7 +24,6 @@ extern "C" { - EXPORT_API int maps_plugin_init(maps_plugin_h *plugin) { int ret = HerePluginInit(plugin); diff --git a/src/here_revgeocode.cpp b/src/here_revgeocode.cpp index b32dd59..ea3c4b8 100644 --- a/src/here_revgeocode.cpp +++ b/src/here_revgeocode.cpp @@ -19,7 +19,7 @@ HERE_PLUGIN_BEGIN_NAMESPACE HereRevGeocode::HereRevGeocode(void* pCbFunc, void* pUserData, int nReqId) -: m_geoCoord(0,0,0) + : m_geoCoord(0, 0, 0) { m_pQuery = NULL; m_pCbFunc = pCbFunc; @@ -29,8 +29,7 @@ HereRevGeocode::HereRevGeocode(void* pCbFunc, void* pUserData, int nReqId) HereRevGeocode::~HereRevGeocode() { - if (m_pQuery) - { + if (m_pQuery) { delete m_pQuery; m_pQuery = NULL; } @@ -99,8 +98,7 @@ here_error_e HereRevGeocode::StartRevGeocode(maps_item_hashtable_h hPref) void HereRevGeocode::OnGeoCoderReply(const GeoCoderReply& Reply) { - if (m_bCanceled || !m_pCbFunc) // ignore call back - { + if (m_bCanceled || !m_pCbFunc) { // ignore call back delete this; return; } @@ -111,16 +109,13 @@ void HereRevGeocode::OnGeoCoderReply(const GeoCoderReply& Reply) float fDistance, fShortestDistance = 0; int nShortestIdx = -1; - for (size_t i = 0; i < (size_t)nResults; i++) - { + for (size_t i = 0; i < (size_t)nResults; i++) { pResult = (Result*)Reply.GetResult(i); - if(pResult) - { + if(pResult) { fDistance = pResult->GetDistance(); - if (nShortestIdx < 0 || fDistance < fShortestDistance) - { + if (nShortestIdx < 0 || fDistance < fShortestDistance) { fShortestDistance = fDistance; nShortestIdx = i; } @@ -128,8 +123,7 @@ void HereRevGeocode::OnGeoCoderReply(const GeoCoderReply& Reply) } - if (nShortestIdx < 0) - { + if (nShortestIdx < 0) { ((maps_service_reverse_geocode_cb)m_pCbFunc)(MAPS_ERROR_NOT_FOUND, m_nReqId, 0, 0, NULL, m_pUserData); delete this; @@ -140,12 +134,10 @@ void HereRevGeocode::OnGeoCoderReply(const GeoCoderReply& Reply) maps_error_e error = (maps_error_e)maps_address_create(&hAddr); String *additionalDataValue = NULL; - if(error == MAPS_ERROR_NONE) - { + if(error == MAPS_ERROR_NONE) { pResult = (Result*)Reply.GetResult(nShortestIdx); - if (pResult) - { + if (pResult) { Address tmpAddr = (pResult->GetLocation()).GetAddress(); if (!tmpAddr.GetHouseNumber().empty()) @@ -189,12 +181,9 @@ void HereRevGeocode::OnGeoCoderReply(const GeoCoderReply& Reply) } } - if (m_bCanceled) - { + if (m_bCanceled) { maps_address_destroy(hAddr); - } - else - { + } else { int nResult = (error == MAPS_ERROR_NONE ? 1 : 0); ((maps_service_reverse_geocode_cb)m_pCbFunc)(error, m_nReqId, 0, nResult, hAddr, m_pUserData); } @@ -210,4 +199,3 @@ void HereRevGeocode::OnGeoCoderFailure(const GeoCoderReply& Reply) } HERE_PLUGIN_END_NAMESPACE - diff --git a/src/here_route.cpp b/src/here_route.cpp index f166c7a..b3f2228 100644 --- a/src/here_route.cpp +++ b/src/here_route.cpp @@ -31,8 +31,7 @@ HereRoute::HereRoute(void *pCbFunc, void *pUserData, int nReqId) HereRoute::~HereRoute() { - if (m_pQuery) - { + if (m_pQuery) { delete m_pQuery; m_pQuery = NULL; } @@ -81,8 +80,7 @@ here_error_e HereRoute::PrepareWaypoint(const maps_coordinates_h* hWaypointList, GeoCoordinates hereCoord; double dLatitude, dLongitude; - for (int index = 0; index < nWaypointNum; index++) - { + for (int index = 0; index < nWaypointNum; index++) { if (hWaypointList[index] != NULL) { maps_coordinates_get_latitude(hWaypointList[index], &dLatitude); maps_coordinates_get_longitude(hWaypointList[index], &dLongitude); @@ -120,8 +118,7 @@ here_error_e HereRoute::PreparePreference(maps_preference_h hPref) /* transport mode */ maps_route_transport_mode_e eTransMode; - if (maps_preference_get_route_transport_mode(hPref, &eTransMode) == MAPS_ERROR_NONE) - { + if (maps_preference_get_route_transport_mode(hPref, &eTransMode) == MAPS_ERROR_NONE) { m_pQuery->SetTravelModes(HereUtils::Convert(eTransMode)); } @@ -129,16 +126,14 @@ here_error_e HereRoute::PreparePreference(maps_preference_h hPref) maps_route_feature_e eFeature; maps_route_feature_weight_e eFeatureWeight; if (maps_preference_get_route_feature(hPref, &eFeature) == MAPS_ERROR_NONE && - maps_preference_get_route_feature_weight(hPref, &eFeatureWeight) == MAPS_ERROR_NONE) - { + maps_preference_get_route_feature_weight(hPref, &eFeatureWeight) == MAPS_ERROR_NONE) { m_pQuery->SetFeatureWeight(HereUtils::Convert(eFeature), HereUtils::Convert(eFeatureWeight)); } /* exclude areas */ char *szAreaToAvoid; - if (maps_preference_get(hPref, MAPS_ROUTE_RECT_AREA_TO_AVOID, &szAreaToAvoid) == MAPS_ERROR_NONE) - { + if (maps_preference_get(hPref, MAPS_ROUTE_RECT_AREA_TO_AVOID, &szAreaToAvoid) == MAPS_ERROR_NONE) { GeoBoundingBox gbBox; GeoBoundingBoxList gbBoxList; gbBoxList.push_back(HereUtils::Convert(szAreaToAvoid, gbBox)); @@ -149,10 +144,8 @@ here_error_e HereRoute::PreparePreference(maps_preference_h hPref) /* optimization */ GeoRouteQuery::RouteOptimization hereOpt; maps_route_optimization_e mapsOpt; - if (maps_preference_get_route_optimization(hPref, &mapsOpt) == MAPS_ERROR_NONE) - { - switch (mapsOpt) - { + if (maps_preference_get_route_optimization(hPref, &mapsOpt) == MAPS_ERROR_NONE) { + switch (mapsOpt) { case MAPS_ROUTE_TYPE_FASTEST: hereOpt = GeoRouteQuery::RO_FastestRoute; break; case MAPS_ROUTE_TYPE_SHORTEST: hereOpt = GeoRouteQuery::RO_ShortestRoute; break; default: hereOpt = GeoRouteQuery::RO_FastestRoute; break; @@ -163,10 +156,8 @@ here_error_e HereRoute::PreparePreference(maps_preference_h hPref) /* Metric System */ GeoRouteQuery::MetricSystem eMetric; maps_distance_unit_e eUnit; - if (maps_preference_get_distance_unit(hPref, &eUnit) == MAPS_ERROR_NONE) - { - switch (eUnit) - { + if (maps_preference_get_distance_unit(hPref, &eUnit) == MAPS_ERROR_NONE) { + switch (eUnit) { case MAPS_DISTANCE_UNIT_M: eMetric = GeoRouteQuery::DIST_metric; break; case MAPS_DISTANCE_UNIT_KM: eMetric = GeoRouteQuery::DIST_metric; break; default: eMetric = GeoRouteQuery::DIST_imperial; break; @@ -176,8 +167,7 @@ here_error_e HereRoute::PreparePreference(maps_preference_h hPref) } char *szViewBounds; - if (maps_preference_get(hPref, MAPS_ROUTE_GEOMETRY_BOUNDING_BOX, &szViewBounds) == MAPS_ERROR_NONE) - { + if (maps_preference_get(hPref, MAPS_ROUTE_GEOMETRY_BOUNDING_BOX, &szViewBounds) == MAPS_ERROR_NONE) { GeoBoundingBox gbBox; HereUtils::Convert(szViewBounds, gbBox); m_pQuery->SetViewBounds(gbBox); @@ -185,27 +175,19 @@ here_error_e HereRoute::PreparePreference(maps_preference_h hPref) } bool is_alternatives_enabled = false; - if (maps_preference_get_route_alternatives_enabled(hPref, &is_alternatives_enabled) == MAPS_ERROR_NONE) - { + if (maps_preference_get_route_alternatives_enabled(hPref, &is_alternatives_enabled) == MAPS_ERROR_NONE) { if (is_alternatives_enabled) - { m_pQuery->SetAlternatives(2); - } } char *szRealtimeTraffic; if (maps_preference_get(hPref, MAPS_ROUTE_REALTIME_TRAFFIC, &szRealtimeTraffic) == MAPS_ERROR_NONE) { - if (!strcmp(szRealtimeTraffic, "true") || !strcmp(szRealtimeTraffic, "enabled")) - { + if (!strcmp(szRealtimeTraffic, "true") || !strcmp(szRealtimeTraffic, "enabled")) { m_pQuery->SetRealtimeTraffic(1); - } - else if (!strcmp(szRealtimeTraffic, "false") || !strcmp(szRealtimeTraffic, "disabled")) - { + } else if (!strcmp(szRealtimeTraffic, "false") || !strcmp(szRealtimeTraffic, "disabled")) { m_pQuery->SetRealtimeTraffic(2); - } - else - { + } else { m_pQuery->SetRealtimeTraffic(0); } g_free(szRealtimeTraffic); @@ -226,8 +208,7 @@ here_error_e HereRoute::StartRoute(void) void HereRoute::OnRouteReply(const GeoRouteReply& Reply) { - if (m_bCanceled || !m_pCbFunc || !m_pQuery) // ignore call back if it was cancelled. - { + if (m_bCanceled || !m_pCbFunc || !m_pQuery) { // ignore call back if it was cancelled. delete this; return; } @@ -238,20 +219,17 @@ void HereRoute::OnRouteReply(const GeoRouteReply& Reply) int nReplyIdx = 0, nReplyNum = hereRouteList.size(); GeoRouteList::iterator hereRoute; - if (nReplyNum == 0) - { + if (nReplyNum == 0) { ((maps_service_search_route_cb)m_pCbFunc)(MAPS_ERROR_NOT_FOUND, m_nReqId, 0, 0, NULL, m_pUserData); delete this; return; } - for (hereRoute = hereRouteList.begin() ; hereRoute != hereRouteList.end() ; hereRoute++) - { + for (hereRoute = hereRouteList.begin() ; hereRoute != hereRouteList.end() ; hereRoute++) { error = (maps_error_e)maps_route_create(&mapsRoute); - if (error == MAPS_ERROR_NONE) - { + if (error == MAPS_ERROR_NONE) { /* route id */ if (!hereRoute->GetRouteId().empty()) maps_route_set_route_id(mapsRoute, (char*)hereRoute->GetRouteId().c_str()); @@ -280,16 +258,13 @@ void HereRoute::OnRouteReply(const GeoRouteReply& Reply) maps_item_list_h mapsPathList; maps_coordinates_h mapsPath; - if (maps_item_list_create(&mapsPathList) == MAPS_ERROR_NONE) - { + if (maps_item_list_create(&mapsPathList) == MAPS_ERROR_NONE) { GeoCoordinateList::iterator herePath; - for (herePath = herePathList.begin(); herePath != herePathList.end(); herePath++) - { + for (herePath = herePathList.begin(); herePath != herePathList.end(); herePath++) { double dLat = herePath->GetLatitude(); double dLng = herePath->GetLongitude(); - if(maps_coordinates_create(dLat, dLng, &mapsPath) == MAPS_ERROR_NONE) - { + if(maps_coordinates_create(dLat, dLng, &mapsPath) == MAPS_ERROR_NONE) { if (herePath == herePathList.begin()) maps_route_set_origin(mapsRoute, mapsPath); else if (herePath == herePathList.end()-1) @@ -301,8 +276,7 @@ void HereRoute::OnRouteReply(const GeoRouteReply& Reply) } } - if (maps_item_list_items(mapsPathList)) - { + if (maps_item_list_items(mapsPathList)) { maps_route_set_path(mapsRoute, mapsPathList); maps_item_list_remove_all(mapsPathList, maps_coordinates_destroy); } @@ -312,8 +286,7 @@ void HereRoute::OnRouteReply(const GeoRouteReply& Reply) /* bounding box */ maps_area_h hMapsArea = NULL; HereUtils::Convert(hereRoute->GetBounds(), hMapsArea); - if (hMapsArea) - { + if (hMapsArea) { maps_route_set_bounding_box(mapsRoute, hMapsArea); maps_area_destroy(hMapsArea); } @@ -322,16 +295,12 @@ void HereRoute::OnRouteReply(const GeoRouteReply& Reply) ProcessSegments(mapsRoute, hereRoute->GetRouteSegmentList()); } - if (m_bCanceled) - { + if (m_bCanceled) { maps_route_destroy(mapsRoute); break; - } - else - { + } else { if (((maps_service_search_route_cb)m_pCbFunc)(error, m_nReqId, - nReplyIdx++, nReplyNum, mapsRoute, m_pUserData) == FALSE) - { + nReplyIdx++, nReplyNum, mapsRoute, m_pUserData) == FALSE) { delete this; return; } @@ -377,8 +346,7 @@ maps_error_e HereRoute::ProcessSegments(maps_route_h mapsRoute, const RouteSegme GeoCoordinateList herePathList = hereSegm->GetPath(); int here_path_list_size = herePathList.size(); - if (here_path_list_size > 0) - { + if (here_path_list_size > 0) { GeoCoordinates hereOrig = herePathList.at(0); GeoCoordinates hereDest = herePathList.at(here_path_list_size-1); @@ -400,8 +368,7 @@ maps_error_e HereRoute::ProcessSegments(maps_route_h mapsRoute, const RouteSegme maps_route_segment_destroy(mapsSegm); } - if (maps_item_list_items(mapsSegmList)) - { + if (maps_item_list_items(mapsSegmList)) { maps_route_set_segments(mapsRoute, mapsSegmList); maps_item_list_remove_all(mapsSegmList, maps_route_segment_destroy); } @@ -423,14 +390,12 @@ maps_error_e HereRoute::ProcessManeuver(maps_route_segment_h mapsSegm, const Man return error; ManeuverList::const_iterator hereMane; - for (hereMane = hereManeList.begin() ; hereMane != hereManeList.end() ; hereMane++) - { + for (hereMane = hereManeList.begin() ; hereMane != hereManeList.end() ; hereMane++) { if (maps_route_maneuver_create(&mapsManeuver) != MAPS_ERROR_NONE) continue; /* position */ if (maps_coordinates_create(hereMane->GetPosition().GetLatitude(), - hereMane->GetPosition().GetLongitude(), &mapsCoord) == MAPS_ERROR_NONE) - { + hereMane->GetPosition().GetLongitude(), &mapsCoord) == MAPS_ERROR_NONE) { maps_route_maneuver_set_position(mapsManeuver, mapsCoord); maps_coordinates_destroy(mapsCoord); } @@ -456,8 +421,7 @@ maps_error_e HereRoute::ProcessManeuver(maps_route_segment_h mapsSegm, const Man maps_route_maneuver_destroy(mapsManeuver); } - if (maps_item_list_items(mapsManeList)) - { + if (maps_item_list_items(mapsManeList)) { maps_route_segment_set_maneuvers(mapsSegm, mapsManeList); maps_item_list_remove_all(mapsManeList, maps_route_maneuver_destroy); } diff --git a/src/here_utils.cpp b/src/here_utils.cpp index 8ac5c74..f2ae864 100644 --- a/src/here_utils.cpp +++ b/src/here_utils.cpp @@ -26,88 +26,84 @@ extern "C" { int ConvertToMapsError(int nErr) { - switch (nErr) - { - case HERE_ERROR_NONE: return MAPS_ERROR_NONE; - case HERE_ERROR_PERMISSION_DENIED: return MAPS_ERROR_PERMISSION_DENIED; - case HERE_ERROR_OUT_OF_MEMORY: return MAPS_ERROR_OUT_OF_MEMORY; - case HERE_ERROR_INVALID_PARAMETER: return MAPS_ERROR_INVALID_PARAMETER; - case HERE_ERROR_NOT_SUPPORTED: return MAPS_ERROR_NOT_SUPPORTED; - case HERE_ERROR_CONNECTION_TIME_OUT: return MAPS_ERROR_CONNECTION_TIME_OUT; - case HERE_ERROR_NETWORK_UNREACHABLE: return MAPS_ERROR_NETWORK_UNREACHABLE; - case HERE_ERROR_INVALID_OPERATION: return MAPS_ERROR_INVALID_OPERATION; - case HERE_ERROR_KEY_NOT_AVAILABLE: return MAPS_ERROR_KEY_NOT_AVAILABLE; - case HERE_ERROR_RESOURCE_BUSY: return MAPS_ERROR_RESOURCE_BUSY; - case HERE_ERROR_CANCELED: return MAPS_ERROR_CANCELED; - case HERE_ERROR_UNKNOWN: return MAPS_ERROR_UNKNOWN; - case HERE_ERROR_SERVICE_NOT_AVAILABLE: return MAPS_ERROR_SERVICE_NOT_AVAILABLE; - case HERE_ERROR_NOT_FOUND: return MAPS_ERROR_NOT_FOUND; + switch (nErr) { + case HERE_ERROR_NONE: return MAPS_ERROR_NONE; + case HERE_ERROR_PERMISSION_DENIED: return MAPS_ERROR_PERMISSION_DENIED; + case HERE_ERROR_OUT_OF_MEMORY: return MAPS_ERROR_OUT_OF_MEMORY; + case HERE_ERROR_INVALID_PARAMETER: return MAPS_ERROR_INVALID_PARAMETER; + case HERE_ERROR_NOT_SUPPORTED: return MAPS_ERROR_NOT_SUPPORTED; + case HERE_ERROR_CONNECTION_TIME_OUT: return MAPS_ERROR_CONNECTION_TIME_OUT; + case HERE_ERROR_NETWORK_UNREACHABLE: return MAPS_ERROR_NETWORK_UNREACHABLE; + case HERE_ERROR_INVALID_OPERATION: return MAPS_ERROR_INVALID_OPERATION; + case HERE_ERROR_KEY_NOT_AVAILABLE: return MAPS_ERROR_KEY_NOT_AVAILABLE; + case HERE_ERROR_RESOURCE_BUSY: return MAPS_ERROR_RESOURCE_BUSY; + case HERE_ERROR_CANCELED: return MAPS_ERROR_CANCELED; + case HERE_ERROR_UNKNOWN: return MAPS_ERROR_UNKNOWN; + case HERE_ERROR_SERVICE_NOT_AVAILABLE: return MAPS_ERROR_SERVICE_NOT_AVAILABLE; + case HERE_ERROR_NOT_FOUND: return MAPS_ERROR_NOT_FOUND; } return MAPS_ERROR_UNKNOWN; } int ConvertToHereError(int nErr) { - switch (nErr) - { - case MAPS_ERROR_NONE: return HERE_ERROR_NONE; - case MAPS_ERROR_PERMISSION_DENIED: return HERE_ERROR_PERMISSION_DENIED; - case MAPS_ERROR_OUT_OF_MEMORY: return HERE_ERROR_OUT_OF_MEMORY; - case MAPS_ERROR_INVALID_PARAMETER: return HERE_ERROR_INVALID_PARAMETER; - case MAPS_ERROR_NOT_SUPPORTED: return HERE_ERROR_NOT_SUPPORTED; - case MAPS_ERROR_CONNECTION_TIME_OUT: return HERE_ERROR_CONNECTION_TIME_OUT; - case MAPS_ERROR_NETWORK_UNREACHABLE: return HERE_ERROR_NETWORK_UNREACHABLE; - case MAPS_ERROR_INVALID_OPERATION: return HERE_ERROR_INVALID_OPERATION; - case MAPS_ERROR_KEY_NOT_AVAILABLE: return HERE_ERROR_KEY_NOT_AVAILABLE; - case MAPS_ERROR_RESOURCE_BUSY: return HERE_ERROR_RESOURCE_BUSY; - case MAPS_ERROR_CANCELED: return HERE_ERROR_CANCELED; - case MAPS_ERROR_UNKNOWN: return HERE_ERROR_UNKNOWN; - case MAPS_ERROR_SERVICE_NOT_AVAILABLE: return HERE_ERROR_SERVICE_NOT_AVAILABLE; - case MAPS_ERROR_NOT_FOUND: return HERE_ERROR_NOT_FOUND; + switch (nErr) { + case MAPS_ERROR_NONE: return HERE_ERROR_NONE; + case MAPS_ERROR_PERMISSION_DENIED: return HERE_ERROR_PERMISSION_DENIED; + case MAPS_ERROR_OUT_OF_MEMORY: return HERE_ERROR_OUT_OF_MEMORY; + case MAPS_ERROR_INVALID_PARAMETER: return HERE_ERROR_INVALID_PARAMETER; + case MAPS_ERROR_NOT_SUPPORTED: return HERE_ERROR_NOT_SUPPORTED; + case MAPS_ERROR_CONNECTION_TIME_OUT: return HERE_ERROR_CONNECTION_TIME_OUT; + case MAPS_ERROR_NETWORK_UNREACHABLE: return HERE_ERROR_NETWORK_UNREACHABLE; + case MAPS_ERROR_INVALID_OPERATION: return HERE_ERROR_INVALID_OPERATION; + case MAPS_ERROR_KEY_NOT_AVAILABLE: return HERE_ERROR_KEY_NOT_AVAILABLE; + case MAPS_ERROR_RESOURCE_BUSY: return HERE_ERROR_RESOURCE_BUSY; + case MAPS_ERROR_CANCELED: return HERE_ERROR_CANCELED; + case MAPS_ERROR_UNKNOWN: return HERE_ERROR_UNKNOWN; + case MAPS_ERROR_SERVICE_NOT_AVAILABLE: return HERE_ERROR_SERVICE_NOT_AVAILABLE; + case MAPS_ERROR_NOT_FOUND: return HERE_ERROR_NOT_FOUND; } return HERE_ERROR_UNKNOWN; } const char* ConverHereErrorToString(int nErr) { - switch (nErr) - { - case HERE_ERROR_NONE: return "No errors"; - case HERE_ERROR_PERMISSION_DENIED: return "Permission denied"; - case HERE_ERROR_OUT_OF_MEMORY: return "Out of memory"; - case HERE_ERROR_INVALID_PARAMETER: return "Invalid Parameter"; - case HERE_ERROR_NOT_SUPPORTED: return "Not suppoerted"; - case HERE_ERROR_CONNECTION_TIME_OUT: return "Connection time out"; - case HERE_ERROR_NETWORK_UNREACHABLE: return "Network unreachable"; - case HERE_ERROR_INVALID_OPERATION: return "Invalid operation"; - case HERE_ERROR_KEY_NOT_AVAILABLE: return "Key not available"; - case HERE_ERROR_RESOURCE_BUSY: return "Resource busy"; - case HERE_ERROR_CANCELED: return "Canceled"; - case HERE_ERROR_UNKNOWN: return "Unknown"; - case HERE_ERROR_SERVICE_NOT_AVAILABLE: return "Service not available"; - case HERE_ERROR_NOT_FOUND: return "Not found"; + switch (nErr) { + case HERE_ERROR_NONE: return "No errors"; + case HERE_ERROR_PERMISSION_DENIED: return "Permission denied"; + case HERE_ERROR_OUT_OF_MEMORY: return "Out of memory"; + case HERE_ERROR_INVALID_PARAMETER: return "Invalid Parameter"; + case HERE_ERROR_NOT_SUPPORTED: return "Not suppoerted"; + case HERE_ERROR_CONNECTION_TIME_OUT: return "Connection time out"; + case HERE_ERROR_NETWORK_UNREACHABLE: return "Network unreachable"; + case HERE_ERROR_INVALID_OPERATION: return "Invalid operation"; + case HERE_ERROR_KEY_NOT_AVAILABLE: return "Key not available"; + case HERE_ERROR_RESOURCE_BUSY: return "Resource busy"; + case HERE_ERROR_CANCELED: return "Canceled"; + case HERE_ERROR_UNKNOWN: return "Unknown"; + case HERE_ERROR_SERVICE_NOT_AVAILABLE: return "Service not available"; + case HERE_ERROR_NOT_FOUND: return "Not found"; } return "Unknown"; } const char* ConvertMapsErrorToChar(int nErr) { - switch (nErr) - { - case MAPS_ERROR_NONE: return "MAPS_ERROR_NONE"; - case MAPS_ERROR_PERMISSION_DENIED: return "MAPS_ERROR_PERMISSION_DENIED"; - case MAPS_ERROR_OUT_OF_MEMORY: return "MAPS_ERROR_OUT_OF_MEMORY"; - case MAPS_ERROR_INVALID_PARAMETER: return "MAPS_ERROR_INVALID_PARAMETER"; - case MAPS_ERROR_NOT_SUPPORTED: return "MAPS_ERROR_NOT_SUPPORTED"; - case MAPS_ERROR_CONNECTION_TIME_OUT: return "MAPS_ERROR_CONNECTION_TIME_OUT"; - case MAPS_ERROR_NETWORK_UNREACHABLE: return "MAPS_ERROR_NETWORK_UNREACHABLE"; - case MAPS_ERROR_INVALID_OPERATION: return "MAPS_ERROR_INVALID_OPERATION"; - case MAPS_ERROR_KEY_NOT_AVAILABLE: return "MAPS_ERROR_KEY_NOT_AVAILABLE"; - case MAPS_ERROR_RESOURCE_BUSY: return "MAPS_ERROR_RESOURCE_BUSY"; - case MAPS_ERROR_CANCELED: return "MAPS_ERROR_CANCELED"; - case MAPS_ERROR_UNKNOWN: return "MAPS_ERROR_UNKNOWN"; - case MAPS_ERROR_SERVICE_NOT_AVAILABLE: return "MAPS_ERROR_SERVICE_NOT_AVAILABLE"; - case MAPS_ERROR_NOT_FOUND: return "MAPS_ERROR_NOT_FOUND"; + switch (nErr) { + case MAPS_ERROR_NONE: return "MAPS_ERROR_NONE"; + case MAPS_ERROR_PERMISSION_DENIED: return "MAPS_ERROR_PERMISSION_DENIED"; + case MAPS_ERROR_OUT_OF_MEMORY: return "MAPS_ERROR_OUT_OF_MEMORY"; + case MAPS_ERROR_INVALID_PARAMETER: return "MAPS_ERROR_INVALID_PARAMETER"; + case MAPS_ERROR_NOT_SUPPORTED: return "MAPS_ERROR_NOT_SUPPORTED"; + case MAPS_ERROR_CONNECTION_TIME_OUT: return "MAPS_ERROR_CONNECTION_TIME_OUT"; + case MAPS_ERROR_NETWORK_UNREACHABLE: return "MAPS_ERROR_NETWORK_UNREACHABLE"; + case MAPS_ERROR_INVALID_OPERATION: return "MAPS_ERROR_INVALID_OPERATION"; + case MAPS_ERROR_KEY_NOT_AVAILABLE: return "MAPS_ERROR_KEY_NOT_AVAILABLE"; + case MAPS_ERROR_RESOURCE_BUSY: return "MAPS_ERROR_RESOURCE_BUSY"; + case MAPS_ERROR_CANCELED: return "MAPS_ERROR_CANCELED"; + case MAPS_ERROR_UNKNOWN: return "MAPS_ERROR_UNKNOWN"; + case MAPS_ERROR_SERVICE_NOT_AVAILABLE: return "MAPS_ERROR_SERVICE_NOT_AVAILABLE"; + case MAPS_ERROR_NOT_FOUND: return "MAPS_ERROR_NOT_FOUND"; } return "MAPS_ERROR_UNKNOWN"; } @@ -126,150 +122,142 @@ HereUtils::~HereUtils() GeoRouteQuery::TravelMode HereUtils::Convert(maps_route_transport_mode_e nVal) { - switch (nVal) - { - case MAPS_ROUTE_TRANSPORT_MODE_CAR: return GeoRouteQuery::TM_CarTravel; - case MAPS_ROUTE_TRANSPORT_MODE_PEDESTRIAN: return GeoRouteQuery::TM_PedestrianTravel; - case MAPS_ROUTE_TRANSPORT_MODE_PUBLICTRANSIT: return GeoRouteQuery::TM_PublicTransitTravel; - default: break; + switch (nVal) { + case MAPS_ROUTE_TRANSPORT_MODE_CAR: return GeoRouteQuery::TM_CarTravel; + case MAPS_ROUTE_TRANSPORT_MODE_PEDESTRIAN: return GeoRouteQuery::TM_PedestrianTravel; + case MAPS_ROUTE_TRANSPORT_MODE_PUBLICTRANSIT: return GeoRouteQuery::TM_PublicTransitTravel; + default: break; } return GeoRouteQuery::TM_CarTravel; } maps_route_transport_mode_e HereUtils::Convert(GeoRouteQuery::TravelMode nVal) { - switch (nVal) - { - case GeoRouteQuery::TM_CarTravel: return MAPS_ROUTE_TRANSPORT_MODE_CAR; - case GeoRouteQuery::TM_PedestrianTravel: return MAPS_ROUTE_TRANSPORT_MODE_PEDESTRIAN; - case GeoRouteQuery::TM_PublicTransitTravel: return MAPS_ROUTE_TRANSPORT_MODE_PUBLICTRANSIT; - default: break; + switch (nVal) { + case GeoRouteQuery::TM_CarTravel: return MAPS_ROUTE_TRANSPORT_MODE_CAR; + case GeoRouteQuery::TM_PedestrianTravel: return MAPS_ROUTE_TRANSPORT_MODE_PEDESTRIAN; + case GeoRouteQuery::TM_PublicTransitTravel: return MAPS_ROUTE_TRANSPORT_MODE_PUBLICTRANSIT; + default: break; } return MAPS_ROUTE_TRANSPORT_MODE_CAR; } GeoRouteQuery::FeatureType HereUtils::Convert(maps_route_feature_e nVal) { - switch (nVal) - { - case MAPS_ROUTE_FEATURE_NO: return GeoRouteQuery::FT_NoFeature; - case MAPS_ROUTE_FEATURE_TOLL: return GeoRouteQuery::FT_TollFeature; - case MAPS_ROUTE_FEATURE_MOTORWAY: return GeoRouteQuery::FT_MotorwayFeature; - case MAPS_ROUTE_FEATURE_BOATFERRY: return GeoRouteQuery::FT_BoatFerryFeature; - case MAPS_ROUTE_FEATURE_RAILFERRY: return GeoRouteQuery::FT_RailFerryFeature; - case MAPS_ROUTE_FEATURE_PUBLICTTRANSIT: return GeoRouteQuery::FT_PublicTransitFeature; - case MAPS_ROUTE_FEATURE_TUNNEL: return GeoRouteQuery::FT_TunnelFeature; - case MAPS_ROUTE_FEATURE_DIRTROAD: return GeoRouteQuery::FT_DirtRoadFeature; - case MAPS_ROUTE_FEATURE_PARKS: return GeoRouteQuery::FT_ParksFeature; - case MAPS_ROUTE_FEATURE_HOVLANE: return GeoRouteQuery::FT_HOVLane; - case MAPS_ROUTE_FEATURE_STAIRS: return GeoRouteQuery::FT_Stairs; - default: break; + switch (nVal) { + case MAPS_ROUTE_FEATURE_NO: return GeoRouteQuery::FT_NoFeature; + case MAPS_ROUTE_FEATURE_TOLL: return GeoRouteQuery::FT_TollFeature; + case MAPS_ROUTE_FEATURE_MOTORWAY: return GeoRouteQuery::FT_MotorwayFeature; + case MAPS_ROUTE_FEATURE_BOATFERRY: return GeoRouteQuery::FT_BoatFerryFeature; + case MAPS_ROUTE_FEATURE_RAILFERRY: return GeoRouteQuery::FT_RailFerryFeature; + case MAPS_ROUTE_FEATURE_PUBLICTTRANSIT: return GeoRouteQuery::FT_PublicTransitFeature; + case MAPS_ROUTE_FEATURE_TUNNEL: return GeoRouteQuery::FT_TunnelFeature; + case MAPS_ROUTE_FEATURE_DIRTROAD: return GeoRouteQuery::FT_DirtRoadFeature; + case MAPS_ROUTE_FEATURE_PARKS: return GeoRouteQuery::FT_ParksFeature; + case MAPS_ROUTE_FEATURE_HOVLANE: return GeoRouteQuery::FT_HOVLane; + case MAPS_ROUTE_FEATURE_STAIRS: return GeoRouteQuery::FT_Stairs; + default: break; } return GeoRouteQuery::FT_NoFeature; } GeoRouteQuery::FeatureWeight HereUtils::Convert(maps_route_feature_weight_e nVal) { - switch (nVal) - { - case MAPS_ROUTE_FEATURE_WEIGHT_NORMAL: return GeoRouteQuery::FW_NormalFeatureWeight; - case MAPS_ROUTE_FEATURE_WEIGHT_PREFER: return GeoRouteQuery::FW_PreferFeatureWeight; - case MAPS_ROUTE_FEATURE_WEIGHT_AVOID: return GeoRouteQuery::FW_AvoidFeatureWeight; - case MAPS_ROUTE_FEATURE_WEIGHT_SOFTEXCLUDE: return GeoRouteQuery::FW_SoftExcludeFeatureWeight; - case MAPS_ROUTE_FEATURE_WEIGHT_STRICTEXCLUDE: return GeoRouteQuery::FW_StrictExcludeFeatureWeight; - default: break; + switch (nVal) { + case MAPS_ROUTE_FEATURE_WEIGHT_NORMAL: return GeoRouteQuery::FW_NormalFeatureWeight; + case MAPS_ROUTE_FEATURE_WEIGHT_PREFER: return GeoRouteQuery::FW_PreferFeatureWeight; + case MAPS_ROUTE_FEATURE_WEIGHT_AVOID: return GeoRouteQuery::FW_AvoidFeatureWeight; + case MAPS_ROUTE_FEATURE_WEIGHT_SOFTEXCLUDE: return GeoRouteQuery::FW_SoftExcludeFeatureWeight; + case MAPS_ROUTE_FEATURE_WEIGHT_STRICTEXCLUDE: return GeoRouteQuery::FW_StrictExcludeFeatureWeight; + default: break; } return GeoRouteQuery::FW_NormalFeatureWeight; } maps_route_turn_type_e HereUtils::Convert(Maneuver::InstructionDirection nVal) { - switch (nVal) - { - case Maneuver::ID_NoDirection: return MAPS_ROUTE_TURN_TYPE_NONE; - case Maneuver::ID_DirectionForward: return MAPS_ROUTE_TURN_TYPE_STRAIGHT; - case Maneuver::ID_DirectionBearRight: return MAPS_ROUTE_TURN_TYPE_BEAR_RIGHT; - case Maneuver::ID_DirectionLightRight: return MAPS_ROUTE_TURN_TYPE_LIGHT_RIGHT; - case Maneuver::ID_DirectionRight: return MAPS_ROUTE_TURN_TYPE_RIGHT; - case Maneuver::ID_DirectionHardRight: return MAPS_ROUTE_TURN_TYPE_HARD_RIGHT; - case Maneuver::ID_DirectionUTurnRight: return MAPS_ROUTE_TURN_TYPE_UTURN_RIGHT; - case Maneuver::ID_DirectionUTurnLeft: return MAPS_ROUTE_TURN_TYPE_UTURN_LEFT; - case Maneuver::ID_DirectionHardLeft: return MAPS_ROUTE_TURN_TYPE_HARD_LEFT; - case Maneuver::ID_DirectionLeft: return MAPS_ROUTE_TURN_TYPE_LEFT; - case Maneuver::ID_DirectionLightLeft: return MAPS_ROUTE_TURN_TYPE_LIGHT_LEFT; - case Maneuver::ID_DirectionBearLeft: return MAPS_ROUTE_TURN_TYPE_BEAR_LEFT; - default: break; + switch (nVal) { + case Maneuver::ID_NoDirection: return MAPS_ROUTE_TURN_TYPE_NONE; + case Maneuver::ID_DirectionForward: return MAPS_ROUTE_TURN_TYPE_STRAIGHT; + case Maneuver::ID_DirectionBearRight: return MAPS_ROUTE_TURN_TYPE_BEAR_RIGHT; + case Maneuver::ID_DirectionLightRight: return MAPS_ROUTE_TURN_TYPE_LIGHT_RIGHT; + case Maneuver::ID_DirectionRight: return MAPS_ROUTE_TURN_TYPE_RIGHT; + case Maneuver::ID_DirectionHardRight: return MAPS_ROUTE_TURN_TYPE_HARD_RIGHT; + case Maneuver::ID_DirectionUTurnRight: return MAPS_ROUTE_TURN_TYPE_UTURN_RIGHT; + case Maneuver::ID_DirectionUTurnLeft: return MAPS_ROUTE_TURN_TYPE_UTURN_LEFT; + case Maneuver::ID_DirectionHardLeft: return MAPS_ROUTE_TURN_TYPE_HARD_LEFT; + case Maneuver::ID_DirectionLeft: return MAPS_ROUTE_TURN_TYPE_LEFT; + case Maneuver::ID_DirectionLightLeft: return MAPS_ROUTE_TURN_TYPE_LIGHT_LEFT; + case Maneuver::ID_DirectionBearLeft: return MAPS_ROUTE_TURN_TYPE_BEAR_LEFT; + default: break; } return MAPS_ROUTE_TURN_TYPE_NONE; } Maneuver::InstructionDirection HereUtils::Convert(maps_route_turn_type_e nVal) { - switch (nVal) - { - case MAPS_ROUTE_TURN_TYPE_NONE: return Maneuver::ID_NoDirection; - case MAPS_ROUTE_TURN_TYPE_STRAIGHT: return Maneuver::ID_DirectionForward; - case MAPS_ROUTE_TURN_TYPE_BEAR_RIGHT: return Maneuver::ID_DirectionBearRight; - case MAPS_ROUTE_TURN_TYPE_LIGHT_RIGHT: return Maneuver::ID_DirectionLightRight; - case MAPS_ROUTE_TURN_TYPE_RIGHT: return Maneuver::ID_DirectionRight; - case MAPS_ROUTE_TURN_TYPE_HARD_RIGHT: return Maneuver::ID_DirectionHardRight; - case MAPS_ROUTE_TURN_TYPE_UTURN_RIGHT: return Maneuver::ID_DirectionUTurnRight; - case MAPS_ROUTE_TURN_TYPE_UTURN_LEFT: return Maneuver::ID_DirectionUTurnLeft; - case MAPS_ROUTE_TURN_TYPE_HARD_LEFT: return Maneuver::ID_DirectionHardLeft; - case MAPS_ROUTE_TURN_TYPE_LEFT: return Maneuver::ID_DirectionLeft; - case MAPS_ROUTE_TURN_TYPE_LIGHT_LEFT: return Maneuver::ID_DirectionLightLeft; - case MAPS_ROUTE_TURN_TYPE_BEAR_LEFT: return Maneuver::ID_DirectionBearLeft; - default: break; + switch (nVal) { + case MAPS_ROUTE_TURN_TYPE_NONE: return Maneuver::ID_NoDirection; + case MAPS_ROUTE_TURN_TYPE_STRAIGHT: return Maneuver::ID_DirectionForward; + case MAPS_ROUTE_TURN_TYPE_BEAR_RIGHT: return Maneuver::ID_DirectionBearRight; + case MAPS_ROUTE_TURN_TYPE_LIGHT_RIGHT: return Maneuver::ID_DirectionLightRight; + case MAPS_ROUTE_TURN_TYPE_RIGHT: return Maneuver::ID_DirectionRight; + case MAPS_ROUTE_TURN_TYPE_HARD_RIGHT: return Maneuver::ID_DirectionHardRight; + case MAPS_ROUTE_TURN_TYPE_UTURN_RIGHT: return Maneuver::ID_DirectionUTurnRight; + case MAPS_ROUTE_TURN_TYPE_UTURN_LEFT: return Maneuver::ID_DirectionUTurnLeft; + case MAPS_ROUTE_TURN_TYPE_HARD_LEFT: return Maneuver::ID_DirectionHardLeft; + case MAPS_ROUTE_TURN_TYPE_LEFT: return Maneuver::ID_DirectionLeft; + case MAPS_ROUTE_TURN_TYPE_LIGHT_LEFT: return Maneuver::ID_DirectionLightLeft; + case MAPS_ROUTE_TURN_TYPE_BEAR_LEFT: return Maneuver::ID_DirectionBearLeft; + default: break; } return Maneuver::ID_NoDirection; } GeoTiledMap::MapType HereUtils::Convert(maps_view_type_e nMapType, bool bBuildings, bool bTraffic, bool bPublicTransit) { - switch (nMapType) - { - case MAPS_VIEW_TYPE_NORMAL: - if (bPublicTransit) return GeoTiledMap::MT_Normal_Day_Transit; - if (bTraffic) return GeoTiledMap::MT_Normal_Traffic_Day; - return GeoTiledMap::MT_Normal_Day; - case MAPS_VIEW_TYPE_SATELLITE: - return GeoTiledMap::MT_Satellite_Day; - case MAPS_VIEW_TYPE_TERRAIN: - return GeoTiledMap::MT_Terrain_Day; - case MAPS_VIEW_TYPE_HYBRID: - if (bPublicTransit) return GeoTiledMap::MT_Hybrid_Day_Transit; - if (bTraffic) return GeoTiledMap::MT_Hybrid_Traffic_Day; - return GeoTiledMap::MT_Hybrid_Day; - default: break; + switch (nMapType) { + case MAPS_VIEW_TYPE_NORMAL: + if (bPublicTransit) return GeoTiledMap::MT_Normal_Day_Transit; + if (bTraffic) return GeoTiledMap::MT_Normal_Traffic_Day; + return GeoTiledMap::MT_Normal_Day; + case MAPS_VIEW_TYPE_SATELLITE: + return GeoTiledMap::MT_Satellite_Day; + case MAPS_VIEW_TYPE_TERRAIN: + return GeoTiledMap::MT_Terrain_Day; + case MAPS_VIEW_TYPE_HYBRID: + if (bPublicTransit) return GeoTiledMap::MT_Hybrid_Day_Transit; + if (bTraffic) return GeoTiledMap::MT_Hybrid_Traffic_Day; + return GeoTiledMap::MT_Hybrid_Day; + default: break; } return GeoTiledMap::MT_Normal_Day; } maps_error_e HereUtils::ConvertHttpCodeToMapsError(int nVal) { - switch (nVal) - { - case 200:/*Ok*/ return MAPS_ERROR_NONE; - case 408:/*Request timeout*/ - case 504:/*Gateway timeout*/ - case 598:/*Network reading timeout*/ - case 599:/*Network connection timeout*/ return MAPS_ERROR_CONNECTION_TIME_OUT; - - case 404:/*Not found*/ - case 407:/*Proxy auth. required*/ - case 502:/*Bad gateway*/ return MAPS_ERROR_NETWORK_UNREACHABLE; - - case 401:/*Unauthorized*/ - case 402:/*Payment required*/ return MAPS_ERROR_KEY_NOT_AVAILABLE; - - case 405:/*Method not allowed*/ - case 413:/*Request entity too larget*/ - case 414:/*Request uri too large*/ return MAPS_ERROR_INVALID_OPERATION; - - case 403:/*Forbidden*/ - case 500:/*Server internal error*/ - case 501:/*Not implemented*/ - case 503:/*Service unavailable*/ return MAPS_ERROR_SERVICE_NOT_AVAILABLE; + switch (nVal) { + case 200:/*Ok*/ return MAPS_ERROR_NONE; + case 408:/*Request timeout*/ + case 504:/*Gateway timeout*/ + case 598:/*Network reading timeout*/ + case 599:/*Network connection timeout*/ return MAPS_ERROR_CONNECTION_TIME_OUT; + + case 404:/*Not found*/ + case 407:/*Proxy auth. required*/ + case 502:/*Bad gateway*/ return MAPS_ERROR_NETWORK_UNREACHABLE; + + case 401:/*Unauthorized*/ + case 402:/*Payment required*/ return MAPS_ERROR_KEY_NOT_AVAILABLE; + + case 405:/*Method not allowed*/ + case 413:/*Request entity too larget*/ + case 414:/*Request uri too large*/ return MAPS_ERROR_INVALID_OPERATION; + + case 403:/*Forbidden*/ + case 500:/*Server internal error*/ + case 501:/*Not implemented*/ + case 503:/*Service unavailable*/ return MAPS_ERROR_SERVICE_NOT_AVAILABLE; } if (nVal > 0 && nVal < 100) // curl error code @@ -349,8 +337,7 @@ GeoBoundingBox& HereUtils::Convert(const char *src, GeoBoundingBox &box) double coord[4] = { 0.0, }; token = strtok_r((char*)src, ",;", &next); - while (token && i < 4) - { + while (token && i < 4) { coord[i++] = atof(token); token = strtok_r(NULL, ",;", &next); } @@ -377,17 +364,14 @@ bool HereUtils::IsValidCoord(double dLat, double dLng) bool HereUtils::IsValid(maps_area_s hArea) { - if (hArea.type == MAPS_AREA_RECTANGLE) - { + if (hArea.type == MAPS_AREA_RECTANGLE) { return (HereUtils::IsValid(hArea.rect.top_left) && HereUtils::IsValid(hArea.rect.bottom_right)); - } - else if(hArea.type == MAPS_AREA_CIRCLE) - { + } else if (hArea.type == MAPS_AREA_CIRCLE) { return HereUtils::IsValid(hArea.circle.center); - } - else + } else { return false; + } } const double HereUtils::ConvertDistance(const double originValue, maps_distance_unit_e destUnit) diff --git a/src/here_view.cpp b/src/here_view.cpp index f9c4d6e..0caa3bc 100755 --- a/src/here_view.cpp +++ b/src/here_view.cpp @@ -56,31 +56,31 @@ HereView::~HereView() { } -here_error_e HereView::Init(maps_view_h hView, maps_plugin_map_view_ready_cb pCbFunc) +here_error_e HereView::init(maps_view_h view, maps_plugin_map_view_ready_cb callback) { - if (!hView) + if (!view) return HERE_ERROR_INVALID_PARAMETER; - __idler = ecore_idler_add(__idlerCb, (void*)hView); + __idler = ecore_idler_add(__idlerCb, (void*)view); here_error_e error = HERE_ERROR_NONE; int error2 = MAPS_ERROR_NONE; do { - error2 = maps_view_get_viewport(hView, &__img); + error2 = maps_view_get_viewport(view, &__img); if (error2 != MAPS_ERROR_NONE) break; - error2 = maps_view_get_screen_location(hView, &__x, &__y, &__w, &__h); + error2 = maps_view_get_screen_location(view, &__x, &__y, &__w, &__h); if (error2 != MAPS_ERROR_NONE) break; - error = __initOpenGL(); + error = initOpenGL(); if (error != HERE_ERROR_NONE) break; - error = __initOpenGLSurface(hView); + error = initOpenGLSurface(view); if (error != HERE_ERROR_NONE) break; - error = __initMap(hView, pCbFunc); - } while(0); + error = initMap(view, callback); + } while (0); if (error == HERE_ERROR_NONE && error2 != MAPS_ERROR_NONE) error = (here_error_e)ConvertToHereError(error2); @@ -88,7 +88,7 @@ here_error_e HereView::Init(maps_view_h hView, maps_plugin_map_view_ready_cb pCb return error; } -here_error_e HereView::__initOpenGL() +here_error_e HereView::initOpenGL() { __cfg = evas_gl_config_new(); if (!__cfg) { @@ -122,9 +122,9 @@ here_error_e HereView::__initOpenGL() return HERE_ERROR_NONE; } -here_error_e HereView::__initOpenGLSurface(maps_view_h hView) +here_error_e HereView::initOpenGLSurface(maps_view_h view) { - if (!hView || !__gl || !__cfg || !__img || !__ctx) + if (!view || !__gl || !__cfg || !__img || !__ctx) return HERE_ERROR_INVALID_PARAMETER; evas_object_image_pixels_get_callback_set(__img, NULL, NULL); @@ -155,35 +155,35 @@ here_error_e HereView::__initOpenGLSurface(maps_view_h hView) } evas_object_image_native_surface_set(__img, &ns); - evas_object_image_pixels_get_callback_set(__img, __pixelGetCb, hView); + evas_object_image_pixels_get_callback_set(__img, __pixelGetCb, view); __isInitialized = true; return HERE_ERROR_NONE; } -here_error_e HereView::__initMap(maps_view_h hView, maps_plugin_map_view_ready_cb pCbFunc) +here_error_e HereView::initMap(maps_view_h view, maps_plugin_map_view_ready_cb callback) { - if (!hView) + if (!view) return HERE_ERROR_INVALID_PARAMETER; __map = new (std::nothrow) GeoTiledMap(); if (!__map) return HERE_ERROR_OUT_OF_MEMORY; - __readyCb = pCbFunc; + __readyCb = callback; - __map->SetReadyMapSignal((GeoTiledMap::ReadyMapSignalFunctor)__readyMapCb, (void *)hView); + __map->SetReadyMapSignal((GeoTiledMap::ReadyMapSignalFunctor)__readyMapCb, (void *)view); __map->SetEvasGlApi(__api); - __map->SetMapSize(Dimension(__w,__h)); + __map->SetMapSize(Dimension(__w, __h)); __visualObjects.set(__map, evas_object_evas_get(__img)); return HERE_ERROR_NONE; } -here_error_e HereView::Close(maps_view_h hView) +here_error_e HereView::close(maps_view_h view) { - if (!hView) + if (!view) return HERE_ERROR_INVALID_PARAMETER; __isInitialized = false; @@ -250,23 +250,23 @@ void HereView::__renderingCb(void *data) evas_object_image_pixels_dirty_set((Evas_Object*)data, EINA_TRUE); } -void HereView::__setMapType(maps_view_h hView) +void HereView::setMapType(maps_view_h view) { - if (!hView) + if (!view) return; /* When the theme is changed, clear cache */ maps_view_type_e map_type; - maps_view_get_type(hView, &map_type); + maps_view_get_type(view, &map_type); bool buildings_enabled = false; - maps_view_get_buildings_enabled(hView, &buildings_enabled); + maps_view_get_buildings_enabled(view, &buildings_enabled); bool traffic_enabled = false; - maps_view_get_traffic_enabled(hView, &traffic_enabled); + maps_view_get_traffic_enabled(view, &traffic_enabled); bool public_transit_enabled = false; - maps_view_get_public_transit_enabled(hView, &public_transit_enabled); + maps_view_get_public_transit_enabled(view, &public_transit_enabled); GeoTiledMap::MapType hereMapType = HereUtils::Convert(map_type, buildings_enabled, traffic_enabled, public_transit_enabled); @@ -282,33 +282,32 @@ void HereView::__setMapType(maps_view_h hView) } } -here_error_e HereView::RenderMap(maps_view_h hView, const maps_coordinates_h mapsCoord, double dZoom, double dAngle) +here_error_e HereView::renderMap(maps_view_h view, const maps_coordinates_h coord, double zoom, double angle) { - if (!hView || !mapsCoord) + if (!view || !coord) return HERE_ERROR_INVALID_PARAMETER; if (!__isInitialized || !__map || !__api) return HERE_ERROR_SERVICE_NOT_AVAILABLE; /* set map type */ - __setMapType(hView); + setMapType(view); /* resize window */ int x, y, w, h; - maps_view_get_screen_location(hView, &x, &y, &w, &h); + maps_view_get_screen_location(view, &x, &y, &w, &h); __w = MAX(__w, 1); __h = MAX(__h, 1); - if (x != __x || y != __y || w != __w || h != __h) - { + if (x != __x || y != __y || w != __w || h != __h) { __x = x; __y = y; __w = w; __h = h; __api->glViewport(0, 0, __w, __h); - __map->SetMapSize(Dimension(__w,__h)); - __initOpenGLSurface(hView); + __map->SetMapSize(Dimension(__w, __h)); + initOpenGLSurface(view); } /* callback */ @@ -316,22 +315,21 @@ here_error_e HereView::RenderMap(maps_view_h hView, const maps_coordinates_h map __map->SetUpdateMapSignal(callback); /* zoom level */ - if (__map->GetZoomLevel() != dZoom) - { - __zoom = dZoom; - __map->SetZoomLevel(dZoom, false); + if (__map->GetZoomLevel() != zoom) { + __zoom = zoom; + __map->SetZoomLevel(zoom, false); } /* angle */ - if (__angle != dAngle) { - __angle = dAngle; - __map->SetAngle(dAngle); + if (__angle != angle) { + __angle = angle; + __map->SetAngle(angle); } /* center */ double lat, lng; - maps_coordinates_get_latitude(mapsCoord, &lat); - maps_coordinates_get_longitude(mapsCoord, &lng); + maps_coordinates_get_latitude(coord, &lat); + maps_coordinates_get_longitude(coord, &lng); GeoCoordinates geoCoord(lat, lng); __lat = lat; @@ -341,20 +339,9 @@ here_error_e HereView::RenderMap(maps_view_h hView, const maps_coordinates_h map return HERE_ERROR_NONE; } -here_error_e HereView::RenderMapByArea(maps_view_h hView, const maps_area_h hArea, double dZoom, double dAngle) -{ - if (!hView || !hArea) - return HERE_ERROR_INVALID_PARAMETER; - - if (!__isInitialized || !__map) - return HERE_ERROR_SERVICE_NOT_AVAILABLE; - - return HERE_ERROR_NONE; -} - -here_error_e HereView::MoveCenter(maps_view_h hView, int delta_x, int delta_y) +here_error_e HereView::moveCenter(maps_view_h view, int delta_x, int delta_y) { - if (!hView) + if (!view) return HERE_ERROR_INVALID_PARAMETER; if (!__isInitialized || !__map) @@ -368,9 +355,9 @@ here_error_e HereView::MoveCenter(maps_view_h hView, int delta_x, int delta_y) return HERE_ERROR_NONE; } -here_error_e HereView::GetCenter(maps_view_h hView, maps_coordinates_h *center) +here_error_e HereView::getCenter(maps_view_h view, maps_coordinates_h *center) { - if (!hView || !center) + if (!view || !center) return HERE_ERROR_INVALID_PARAMETER; if (!__isInitialized || !__map) @@ -387,9 +374,9 @@ here_error_e HereView::GetCenter(maps_view_h hView, maps_coordinates_h *center) return HERE_ERROR_NONE; } -here_error_e HereView::SetScalebar(maps_view_h hView, bool enable) +here_error_e HereView::setScalebarEnabled(maps_view_h view, bool enable) { - if (!hView) + if (!view) return HERE_ERROR_INVALID_PARAMETER; if (!__isInitialized || !__map) @@ -400,9 +387,9 @@ here_error_e HereView::SetScalebar(maps_view_h hView, bool enable) return HERE_ERROR_NONE; } -here_error_e HereView::GetScalebar(maps_view_h hView, bool *enabled) +here_error_e HereView::getScalebarEnabled(maps_view_h view, bool *enabled) { - if (!hView || !enabled) + if (!view || !enabled) return HERE_ERROR_INVALID_PARAMETER; if (!__isInitialized || !__map) @@ -412,119 +399,75 @@ here_error_e HereView::GetScalebar(maps_view_h hView, bool *enabled) return HERE_ERROR_NONE; } -here_error_e HereView::DrawMap(maps_view_h hView, Evas* pCanvas, int x, int y, int nWidth, int nHeight) -{ - if (!hView || !pCanvas || nWidth <= 0 || nHeight <= 0) - return HERE_ERROR_INVALID_PARAMETER; - - if (!__isInitialized || !__map || !__map->GetRootPixmap() || !__api || __w <= 0 || __h <= 0) - return HERE_ERROR_SERVICE_NOT_AVAILABLE; - - unsigned char* srcimg_data = (unsigned char*)malloc(__w * __h * 4); - if (!srcimg_data) - return HERE_ERROR_OUT_OF_MEMORY; - - Evas_Object *dstimg = evas_object_image_filled_add(pCanvas); - if (!dstimg) { - g_free(srcimg_data); - return HERE_ERROR_INVALID_OPERATION; - } - - unsigned char *dstimg_data = (unsigned char *)evas_object_image_data_get(dstimg, EINA_TRUE); - if (!dstimg_data) { - g_free(srcimg_data); - return HERE_ERROR_INVALID_OPERATION; - } - - int w = nWidth; - int h = nHeight; - - if (__w < w) w = __w; - if (__h < h) h = __h; - - __api->glReadPixels(x, y, w, h, GL_RGBA, GL_UNSIGNED_BYTE, srcimg_data); - - try { - for(int i = 0; i < h; i++) - memcpy(dstimg_data+(i*w), srcimg_data+(i * w + x), w * 4); - } - catch(std::exception &e) { - MAPS_LOGD("Exception caught: %s", e.what()); - } - g_free(srcimg_data); - - return HERE_ERROR_NONE; -} - -here_error_e HereView::ScreenToGeolocation(maps_view_h hView, int x, int y, maps_coordinates_h *mapsCoord) +here_error_e HereView::convertScreenToGeolocation(maps_view_h view, int x, int y, maps_coordinates_h *coord) { - if (!hView || !mapsCoord) + if (!view || !coord) return HERE_ERROR_INVALID_PARAMETER; if (!__isInitialized || !__map) return HERE_ERROR_SERVICE_NOT_AVAILABLE; - Tizen::Maps::Point mapsPoint(x, y); - GeoCoordinates hereCoord = __map->ScreenPositionToCoordinate(mapsPoint); - double lat = hereCoord.GetLatitude(); - double lng = hereCoord.GetLongitude(); + Tizen::Maps::Point point(x, y); + GeoCoordinates geoCoord = __map->ScreenPositionToCoordinate(point); + double lat = geoCoord.GetLatitude(); + double lng = geoCoord.GetLongitude(); - int error = maps_coordinates_create(lat, lng, mapsCoord); + int error = maps_coordinates_create(lat, lng, coord); if (error != MAPS_ERROR_NONE) return (here_error_e)ConvertToHereError(error); return HERE_ERROR_NONE; } -here_error_e HereView::GeolocationToScreen(maps_view_h hView, const maps_coordinates_h mapsCoord, int *x, int *y) +here_error_e HereView::convertGeolocationToScreen(maps_view_h view, const maps_coordinates_h coord, int *x, int *y) { - if (!hView || !x || !y) + if (!view || !x || !y) return HERE_ERROR_INVALID_PARAMETER; if (!__isInitialized || !__map) return HERE_ERROR_SERVICE_NOT_AVAILABLE; double lat, lng; - maps_coordinates_get_latitude(mapsCoord, &lat); - maps_coordinates_get_longitude(mapsCoord, &lng); - GeoCoordinates hereCoord(lat, lng); - Tizen::Maps::Point mapsPoint = __map->CoordinateToScreenPosition(hereCoord); + maps_coordinates_get_latitude(coord, &lat); + maps_coordinates_get_longitude(coord, &lng); + GeoCoordinates geoCoord(lat, lng); + Tizen::Maps::Point point = __map->CoordinateToScreenPosition(geoCoord); - *x = mapsPoint.x; - *y = mapsPoint.y; + *x = point.x; + *y = point.y; return HERE_ERROR_NONE; } -here_error_e HereView::GetMinZoomLevel(maps_view_h hView, int *nMinZoomLevel) +here_error_e HereView::getMinZoomLevel(maps_view_h view, int *zoom) { - if (!hView || !nMinZoomLevel) + if (!view || !zoom) return HERE_ERROR_INVALID_PARAMETER; if (!__isInitialized || !__map) return HERE_ERROR_SERVICE_NOT_AVAILABLE; - *nMinZoomLevel = (int)__map->GetMinimumZoomLevel(); + *zoom = (int)__map->GetMinimumZoomLevel(); return HERE_ERROR_NONE; } -here_error_e HereView::GetMaxZoomLevel(maps_view_h hView, int *nMaxZoomLevel) +here_error_e HereView::getMaxZoomLevel(maps_view_h view, int *zoom) { - if (!hView || !nMaxZoomLevel) + if (!view || !zoom) return HERE_ERROR_INVALID_PARAMETER; if (!__isInitialized || !__map) return HERE_ERROR_SERVICE_NOT_AVAILABLE; - *nMaxZoomLevel = (int)__map->GetMaximumZoomLevel(); + *zoom = (int)__map->GetMaximumZoomLevel(); return HERE_ERROR_NONE; } -here_error_e HereView::OnViewObject(maps_view_h hView, const maps_view_object_h object, maps_view_object_operation_e operation) +here_error_e HereView::onViewObject(maps_view_h view, const maps_view_object_h object, maps_view_object_operation_e operation) { - if (!hView || !object || + if (!view || !object || operation < MAPS_VIEW_OBJECT_ADD || operation > MAPS_VIEW_OBJECT_REMOVE) return HERE_ERROR_INVALID_PARAMETER; @@ -532,7 +475,7 @@ here_error_e HereView::OnViewObject(maps_view_h hView, const maps_view_object_h return HERE_ERROR_SERVICE_NOT_AVAILABLE; if (__map->GetRootPixmap()) - __processViewObject(hView, object, operation); + __processViewObject(view, object, operation); else __pendingObjects.push_back(std::make_pair(object, operation)); @@ -557,10 +500,10 @@ Eina_Bool HereView::__idlerCb(void *data) return true; } -void HereView::__processViewObject(maps_view_h hView, const maps_view_object_h object, maps_view_object_operation_e operation) +void HereView::__processViewObject(maps_view_h view, const maps_view_object_h object, maps_view_object_operation_e operation) { HereView *hv = NULL; - int maps_error = maps_view_get_maps_plugin_view_handle(hView, (void**)&hv); + int maps_error = maps_view_get_maps_plugin_view_handle(view, (void**)&hv); if (maps_error != MAPS_ERROR_NONE || !hv) return; maps_view_object_type_e type; diff --git a/src/here_view_objects.cpp b/src/here_view_objects.cpp index 189cba8..fdb0477 100644 --- a/src/here_view_objects.cpp +++ b/src/here_view_objects.cpp @@ -66,8 +66,7 @@ here_error_e HereViewObjects::__add(maps_view_object_h hObj) maps_view_object_type_e type; maps_view_object_get_type(hObj, &type); - switch(type) - { + switch(type) { case MAPS_VIEW_OBJECT_MARKER: hereObject = new (std::nothrow) GeoMapObjectMarker; error = __updateMarker(hObj, (GeoMapObjectMarker*)hereObject); @@ -84,11 +83,9 @@ here_error_e HereViewObjects::__add(maps_view_object_h hObj) break; #ifdef TIZEN_3_0_NEXT_MS case MAPS_VIEW_OBJECT_ROUTE: - for (int i=0; i < 2; i++) - { + for (int i=0; i < 2; i++) { hereObject = new (std::nothrow) GeoMapObjectPolyline; - if (hereObject) - { + if (hereObject) { __map->AddObject(hereObject); error = __updateRoute(hObj); if (error != HERE_ERROR_NONE) break; @@ -98,8 +95,7 @@ here_error_e HereViewObjects::__add(maps_view_object_h hObj) } hereObject = new (std::nothrow) GeoMapObjectMarker; - if (hereObject) - { + if (hereObject) { __map->AddObject(hereObject); error = __updateRoute(hObj); if (error != HERE_ERROR_NONE) break; @@ -115,18 +111,16 @@ here_error_e HereViewObjects::__add(maps_view_object_h hObj) break; } - if (error != HERE_ERROR_NONE) - { + if (error != HERE_ERROR_NONE) { if (hereObject) delete hereObject; hereObject = NULL; } + if (hereObject #ifdef TIZEN_3_0_NEXT_MS - if (hereObject && type != MAPS_VIEW_OBJECT_ROUTE) -#else - if (hereObject) + && type != MAPS_VIEW_OBJECT_ROUTE #endif /* TIZEN_3_0_NEXT_MS */ - { + ) { __map->AddObject(hereObject); pthread_mutex_lock(&__mutex); __currentObjects.insert(std::make_pair(hObj, hereObject)); @@ -152,8 +146,7 @@ here_error_e HereViewObjects::__remove(maps_view_object_h hObj) VisualObjects::iterator it; pthread_mutex_lock(&__mutex); - while ((it = __currentObjects.find(hObj)) != __currentObjects.end()) - { + while ((it = __currentObjects.find(hObj)) != __currentObjects.end()) { __map->RemoveObject((GeoMapObject*)it->second); it = __currentObjects.erase(it); error = HERE_ERROR_NONE; @@ -180,9 +173,7 @@ here_error_e HereViewObjects::move(maps_view_object_h hObj) VisualObjects::iterator it; while ((it = __currentObjects.find(hObj)) != __currentObjects.end()) - { MAPS_LOGD("TODO: implement moving"); - } return HERE_ERROR_NONE; } @@ -211,8 +202,7 @@ here_error_e HereViewObjects::__update(maps_view_object_h hObj, GeoMapObject *he maps_view_object_type_e type; maps_view_object_get_type(hObj, &type); - switch(type) - { + switch(type) { case MAPS_VIEW_OBJECT_MARKER: error = __updateMarker(hObj, (GeoMapObjectMarker*)hereObject); break; @@ -234,7 +224,7 @@ here_error_e HereViewObjects::__update(maps_view_object_h hObj, GeoMapObject *he default: break; } - } while(0); + } while (0); return error; } @@ -269,8 +259,7 @@ here_error_e HereViewObjects::__updateMarker(maps_view_object_h hMarker, GeoMapO evas_object_image_file_set(img, szPath, NULL); int err = evas_object_image_load_error_get(img); - if (err != EVAS_LOAD_ERROR_NONE) - { + if (err != EVAS_LOAD_ERROR_NONE) { MAPS_LOGE("Failed to load the image file for new marker. '%s'", (szPath ? szPath : "null")); g_free(szPath); @@ -297,8 +286,7 @@ here_error_e HereViewObjects::__updateMarker(maps_view_object_h hMarker, GeoMapO /* resize the marker image */ int nw = 0, nh = 0; - if (__resizeMarker(hMarker, w, h, &nw, &nh, &dst)) - { + if (__resizeMarker(hMarker, w, h, &nw, &nh, &dst)) { w = nw; h = nh; nSize = w * h * 4; @@ -320,8 +308,7 @@ here_error_e HereViewObjects::__updateMarker(maps_view_object_h hMarker, GeoMapO maps_coordinates_get_longitude(mapsCoord, &lng); maps_coordinates_destroy(mapsCoord); - if (!HereUtils::IsValidCoord(lat, lng)) - { + if (!HereUtils::IsValidCoord(lat, lng)) { error = MAPS_ERROR_INVALID_PARAMETER; break; } @@ -338,7 +325,7 @@ here_error_e HereViewObjects::__updateMarker(maps_view_object_h hMarker, GeoMapO int z_order = 0; maps_view_object_marker_get_z_order(hMarker, &z_order); hereMarker->SetZorder(z_order); - } while(0); + } while (0); if (img) evas_object_del(img); return (here_error_e)ConvertToHereError(error); @@ -366,7 +353,7 @@ here_error_e HereViewObjects::__updatePolyline(maps_view_object_h hPolyline, Geo error = maps_view_object_polyline_get_width(hPolyline, &nThickness); if (error != MAPS_ERROR_NONE) break; herePolyline->SetStrokeThickness(nThickness); - } while(0); + } while (0); return (here_error_e)ConvertToHereError(error); } @@ -388,7 +375,7 @@ here_error_e HereViewObjects::__updatePolygon(maps_view_object_h hPolygon, GeoMa error = maps_view_object_polygon_get_fill_color(hPolygon, &r, &g, &b, &a); if (error != MAPS_ERROR_NONE) break; herePolygon->SetFillColor(Color(r, g, b, a)); - } while(0); + } while (0); return (here_error_e)ConvertToHereError(error); } @@ -400,8 +387,7 @@ here_error_e HereViewObjects::__updateRoute(maps_view_object_h hRoute) VisualObjects::iterator it; - if ((it = __currentObjects.find(hRoute)) != __currentObjects.end()) - { + if ((it = __currentObjects.find(hRoute)) != __currentObjects.end()) { maps_route_h route = NULL; int ret = maps_view_object_route_get_content(hRoute, &route); if (ret != MAPS_ERROR_NONE || !route) @@ -410,19 +396,15 @@ here_error_e HereViewObjects::__updateRoute(maps_view_object_h hRoute) GeoCoordinateList coordList; GeoMapObjectPolyline *polyline_path = NULL, *polyline_seg = NULL; - if (it->second->GetType() == GeoMapObject::GMO_Polyline) - { - if (!polyline_path) - { + if (it->second->GetType() == GeoMapObject::GMO_Polyline) { + if (!polyline_path) { MAPS_LOGD("Route Path"); polyline_path = (GeoMapObjectPolyline*)it->second; maps_route_foreach_path(route, __foreachForCoordinates, &coordList); polyline_path->SetPath(coordList); polyline_path->SetStrokeColor(Tizen::Maps::Color(255, 0, 0, 255)); polyline_path->SetStrokeThickness(3); - } - else if (!polyline_seg) - { + } else if (!polyline_seg) { MAPS_LOGD("Route Segments"); polyline_seg = (GeoMapObjectPolyline*)it->second; maps_route_foreach_path(route, __foreachForCoordinates, &coordList); @@ -430,9 +412,7 @@ here_error_e HereViewObjects::__updateRoute(maps_view_object_h hRoute) polyline_seg->SetStrokeColor(Tizen::Maps::Color(0, 255, 0, 255)); polyline_seg->SetStrokeThickness(3); } - } - else if (it->second->GetType() == GeoMapObject::GMO_Marker) - { + } else if (it->second->GetType() == GeoMapObject::GMO_Marker) { // to implement } maps_route_destroy(route); @@ -458,10 +438,8 @@ here_error_e HereViewObjects::__setVisible(maps_view_object_h hObj, bool bVisibl here_error_e error = HERE_ERROR_NOT_FOUND; VisualObjects::iterator it; - for (it = __currentObjects.begin(); it != __currentObjects.end(); it++) - { - if (it->first == hObj) - { + for (it = __currentObjects.begin(); it != __currentObjects.end(); it++) { + if (it->first == hObj) { ((GeoMapObject*)it->second)->SetVisible(bVisible); error = HERE_ERROR_NONE; } @@ -477,9 +455,7 @@ bool HereViewObjects::__foreachForCoordinates(int index, maps_coordinates_h poin return false; if (!HereUtils::IsValid(*(maps_coordinates_s*)point)) - { return false; - } int error; double lat = 0.0, lng = 0.0; @@ -490,7 +466,7 @@ bool HereViewObjects::__foreachForCoordinates(int index, maps_coordinates_h poin error = maps_coordinates_get_longitude(point, &lng); if (error != MAPS_ERROR_NONE) break; - } while(0); + } while (0); MAPS_LOGD("[%d] %f,%f", index+1, lat, lng); @@ -545,8 +521,7 @@ bool HereViewObjects::__resizeMarker(maps_view_object_h hMarker, int resizedWidth = 0, resizedHeight = 0; maps_view_object_marker_get_size(hMarker, &resizedWidth, &resizedHeight); - if (__resizeBitmap(bitmap, originWidth, originHeight, resizedWidth, resizedHeight)) - { + if (__resizeBitmap(bitmap, originWidth, originHeight, resizedWidth, resizedHeight)) { *newWidth = resizedWidth; *newHeight = resizedHeight; return true; @@ -566,10 +541,8 @@ bool HereViewObjects::__resizeBitmap(unsigned char **curBmp, int curWidth, int c int newPixel, curPixel; - for(int y = 0; y < newHeight; y++) - { - for(int x = 0; x < newWidth; x++) - { + for (int y = 0; y < newHeight; y++) { + for (int x = 0; x < newWidth; x++) { newPixel = (y * (newWidth *4)) + (x * 4); curPixel = (((int)(y / scaleHeight) * (curWidth * 4)) + ((int)(x / scaleWidth) * 4));