src/mapzen_plugin.c
# Mapzen Engine
- src/mapzen/mapzen_api.c
+ src/mapzen/mapzen_api.cpp
src/mapzen/mapzen_geocode.c
src/mapzen/mapzen_revgeocode.c
src/mapzen/mapzen_route.cpp
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "mapzen_api.h"
-#include "mapzen_server_private.h"
-#include "mapzen_queue.h"
-#include "mapzen_debug.h"
-
-int mapzen_init()
-{
- int ret = mapzen_init_queue();
-
- return ret;
-}
-
-int mapzen_shutdown()
-{
- int ret = mapzen_deinit_queue();
-
- return ret;
-}
-
-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;
-}
-
-int mapzen_cancel_request(int request_id)
-{
- int ret = remove_from_request_list(request_id);
-
- return ret;
-}
-
-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;
-}
-
-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_place_service(req_details, callback, request_id, user_data);
-
- return ret;
-}
-
-int mapzen_get_place_details(mapzen_get_details_req_s *req_details, mapzen_get_place_details_cb callback, int request_id, void *user_data)
-{
- int ret = MAPZEN_ERROR_NONE;
- ret = start_place_details_service(req_details, callback, request_id, user_data);
-
- return ret;
-}
-
-int mapzen_search_place_list(mapzen_search_req_s *req_details, mapzen_place_list_search_cb callback, int request_id, void *user_data)
-{
- int ret = MAPZEN_ERROR_NONE;
- ret = start_places_list_service(req_details, callback, request_id, user_data);
-
- return ret;
-}
-
-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);
-
- return ret;
-}
--- /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.
+ */
+
+extern "C" {
+#include "mapzen_queue.h"
+#include "mapzen_debug.h"
+#include "mapzen_util.h"
+}
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "mapzen_api.hpp"
+#include "mapzen_server_private.h"
+#include "tangram_view.hpp"
+
+int mapzen_init()
+{
+ int ret = mapzen_init_queue();
+
+ return ret;
+}
+
+int mapzen_shutdown()
+{
+ int ret = mapzen_deinit_queue();
+
+ return ret;
+}
+
+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;
+}
+
+int mapzen_cancel_request(int request_id)
+{
+ int ret = remove_from_request_list(request_id);
+
+ return ret;
+}
+
+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;
+}
+
+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_place_service(req_details, callback, request_id, user_data);
+
+ return ret;
+}
+
+int mapzen_get_place_details(mapzen_get_details_req_s *req_details, mapzen_get_place_details_cb callback, int request_id, void *user_data)
+{
+ int ret = MAPZEN_ERROR_NONE;
+ ret = start_place_details_service(req_details, callback, request_id, user_data);
+
+ return ret;
+}
+
+int mapzen_search_place_list(mapzen_search_req_s *req_details, mapzen_place_list_search_cb callback, int request_id, void *user_data)
+{
+ int ret = MAPZEN_ERROR_NONE;
+ ret = start_places_list_service(req_details, callback, request_id, user_data);
+
+ return ret;
+}
+
+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);
+
+ return ret;
+}
+
+int mapzen_create_map_view(maps_view_h hView, maps_plugin_map_view_ready_cb pCbFunc)
+{
+ TangramView* tv = new TangramView();
+ if (!tv) {
+ return MAPZEN_ERROR_OUT_OF_MEMORY;
+ }
+ TangramView* old_tv = nullptr;
+ maps_view_get_maps_plugin_view_handle(hView, (void**)&old_tv);
+ maps_view_set_maps_plugin_view_handle(hView, tv);
+ if (old_tv) {
+ delete old_tv;
+ }
+ return tv->create(hView, pCbFunc);
+}
+
+int mapzen_destroy_map_view(maps_view_h hView)
+{
+ TangramView* tv = nullptr;
+ int maps_error = maps_view_get_maps_plugin_view_handle(hView, (void**)&tv);
+ mapzen_error_e error = (mapzen_error_e)convert_maps_error_to_mapzen_error(maps_error);
+ if (error == MAPZEN_ERROR_NONE && tv) {
+ maps_view_set_maps_plugin_view_handle(hView, nullptr);
+ error = tv->destroy(hView);
+ }
+ return error;
+}
+
+int mapzen_render_map(maps_view_h hView, const maps_coordinates_h coordinates, double zoom_factor, double rotation_angle)
+{
+ TangramView* tv = nullptr;
+ int maps_error = maps_view_get_maps_plugin_view_handle(hView, (void**)&tv);
+ mapzen_error_e error = (mapzen_error_e)convert_maps_error_to_mapzen_error(maps_error);
+ if (error == MAPZEN_ERROR_NONE && tv) {
+ error = tv->render(hView, coordinates, zoom_factor, rotation_angle);
+ }
+ return error;
+}
+
+int mapzen_move_center(maps_view_h hView, int delta_x, int delta_y)
+{
+ TangramView* tv = nullptr;
+ int maps_error = maps_view_get_maps_plugin_view_handle(hView, (void**)&tv);
+ mapzen_error_e error = (mapzen_error_e)convert_maps_error_to_mapzen_error(maps_error);
+ if (error == MAPZEN_ERROR_NONE && tv) {
+ error = tv->moveCenter(hView, delta_x, delta_y);
+ }
+ return error;
+}
+
+int mapzen_set_scalebar(maps_view_h hView, bool enable)
+{
+ TangramView* tv = nullptr;
+ int maps_error = maps_view_get_maps_plugin_view_handle(hView, (void**)&tv);
+ mapzen_error_e error = (mapzen_error_e)convert_maps_error_to_mapzen_error(maps_error);
+ if (error == MAPZEN_ERROR_NONE && tv) {
+ error = tv->setScalebarEnabled(hView, enable);
+ }
+ return error;
+}
+
+int mapzen_get_scalebar(maps_view_h hView, bool *enabled)
+{
+ TangramView* tv = nullptr;
+ int maps_error = maps_view_get_maps_plugin_view_handle(hView, (void**)&tv);
+ mapzen_error_e error = (mapzen_error_e)convert_maps_error_to_mapzen_error(maps_error);
+ if (error == MAPZEN_ERROR_NONE && tv) {
+ error = tv->getScalebarEnabled(hView, enabled);
+ }
+ return error;
+}
+
+int mapzen_on_object(maps_view_h hView, const maps_view_object_h object, maps_view_object_operation_e operation)
+{
+ TangramView* tv = nullptr;
+ int maps_error = maps_view_get_maps_plugin_view_handle(hView, (void**)&tv);
+ mapzen_error_e error = (mapzen_error_e)convert_maps_error_to_mapzen_error(maps_error);
+ if (error == MAPZEN_ERROR_NONE && tv) {
+ error = tv->onViewObject(hView, object, operation);
+ }
+ return error;
+}
+
+int mapzen_screen_to_geography(maps_view_h hView, int x, int y, maps_coordinates_h *mapsCoord)
+{
+ TangramView* tv = nullptr;
+ int maps_error = maps_view_get_maps_plugin_view_handle(hView, (void**)&tv);
+ mapzen_error_e error = (mapzen_error_e)convert_maps_error_to_mapzen_error(maps_error);
+ if (error == MAPZEN_ERROR_NONE && tv) {
+ error = tv->convertScreenToGeolocation(hView, x, y, mapsCoord);
+ }
+ return error;
+}
+
+int mapzen_geography_to_screen(maps_view_h hView, const maps_coordinates_h mapsCoord, int* x, int* y)
+{
+ TangramView* tv = nullptr;
+ int maps_error = maps_view_get_maps_plugin_view_handle(hView, (void**)&tv);
+ mapzen_error_e error = (mapzen_error_e)convert_maps_error_to_mapzen_error(maps_error);
+ if (error == MAPZEN_ERROR_NONE && tv) {
+ error = tv->convertGeolocationToScreen(hView, mapsCoord, x, y);
+ }
+ return error;
+}
+
+int mapzen_get_min_zoom_level(maps_view_h hView, int *min_zoom_level)
+{
+ TangramView* tv = nullptr;
+ int maps_error = maps_view_get_maps_plugin_view_handle(hView, (void**)&tv);
+ mapzen_error_e error = (mapzen_error_e)convert_maps_error_to_mapzen_error(maps_error);
+ if (error == MAPZEN_ERROR_NONE && tv) {
+ error = tv->getMinZoomLevel(hView, min_zoom_level);
+ }
+ return error;
+}
+
+int mapzen_get_max_zoom_level(maps_view_h hView, int *max_zoom_level)
+{
+ TangramView* tv = nullptr;
+ int maps_error = maps_view_get_maps_plugin_view_handle(hView, (void**)&tv);
+ mapzen_error_e error = (mapzen_error_e)convert_maps_error_to_mapzen_error(maps_error);
+ if (error == MAPZEN_ERROR_NONE && tv) {
+ error = tv->getMaxZoomLevel(hView, max_zoom_level);
+ }
+ return error;
+}
+
+int mapzen_get_center(maps_view_h hView, maps_coordinates_h *center)
+{
+ TangramView* tv = nullptr;
+ int maps_error = maps_view_get_maps_plugin_view_handle(hView, (void**)&tv);
+ mapzen_error_e error = (mapzen_error_e)convert_maps_error_to_mapzen_error(maps_error);
+ if (error == MAPZEN_ERROR_NONE && tv) {
+ error = tv->getCenter(hView, center);
+ }
+ return error;
+}
+++ /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_API_H_
-#define _MAPZEN_API_H_
-
-#include "mapzen_types.h"
-#include <tizen_type.h>
-
-/**
- * @ingroup MAPZEN_ENGINE_MODULE
- * @defgroup MAPZEN_ENGINE_API_MODULE
- *
- * @file mapzen_api.h
- * @brief This file contains the Mapzen engine API's that should be called by the plugin
- *
- * @addtogroup MAPZEN_ENGINE_MODULE
- * @{
- * @brief This provides APIs related to Mapzen engine.
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
- /* Callbacks */
-typedef void (*mapzen_geocode_cb) (mapzen_error_e result, int request_id, GList *co_ordinates, void *user_data);
-
-typedef void (*mapzen_reverse_geocode_cb) (mapzen_error_e result, int request_id, mapzen_address_resp_s *address, void *user_data);
-
-typedef void (*mapzen_place_search_cb) (mapzen_error_e result, int request_id, GList *places, void *user_data);
-
-typedef void (*mapzen_get_place_details_cb) (mapzen_error_e result, int request_id, GList *places, void *user_data);
-
-typedef void (*mapzen_place_list_search_cb) (mapzen_error_e result, int request_id, GList *places, void *user_data);
-
-typedef void (*mapzen_route_cb) (mapzen_error_e result, int request_id, mapzen_route_resp_s *route_info, void *user_data);
-
-typedef void (*mapzen_maptile_cb) (mapzen_error_e result, int request_id, char *buffer, void *user_data);
-
-int mapzen_init();
-
-int mapzen_shutdown();
-
-int mapzen_geocode(mapzen_geocode_req_s *req_details, mapzen_geocode_cb callback, int request_id, void *user_data);
-
-int mapzen_cancel_request(int request_id);
-
-int mapzen_reverse_geocode(mapzen_revgeocode_req_s *req_details, mapzen_reverse_geocode_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 mapzen_get_place_details(mapzen_get_details_req_s *req_details, mapzen_get_place_details_cb callback, int request_id, void *user_data);
-
-int mapzen_search_place_list(mapzen_search_req_s *req_details, mapzen_place_list_search_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);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _MAPZEN_API_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_API_H_
+#define _MAPZEN_API_H_
+
+#include "mapzen_types.h"
+#include <maps_plugin.h>
+#include <tizen_type.h>
+
+/**
+ * @ingroup MAPZEN_ENGINE_MODULE
+ * @defgroup MAPZEN_ENGINE_API_MODULE
+ *
+ * @file mapzen_api.h
+ * @brief This file contains the Mapzen engine API's that should be called by the plugin
+ *
+ * @addtogroup MAPZEN_ENGINE_MODULE
+ * @{
+ * @brief This provides APIs related to Mapzen engine.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ /* Callbacks */
+typedef void (*mapzen_geocode_cb) (mapzen_error_e result, int request_id, GList *co_ordinates, void *user_data);
+
+typedef void (*mapzen_reverse_geocode_cb) (mapzen_error_e result, int request_id, mapzen_address_resp_s *address, void *user_data);
+
+typedef void (*mapzen_place_search_cb) (mapzen_error_e result, int request_id, GList *places, void *user_data);
+
+typedef void (*mapzen_get_place_details_cb) (mapzen_error_e result, int request_id, GList *places, void *user_data);
+
+typedef void (*mapzen_place_list_search_cb) (mapzen_error_e result, int request_id, GList *places, void *user_data);
+
+typedef void (*mapzen_route_cb) (mapzen_error_e result, int request_id, mapzen_route_resp_s *route_info, void *user_data);
+
+typedef void (*mapzen_maptile_cb) (mapzen_error_e result, int request_id, char *buffer, void *user_data);
+
+int mapzen_init();
+
+int mapzen_shutdown();
+
+int mapzen_geocode(mapzen_geocode_req_s *req_details, mapzen_geocode_cb callback, int request_id, void *user_data);
+
+int mapzen_cancel_request(int request_id);
+
+int mapzen_reverse_geocode(mapzen_revgeocode_req_s *req_details, mapzen_reverse_geocode_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 mapzen_get_place_details(mapzen_get_details_req_s *req_details, mapzen_get_place_details_cb callback, int request_id, void *user_data);
+
+int mapzen_search_place_list(mapzen_search_req_s *req_details, mapzen_place_list_search_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 mapzen_create_map_view(maps_view_h hView, maps_plugin_map_view_ready_cb pCbFunc);
+
+int mapzen_destroy_map_view(maps_view_h hView);
+
+int mapzen_render_map(maps_view_h hView, const maps_coordinates_h coordinates, double zoom_factor, double rotation_angle);
+
+int mapzen_move_center(maps_view_h hView, int delta_x, int delta_y);
+
+int mapzen_set_scalebar(maps_view_h hView, bool enable);
+
+int mapzen_get_scalebar(maps_view_h hView, bool *enabled);
+
+int mapzen_on_object(maps_view_h hView, const maps_view_object_h object, maps_view_object_operation_e operation);
+
+int mapzen_screen_to_geography(maps_view_h hView, int x, int y, maps_coordinates_h *mapsCoord);
+
+int mapzen_geography_to_screen(maps_view_h hView, const maps_coordinates_h mapsCoord, int* x, int* y);
+
+int mapzen_get_min_zoom_level(maps_view_h hView, int *min_zoom_level);
+
+int mapzen_get_max_zoom_level(maps_view_h hView, int *max_zoom_level);
+
+int mapzen_get_center(maps_view_h hView, maps_coordinates_h *center);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _MAPZEN_API_H_ */
#ifndef _MAPZEN_GEOCODE_H_
#define _MAPZEN_GEOCODE_H_
-#include "mapzen_api.h"
+#include "mapzen_api.hpp"
#include "mapzen_types.h"
int query_geocode(gchar *maps_key, char *address, int num_results, gpointer user_data);
#ifndef _MAPZEN_PLACES_H_
#define _MAPZEN_PLACES_H_
-#include "mapzen_api.h"
+#include "mapzen_api.hpp"
#include "mapzen_types.h"
#include "mapzen_server_private.h"
#ifndef _MAPZEN_REVGEOCODE_H_
#define _MAPZEN_REVGEOCODE_H_
-#include "mapzen_api.h"
+#include "mapzen_api.hpp"
#include "mapzen_types.h"
int query_revgeocode(gchar *maps_key, gdouble latitude, gdouble longitude, gpointer user_data);
#ifndef _MAPZEN_ROUTE_H_
#define _MAPZEN_ROUTE_H_
-#include "mapzen_api.h"
+#include "mapzen_api.hpp"
#include "mapzen_types.h"
#ifdef __cplusplus
#ifndef _MAPZEN_PRIVATE_H_
#define _MAPZEN_PRIVATE_H_
-#include "mapzen_api.h"
+#include "mapzen_api.hpp"
typedef enum {
REQ_TYPE_GEOCODE = 0,
* limitations under the License.
*/
+extern "C" {
+#include "mapzen_queue.h"
+#include "mapzen_debug.h"
#include "mapzen_util.h"
+}
+
#include "mapzen_plugin_internal.h"
#include "tangram_view.hpp"
#include "tangram/tangram.h"
#include <stdlib.h>
#include "mapzen_plugin.h"
#include "mapzen_plugin_internal.h"
-#include "mapzen_api.h"
+#include "mapzen_api.hpp"
#include "mapzen_util.h"
#include <maps_error.h>
#include <maps_route_plugin.h>