diff options
author | <philippe colliot> | 2015-07-27 18:42:44 +0200 |
---|---|---|
committer | <philippe colliot> | 2015-07-27 18:42:44 +0200 |
commit | 170d86f1772973d69447b8d5a37d1939ecc8dc25 (patch) | |
tree | e41dca5f77ec97a3f8cfbcf019bb775f1968153b /src/poi-service | |
parent | 7e4d4a47ae3a55ae93341782a809efaa697a2cfe (diff) | |
download | poi-service-170d86f1772973d69447b8d5a37d1939ecc8dc25.tar.gz |
Start the update of the poi-manager POC for CommonAPI 3.1.2.
Diffstat (limited to 'src/poi-service')
-rw-r--r-- | src/poi-service/CMakeLists.txt | 7 | ||||
-rw-r--r-- | src/poi-service/README | 8 | ||||
-rw-r--r-- | src/poi-service/poi-common/poi-common-data-model.h | 18 | ||||
-rw-r--r-- | src/poi-service/poi-manager-server/CMakeLists.txt | 33 | ||||
-rw-r--r-- | src/poi-service/poi-manager-server/main.cpp | 30 | ||||
-rw-r--r-- | src/poi-service/poi-manager-server/poi-manager-server-stub.cpp | 234 | ||||
-rw-r--r-- | src/poi-service/poi-manager-server/poi-manager-server-stub.h | 11 | ||||
-rw-r--r-- | src/poi-service/resource/commonapi-dbus.ini | 4 |
8 files changed, 211 insertions, 134 deletions
diff --git a/src/poi-service/CMakeLists.txt b/src/poi-service/CMakeLists.txt index e7b01e6..5e2a8ec 100644 --- a/src/poi-service/CMakeLists.txt +++ b/src/poi-service/CMakeLists.txt @@ -19,7 +19,7 @@ project(poi-server) cmake_minimum_required(VERSION 2.8) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11") -message(STATUS "poi-server") +message(STATUS "poi-service-server") option(WITH_FRANCA_INTERFACE "Build using the Franca interfaces" OFF) @@ -48,7 +48,6 @@ add_subdirectory(${API_DIR}/poi-service "${DBUS_GENERATED_INCLUDE_DIR}/poi-servi add_subdirectory(poi-server) if (WITH_FRANCA_INTERFACE) - set(COMMON_API_GENERATED_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../api/franca/navigation/src-gen") - set(DBUS_LIB_PATH "/usr/local/lib") - add_subdirectory(poi-manager-server) + set(FRANCA_DIR "${API_DIR}/franca/navigation") + add_subdirectory(poi-manager-server) endif() diff --git a/src/poi-service/README b/src/poi-service/README index 591a570..fdd3a15 100644 --- a/src/poi-service/README +++ b/src/poi-service/README @@ -57,3 +57,11 @@ How To Run ./run + +Copy the configuration file commonapi-dbus.ini in a directory of your choice + +Set the environment variable COMMONAPI_DBUS_DEFAULT_CONFIG before starting the EnhancedPositionService. + +Example: +export COMMONAPI_DBUS_DEFAULT_CONFIG=<your path>/commonapi-dbus.ini + 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 d90b3c0..d1c12d3 100644 --- a/src/poi-service/poi-common/poi-common-data-model.h +++ b/src/poi-service/poi-common/poi-common-data-model.h @@ -94,22 +94,34 @@ typedef struct std::vector<categoryId_t> childList; //list of children } poi_category_common_t; -// some remaining defines +// some defines to be used by the test #define ALL_CATEGORIES 0 #define INVALID_CATEGORY 0x00 #define MAX_CATEGORIES 256 //to be improved #define CAM_CATEGORY_OFFSET 0x0100 //offset added to create the id of a category provided by a CAM (to be multiplied by the camId) #define CAM_ATTRIBUTE_OFFSET 0x0100 //offset added to create the id of an attribute provided by a CAM (to be multiplied by the camId) - -// some test defines #define ICON_WIDTH 32 #define ICON_HEIGHT 37 +#define NEW_CATEGORY_NAME "recreation" +#define ATTRIBUTE_PHONE_NAME "phone" +#define ATTRIBUTE_CREDIT_CARD_NAME "credit card" +#define NEW_CITY_NAME "Velizy" +#define NEW_STARS_VALUE 5 #define ICON_URL "../resource/file" #define ICON_FORMAT "png" #define POI_PROVIDER "OpenStreetMap" #define POI_NAME "mySweetHome" +#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_STRING "Sweet" #define MEDIASET 1 +#define PARENT_ID 0 #endif diff --git a/src/poi-service/poi-manager-server/CMakeLists.txt b/src/poi-service/poi-manager-server/CMakeLists.txt index 3520715..6f79838 100644 --- a/src/poi-service/poi-manager-server/CMakeLists.txt +++ b/src/poi-service/poi-manager-server/CMakeLists.txt @@ -18,7 +18,15 @@ project(poi-manager-server) set(PARENT_API poiservice) set(ROOT_API navigation) -set(COMMON_API_VERSION CommonAPI-2.1) +set(API_VERSION_MAJOR 0) +set(API_VERSION_MINOR 1) +set(API_VERSION "v${API_VERSION_MAJOR}_${API_VERSION_MINOR}") +set(COMMONAPI_GEN_DIR "${CMAKE_CURRENT_BINARY_DIR}/franca-gen") +set(PRJ_SRC_GEN_PATH ${COMMONAPI_GEN_DIR}/${API_VERSION}/org/genivi/${ROOT_API}/${PARENT_API}) +set(PRJ_SRC_GEN_NAVIGATION_TYPES_PATH ${COMMONAPI_GEN_DIR}/org/genivi/${ROOT_API}) +set(PRJ_SRC_GEN_POISERVICE_TYPES_PATH ${COMMONAPI_GEN_DIR}/v1_0/org/genivi/${ROOT_API}/${PARENT_API}) + +set(DBUS_LIB_PATH "/usr/local/lib") set(CMAKE_VERBOSE_MAKEFILE off) cmake_minimum_required(VERSION 2.8) @@ -32,28 +40,33 @@ endif() # Packages find_package(PkgConfig REQUIRED) +find_package(CommonAPI 3.1.2 REQUIRED) +find_package(CommonAPI-DBus 3.1.2 REQUIRED) + pkg_check_modules(DBUS "dbus-1 >= 1.4") -pkg_check_modules(COMMONAPI "CommonAPI >= 2.1") -pkg_check_modules(COMMONAPI_DBUS "CommonAPI-DBus >= 2.1") +pkg_check_modules(COMMONAPI "CommonAPI >= 3.1") +pkg_check_modules(COMMONAPI_DBUS "CommonAPI-DBus >= 3.1") pkg_check_modules(SQLITE3 REQUIRED sqlite3) pkg_check_modules(GLIBMM glibmm-2.4) pkg_check_modules(GOBJECT gobject-2.0) # Source Files -set(PRJ_SRC_GEN_PATH ${COMMON_API_GENERATED_INCLUDE_DIR}/org/genivi) FILE(GLOB PRJ_LOCAL_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) FILE(GLOB PRJ_COMMON_SRCS ${COMMON_DIR}/*.cpp) -FILE(GLOB PRJ_STUB_GEN_SRCS ${PRJ_SRC_GEN_PATH}/${ROOT_API}/${PARENT_API}/*Stub*.cpp) -FILE(GLOB PRJ_STUB_GEN_TYPES ${PRJ_SRC_GEN_PATH}/${ROOT_API}/${PARENT_API}/*Types*.cpp ${PRJ_SRC_GEN_PATH}/${ROOT_API}/*Types*.cpp) + +add_subdirectory(${FRANCA_DIR}/poiservice "${CMAKE_CURRENT_BINARY_DIR}/franca") + +FILE(GLOB PRJ_STUB_GEN_SRCS ${PRJ_SRC_GEN_PATH}/*Stub*.cpp) +FILE(GLOB PRJ_STUB_GEN_TYPES ${PRJ_SRC_GEN_NAVIGATION_TYPES_PATH}/*Types*.cpp ${PRJ_SRC_GEN_POISERVICE_TYPES_PATH}/*Types*.cpp) set(PRJ_SRCS ${PRJ_LOCAL_SRCS} ${PRJ_COMMON_SRCS} ${PRJ_STUB_GEN_SRCS} ${PRJ_STUB_GEN_TYPES}) include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} ${COMMON_DIR} - ${COMMON_API_GENERATED_INCLUDE_DIR} + ${PRJ_SRC_GEN_PATH} + ${COMMONAPI_GEN_DIR} ${DBUS_INCLUDE_DIRS} - ${COMMONAPI_INCLUDEDIR}/${COMMON_API_VERSION} - ${COMMONAPI_DBUS_INCLUDEDIR} + ${COMMONAPI_INCLUDE_DIRS} + ${COMMONAPI_DBUS_INCLUDE_DIRS} ${GLIBMM_INCLUDE_DIRS} ${GOBJECT_INCLUDE_DIRS} ${SQLITE3_INCLUDE_DIRS} diff --git a/src/poi-service/poi-manager-server/main.cpp b/src/poi-service/poi-manager-server/main.cpp index 32e7e4e..c70a075 100644 --- a/src/poi-service/poi-manager-server/main.cpp +++ b/src/poi-service/poi-manager-server/main.cpp @@ -37,7 +37,7 @@ #include <typeinfo> #include <getopt.h> -#include <CommonAPI/CommonAPI.h> //Defined in the Common API Runtime library +#include <CommonAPI/CommonAPI.hpp> //Defined in the Common API Runtime library #include "poi-manager-server-stub.h" const char* program_name; //file to sink outputs @@ -79,11 +79,20 @@ int main(int argc , char** argv ) std::locale::global(std::locale("")); // Common API data init - std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::load(); - std::shared_ptr<CommonAPI::Factory> factory = runtime->createFactory(); - std::shared_ptr<CommonAPI::ServicePublisher> servicePublisher = runtime->getServicePublisher(); - const std::string& serviceAddress = "local:org.genivi.poiservice.POIContentManager:org.genivi.poiservice.POIContentManager"; - std::shared_ptr<PoiManagerServerStub> myService = std::make_shared<PoiManagerServerStub>(); + std::shared_ptr < CommonAPI::Runtime > runtime = CommonAPI::Runtime::get(); + + const std::string &domain = "local"; + const std::string &instance = "POIContentManager"; + + std::string connection = "POIContentManager"; + + std::shared_ptr<PoiManagerServerStub> myServicePOIContentManager = std::make_shared<PoiManagerServerStub>(); + + bool successfullyRegistered = runtime->registerService(domain, instance, myServicePOIContentManager, connection); + while (!successfullyRegistered) { + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + successfullyRegistered = runtime->registerService(domain, instance, myServicePOIContentManager, connection); + } //index used for argument analysis int next_option; @@ -101,7 +110,6 @@ int main(int argc , char** argv ) GMainLoop * mainloop ; - bool registerResult; do { next_option = getopt_long (argc, argv, short_options, long_options, NULL); @@ -116,14 +124,10 @@ int main(int argc , char** argv ) print_usage (stderr, 1); else { - myService->initDatabase(database_filename); + myServicePOIContentManager->initDatabase(database_filename); //register Interface for Management of a POI Content Access Module with add/remove features - registerResult = servicePublisher->registerService(myService, serviceAddress, factory); - if (registerResult != true) { - std::cerr << "Registering of POI Manager stub failed." << std::endl; - exit(EXIT_FAILURE); - } + myServicePOIContentManager->run(); // Create a new GMainLoop with default context and initial state of "not running " mainloop = g_main_loop_new (g_main_context_default() , FALSE ); 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 3af886b..f6a9035 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 @@ -189,6 +189,7 @@ void sqlRequest::getAvailableArea() { vector<vector<string> > query_result; vector<string > query_line; + double doubleValue; //retrieve the available area into the database query_result = mp_database->queryNotUTF(m_SQL_REQUEST_GET_AVAILABLE_AREA); @@ -201,10 +202,14 @@ void sqlRequest::getAvailableArea() { // read the result of the query, for the moment only the first area ! query_line = query_result.at(0); - fromString<double>(m_leftBottomLocation.latitude,query_line[0], std::dec); - fromString<double>(m_leftBottomLocation.longitude,query_line[1], std::dec); - fromString<double>(m_rightTopLocation.latitude,query_line[2], std::dec); - fromString<double>(m_rightTopLocation.longitude,query_line[3], std::dec); + fromString<double>(doubleValue,query_line[0], std::dec); + m_leftBottomLocation.setLatitude(doubleValue); + fromString<double>(doubleValue,query_line[1], std::dec); + m_leftBottomLocation.setLongitude(doubleValue); + fromString<double>(doubleValue,query_line[2], std::dec); + m_rightTopLocation.setLatitude(doubleValue); + fromString<double>(doubleValue,query_line[3], std::dec); + m_rightTopLocation.setLongitude(doubleValue); } } @@ -219,7 +224,7 @@ sqlRequest::SQL_REQUEST_ERRORS sqlRequest::createCategory(POIServiceTypes::CAMCa iconId_t iconId; //Check if the name doesn't exist into the database to avoid duplications - ret = checkIfCategoryNameDoesntExist(category.details.name); + ret = checkIfCategoryNameDoesntExist(category.getDetails().getName()); if (ret != OK) return ret; @@ -235,7 +240,7 @@ sqlRequest::SQL_REQUEST_ERRORS sqlRequest::createCategory(POIServiceTypes::CAMCa strStream << unique_id; sqlQuery += strStream.str(); sqlQuery += ",'"; - sqlQuery.append(category.details.name); + sqlQuery.append(category.getDetails().getName()); sqlQuery += "');"; query_result = mp_database->queryNotUTF(sqlQuery.c_str()); if (!query_result.empty()) @@ -247,18 +252,18 @@ sqlRequest::SQL_REQUEST_ERRORS sqlRequest::createCategory(POIServiceTypes::CAMCa } //Check the attributes and complete the table if necessary (poiattribute) - for (index=0;index < category.attributes.size();index++) + for (index=0;index < category.getAttributes().size();index++) { - ret = checkIfAttributeExist((category.attributes.at(index)).id,(category.attributes.at(index)).name); + ret = checkIfAttributeExist((category.getAttributes().at(index)).getId(),(category.getAttributes().at(index)).getName()); if (ret == ATTRIBUTE_ID_NOT_EXIST) { //Create the attribute sqlQuery = m_SQL_REQUEST_INSERT_ATTRIBUTE; strStream.str(""); - strStream << (category.attributes.at(index)).id; + strStream << (category.getAttributes().at(index)).getId(); sqlQuery += strStream.str(); sqlQuery += ",'"; - sqlQuery.append((category.attributes.at(index)).name); + sqlQuery.append((category.getAttributes().at(index)).getName()); sqlQuery += "');"; query_result = mp_database->queryNotUTF(sqlQuery.c_str()); if (!query_result.empty()) @@ -305,7 +310,7 @@ sqlRequest::SQL_REQUEST_ERRORS sqlRequest::createCategory(POIServiceTypes::CAMCa sqlQuery += strStream.str(); sqlQuery += ","; strStream.str(""); - strStream << (category.attributes.at(index)).id; + strStream << (category.getAttributes().at(index)).getId(); sqlQuery += strStream.str(); sqlQuery += ");"; query_result = mp_database->queryNotUTF(sqlQuery.c_str()); @@ -319,9 +324,9 @@ sqlRequest::SQL_REQUEST_ERRORS sqlRequest::createCategory(POIServiceTypes::CAMCa } //Check if all the parent categories exist and complete the table of family categories (poicategorykinship) - for (index=0;index < category.details.parentsId.size();index++) + for (index=0;index < category.getDetails().getParentsId().size();index++) { - ret = checkIfCategoryExist(category.details.parentsId.at(index)); + ret = checkIfCategoryExist(category.getDetails().getParentsId().at(index)); if (ret != OK) return ret; @@ -339,7 +344,7 @@ sqlRequest::SQL_REQUEST_ERRORS sqlRequest::createCategory(POIServiceTypes::CAMCa sqlQuery += strStream.str(); sqlQuery += ","; strStream.str(""); - strStream << category.details.parentsId.at(index); + strStream << category.getDetails().getParentsId().at(index); sqlQuery += strStream.str(); sqlQuery += ");"; query_result = mp_database->queryNotUTF(sqlQuery.c_str()); @@ -866,45 +871,45 @@ sqlRequest::SQL_REQUEST_ERRORS sqlRequest::createPoi(POIServiceTypes::CategoryID poiRecorded.website = ""; //and scan the poi attributes - for (index=0; index < poi.attributes.size();index++) + for (index=0; index < poi.getAttributes().size();index++) { - switch ((poi.attributes.at(index)).id) + switch ((poi.getAttributes().at(index)).getId()) { case ATTRIBUTE_SOURCE: - poiRecorded.source = (poi.attributes.at(index)).value.get<std::string>(); + poiRecorded.source = (poi.getAttributes().at(index)).getValue().get<std::string>(); break; case ATTRIBUTE_WEBSITE: - poiRecorded.website = (poi.attributes.at(index)).value.get<std::string>(); + poiRecorded.website = (poi.getAttributes().at(index)).getValue().get<std::string>(); break; case ATTRIBUTE_PHONE : - poiRecorded.phone = (poi.attributes.at(index)).value.get<std::string>(); + poiRecorded.phone = (poi.getAttributes().at(index)).getValue().get<std::string>(); break; case ATTRIBUTE_STARS: - poiRecorded.stars = (poi.attributes.at(index)).value.get<int>(); + poiRecorded.stars = (poi.getAttributes().at(index)).getValue().get<int>(); break; case ATTRIBUTE_OPENINGHOURS: - poiRecorded.openinghours = (poi.attributes.at(index)).value.get<std::string>(); + poiRecorded.openinghours = (poi.getAttributes().at(index)).getValue().get<std::string>(); break; case ATTRIBUTE_ADDRHOUSENUMBER: - poiRecorded.addr_house_number = (poi.attributes.at(index)).value.get<std::string>(); + poiRecorded.addr_house_number = (poi.getAttributes().at(index)).getValue().get<std::string>(); break; case ATTRIBUTE_ADDRSTREET: - poiRecorded.addr_street = (poi.attributes.at(index)).value.get<std::string>(); + poiRecorded.addr_street = (poi.getAttributes().at(index)).getValue().get<std::string>(); break; case ATTRIBUTE_ADDRPOSTCODE: - poiRecorded.addr_postcode = (poi.attributes.at(index)).value.get<int>(); + poiRecorded.addr_postcode = (poi.getAttributes().at(index)).getValue().get<int>(); break; case ATTRIBUTE_ADDRCITY: - poiRecorded.addr_city = (poi.attributes.at(index)).value.get<std::string>(); + poiRecorded.addr_city = (poi.getAttributes().at(index)).getValue().get<std::string>(); break; case ATTRIBUTE_BRAND: - poiRecorded.brand = (poi.attributes.at(index)).value.get<std::string>(); + poiRecorded.brand = (poi.getAttributes().at(index)).getValue().get<std::string>(); break; case ATTRIBUTE_OPERATEUR: - poiRecorded.operateur = (poi.attributes.at(index)).value.get<std::string>(); + poiRecorded.operateur = (poi.getAttributes().at(index)).getValue().get<std::string>(); break; case ATTRIBUTE_CREDIT_CARD: - poiRecorded.credit_card = (poi.attributes.at(index)).value.get<std::string>(); + poiRecorded.credit_card = (poi.getAttributes().at(index)).getValue().get<std::string>(); break; default: return ATTRIBUTE_ID_NOT_EXIST; @@ -919,20 +924,20 @@ sqlRequest::SQL_REQUEST_ERRORS sqlRequest::createPoi(POIServiceTypes::CategoryID strStream << unique_id; sqlQuery += strStream.str(); sqlQuery += ",'"; - sqlQuery.append(poi.name); + sqlQuery.append(poi.getName()); sqlQuery += "',"; strStream.str(""); strStream.precision(7); - strStream << fixed << poi.location.latitude; + strStream << fixed << poi.getLocation().getLatitude(); sqlQuery += strStream.str(); sqlQuery += ","; strStream.str(""); strStream.precision(7); - strStream << fixed << poi.location.longitude; + strStream << fixed << poi.getLocation().getLongitude(); sqlQuery += strStream.str(); sqlQuery += ","; strStream.str(""); - strStream << poi.location.altitude; + strStream << poi.getLocation().getAltitude(); sqlQuery += strStream.str(); sqlQuery += ","; strStream.str(""); @@ -1122,7 +1127,7 @@ sqlRequest::SQL_REQUEST_ERRORS sqlRequest::removePoi(POIServiceTypes::POI_ID uni return ret; } -sqlRequest::SQL_REQUEST_ERRORS sqlRequest::searchPoi(string &categoryName, string &search_string, NavigationTypes::Coordinate3D &left_bottom_location, NavigationTypes::Coordinate3D &right_top_location, std::vector<POIServiceTypes::POI_ID> &poi_id_list) +sqlRequest::SQL_REQUEST_ERRORS sqlRequest::searchPoi(const string &categoryName,const string &search_string, NavigationTypes::Coordinate3D &left_bottom_location, NavigationTypes::Coordinate3D &right_top_location, std::vector<POIServiceTypes::POI_ID> &poi_id_list) { sqlRequest::SQL_REQUEST_ERRORS ret; std::string sqlQuery; //SQL request on database @@ -1142,43 +1147,43 @@ sqlRequest::SQL_REQUEST_ERRORS sqlRequest::searchPoi(string &categoryName, strin // AND (name LIKE '%Sweet%'); // it's needed to reorder the latitude and longitude for the test coherency - if (left_bottom_location.latitude > right_top_location.latitude) + if (left_bottom_location.getLatitude() > right_top_location.getLatitude()) { - recordedBottom.latitude = right_top_location.latitude; - recordedTop.latitude = left_bottom_location.latitude; + recordedBottom.setLatitude(right_top_location.getLatitude()); + recordedTop.setLatitude(left_bottom_location.getLatitude()); } else { - recordedBottom.latitude = left_bottom_location.latitude; - recordedTop.latitude = right_top_location.latitude; + recordedBottom.setLatitude(left_bottom_location.getLatitude()); + recordedTop.setLatitude(right_top_location.getLatitude()); } - if (left_bottom_location.longitude > right_top_location.longitude) + if (left_bottom_location.getLongitude() > right_top_location.getLongitude()) { - recordedBottom.longitude = right_top_location.longitude; - recordedTop.longitude = left_bottom_location.longitude; + recordedBottom.setLongitude(right_top_location.getLongitude()); + recordedTop.setLongitude(left_bottom_location.getLongitude()); } else { - recordedBottom.longitude = left_bottom_location.longitude; - recordedTop.longitude = right_top_location.longitude; + recordedBottom.setLongitude(left_bottom_location.getLongitude()); + recordedTop.setLongitude(right_top_location.getLongitude()); } sqlQuery = m_SQL_REQUEST_SEARCH_POI; sqlQuery += categoryName; sqlQuery += "'))) AND ((latitude > "; strStream.str(""); - strStream << recordedBottom.latitude; + strStream << recordedBottom.getLatitude(); sqlQuery += strStream.str(); sqlQuery += ") AND (latitude < "; strStream.str(""); - strStream << recordedTop.latitude; + strStream << recordedTop.getLatitude(); sqlQuery += strStream.str(); sqlQuery += ")) AND ((longitude > "; strStream.str(""); - strStream << recordedBottom.longitude; + strStream << recordedBottom.getLongitude(); sqlQuery += strStream.str(); sqlQuery += ") AND (longitude < "; strStream.str(""); - strStream << recordedTop.longitude; + strStream << recordedTop.getLongitude(); sqlQuery += strStream.str(); sqlQuery += ")) AND (name LIKE '%"; sqlQuery += search_string; @@ -1204,17 +1209,17 @@ sqlRequest::SQL_REQUEST_ERRORS sqlRequest::searchPoi(string &categoryName, strin } PoiManagerServerStub::PoiManagerServerStub() { - m_version.versionMajor = 1; - m_version.versionMicro = 0; - m_version.versionMinor = 0; - m_version.date = "19-13-2015"; + m_version.setVersionMajor(1); + m_version.setVersionMicro(0); + m_version.setVersionMicro(0); + m_version.setDate("19-13-2015"); m_rootCategory = ALL_CATEGORIES; //by default m_languageCode = "eng"; m_countryCode = "USA"; m_scriptCode = "Latn"; - m_centerLocation.latitude = 48.85792; //by default center of Paris - m_centerLocation.longitude = 2.3383145; - m_centerLocation.altitude = 0; + m_centerLocation.setLatitude(48.85792); //by default center of Paris + m_centerLocation.setLongitude(2.3383145); + m_centerLocation.setAltitude(30); mp_sqlRequest = new sqlRequest; } @@ -1258,9 +1263,9 @@ void PoiManagerServerStub::getAvailableCategories(const std::shared_ptr<CommonAP // load categories from the embedded database for (index = 0; index < m_availableCategories; index++) { - category.uniqueId = m_availableCategoryTable.at(index).id; - category.topLevel = m_availableCategoryTable.at(index).top_level; - category.name = m_availableCategoryTable.at(index).name; + category.setUniqueId(m_availableCategoryTable.at(index).id); + category.setTopLevel(m_availableCategoryTable.at(index).top_level); + category.setName(m_availableCategoryTable.at(index).name); categories.push_back(category); } @@ -1277,8 +1282,8 @@ void PoiManagerServerStub::getParentCategories(const std::shared_ptr<CommonAPI:: POIServiceTypes::CategoryAndLevel categoryAndLevel; for (index=0;index<m_availableCategoryTable.at(category).parentList.size();index++) { - categoryAndLevel.uniqueId = m_availableCategoryTable.at(category).parentList[index]; - categoryAndLevel.topLevel = m_availableCategoryTable.at(categoryAndLevel.uniqueId).top_level; + categoryAndLevel.setUniqueId(m_availableCategoryTable.at(category).parentList[index]); + categoryAndLevel.setTopLevel(m_availableCategoryTable.at(categoryAndLevel.getUniqueId()).top_level); categories.push_back(categoryAndLevel); } } @@ -1289,8 +1294,8 @@ void PoiManagerServerStub::getChildrenCategories(const std::shared_ptr<CommonAPI POIServiceTypes::CategoryAndLevel categoryAndLevel; for (index=0;index<m_availableCategoryTable.at(category).childList.size();index++) { - categoryAndLevel.uniqueId = m_availableCategoryTable.at(category).childList[index]; - categoryAndLevel.topLevel = m_availableCategoryTable.at(categoryAndLevel.uniqueId).top_level; + categoryAndLevel.setUniqueId(m_availableCategoryTable.at(category).childList[index]); + categoryAndLevel.setTopLevel(m_availableCategoryTable.at(categoryAndLevel.getUniqueId()).top_level); categories.push_back(categoryAndLevel); } } @@ -1363,6 +1368,10 @@ void PoiManagerServerStub::removePOIs(const std::shared_ptr<CommonAPI::ClientId> } } +void PoiManagerServerStub::run() +{ +} + bool PoiManagerServerStub::initDatabase(const char* poiDatabaseFileName) { mp_sqlRequest->setDatabase(poiDatabaseFileName); @@ -1377,76 +1386,101 @@ bool PoiManagerServerStub::test() { // test: create a new category, with a new attribute and add a poi under this category POIServiceTypes::CAMCategory category; - POIServiceTypes::CategoryAttribute category_attribute; - POIServiceTypes::CategoryID category_id; - POIServiceTypes::POI_ID poi_id; + 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 poi_attribute; - NavigationTypes::Coordinate3D left_bottom_location,right_top_location; - std::vector<POIServiceTypes::POI_ID> poi_id_list; + POIServiceTypes::PoiAttribute poiAttribute; + std::vector<POIServiceTypes::PoiAttribute> poiAttributeList; + + NavigationTypes::Coordinate3D left_bottom_location,right_top_location,location; std::string str; - category.details.name = "recreation"; //new category - category_attribute.id = ATTRIBUTE_PHONE; - category_attribute.name = "phone"; //existing attribute - category.attributes.push_back(category_attribute); - category_attribute.id = ATTRIBUTE_CREDIT_CARD; //new attribute id - category_attribute.name = "credit card"; //new attribute - category.attributes.push_back(category_attribute); - category.details.parentsId.push_back(0); - poi.name = POI_NAME; - poi.location.altitude = 120; - poi.location.latitude = 48.779839; - poi.location.longitude = 2.217260; - poi_attribute.id = ATTRIBUTE_ADDRCITY; - POIServiceTypes::AttributeValue vs(string("Velizy")); - poi_attribute.value = vs; - poi.attributes.push_back(poi_attribute); - poi_attribute.id = ATTRIBUTE_STARS; - POIServiceTypes::AttributeValue v(5); - poi_attribute.value = v; - poi.attributes.push_back(poi_attribute); - left_bottom_location.latitude = 48.76; - left_bottom_location.longitude = 2.22; - right_top_location.latitude = 48.78; - right_top_location.longitude = 2.20; + + 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,category_id) != sqlRequest::OK) + if (mp_sqlRequest->createCategory(category,categoryId) != sqlRequest::OK) return false; refreshCategoryList(); //read the database and buffer the category list locally - if (mp_sqlRequest->createPoi(category_id,poi,poi_id) != sqlRequest::OK) + if (mp_sqlRequest->createPoi(categoryId,poi,poiId) != sqlRequest::OK) return false; str = SEARCH_STRING; - if (mp_sqlRequest->searchPoi(category.details.name,str,left_bottom_location,right_top_location,poi_id_list) != sqlRequest::OK) + if (mp_sqlRequest->searchPoi(category.getDetails().getName(),str,left_bottom_location,right_top_location,poiIdList) != sqlRequest::OK) return false; - if (mp_sqlRequest->removePoi(poi_id) != sqlRequest::OK) + if (mp_sqlRequest->removePoi(poiId) != sqlRequest::OK) return false; - if (mp_sqlRequest->removeCategory(category_id) != sqlRequest::OK) + if (mp_sqlRequest->removeCategory(categoryId) != sqlRequest::OK) return false; 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,category_id) != sqlRequest::OK) + if (mp_sqlRequest->createCategory(category,categoryId) != sqlRequest::OK) return false; refreshCategoryList(); //read the database and buffer the category list locally - if (mp_sqlRequest->createPoi(category_id,poi,poi_id) != sqlRequest::OK) + if (mp_sqlRequest->createPoi(categoryId,poi,poiId) != sqlRequest::OK) return false; - if (mp_sqlRequest->removeCategory(category_id) != sqlRequest::OK) + if (mp_sqlRequest->removeCategory(categoryId) != sqlRequest::OK) return false; refreshCategoryList(); //read the database and buffer the category list locally str = SEARCH_STRING; - if (mp_sqlRequest->searchPoi(category.details.name,str,left_bottom_location,right_top_location,poi_id_list) != sqlRequest::POI_ID_NOT_EXIST) + if (mp_sqlRequest->searchPoi(category.getDetails().getName(),str,left_bottom_location,right_top_location,poiIdList) != sqlRequest::POI_ID_NOT_EXIST) return false; return true; 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 7997a14..7255425 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 @@ -27,17 +27,18 @@ #ifndef POIMANAGERSERVERSTUBIMPL_H_ #define POIMANAGERSERVERSTUBIMPL_H_ -#include <CommonAPI/CommonAPI.h> +#include <CommonAPI/CommonAPI.hpp> -#include "org/genivi/navigation/poiservice/POIContentManagerStubDefault.h" +#include <v0_1/org/genivi/navigation/poiservice/POIContentManagerStubDefault.hpp> #include "poi-common-database.h" #include "poi-common-data-model.h" using namespace std; -using namespace org::genivi::navigation; +using namespace v0_1::org::genivi::navigation; using namespace poiservice; +using namespace org::genivi::navigation; class sqlRequest { @@ -83,7 +84,7 @@ public: SQL_REQUEST_ERRORS removeCategory(POIServiceTypes::CategoryID unique_id); SQL_REQUEST_ERRORS createPoi(POIServiceTypes::CategoryID categoryId, POIServiceTypes::PoiAddedDetails poi, POIServiceTypes::POI_ID& unique_id); SQL_REQUEST_ERRORS removePoi(POIServiceTypes::POI_ID unique_id); - SQL_REQUEST_ERRORS searchPoi(string &categoryName, string &search_string, NavigationTypes::Coordinate3D &left_bottom_location, NavigationTypes::Coordinate3D &right_top_location, std::vector<POIServiceTypes::POI_ID> &poi_id_list); + SQL_REQUEST_ERRORS searchPoi(const string &categoryName, const string &search_string, NavigationTypes::Coordinate3D &left_bottom_location, NavigationTypes::Coordinate3D &right_top_location, std::vector<POIServiceTypes::POI_ID> &poi_id_list); private: const char* m_SQL_REQUEST_GET_AVAILABLE_CATEGORIES = "SELECT Id,name FROM poicategory;"; @@ -199,6 +200,8 @@ public: void addPOIs(const std::shared_ptr<CommonAPI::ClientId> clientId, POIServiceTypes::CategoryID unique_id, std::vector<POIServiceTypes::PoiAddedDetails> poiList); void removePOIs(const std::shared_ptr<CommonAPI::ClientId> clientId, std::vector<POIServiceTypes::POI_ID> ids); + void run(); + bool initDatabase(const char* poiDatabaseFileName); diff --git a/src/poi-service/resource/commonapi-dbus.ini b/src/poi-service/resource/commonapi-dbus.ini new file mode 100644 index 0000000..4cddb07 --- /dev/null +++ b/src/poi-service/resource/commonapi-dbus.ini @@ -0,0 +1,4 @@ +[local:org.genivi.poiservice.POIContentManager:org.genivi.poiservice.POIContentManager] +service=org.genivi.poiservice.POIContentManager +path=/org/genivi/poiservice/POIContentManager +interface=org.genivi.poiservice.POIContentManager |