Renames mapzen_api.h to mapzen_api.hpp and adds interface to TangramView 11/80311/2
authorMatt Blair <blair1618@gmail.com>
Wed, 29 Jun 2016 23:34:10 +0000 (19:34 -0400)
committerJongmun Woo <jongmun.woo@samsung.com>
Tue, 19 Jul 2016 01:12:04 +0000 (18:12 -0700)
Change-Id: I3a09fba697702577550beb132502c63fc16b4fa7

CMakeLists.txt
src/mapzen/mapzen_api.c [deleted file]
src/mapzen/mapzen_api.cpp [new file with mode: 0644]
src/mapzen/mapzen_api.hpp [moved from src/mapzen/mapzen_api.h with 73% similarity]
src/mapzen/mapzen_geocode.h
src/mapzen/mapzen_place.h
src/mapzen/mapzen_revgeocode.h
src/mapzen/mapzen_route.hpp
src/mapzen/mapzen_server_private.h
src/mapzen/tangram_view.cpp
src/mapzen_plugin.c

index 676cb16..38f0f11 100644 (file)
@@ -68,7 +68,7 @@ SET(SRCS
        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
diff --git a/src/mapzen/mapzen_api.c b/src/mapzen/mapzen_api.c
deleted file mode 100644 (file)
index 111ba88..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * 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;
-}
diff --git a/src/mapzen/mapzen_api.cpp b/src/mapzen/mapzen_api.cpp
new file mode 100644 (file)
index 0000000..f780231
--- /dev/null
@@ -0,0 +1,233 @@
+/*
+ * 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;
+}
similarity index 73%
rename from src/mapzen/mapzen_api.h
rename to src/mapzen/mapzen_api.hpp
index 74765e5..a73b94d 100644 (file)
@@ -18,6 +18,7 @@
 #define _MAPZEN_API_H_
 
 #include "mapzen_types.h"
+#include <maps_plugin.h>
 #include <tizen_type.h>
 
 /**
@@ -69,6 +70,30 @@ int mapzen_search_place_list(mapzen_search_req_s *req_details, mapzen_place_list
 
 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
index 6c330ca..04d6dbf 100644 (file)
@@ -17,7 +17,7 @@
 #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);
index 84026a1..353debf 100644 (file)
@@ -17,7 +17,7 @@
 #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"
 
index e61546f..6ec6ed9 100644 (file)
@@ -17,7 +17,7 @@
 #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);
index 3af7b77..b464915 100644 (file)
@@ -17,7 +17,7 @@
 #ifndef _MAPZEN_ROUTE_H_
 #define _MAPZEN_ROUTE_H_
 
-#include "mapzen_api.h"
+#include "mapzen_api.hpp"
 #include "mapzen_types.h"
 
 #ifdef __cplusplus
index f587cd9..e96c998 100644 (file)
@@ -17,7 +17,7 @@
 #ifndef _MAPZEN_PRIVATE_H_
 #define _MAPZEN_PRIVATE_H_
 
-#include "mapzen_api.h"
+#include "mapzen_api.hpp"
 
 typedef enum {
        REQ_TYPE_GEOCODE = 0,
index 6b3b663..9dcadcd 100644 (file)
  * 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"
index 5d4e712..15517e1 100644 (file)
@@ -18,7 +18,7 @@
 #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>