CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-SET(pkg_name "maps-plugin-mapzen")
-PROJECT(${pkg_name} C CXX)
+SET(fw_name "maps-plugin-mapzen")
+PROJECT(${fw_name} C CXX)
SET(CMAKE_INSTALL_PREFIX /usr)
SET(PREFIX ${CMAKE_INSTALL_PREFIX})
-SET(LIBDIR ${LIBDIR})
# Dependencies
-SET(dependents
- glib-2.0
- gmodule-2.0
- libxml-2.0
- dlog
- capi-maps-service
- capi-network-connection
- capi-appfw-app-manager
- capi-appfw-application
- evas
- ecore-evas
- elementary
- vconf
- )
+SET(dependents "glib-2.0 gmodule-2.0 dlog libcurl capi-network-connection capi-maps-service")
INCLUDE(FindPkgConfig)
pkg_check_modules(pkgs REQUIRED ${dependents})
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fvisibility=hidden -fPIC -Wall -Werror")
SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -Wall -fPIC -std=c++11 -fvisibility=hidden")
-SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpie ${EXTRA_CFLAGS} -Wall -g -fPIC -std=c++11 -fvisibility=hidden")
+
+IF("${ARCH}" STREQUAL "arm")
+ ADD_DEFINITIONS("-DTARGET")
+ENDIF("${ARCH}" STREQUAL "arm")
ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
ADD_DEFINITIONS("-DEXPORT_API=__attribute__((visibility(\"default\")))")
SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${LIBDIR}")
-# Includes
+
+# Include files
+# Maps Service Includes
SET(INC_DIR
- inc
+ include
+)
+
+# Maps Service Implementation
+SET(INTERNAL_INC_DIR
+ src
+)
+
+# Mapzen Engine Implementation
+SET(ENGINE_INC_DIR
src/mapzen
- external/rapidjson/include
+)
+
+# External dependencies
+SET(EXTERNAL_INC_DIR
+ external/rapidjson/include
)
INCLUDE_DIRECTORIES(
- ${INC_DIR}
+${INC_DIR} ${INTERNAL_INC_DIR} ${ENGINE_INC_DIR} ${EXTERNAL_INC_DIR}
)
#This file must be corrected
SET(SRCS
# Maps API
src/mapzen_plugin.c
+
+ # Mapzen Engine
src/mapzen/mapzen_api.c
src/mapzen/mapzen_geocode.c
- src/mapzen/mapzen_jsonparser.cpp
- src/mapzen/mapzen_place.c
- src/mapzen/mapzen_queue.c
- src/mapzen/mapzen_restcurl.c
src/mapzen/mapzen_revgeocode.c
src/mapzen/mapzen_route.cpp
+ src/mapzen/mapzen_place.c
+ src/mapzen/mapzen_restcurl.c
+ src/mapzen/mapzen_jsonparser.cpp
+ src/mapzen/mapzen_queue.c
src/mapzen/mapzen_util.c
)
-ADD_LIBRARY(${pkg_name} SHARED ${SRCS})
+ADD_LIBRARY(${fw_name} SHARED ${SRCS})
-SET_TARGET_PROPERTIES(${pkg_name}
+SET_TARGET_PROPERTIES(${fw_name}
PROPERTIES
VERSION ${FULLVER}
SOVERSION ${MAJORVER}
CLEAN_DIRECT_OUTPUT 1
)
+TARGET_LINK_LIBRARIES(${fw_name} ${pkgs_LDFLAGS})
+
+SET(PC_NAME ${fw_name})
+SET(PC_DESCRIPTION "Tizen mapzen plugin Library")
+SET(PC_LDFLAGS -l${fw_name})
+SET(PC_INCLUDE /usr/include/maps)
+
+CONFIGURE_FILE(
+ ${fw_name}.pc.in
+ ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc
+ @ONLY
+)
+
# Install
-INSTALL(TARGETS ${pkg_name} DESTINATION ${LIBDIR}/maps/plugins)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION lib/pkgconfig)
+INSTALL(TARGETS ${fw_name} DESTINATION lib/maps/plugins)
+
+#INCLUDE(FindPkgConfig)
+#pkg_check_modules(lib_pkgs REQUIRED
+# capi-maps-service
+#)
+
+SET(LIB_APP_ASSIST capi-maps-service)
+INSTALL(
+ DIRECTORY ${INC_DIR}/ DESTINATION include/mapzen-plugin
+ FILES_MATCHING
+ PATTERN "*_internal.h" EXCLUDE
+ PATTERN "${INC_DIR}/mapzen_*.h"
+)
+
+# Test Suite
+#IF("${BINTYPE}" STREQUAL "eng")
+#ENDIF("${BINTYPE}" STREQUAL "eng")
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef _MAPZEN_PLUGIN_H_
-#define _MAPZEN_PLUGIN_H_
-
-#include <maps_plugin.h>
-#include <glib.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct callback_geocode {
- maps_service_geocode_cb callback;
- void *data;
- int reqID;
-} callback_info_geocode;
-
-typedef struct callback_reverse_geocode {
- maps_service_reverse_geocode_cb callback;
- void *data;
- int reqID;
-} callback_info_reverse_geocode;
-
-typedef struct callback_route {
- maps_service_search_route_cb callback;
- void *data;
- int reqID;
-} callback_info_route;
-
-typedef struct callback_place {
- maps_service_search_place_cb callback;
- void *data;
- int reqID;
-} callback_info_place;
-
-int maps_plugin_init(maps_plugin_h *plugin);
-
-int maps_plugin_shutdown(maps_plugin_h plugin);
-
-int maps_plugin_is_service_supported(maps_service_e service, bool *supported);
-
-int maps_plugin_is_data_supported(maps_service_data_e data, bool *supported);
-
-int maps_plugin_get_info(maps_plugin_info_h *info);
-
-int maps_plugin_set_provider_key(const char *provider_key);
-
-int maps_plugin_get_provider_key(char **provider_key);
-
-int maps_plugin_set_preference(maps_item_hashtable_h preference);
-
-int maps_plugin_get_preference(maps_item_hashtable_h *preference);
-
-/* Geocode */
-int maps_plugin_geocode(const char *address, const maps_preference_h preference, maps_service_geocode_cb callback, void *user_data, int *request_id);
-
-/* Geocode inside area */
-int maps_plugin_geocode_inside_area(const char *address, const maps_area_h bounds, const maps_preference_h preference, maps_service_geocode_cb callback, void *user_data, int *request_id);
-
-/* Geocode by structured address */
-int maps_plugin_geocode_by_structured_address(const maps_address_h address, const maps_preference_h preference, maps_service_geocode_cb callback, void *user_data, int *request_id);
-
-/* Rev Geocode */
-int maps_plugin_reverse_geocode(double latitude, double longitude, const maps_preference_h preference, maps_service_reverse_geocode_cb callback, void *user_data, int *request_id);
-
-/* Route search */
-int maps_plugin_search_route(const maps_coordinates_h origin, const maps_coordinates_h destination, maps_preference_h preference, maps_service_search_route_cb callback, void *user_data, int *request_id);
-
-/* Route search waypoints */
-int maps_plugin_search_route_waypoints(const maps_coordinates_h *waypoint_list, int waypoint_num, maps_preference_h preference, maps_service_search_route_cb callback, void *user_data, int *request_id);
-
-/* Place search */
-int maps_plugin_search_place(const maps_coordinates_h position, int distance, const maps_place_filter_h filter, maps_preference_h preference, maps_service_search_place_cb callback, void *user_data, int *request_id);
-
-/* Place search by area */
-int maps_plugin_search_place_by_area(const maps_area_h boundary, const maps_place_filter_h filter, maps_preference_h preference, maps_service_search_place_cb callback, void *user_data, int *request_id);
-
-/* Place search by address */
-int maps_plugin_search_place_by_address(const char *address, const maps_area_h boundary, const maps_place_filter_h filter, maps_preference_h preference, maps_service_search_place_cb callback, void *user_data, int *request_id);
-
-/* Cancel Request */
-int maps_plugin_cancel_request(int request_id);
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* _MAPZEN_PLUGIN_H_ */
+++ /dev/null
-/* Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __MAPZEN_PLUGIN_INTERNAL_H__
-#define __MAPZEN_PLUGIN_INTERNAL_H__
-
-#include <dlog.h>
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-#define LOG_TAG "MAPZEN_PLUGIN"
-
-/*
- * 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_CHECK_CONDITION(condition, error, msg) \
- do { \
- if (condition) { \
- } else { \
- MAPS_LOGE("%s(0x%08x)", msg, error); \
- return error; \
- } \
- } while (0)
-
-#define MAPS_NULL_ARG_CHECK_RETURN_FALSE(arg)\
- do { \
- if (arg != NULL) { \
- } else { \
- MAPS_LOGE("MAPS_ERROR_INVALID_PARAMETER"); \
- return false; }; \
- } while (0)
-
-#define MAPS_NULL_ARG_CHECK(arg) \
- MAPS_CHECK_CONDITION(arg != NULL, MAPS_ERROR_INVALID_PARAMETER, "MAPS_ERROR_INVALID_PARAMETER")
-
-#define MAPS_PRINT_ERROR_CODE_RETURN(code) \
- do { \
- MAPS_LOGE("%s(0x%08x)", #code, code); \
- return code; \
- } while (0)
-
-#endif /* __MAPZEN_PLUGIN_INTERNAL_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _MAPZEN_PLUGIN_H_
+#define _MAPZEN_PLUGIN_H_
+
+#include <maps_plugin.h>
+#include <glib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct callback_geocode {
+ maps_service_geocode_cb callback;
+ void *data;
+ int reqID;
+} callback_info_geocode;
+
+typedef struct callback_reverse_geocode {
+ maps_service_reverse_geocode_cb callback;
+ void *data;
+ int reqID;
+} callback_info_reverse_geocode;
+
+typedef struct callback_route {
+ maps_service_search_route_cb callback;
+ void *data;
+ int reqID;
+} callback_info_route;
+
+typedef struct callback_place {
+ maps_service_search_place_cb callback;
+ void *data;
+ int reqID;
+} callback_info_place;
+
+
+/* TODO: IMPLEMENT THESE FOR REAL */
+
+int maps_plugin_multi_reverse_geocode(const maps_coordinates_list_h geocode_list,
+ const maps_preference_h preference, maps_service_multi_reverse_geocode_cb callback,
+ void *user_data, int *request_id);
+
+int maps_plugin_search_place_list(const maps_area_h boundary, const maps_place_filter_h filter,
+ maps_preference_h preference, maps_service_search_place_list_cb callback, void* user_data, int* request_id);
+
+int maps_plugin_get_place_details(const char* url,
+ maps_service_get_place_details_cb callback, void* user_data, int* request_id);
+
+int maps_plugin_create_map_view(maps_view_h hView, maps_plugin_map_view_ready_cb pCbFunc);
+
+int maps_plugin_destroy_map_view(maps_view_h hView);
+
+int maps_plugin_render_map(maps_view_h hView,
+ const maps_coordinates_h coordinates, double zoom_factor, double rotation_angle);
+
+int maps_plugin_move_center(maps_view_h hView, int delta_x, int delta_y);
+
+int maps_plugin_set_scalebar(maps_view_h hView, bool enable);
+
+int maps_plugin_get_scalebar(maps_view_h hView, bool *enabled);
+
+int maps_plugin_draw_map(maps_view_h hView, Evas* canvas, int x, int y, int w, int h);
+
+int maps_plugin_on_object(maps_view_h hView, const maps_view_object_h object, maps_view_object_operation_e operation);
+
+int maps_plugin_screen_to_geography(maps_view_h hView, int x, int y, maps_coordinates_h *mapsCoord);
+
+int maps_plugin_geography_to_screen(maps_view_h hView, const maps_coordinates_h mapsCoord, int* x, int* y);
+
+int maps_plugin_get_min_zoom_level(maps_view_h hView, int *min_zoom_level);
+
+int maps_plugin_get_max_zoom_level(maps_view_h hView, int *max_zoom_level);
+
+int maps_plugin_get_center(maps_view_h hView, maps_coordinates_h *center);
+
+/* ABOVE METHODS ARE THERE BUT RETURN MAPS_ERROR_NOT_SUPPORTED */
+
+
+int maps_plugin_init_module(maps_plugin_h *plugin, const char *module);
+
+int maps_plugin_init(maps_plugin_h *plugin);
+
+int maps_plugin_shutdown(maps_plugin_h plugin);
+
+int maps_plugin_is_service_supported(maps_service_e service, bool *supported);
+
+int maps_plugin_is_data_supported(maps_service_data_e data, bool *supported);
+
+int maps_plugin_get_info(maps_plugin_info_h *info);
+
+int maps_plugin_set_provider_key(const char *provider_key);
+
+int maps_plugin_get_provider_key(char **provider_key);
+
+int maps_plugin_set_preference(maps_item_hashtable_h preference);
+
+int maps_plugin_get_preference(maps_item_hashtable_h *preference);
+
+/* Geocode */
+int maps_plugin_geocode(const char *address, const maps_preference_h preference, maps_service_geocode_cb callback, void *user_data, int *request_id);
+
+/* Geocode inside area */
+int maps_plugin_geocode_inside_area(const char *address, const maps_area_h bounds, const maps_preference_h preference, maps_service_geocode_cb callback, void *user_data, int *request_id);
+
+/* Geocode by structured address */
+int maps_plugin_geocode_by_structured_address(const maps_address_h address, const maps_preference_h preference, maps_service_geocode_cb callback, void *user_data, int *request_id);
+
+/* Rev Geocode */
+int maps_plugin_reverse_geocode(double latitude, double longitude, const maps_preference_h preference, maps_service_reverse_geocode_cb callback, void *user_data, int *request_id);
+
+/* Route search */
+int maps_plugin_search_route(const maps_coordinates_h origin, const maps_coordinates_h destination, maps_preference_h preference, maps_service_search_route_cb callback, void *user_data, int *request_id);
+
+/* Route search waypoints */
+int maps_plugin_search_route_waypoints(const maps_coordinates_h *waypoint_list, int waypoint_num, maps_preference_h preference, maps_service_search_route_cb callback, void *user_data, int *request_id);
+
+/* Place search */
+int maps_plugin_search_place(const maps_coordinates_h position, int distance, const maps_place_filter_h filter, maps_preference_h preference, maps_service_search_place_cb callback, void *user_data, int *request_id);
+
+/* Place search by area */
+int maps_plugin_search_place_by_area(const maps_area_h boundary, const maps_place_filter_h filter, maps_preference_h preference, maps_service_search_place_cb callback, void *user_data, int *request_id);
+
+/* Place search by address */
+int maps_plugin_search_place_by_address(const char *address, const maps_area_h boundary, const maps_place_filter_h filter, maps_preference_h preference, maps_service_search_place_cb callback, void *user_data, int *request_id);
+
+/* Cancel Request */
+int maps_plugin_cancel_request(int request_id);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* _MAPZEN_PLUGIN_H_ */
--- /dev/null
+/* Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __MAPZEN_PLUGIN_INTERNAL_H__
+#define __MAPZEN_PLUGIN_INTERNAL_H__
+
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "MAPZEN_PLUGIN"
+
+/*
+ * 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_CHECK_CONDITION(condition, error, msg) \
+ do { \
+ if (condition) { \
+ } else { \
+ MAPS_LOGE("%s(0x%08x)", msg, error); \
+ return error; \
+ } \
+ } while (0)
+
+#define MAPS_NULL_ARG_CHECK_RETURN_FALSE(arg)\
+ do { \
+ if (arg != NULL) { \
+ } else { \
+ MAPS_LOGE("MAPS_ERROR_INVALID_PARAMETER"); \
+ return false; }; \
+ } while (0)
+
+#define MAPS_NULL_ARG_CHECK(arg) \
+ MAPS_CHECK_CONDITION(arg != NULL, MAPS_ERROR_INVALID_PARAMETER, "MAPS_ERROR_INVALID_PARAMETER")
+
+#define MAPS_PRINT_ERROR_CODE_RETURN(code) \
+ do { \
+ MAPS_LOGE("%s(0x%08x)", #code, code); \
+ return code; \
+ } while (0)
+
+#endif /* __MAPZEN_PLUGIN_INTERNAL_H__ */
Source1: deps.tar.gz
ExclusiveArch: %ix86 x86_64 %arm aarch64
-BuildRequires: cmake
-BuildRequires: pkgconfig(libxml-2.0)
-BuildRequires: pkgconfig(dlog)
-BuildRequires: pkgconfig(libcurl)
-BuildRequires: pkgconfig(capi-maps-service)
-BuildRequires: capi-maps-service-plugin-devel
-BuildRequires: pkgconfig(capi-network-connection)
-BuildRequires: pkgconfig(capi-appfw-app-manager)
-BuildRequires: pkgconfig(capi-appfw-application)
-BuildRequires: pkgconfig(capi-system-info)
-BuildRequires: pkgconfig(elementary)
-BuildRequires: pkgconfig(vconf)
-BuildRequires: boost-devel
-BuildRequires: capi-maps-service-devel
-BuildRequires: elementary-devel
+BuildRequires: cmake
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(gmodule-2.0)
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(libcurl)
+BuildRequires: pkgconfig(capi-network-connection)
+BuildRequires: pkgconfig(capi-maps-service)
+BuildRequires: capi-maps-service-plugin-devel
+BuildRequires: pkgconfig(json-glib-1.0)
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
#
Requires(post): /sbin/ldconfig
%manifest maps-plugin-mapzen.manifest
%defattr(-,root,root,-)
%{_prefix}/lib/maps/plugins/libmaps-plugin-mapzen.so*
+%{_prefix}/lib/pkgconfig/maps-plugin-mapzen.pc
/usr/share/license/maps-plugin-mapzen
+
+%package devel
+Summary: Tizen Mapzen Maps Plug-in Library (Development)
+Group: Framework/maps
+Requires: %{name} = %{version}-%{release}
+
+%description devel
+This package provides Plugin APIs for Mapzen. (Development)
+
+%post devel
+/sbin/ldconfig
+
+%postun devel
+/sbin/ldconfig
+
+%files devel
+%defattr(-,root,root,-)
+%{_includedir}/mapzen-plugin/*.h
+%{_prefix}/lib/pkgconfig/maps-plugin-mapzen.pc
+%{_prefix}/lib/maps/plugins/libmaps-plugin-mapzen.so
#include "mapzen_queue.h"
#include "mapzen_debug.h"
-EXPORT_API int mapzen_init()
+int mapzen_init()
{
int ret = mapzen_init_queue();
return ret;
}
-EXPORT_API int mapzen_shutdown()
+int mapzen_shutdown()
{
int ret = mapzen_deinit_queue();
return ret;
}
-EXPORT_API int mapzen_geocode(mapzen_geocode_req_s *req_details, mapzen_geocode_cb callback, int request_id, void *user_data)
+int mapzen_geocode(mapzen_geocode_req_s *req_details, mapzen_geocode_cb callback, int request_id, void *user_data)
{
int ret = MAPZEN_ERROR_NONE;
ret = start_geocode_service(req_details, callback, request_id, user_data);
return ret;
}
-EXPORT_API int mapzen_cancel_request(int request_id)
+int mapzen_cancel_request(int request_id)
{
int ret = remove_from_request_list(request_id);
return ret;
}
-EXPORT_API int mapzen_reverse_geocode(mapzen_revgeocode_req_s *req_details, mapzen_reverse_geocode_cb callback, int request_id, void *user_data)
+int mapzen_reverse_geocode(mapzen_revgeocode_req_s *req_details, mapzen_reverse_geocode_cb callback, int request_id, void *user_data)
{
int ret = MAPZEN_ERROR_NONE;
ret = start_reversegeocode_service(req_details, callback, request_id, user_data);
return ret;
}
-EXPORT_API int mapzen_search_place(mapzen_search_req_s *req_details, mapzen_place_search_cb callback, int request_id, void *user_data)
+int mapzen_search_place(mapzen_search_req_s *req_details, mapzen_place_search_cb callback, int request_id, void *user_data)
{
int ret = MAPZEN_ERROR_NONE;
ret = start_places_service(req_details, callback, request_id, user_data);
return ret;
}
-EXPORT_API int mapzen_start_route(mapzen_route_req_s *req_details, mapzen_route_cb callback, int request_id, void *user_data)
+int mapzen_start_route(mapzen_route_req_s *req_details, mapzen_route_cb callback, int request_id, void *user_data)
{
int ret = MAPZEN_ERROR_NONE;
ret = start_route_service(req_details, callback, request_id, user_data);
#include "mapzen_restcurl.h"
#include "mapzen_util.h"
-#define GEOCODE_URL "https://open.mapzenapi.com/geocoding/v1/address?key=%s&inFormat=kvp&outFormat=json"
+#define GEOCODE_URL "https://search.mapzen.com/v1/search?api_key=%s"
int query_geocode_within_bounds(gchar *maps_key, char *address, coords_s top_left, coords_s bottom_right, int num_results, gpointer user_data)
{
STRCPY(url, tmpStr);
- snprintf(tmpStr, sizeof(tmpStr), "&boundingBox=%f,%f,%f,%f", top_left.latitude, top_left.longitude, bottom_right.latitude, bottom_right.longitude);
+ snprintf(tmpStr, sizeof(tmpStr), "&boundary.rect.min_lat=%f&boundary.rect.min_lon=%f&boundary.rect.max_lat=%f&boundary.rect.max_lon=%f",
+ top_left.latitude, top_left.longitude, bottom_right.latitude, bottom_right.longitude);
STRCAT(url, tmpStr);
- snprintf(tmpStr, sizeof(tmpStr), "&maxResults=%d", num_results);
+ snprintf(tmpStr, sizeof(tmpStr), "&size=%d", num_results);
STRCAT(url, tmpStr);
- snprintf(tmpStr, sizeof(tmpStr), "&location=%s", address);
+ snprintf(tmpStr, sizeof(tmpStr), "&layers=address&text=%s", address);
STRCAT(url, tmpStr);
add_handle(url, REQ_TYPE_GEOCODE, user_data);
STRCPY(url, tmpStr);
- snprintf(tmpStr, sizeof(tmpStr), "&maxResults=%d", num_results);
+ snprintf(tmpStr, sizeof(tmpStr), "&size=%d", num_results);
STRCAT(url, tmpStr);
- snprintf(tmpStr, sizeof(tmpStr), "&location=%s", address);
+ snprintf(tmpStr, sizeof(tmpStr), "&layers=address&text=%s", address);
STRCAT(url, tmpStr);
add_handle(url, REQ_TYPE_GEOCODE, user_data);
#include <maps_coordinates.h>
#include <stdlib.h>
-#include "rapidjson/rapidjson.h"
+#include "rapidjson/document.h"
#include "mapzen_jsonparser.hpp"
#include "mapzen_queue.h"
#include "mapzen_debug.h"
#include <string>
#include <vector>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#define ROUTE_UNIT_CONVERSION_MILE_TO_M(x) (1609.34 * (x))
#define ROUTE_UNIT_CONVERSION_MILE_TO_KM(x) (1.60934 * (x))
#define ROUTE_UNIT_CONVERSION_MILE_TO_FT(x) (5280 * (x))
return error;
}
+bool __get_string(const rapidjson::Value& obj, const char* key, char** value)
+{
+ //if we have the key and its not an empty value
+ rapidjson::Value::ConstMemberIterator itr = obj.FindMember(key);
+ if(itr != obj.MemberEnd() && itr->value.GetStringLength()){
+ (*value) = (gchar *)g_malloc(itr->value.GetStringLength() + 1);
+ strncpy((*value), itr->value.GetString(), itr->value.GetStringLength());
+ }//we had nothing
+ else
+ (*value) = NULL;
+ //is this something
+ return *value != NULL;
+}
+
/************ GEOCODE ***************/
static void __parse_geocode_response(char *response, int size, int *status, GList **coordsList)
{
+ MAP_DEBUG("Inside __parse_geocode_response..");
+
+
if (!response || !status || !coordsList) return;
*coordsList = NULL;
- //TODO:
+ //crack open that json
+ rapidjson::Document document;
+ document.Parse(std::string(response, size).c_str());
+ rapidjson::Value::ConstMemberIterator features = document.FindMember("features");
+ if(features != document.MemberEnd() && features->value.IsArray()) {
+ //for each feature
+ for (rapidjson::Value::ConstValueIterator f = features->value.Begin(); f != features->value.End(); ++f) {
+ //it has to have geometry
+ rapidjson::Value::ConstMemberIterator geom = f->FindMember("geometry");
+ if(geom != f->MemberEnd()) {
+ //skip non-points
+ rapidjson::Value::ConstMemberIterator type = geom->value.FindMember("type");
+ if(type == geom->value.MemberEnd() || strcmp(type->value.GetString(), "Point"))
+ continue;
+ //get actual points
+ rapidjson::Value::ConstMemberIterator coords = geom->value.FindMember("coordinates");
+ if(coords == geom->value.MemberEnd() || !coords->value.IsArray() || coords->value.Size() != 2)
+ continue;
+
+ coords_s *coord = (coords_s *)g_malloc0(sizeof(coords_s));
+ if (coord != NULL) {
+ coord->latitude = coords->value[0].GetDouble();
+ coord->longitude = coords->value[1].GetDouble();
+ }
+
+ if (*coordsList == NULL)
+ *coordsList = g_list_append(*coordsList, coord);
+ else
+ *coordsList = g_list_insert_before(*coordsList, NULL, coord);
+ }
+ }
+ }
}
/****************** REVERSE GEOCODE *********************/
*respAddr = NULL;
- //TODO:
+ //crack open that json
+ rapidjson::Document document;
+ document.Parse(std::string(response, size).c_str());
+ rapidjson::Value::ConstMemberIterator features = document.FindMember("features");
+ if(features != document.MemberEnd() && features->value.IsArray()) {
+ //for each feature
+ for (rapidjson::Value::ConstValueIterator f = features->value.Begin(); f != features->value.End(); ++f) {
+ //it has to have geometry
+ rapidjson::Value::ConstMemberIterator geom = f->FindMember("geometry");
+ if(geom != f->MemberEnd()) {
+ //skip non-points
+ rapidjson::Value::ConstMemberIterator type = geom->value.FindMember("type");
+ if(type == geom->value.MemberEnd() || strcmp(type->value.GetString(), "Point"))
+ continue;
+ //get actual points
+ rapidjson::Value::ConstMemberIterator coords = geom->value.FindMember("coordinates");
+ if(coords == geom->value.MemberEnd() || !coords->value.IsArray() || coords->value.Size() != 2)
+ continue;
+ maps_coordinates_s coord;
+ coord.longitude = coords->value[0].GetDouble();
+ coord.latitude = coords->value[1].GetDouble();
+ //NOTE: it seems as though the tizen maps plugin api assumes that reverse geocode results will
+ //actually be at the coordinates where you requested the reverse geocode. the mapzen api can return
+ //POIS which are some distance away from the location and currently this is not accounted for :o(
+
+ //get out the address information
+ rapidjson::Value::ConstMemberIterator properties = f->FindMember("properties");
+ if(properties != f->MemberEnd()) {
+ //fill this out as we go
+ *respAddr = (mapzen_address_resp_s *)g_malloc(sizeof(mapzen_address_resp_s));
+ bool something = false;
+ something = __get_string(properties->value, "street", &(*respAddr)->street) || something;
+ something = __get_string(properties->value, "neighbourhood", &(*respAddr)->neighbourhood) || something;
+ something = __get_string(properties->value, "housenumber", &(*respAddr)->housenumber) || something;
+ something = __get_string(properties->value, "localadmin", &(*respAddr)->localadmin) || something;
+ something = __get_string(properties->value, "county", &(*respAddr)->county) || something;
+ something = __get_string(properties->value, "region", &(*respAddr)->region) || something;
+ something = __get_string(properties->value, "country", &(*respAddr)->country) || something;
+ something = __get_string(properties->value, "country_a", &(*respAddr)->country_a) || something;
+ something = __get_string(properties->value, "postalcode", &(*respAddr)->postalcode) || something;
+ //if everything was null thats pretty much unusable
+ //TODO: these are pretty weak criteria..
+ if(!something) {
+ g_free(*respAddr);
+ (*respAddr) = NULL;
+ }//forget the rest, we have one with something in it
+ else
+ break;
+ }
+ }
+ }
+
+ }
}
/**************** PLACE SEARCH ********************/
}
}
}
+
+#ifdef __cplusplus
+}
+#endif
#include "mapzen_server_private.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
void post_curl_response(char *response, int size, mapzen_resp_type type, void *user_data);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _MAPZEN_JSONPARSER_H_ */
*/
#include <stdio.h>
-#include<stdlib.h>
+#include <stdlib.h>
#include "mapzen_queue.h"
#include "mapzen_geocode.h"
#include "mapzen_revgeocode.h"
MapzenRevGeocodeResponseData *revGeocodeData = (MapzenRevGeocodeResponseData *) (ptr);
if (revGeocodeData) {
if (revGeocodeData->addressDetails) {
- if (revGeocodeData->addressDetails->street_add) {
- g_free(revGeocodeData->addressDetails->street_add);
- revGeocodeData->addressDetails->street_add = NULL;
+ if (revGeocodeData->addressDetails->street) {
+ g_free(revGeocodeData->addressDetails->street);
+ revGeocodeData->addressDetails->street = NULL;
}
if (revGeocodeData->addressDetails->neighbourhood) {
g_free(revGeocodeData->addressDetails->neighbourhood);
revGeocodeData->addressDetails->neighbourhood = NULL;
}
- if (revGeocodeData->addressDetails->city) {
- g_free(revGeocodeData->addressDetails->city);
- revGeocodeData->addressDetails->city = NULL;
+ if (revGeocodeData->addressDetails->localadmin) {
+ g_free(revGeocodeData->addressDetails->localadmin);
+ revGeocodeData->addressDetails->localadmin = NULL;
}
if (revGeocodeData->addressDetails->county) {
g_free(revGeocodeData->addressDetails->county);
revGeocodeData->addressDetails->county = NULL;
}
- if (revGeocodeData->addressDetails->state) {
- g_free(revGeocodeData->addressDetails->state);
- revGeocodeData->addressDetails->state = NULL;
+ if (revGeocodeData->addressDetails->region) {
+ g_free(revGeocodeData->addressDetails->region);
+ revGeocodeData->addressDetails->region = NULL;
}
if (revGeocodeData->addressDetails->country) {
g_free(revGeocodeData->addressDetails->country);
revGeocodeData->addressDetails->country = NULL;
}
- if (revGeocodeData->addressDetails->country_code) {
- g_free(revGeocodeData->addressDetails->country_code);
- revGeocodeData->addressDetails->country_code = NULL;
+ if (revGeocodeData->addressDetails->country_a) {
+ g_free(revGeocodeData->addressDetails->country_a);
+ revGeocodeData->addressDetails->country_a = NULL;
}
- if (revGeocodeData->addressDetails->postal_code) {
- g_free(revGeocodeData->addressDetails->postal_code);
- revGeocodeData->addressDetails->postal_code = NULL;
+ if (revGeocodeData->addressDetails->postalcode) {
+ g_free(revGeocodeData->addressDetails->postalcode);
+ revGeocodeData->addressDetails->postalcode = NULL;
}
g_free(revGeocodeData->addressDetails);
mapzen_place_resp_s *mapzen_place = (mapzen_place_resp_s *) place->data;
if (mapzen_place->address) {
- if (mapzen_place->address->street_add) {
- g_free(mapzen_place->address->street_add);
- mapzen_place->address->street_add = NULL;
+ if (mapzen_place->address->street) {
+ g_free(mapzen_place->address->street);
+ mapzen_place->address->street = NULL;
}
if (mapzen_place->address->neighbourhood) {
g_free(mapzen_place->address->neighbourhood);
mapzen_place->address->neighbourhood = NULL;
}
- if (mapzen_place->address->building_number) {
- g_free(mapzen_place->address->building_number);
- mapzen_place->address->building_number = NULL;
+ if (mapzen_place->address->housenumber) {
+ g_free(mapzen_place->address->housenumber);
+ mapzen_place->address->housenumber = NULL;
}
- if (mapzen_place->address->city) {
- g_free(mapzen_place->address->city);
- mapzen_place->address->city = NULL;
+ if (mapzen_place->address->localadmin) {
+ g_free(mapzen_place->address->localadmin);
+ mapzen_place->address->localadmin = NULL;
}
if (mapzen_place->address->county) {
g_free(mapzen_place->address->county);
mapzen_place->address->county = NULL;
}
- if (mapzen_place->address->state) {
- g_free(mapzen_place->address->state);
- mapzen_place->address->state = NULL;
+ if (mapzen_place->address->region) {
+ g_free(mapzen_place->address->region);
+ mapzen_place->address->region = NULL;
}
if (mapzen_place->address->country) {
g_free(mapzen_place->address->country);
mapzen_place->address->country = NULL;
}
- if (mapzen_place->address->country_code) {
- g_free(mapzen_place->address->country_code);
- mapzen_place->address->country_code = NULL;
+ if (mapzen_place->address->country_a) {
+ g_free(mapzen_place->address->country_a);
+ mapzen_place->address->country_a = NULL;
}
- if (mapzen_place->address->postal_code) {
- g_free(mapzen_place->address->postal_code);
- mapzen_place->address->postal_code = NULL;
+ if (mapzen_place->address->postalcode) {
+ g_free(mapzen_place->address->postalcode);
+ mapzen_place->address->postalcode = NULL;
}
g_free(mapzen_place->address);
mapzen_place->address = NULL;
int mapzen_init_queue()
{
-#if !GLIB_CHECK_VERSION(2, 35, 0)
- g_type_init(); /* Needed for using json in Emulator */
-#endif
-
pthread_mutex_init(&__requestLock, NULL);
/* Queue initialize */
#include "mapzen_restcurl.h"
#include "mapzen_util.h"
-#define REVERSE_GEOCODE_URL "https://search.mapzen.com/v1/reverse?size=1&point.lat=%f&point.lon=%f&api_key=%s"
+#define REVERSE_GEOCODE_URL "https://search.mapzen.com/v1/reverse?size=10&layers=address,locality&point.lat=%f&point.lon=%f&api_key=%s"
int query_revgeocode(gchar *maps_key, gdouble latitude, gdouble longitude, gpointer user_data)
{
} mapzen_tiledata_req_s;
typedef struct {
- gchar *street_add;
+ gchar *street;
gchar *neighbourhood;
- gchar *building_number;
- gchar *city;
+ gchar *housenumber;
+ gchar *localadmin;
gchar *county;
- gchar *state;
+ gchar *region;
gchar *country;
- gchar *country_code;
- gchar *postal_code;
+ gchar *country_a;
+ gchar *postalcode;
} mapzen_address_resp_s;
typedef struct {
return false;
}
-EXPORT_API int maps_plugin_init(maps_plugin_h *plugin)
+
+/*MASSIVE TODO:
+ *
+ * THE TIZEN API REQUIRES A BUNCH MORE FUNCTIONS A LOT OF WHICH HAVE TO DO WITH MAP RENDERING
+ * TO BE ABLE TO LOAD THE LIBRARY IN A COMPATIBLE WAY. HERE WE STUB OUT THE METHODS BUT DO NO
+ * IMPLEMENTING JUST SO WE CAN TEST THE STUFF WE HAVE DONE...
+ */
+
+EXPORT_API int maps_plugin_multi_reverse_geocode(const maps_coordinates_list_h geocode_list,
+ const maps_preference_h preference, maps_service_multi_reverse_geocode_cb callback,
+ void *user_data, int *request_id){return MAPS_ERROR_NOT_SUPPORTED ;}
+EXPORT_API int maps_plugin_search_place_list(const maps_area_h boundary, const maps_place_filter_h filter,
+ maps_preference_h preference, maps_service_search_place_list_cb callback, void* user_data, int* request_id){return MAPS_ERROR_NOT_SUPPORTED ;}
+EXPORT_API int maps_plugin_get_place_details(const char* url,
+ maps_service_get_place_details_cb callback, void* user_data, int* request_id){return MAPS_ERROR_NOT_SUPPORTED ;}
+EXPORT_API int maps_plugin_create_map_view(maps_view_h hView, maps_plugin_map_view_ready_cb pCbFunc){return MAPS_ERROR_NOT_SUPPORTED ;}
+EXPORT_API int maps_plugin_destroy_map_view(maps_view_h hView){return MAPS_ERROR_NOT_SUPPORTED ;}
+EXPORT_API int maps_plugin_render_map(maps_view_h hView,
+ const maps_coordinates_h coordinates, double zoom_factor, double rotation_angle){return MAPS_ERROR_NOT_SUPPORTED ;}
+EXPORT_API int maps_plugin_move_center(maps_view_h hView, int delta_x, int delta_y){return MAPS_ERROR_NOT_SUPPORTED ;}
+EXPORT_API int maps_plugin_set_scalebar(maps_view_h hView, bool enable){return MAPS_ERROR_NOT_SUPPORTED ;}
+EXPORT_API int maps_plugin_get_scalebar(maps_view_h hView, bool *enabled){return MAPS_ERROR_NOT_SUPPORTED ;}
+EXPORT_API int maps_plugin_draw_map(maps_view_h hView, Evas* canvas, int x, int y, int w, int h){return MAPS_ERROR_NOT_SUPPORTED ;}
+EXPORT_API int maps_plugin_on_object(maps_view_h hView, const maps_view_object_h object, maps_view_object_operation_e operation){return MAPS_ERROR_NOT_SUPPORTED ;}
+EXPORT_API int maps_plugin_screen_to_geography(maps_view_h hView, int x, int y, maps_coordinates_h *mapsCoord){return MAPS_ERROR_NOT_SUPPORTED ;}
+EXPORT_API int maps_plugin_geography_to_screen(maps_view_h hView, const maps_coordinates_h mapsCoord, int* x, int* y){return MAPS_ERROR_NOT_SUPPORTED ;}
+EXPORT_API int maps_plugin_get_min_zoom_level(maps_view_h hView, int *min_zoom_level){return MAPS_ERROR_NOT_SUPPORTED ;}
+EXPORT_API int maps_plugin_get_max_zoom_level(maps_view_h hView, int *max_zoom_level){return MAPS_ERROR_NOT_SUPPORTED ;}
+EXPORT_API int maps_plugin_get_center(maps_view_h hView, maps_coordinates_h *center){return MAPS_ERROR_NOT_SUPPORTED ;}
+
+/*END MASSIVE TODO:
+ */
+
+EXPORT_API int maps_plugin_init_module(maps_plugin_h *plugin, const char* module)
{
if (!plugin)
return MAPS_ERROR_INVALID_PARAMETER;
return __convert_to_maps_error(ret);
}
+EXPORT_API int maps_plugin_init(maps_plugin_h *plugin)
+{
+ return maps_plugin_init_module(plugin, NULL);
+}
+
EXPORT_API int maps_plugin_shutdown(maps_plugin_h plugin)
{
MAPS_LOGD("PLUGIN SHUTDOWN");
return MAPS_ERROR_INVALID_PARAMETER;
maps_plugin_info_create(info);
- maps_plugin_info_set_provider_name(*info, "MAPZEN");
+ maps_plugin_info_set_provider_name(*info, "mapzen");
return MAPS_ERROR_NONE;
}
maps_address_h addr = NULL;
maps_address_create(&addr);
- maps_address_set_street(addr, address->street_add);
- maps_address_set_city(addr, address->city);
+ //TODO: housenumber??
+ maps_address_set_street(addr, address->street);
+ maps_address_set_city(addr, address->localadmin);
maps_address_set_county(addr, address->county);
- maps_address_set_state(addr, address->state);
+ maps_address_set_state(addr, address->region);
maps_address_set_country(addr, address->country);
- maps_address_set_country_code(addr, address->country_code);
- maps_address_set_postal_code(addr, address->postal_code);
+ maps_address_set_country_code(addr, address->country_a);
+ maps_address_set_postal_code(addr, address->postalcode);
calldata_reverse_geocode->callback(MAPS_ERROR_NONE, calldata_reverse_geocode->reqID, index, total_count, addr, calldata_reverse_geocode->data);
}
maps_address_h addr = NULL;
maps_address_create(&addr);
- maps_address_set_street(addr, mapzen_place->address->street_add);
- maps_address_set_building_number(addr, mapzen_place->address->building_number);
- maps_address_set_city(addr, mapzen_place->address->city);
+ maps_address_set_street(addr, mapzen_place->address->street);
+ maps_address_set_building_number(addr, mapzen_place->address->housenumber);
+ maps_address_set_city(addr, mapzen_place->address->localadmin);
maps_address_set_county(addr, mapzen_place->address->county);
- maps_address_set_state(addr, mapzen_place->address->state);
+ maps_address_set_state(addr, mapzen_place->address->region);
maps_address_set_country(addr, mapzen_place->address->country);
- maps_address_set_country_code(addr, mapzen_place->address->country_code);
- maps_address_set_postal_code(addr, mapzen_place->address->postal_code);
+ maps_address_set_country_code(addr, mapzen_place->address->country_a);
+ maps_address_set_postal_code(addr, mapzen_place->address->postalcode);
maps_address_set_freetext(addr, mapzen_place->display_name);
maps_place_set_address(place, addr);