diff options
author | <philippe colliot> | 2015-07-31 17:35:52 +0200 |
---|---|---|
committer | <philippe colliot> | 2015-07-31 17:35:52 +0200 |
commit | ac409b558640628fc6f1f6950f21445191806b17 (patch) | |
tree | 3ae89254b7371d1bee2fce6c8f949ed7502c880b | |
parent | ad37685c632afe2129082ff6a76e5c243dda6a18 (diff) | |
download | poi-service-ac409b558640628fc6f1f6950f21445191806b17.tar.gz |
[POISERVICE] Add/remove category and POI tested, still need to test
search, some math functions added お疲れ様 !
-rwxr-xr-x | api/franca/navigation/poiservice/POIContentManager.fidl | 10 | ||||
-rw-r--r-- | src/poi-service/poi-common/poi-common-data-model.h | 22 | ||||
-rw-r--r-- | src/poi-service/poi-common/poi-common-math.cpp | 77 | ||||
-rw-r--r-- | src/poi-service/poi-common/poi-common-math.h | 47 | ||||
-rw-r--r-- | src/poi-service/poi-manager-server/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/poi-service/poi-manager-server/poi-manager-server-stub.cpp | 155 | ||||
-rw-r--r-- | src/poi-service/poi-manager-server/poi-manager-server-stub.h | 9 | ||||
-rw-r--r-- | test/poi-service/poi-manager-client/main.cpp | 151 |
8 files changed, 310 insertions, 163 deletions
diff --git a/api/franca/navigation/poiservice/POIContentManager.fidl b/api/franca/navigation/poiservice/POIContentManager.fidl index ce0fbbf..a20e15e 100755 --- a/api/franca/navigation/poiservice/POIContentManager.fidl +++ b/api/franca/navigation/poiservice/POIContentManager.fidl @@ -236,4 +236,14 @@ interface POIContentManager { }
}
+ <** @description : SearchStatusChanged = This signal updates the search or proximity alert status of the specified handle.**>
+ broadcast SearchStatusChanged {
+ out {
+ <** @description : poi search unique handle.**>
+ Handle poiSearchHandle
+ <** @description : enum(INVALID,NOT_STARTED,SEARCHING,FINISHED, ... ).**>
+ SearchStatusState statusValue
+ }
+ }
+
}
\ No newline at end of file diff --git a/src/poi-service/poi-common/poi-common-data-model.h b/src/poi-service/poi-common/poi-common-data-model.h index 8adc3e1..de68ffd 100644 --- a/src/poi-service/poi-common/poi-common-data-model.h +++ b/src/poi-service/poi-common/poi-common-data-model.h @@ -37,6 +37,12 @@ typedef uint32_t attributeId_t; typedef uint32_t handleId_t; typedef uint8_t camId_t; +typedef struct +{ + double latitude; + double longitude; + int altitude; +} geocoordinate3D_t; enum ATTRIBUTE_LIST{ ATTRIBUTE_SOURCE = 0, @@ -94,7 +100,6 @@ typedef struct std::vector<categoryId_t> childList; //list of children } poi_category_common_t; - // some defines to be used by the test #define ALL_CATEGORIES 0 #define INVALID_CATEGORY 0x00 @@ -115,17 +120,22 @@ typedef struct #define POI_LOCATION_LATITUDE 48.779839 #define POI_LOCATION_LONGITUDE 2.217260 #define POI_LOCATION_ALTITUDE 120 -#define LEFT_BOTTOM_LOCATION_LATITUDE 48.76 -#define LEFT_BOTTOM_LOCATION_LONGITUDE 2.22 -#define RIGHT_TOP_LOCATION_LATITUDE 48.78 -#define RIGHT_TOP_LOCATION_LONGITUDE 2.20 +#define SEARCH_CENTER_LOCATION_LATITUDE 48.76 +#define SEARCH_CENTER_LOCATION_LONGITUDE 2.22 +#define SEARCH_CENTER_LOCATION_ALTITUDE 100 +#define SEARCH_RADIUS 200 //in tens of meters +#define SEARCH_STRING "Sweet" #define LANGUAGE_CODE "fra" #define COUNTRY_CODE "FRA" #define SCRIPT_CODE "Latn" -#define SEARCH_STRING "Sweet" #define MEDIASET 1 #define PARENT_ID 0 +#define SEARCH_HANDLE 1 +#define SEARCH_MAX_SIZE 50 + +#define NO_HANDLE 0 + #endif diff --git a/src/poi-service/poi-common/poi-common-math.cpp b/src/poi-service/poi-common/poi-common-math.cpp new file mode 100644 index 0000000..e7c1706 --- /dev/null +++ b/src/poi-service/poi-common/poi-common-math.cpp @@ -0,0 +1,77 @@ +/** +* @licence app begin@ +* SPDX-License-Identifier: MPL-2.0 +* +* \copyright Copyright (C) 2013-2015, PCA Peugeot Citroen +* +* \file poi-common-math.cpp +* +* \brief This file is part of the poi proof of concept. +* +* \author Philippe Colliot <philippe.colliot@mpsa.com> +* +* \version 1.1 +* +* This Source Code Form is subject to the terms of the +* Mozilla Public License (MPL), v. 2.0. +* If a copy of the MPL was not distributed with this file, +* You can obtain one at http://mozilla.org/MPL/2.0/. +* +* For further information see http://www.genivi.org/. +* +* List of changes: +* <date>, <name>, <description of change> +* +* @licence end@ +*/ + +#include "poi-common-math.h" + +double calculateAngle(const uint32_t radius) + { + //N is the point on the sphere for the origin + //M is a point of the sphere at the distance radius (NM = radius) + //O is the center of the earth + //ON=OM so the triangle is isosceles + //alpha is the angle ON,OM + //beta is the angle NM,NO + //OM*sin(alpha)=NM*sin(beta) + //alpha+beta+beta=PI (because of isoceles) + //beta=(PI-alpha)/2 + //sin(beta) = cos(alpha/2) + //sin(alpha)=2*sin(alpha/2)*cos(alpha/2) + //alpha=2*arcsin(NM/(2*OM)) + + //earth is considered to be a perfect spĥere, in order to simplify calculation + const double PI = 4.0*atan(1.0); + const double earth=6378137; //IUGG value for the equatorial radius of the Earth in m + double angle; + angle=2*asin(radius/(2*earth)); + angle = (angle*180)/PI; //in degrees + return(angle); + } + +uint32_t calculateDistance(const geocoordinate3D_t origin, const geocoordinate3D_t target) + { + //this piece of software is based on an haversine formula given by: + // - Doctors Rick and Peterson, The Math Forum + // http://mathforum.org/dr.math/ + // haversine of angle A is (1-cos(A))/2 that is equal to sin^2(A/2) + + //earth is considered to be a perfect spĥere, in order to simplify calculation + const double PI = 4.0*atan(1.0); + const double earth=6378137; //IUGG value for the equatorial radius of the Earth in m + geocoordinate3D_t pointA, pointB; + double buffer; + + pointA.latitude = origin.latitude * (PI/180); + pointA.longitude = origin.longitude * (PI/180); + pointB.latitude = target.latitude * (PI/180); + pointB.longitude = target.longitude * (PI/180); + + buffer= pow(sin((pointA.latitude-pointB.latitude)/2.0),2.0)+cos(pointA.latitude)*cos(pointB.latitude)*pow(sin((pointA.longitude-pointB.longitude)/2),2); + buffer = 2*atan2(sqrt(buffer),sqrt(1.0-buffer)); + buffer=earth*buffer; + return ((uint32_t) buffer); //return distance in meters + } + diff --git a/src/poi-service/poi-common/poi-common-math.h b/src/poi-service/poi-common/poi-common-math.h new file mode 100644 index 0000000..2f27c1d --- /dev/null +++ b/src/poi-service/poi-common/poi-common-math.h @@ -0,0 +1,47 @@ +/** +* @licence app begin@ +* SPDX-License-Identifier: MPL-2.0 +* +* \copyright Copyright (C) 2013-2015, PCA Peugeot Citroen +* +* \file poi-common-math.h +* +* \brief This file is part of the poi proof of concept. +* +* \author Philippe Colliot <philippe.colliot@mpsa.com> +* +* \version 1.1 +* +* This Source Code Form is subject to the terms of the +* Mozilla Public License (MPL), v. 2.0. +* If a copy of the MPL was not distributed with this file, +* You can obtain one at http://mozilla.org/MPL/2.0/. +* +* For further information see http://www.genivi.org/. +* +* List of changes: +* <date>, <name>, <description of change> +* +* @licence end@ +*/ +#ifndef __POICOMMONMATH_H__ +#define __POICOMMONMATH_H__ + +#include <stdbool.h> +#include <unistd.h> +#include <stdio.h> +#include <stdlib.h> +#include <stdint.h> +#include <sys/types.h> +#include <iostream> +#include <cmath> +#include <typeinfo> +#include <vector> +#include "poi-common-data-model.h" + +double calculateAngle(const uint32_t radius); + +uint32_t calculateDistance(const geocoordinate3D_t origin, const geocoordinate3D_t target); + + +#endif diff --git a/src/poi-service/poi-manager-server/CMakeLists.txt b/src/poi-service/poi-manager-server/CMakeLists.txt index 6f79838..c832967 100644 --- a/src/poi-service/poi-manager-server/CMakeLists.txt +++ b/src/poi-service/poi-manager-server/CMakeLists.txt @@ -51,7 +51,7 @@ pkg_check_modules(GLIBMM glibmm-2.4) pkg_check_modules(GOBJECT gobject-2.0) # Source Files -FILE(GLOB PRJ_LOCAL_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) +FILE(GLOB PRJ_LOCAL_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ${COMMON_DIR}/*.cpp) FILE(GLOB PRJ_COMMON_SRCS ${COMMON_DIR}/*.cpp) add_subdirectory(${FRANCA_DIR}/poiservice "${CMAKE_CURRENT_BINARY_DIR}/franca") diff --git a/src/poi-service/poi-manager-server/poi-manager-server-stub.cpp b/src/poi-service/poi-manager-server/poi-manager-server-stub.cpp index 91250ee..9184aa7 100644 --- a/src/poi-service/poi-manager-server/poi-manager-server-stub.cpp +++ b/src/poi-service/poi-manager-server/poi-manager-server-stub.cpp @@ -1223,6 +1223,8 @@ PoiManagerServerStub::PoiManagerServerStub() { m_centerLocation.setAltitude(30); mp_sqlRequest = new sqlRequest; + + m_search_handle = NO_HANDLE; } PoiManagerServerStub::~PoiManagerServerStub() { @@ -1393,122 +1395,79 @@ void PoiManagerServerStub::removePOIs(const std::shared_ptr<CommonAPI::ClientId> } } -void PoiManagerServerStub::run() +void PoiManagerServerStub::poiSearchStarted(const std::shared_ptr<CommonAPI::ClientId> _client, ::org::genivi::navigation::NavigationTypes::Handle _poiSearchHandle, uint16_t _maxSize, ::org::genivi::navigation::NavigationTypes::Coordinate3D _location, std::vector< ::v0_1::org::genivi::navigation::poiservice::POIServiceTypes::CategoryAndRadius> _poiCategories, std::vector< ::v0_1::org::genivi::navigation::poiservice::POIServiceTypes::AttributeDetails> _poiAttributes, std::string _inputString, uint16_t _sortOption, poiSearchStartedReply_t _reply) { -} + POIServiceTypes::CategoryAndRadius categoryAndRadius; + size_t index; + string categoryName; + double angle; + NavigationTypes::Coordinate3D leftBottomLocation, rightTopLocation; + std::vector<POIServiceTypes::POI_ID> poiIDList; -bool PoiManagerServerStub::initDatabase(const char* poiDatabaseFileName) -{ - mp_sqlRequest->setDatabase(poiDatabaseFileName); - refreshCategoryList(); //read the database and buffer the category list locally + //For the moment, just search for one category + categoryAndRadius = _poiCategories.at(0); -// return test(); + //First step is to check the consistency of the request + for(index=0;index<m_availableCategoryTable.size();index++) + { + if ((m_availableCategoryTable.at(index)).id == categoryAndRadius.getId()) + { + categoryName = (m_availableCategoryTable.at(index)).name; + break; + } + } + if (index>=m_availableCategoryTable.size()) + { + //no id found, error to be sent + fireSearchStatusChangedEvent(_poiSearchHandle,POIServiceTypes::SearchStatusState::INVALID); + return; + } - return true; //maybe add some check of the file here -} + //calculate the angle + angle = calculateAngle(categoryAndRadius.getRadius()*10); // radius unit is 10 m -bool PoiManagerServerStub::test() -{ - // test: create a new category, with a new attribute and add a poi under this category - POIServiceTypes::CAMCategory category; - POIServiceTypes::Details categoryDetails; - POIServiceTypes::CategoryAttribute categoryAttribute; - std::vector<POIServiceTypes::CategoryAttribute> categoryAttributeList; - std::vector<POIServiceTypes::CategoryID> categoryParentsId; - - POIServiceTypes::CategoryID categoryId; - POIServiceTypes::POI_ID poiId; - std::vector<POIServiceTypes::POI_ID> poiIdList; - - POIServiceTypes::PoiAddedDetails poi; - POIServiceTypes::PoiAttribute poiAttribute; - std::vector<POIServiceTypes::PoiAttribute> poiAttributeList; - - NavigationTypes::Coordinate3D left_bottom_location,right_top_location,location; - std::string str; - - categoryDetails = category.getDetails(); - categoryDetails.setName(NEW_CATEGORY_NAME); - categoryParentsId = categoryDetails.getParentsId(); - categoryParentsId.clear(); - categoryParentsId.push_back(PARENT_ID); - categoryDetails.setParentsId(categoryParentsId); - category.setDetails(categoryDetails); //new category - - categoryAttributeList = category.getAttributes(); - categoryAttributeList.clear(); - categoryAttribute.setId(ATTRIBUTE_PHONE); - categoryAttribute.setName(ATTRIBUTE_PHONE_NAME); //existing attribute - categoryAttributeList.push_back(categoryAttribute); - categoryAttribute.setId(ATTRIBUTE_CREDIT_CARD); //new attribute id - categoryAttribute.setName(ATTRIBUTE_CREDIT_CARD_NAME); //new attribute - categoryAttributeList.push_back(categoryAttribute); - category.setAttributes(categoryAttributeList); - - poi.setName(POI_NAME); - - location.setLatitude(POI_LOCATION_LATITUDE); - location.setLongitude(POI_LOCATION_LONGITUDE); - location.setAltitude(POI_LOCATION_ALTITUDE); - poi.setLocation(location); - - poiAttributeList = poi.getAttributes(); - poiAttributeList.clear(); - poiAttribute.setId(ATTRIBUTE_ADDRCITY); - POIServiceTypes::AttributeValue vs(string(NEW_CITY_NAME)); - poiAttribute.setValue(vs); - poiAttributeList.push_back(poiAttribute); - poiAttribute.setId(ATTRIBUTE_STARS); - POIServiceTypes::AttributeValue v(NEW_STARS_VALUE); - poiAttribute.setValue(v); - poiAttributeList.push_back(poiAttribute); - poi.setAttributes(poiAttributeList); - - left_bottom_location.setLatitude(LEFT_BOTTOM_LOCATION_LATITUDE); - left_bottom_location.setLongitude(LEFT_BOTTOM_LOCATION_LONGITUDE); - right_top_location.setLatitude(RIGHT_TOP_LOCATION_LATITUDE); - right_top_location.setLongitude(RIGHT_TOP_LOCATION_LONGITUDE); - - // Create category, create poi, search, remove poi, remove category - if (mp_sqlRequest->createCategory(category,categoryId) != sqlRequest::OK) - return false; + leftBottomLocation.setLatitude(_location.getLatitude() - angle); + leftBottomLocation.setLongitude(_location.getLongitude() - angle); + rightTopLocation.setLatitude(_location.getLatitude() + angle); + rightTopLocation.setLongitude(_location.getLongitude() + angle); - refreshCategoryList(); //read the database and buffer the category list locally - if (mp_sqlRequest->createPoi(categoryId,poi,poiId) != sqlRequest::OK) - return false; + m_search_handle = _poiSearchHandle; //for the moment, only one handle is managed - str = SEARCH_STRING; - if (mp_sqlRequest->searchPoi(category.getDetails().getName(),str,left_bottom_location,right_top_location,poiIdList) != sqlRequest::OK) - return false; + fireSearchStatusChangedEvent(_poiSearchHandle,POIServiceTypes::SearchStatusState::SEARCHING); - if (mp_sqlRequest->removePoi(poiId) != sqlRequest::OK) - return false; + mp_sqlRequest->searchPoi(categoryName,_inputString, leftBottomLocation, rightTopLocation, poiIDList); - if (mp_sqlRequest->removeCategory(categoryId) != sqlRequest::OK) - return false; + fireSearchStatusChangedEvent(_poiSearchHandle,POIServiceTypes::SearchStatusState::FINISHED); - refreshCategoryList(); //read the database and buffer the category list locally +} - // Create category, create poi, remove category (auto remove orphan poi), search - if (mp_sqlRequest->createCategory(category,categoryId) != sqlRequest::OK) - return false; +void PoiManagerServerStub::poiSearchCanceled(const std::shared_ptr<CommonAPI::ClientId> _client, ::org::genivi::navigation::NavigationTypes::Handle _poiSearchHandle, poiSearchCanceledReply_t _reply) +{ + m_search_handle = NO_HANDLE; + fireSearchStatusChangedEvent(_poiSearchHandle,POIServiceTypes::SearchStatusState::NOT_STARTED); +} - refreshCategoryList(); //read the database and buffer the category list locally +void PoiManagerServerStub::resultListRequested(const std::shared_ptr<CommonAPI::ClientId> _client, uint8_t _camId, ::org::genivi::navigation::NavigationTypes::Handle _poiSearchHandle, std::vector< ::v0_1::org::genivi::navigation::poiservice::POIServiceTypes::AttributeID> _attributes, resultListRequestedReply_t _reply) +{ - if (mp_sqlRequest->createPoi(categoryId,poi,poiId) != sqlRequest::OK) - return false; +} - if (mp_sqlRequest->removeCategory(categoryId) != sqlRequest::OK) - return false; +void PoiManagerServerStub::poiDetailsRequested(const std::shared_ptr<CommonAPI::ClientId> _client, std::vector< ::v0_1::org::genivi::navigation::poiservice::POIServiceTypes::POI_ID> _source_id, poiDetailsRequestedReply_t _reply) +{ - refreshCategoryList(); //read the database and buffer the category list locally +} - str = SEARCH_STRING; - if (mp_sqlRequest->searchPoi(category.getDetails().getName(),str,left_bottom_location,right_top_location,poiIdList) != sqlRequest::POI_ID_NOT_EXIST) - return false; +void PoiManagerServerStub::run() +{ +} - return true; +bool PoiManagerServerStub::initDatabase(const char* poiDatabaseFileName) +{ + mp_sqlRequest->setDatabase(poiDatabaseFileName); + refreshCategoryList(); //read the database and buffer the category list locally + + return true; //maybe add some check of the file here } // refresh the buffer that contains the categories related data, called each time a category is added or removed diff --git a/src/poi-service/poi-manager-server/poi-manager-server-stub.h b/src/poi-service/poi-manager-server/poi-manager-server-stub.h index 48f283c..26830d1 100644 --- a/src/poi-service/poi-manager-server/poi-manager-server-stub.h +++ b/src/poi-service/poi-manager-server/poi-manager-server-stub.h @@ -37,6 +37,8 @@ #include "poi-common-data-model.h" +#include "poi-common-math.h" + using namespace std; using namespace v0_1::org::genivi::navigation::poiservice; using namespace org::genivi::navigation; @@ -199,6 +201,10 @@ public: void removeCategories(const std::shared_ptr<CommonAPI::ClientId> _client, std::vector< POIServiceTypes::CategoryID> _categories, removeCategoriesReply_t _reply); void addPOIs(const std::shared_ptr<CommonAPI::ClientId> _client, POIServiceTypes::CategoryID _unique_id, std::vector< POIServiceTypes::PoiAddedDetails> _poiList, addPOIsReply_t _reply); void removePOIs(const std::shared_ptr<CommonAPI::ClientId> _client, std::vector< POIServiceTypes::POI_ID> _ids, removePOIsReply_t _reply); + void poiSearchStarted(const std::shared_ptr<CommonAPI::ClientId> _client, ::org::genivi::navigation::NavigationTypes::Handle _poiSearchHandle, uint16_t _maxSize, ::org::genivi::navigation::NavigationTypes::Coordinate3D _location, std::vector< ::v0_1::org::genivi::navigation::poiservice::POIServiceTypes::CategoryAndRadius> _poiCategories, std::vector< ::v0_1::org::genivi::navigation::poiservice::POIServiceTypes::AttributeDetails> _poiAttributes, std::string _inputString, uint16_t _sortOption, poiSearchStartedReply_t _reply); + void poiSearchCanceled(const std::shared_ptr<CommonAPI::ClientId> _client, ::org::genivi::navigation::NavigationTypes::Handle _poiSearchHandle, poiSearchCanceledReply_t _reply); + void resultListRequested(const std::shared_ptr<CommonAPI::ClientId> _client, uint8_t _camId, ::org::genivi::navigation::NavigationTypes::Handle _poiSearchHandle, std::vector< ::v0_1::org::genivi::navigation::poiservice::POIServiceTypes::AttributeID> _attributes, resultListRequestedReply_t _reply); + void poiDetailsRequested(const std::shared_ptr<CommonAPI::ClientId> _client, std::vector< ::v0_1::org::genivi::navigation::poiservice::POIServiceTypes::POI_ID> _source_id, poiDetailsRequestedReply_t _reply); void run(); @@ -214,6 +220,8 @@ private: POIServiceTypes::CategoryID m_rootCategory; NavigationTypes::Coordinate3D m_centerLocation; + NavigationTypes::Handle m_search_handle; + sqlRequest* mp_sqlRequest; void refreshCategoryList(); @@ -225,7 +233,6 @@ private: return !(iss >> f >> t).fail(); } - bool test(); }; #endif /* POIMANAGERSERVERSTUBIMPL_H_ */ diff --git a/test/poi-service/poi-manager-client/main.cpp b/test/poi-service/poi-manager-client/main.cpp index 8f69e17..8a5acbc 100644 --- a/test/poi-service/poi-manager-client/main.cpp +++ b/test/poi-service/poi-manager-client/main.cpp @@ -84,9 +84,9 @@ public: void createCategory(const POIServiceTypes::CategoryID& category); - void createPOIs(const std::vector< POIServiceTypes::POI_ID >& pois); + void dumpCategories(); - void removePOIs(const std::vector< POIServiceTypes::POI_ID >& pois); + void dumpLocales(); private: @@ -97,7 +97,6 @@ private: std::vector<POIServiceTypes::CategoryID> m_category_ids; std::vector<POIServiceTypes::POI_ID> m_poi_ids; POIServiceTypes::PoiAddedDetails m_poi; - NavigationTypes::Coordinate3D m_left_bottom_location,m_right_top_location; POIServiceTypes::Locales m_locales; std::string m_strTest; @@ -109,45 +108,61 @@ contentManager::contentManager(std::shared_ptr<POIContentManagerProxyDefault> pr { // test: create a new category, with a new attribute and add a poi under this category POIServiceTypes::Details categoryDetails; - std::vector<POIServiceTypes::CategoryID> categoryParentsIDs; - POIServiceTypes::Icon categoryIcons; - POIServiceTypes::Media categoryMedia; + std::vector<POIServiceTypes::CategoryID> categoryParentsIDList; + POIServiceTypes::Icon categoryIcons(std::string(ICON_URL)); + POIServiceTypes::Media categoryMedia(std::string("")); POIServiceTypes::CategoryAttribute categoryAttribute; - POIServiceTypes::CategorySortOption categorySortOption; - std::vector<POIServiceTypes::CategorySortOption> categorySortOptions; + POIServiceTypes::Operator categoryOperator; + POIServiceTypes::AttributeValue categoryOperatorAttributeValue(int32_t(0)); + std::vector<POIServiceTypes::Operator> categoryOperatorList; std::vector<POIServiceTypes::CategoryAttribute> categoryAttributeList; + + POIServiceTypes::CategorySortOption categorySortOption; + std::vector<POIServiceTypes::CategorySortOption> categorySortOptionList; + POIServiceTypes::PoiAttribute poiAttribute; std::vector<POIServiceTypes::PoiAttribute> poiAttributeList; NavigationTypes::Coordinate3D location; mp_proxy = proxy; - categoryParentsIDs.clear(); - categoryParentsIDs.push_back(PARENT_ID); - categoryDetails.setParentsId(categoryParentsIDs); -// categoryIcons = ICON_URL; + categoryParentsIDList.clear(); + categoryParentsIDList.push_back(PARENT_ID); + categoryDetails.setParentsId(categoryParentsIDList); categoryDetails.setIcons(categoryIcons); categoryDetails.setName(NEW_CATEGORY_NAME); categoryDetails.setShortDesc(""); -// categoryMedia = ""; categoryDetails.setMedia(categoryMedia); m_category.setDetails(categoryDetails); //new category categoryAttributeList.clear(); categoryAttribute.setId(ATTRIBUTE_PHONE); categoryAttribute.setName(ATTRIBUTE_PHONE_NAME); //existing attribute - categoryAttributeList.push_back(categoryAttribute); + categoryAttribute.setType(POIServiceTypes::AttributeType::INTEGER); + categoryOperator.setName(""); + categoryOperator.setType(POIServiceTypes::OperatorType::EQUAL); + categoryOperator.setValue(categoryOperatorAttributeValue); + categoryOperatorList.push_back(categoryOperator); + categoryAttribute.setOperators(categoryOperatorList); + categoryAttributeList.push_back(categoryAttribute); categoryAttribute.setId(ATTRIBUTE_CREDIT_CARD); //new attribute id categoryAttribute.setName(ATTRIBUTE_CREDIT_CARD_NAME); //new attribute + categoryAttribute.setType(POIServiceTypes::AttributeType::INTEGER); + categoryOperator.setName(""); + categoryOperator.setType(POIServiceTypes::OperatorType::EQUAL); + categoryOperator.setValue(categoryOperatorAttributeValue); + categoryOperatorList.push_back(categoryOperator); + categoryAttribute.setOperators(categoryOperatorList); categoryAttributeList.push_back(categoryAttribute); m_category.setAttributes(categoryAttributeList); categorySortOption.setId(POIServiceTypes::SortOption::SORT_DEFAULT); categorySortOption.setName(""); - categorySortOptions.push_back(categorySortOption); - m_category.setSortOptions(categorySortOptions); + categorySortOptionList.push_back(categorySortOption); + m_category.setSortOptions(categorySortOptionList); + m_poi.setName(POI_NAME); location.setLatitude(POI_LOCATION_LATITUDE); @@ -157,20 +172,17 @@ contentManager::contentManager(std::shared_ptr<POIContentManagerProxyDefault> pr poiAttributeList.clear(); poiAttribute.setId(ATTRIBUTE_ADDRCITY); + poiAttribute.setType(POIServiceTypes::AttributeType::BOOLEAN); POIServiceTypes::AttributeValue vs(string(NEW_CITY_NAME)); poiAttribute.setValue(vs); poiAttributeList.push_back(poiAttribute); poiAttribute.setId(ATTRIBUTE_STARS); + poiAttribute.setType(POIServiceTypes::AttributeType::BOOLEAN); POIServiceTypes::AttributeValue v(NEW_STARS_VALUE); poiAttribute.setValue(v); poiAttributeList.push_back(poiAttribute); m_poi.setAttributes(poiAttributeList); - m_left_bottom_location.setLatitude(LEFT_BOTTOM_LOCATION_LATITUDE); - m_left_bottom_location.setLongitude(LEFT_BOTTOM_LOCATION_LONGITUDE); - m_right_top_location.setLatitude(RIGHT_TOP_LOCATION_LATITUDE); - m_right_top_location.setLongitude(RIGHT_TOP_LOCATION_LONGITUDE); - // init of the data test for search string m_strTest = SEARCH_STRING; @@ -197,44 +209,34 @@ static void getVersionAsyncCallback(const CommonAPI::CallStatus& callStatus, con return; } - cout << "Server:" << endl; cout << "Version " << version.getVersionMajor() << "." << version.getVersionMinor() << "." << version.getVersionMicro() << endl; cout << "Date " << version.getDate() << endl; } -static void getLocaleAsyncCallBack(const CommonAPI::CallStatus& callStatus, const std::string& languageCode, const std::string& countryCode, const std::string& scriptCode) -{ - if (callStatus != CommonAPI::CallStatus::SUCCESS) { - cout << "Remote getLocale failed with status: " << static_cast<std::underlying_type<CommonAPI::CallStatus>::type>(callStatus) << endl; - return; - } - - cout << "languageCode " << languageCode << " " << "countryCode " << countryCode << " " << "scriptCode " << scriptCode << " " << endl; -} - void contentManager::getServerStatus() { function<void(const CommonAPI::CallStatus&, const NavigationTypes::Version&)> getVersion = getVersionAsyncCallback; - function<void(const CommonAPI::CallStatus&, const std::string&, const std::string&, const std::string&)> getLocale = getLocaleAsyncCallBack; - std::string languageCode, countryCode, scriptCode; CommonAPI::CallStatus callStatus; mp_proxy->getVersionAsync(getVersionAsyncCallback); - mp_proxy->getLocale(callStatus,languageCode,countryCode,scriptCode); - - cout << "languageCode " << languageCode << " " << "countryCode " << countryCode << " " << "scriptCode " << scriptCode << " " << endl; + dumpLocales(); mp_proxy->setLocale(m_locales.getLanguageCode(),m_locales.getCountryCode(),m_locales.getScriptCode(),callStatus); - mp_proxy->getLocaleAsync(getLocaleAsyncCallBack); + cout << "Change locales" << endl; + + dumpLocales(); + + dumpCategories(); + } void contentManager::ConfigurationChanged(const std::vector< uint16_t >& changedSettings) { size_t index; - cout << "ConfigurationChanged: "; + cout << "Configuration changed: "; for(index=0;index<changedSettings.size();index++) { cout << changedSettings.at(index); @@ -248,13 +250,14 @@ void contentManager::CategoriesRemoved(const std::vector<POIServiceTypes::Catego for(index=0;index<categories.size();index++) { - cout << "Id: " << categories.at(index) << endl; if (m_category_id == categories.at(index)) { m_category_id = INVALID_CATEGORY; - cout << "Category removed" << endl; + cout << "Category " << categories.at(index) << " removed" << endl; } } + + dumpCategories(); } void contentManager::POIAdded(const std::vector<POIServiceTypes::POI_ID> &pois) @@ -262,10 +265,9 @@ void contentManager::POIAdded(const std::vector<POIServiceTypes::POI_ID> &pois) size_t index; m_poi_ids.clear(); - cout << "POI Added" << endl; for(index=0;index<pois.size();index++) { - cout << "Id: " << pois.at(index) << endl; + cout << "POI " << pois.at(index) << " added" << endl; m_poi_ids.push_back(pois.at(index)); } } @@ -274,11 +276,11 @@ void contentManager::POIRemoved(const std::vector<POIServiceTypes::POI_ID> &pois { size_t index; - cout << "POI Removed" << endl; for(index=0;index<pois.size();index++) { - cout << "Id: " << pois.at(index) << endl; + cout << "POI " << pois.at(index) << "removed" << endl; } + } void contentManager::connectPopupWindow(GtkWidget *window) @@ -293,9 +295,11 @@ static void createCategoryAsyncCallback(const CommonAPI::CallStatus& callStatus, return; } - cout << "Category Created" << endl << "Id: " << categoryID << endl; + cout << "Category " << categoryID << " created" << endl; clientContentManager->createCategory(categoryID); + + clientContentManager->dumpCategories(); } void contentManager::createCategory(const POIServiceTypes::CategoryID& category) @@ -303,6 +307,30 @@ void contentManager::createCategory(const POIServiceTypes::CategoryID& category) m_category_id = category; } +void contentManager::dumpCategories() +{ + std::vector<POIServiceTypes::CategoryAndName> categories; + CommonAPI::CallStatus callStatus; + size_t index; + + mp_proxy->getAvailableCategories(callStatus,categories); + + for(index=0;index<categories.size();index++) + { + cout << "id: " << categories.at(index).getUniqueId() << " name: " << categories.at(index).getName() << " top level: " << categories.at(index).getTopLevel() << endl; + } +} + +void contentManager::dumpLocales() +{ + std::string languageCode, countryCode, scriptCode; + CommonAPI::CallStatus callStatus; + + mp_proxy->getLocale(callStatus,languageCode,countryCode,scriptCode); + + cout << "languageCode: " << languageCode << " " << "countryCode: " << countryCode << " " << "scriptCode: " << scriptCode << " " << endl; +} + void contentManager::testCreateCategory() { function<void(const CommonAPI::CallStatus&, const POIServiceTypes::CategoryID&)> fcb = createCategoryAsyncCallback; @@ -321,11 +349,6 @@ void contentManager::testRemoveCategory() mp_proxy->removeCategories(categories,status); } -void contentManager::createPOIs(const std::vector< POIServiceTypes::POI_ID >& pois) -{ - -} - void contentManager::testCreatePOI() { std::vector<POIServiceTypes::PoiAddedDetails> poiList; @@ -335,11 +358,6 @@ void contentManager::testCreatePOI() mp_proxy->addPOIs(m_category_id,poiList,status); } -void contentManager::removePOIs(const std::vector< POIServiceTypes::POI_ID >& pois) -{ - -} - void contentManager::testRemovePOI() { CommonAPI::CallStatus status; @@ -349,8 +367,27 @@ void contentManager::testRemovePOI() void contentManager::testSearch() { - std::vector<poiId_t> poi_id_list; + NavigationTypes::Coordinate3D location; + POIServiceTypes::AttributeDetails attributeDetails; + std::vector<POIServiceTypes::AttributeDetails> poiAttributes; + POIServiceTypes::CategoryAndRadius categoryAndRadius; + std::vector<POIServiceTypes::CategoryAndRadius> poiCategories; + CommonAPI::CallStatus status; + + location.setLatitude(SEARCH_CENTER_LOCATION_LATITUDE); + location.setLongitude(SEARCH_CENTER_LOCATION_LONGITUDE); + location.setAltitude(SEARCH_CENTER_LOCATION_ALTITUDE); + + poiCategories.clear(); + categoryAndRadius.setId(m_category_id); + categoryAndRadius.setRadius(SEARCH_RADIUS); + poiCategories.push_back(categoryAndRadius); + + attributeDetails.setCategoryId(m_category_id); + attributeDetails.setId(ATTRIBUTE_ADDRCITY); + poiAttributes.push_back(attributeDetails); + mp_proxy->poiSearchStarted(SEARCH_HANDLE,SEARCH_MAX_SIZE,location,poiCategories,poiAttributes,SEARCH_STRING,POIServiceTypes::SortOption::ATTRIBUTE_CUSTOM,status); } const char* program_name; //file to sink outputs |