New APIs for Tizen 3.x 63/82463/1
authorchanywa <cbible.kim@samsung.com>
Fri, 22 Jul 2016 04:16:37 +0000 (13:16 +0900)
committerchanywa <cbible.kim@samsung.com>
Wed, 3 Aug 2016 11:20:47 +0000 (20:20 +0900)
1) Appending a point to the polyline
2) Enabling to set departure time when searching route

Change-Id: Ief4f569c02d2478f602c2a9984f955da41fb5897

include/maps_preference.h
include/maps_route.h
include/maps_view_object.h
src/api/maps_preference.cpp
src/api/maps_view_object.cpp

index 81c0700555f77cb7b7c6994541e4f1869da9b1ad..82dba08839763bc4cf4fa3e998022ee40b9d5bb4 100644 (file)
@@ -463,6 +463,20 @@ int maps_preference_get_route_feature(const maps_preference_h preference,
 int maps_preference_get_route_alternatives_enabled(const maps_preference_h preference,
                                                                bool *enable);
 
+/**
+ * @brief      Gets the departure time of a route.
+ * @details This function retrieves the departure time of a route.
+ * @since_tizen @if MOBILE 3.0 @elseif WEARABLE 2.3.2 @endif
+ *
+ * @param[in]  preference      The preference handle
+ * @param[out] time            The departure time
+ * @return     0 on success, otherwise a negative error value
+ * @retval     #MAPS_ERROR_NONE Successful
+ * @retval     #MAPS_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int maps_preference_get_route_departure_time(const maps_preference_h preference,
+                                                               time_t *time);
+
 /**
  * @brief      Gets the maps preference value by key.
  * @details This function gets the maps preference value by key.
@@ -681,6 +695,20 @@ int maps_preference_set_route_feature(maps_preference_h preference,
 int maps_preference_set_route_alternatives_enabled(maps_preference_h preference,
                                                                bool enable);
 
+/**
+ * @brief      Sets the departure time of a route.
+ * @details This function sets the departure time of a route.
+ * @since_tizen @if MOBILE 3.0 @elseif WEARABLE 2.3.2 @endif
+ *
+ * @param[in]  preference      The preference handle
+ * @param[in]  time            The departure time
+ * @return     0 on success, otherwise a negative error value
+ * @retval     #MAPS_ERROR_NONE Successful
+ * @retval     #MAPS_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int maps_preference_set_route_departure_time(const maps_preference_h preference,
+                                                               time_t time);
+
 /**
  * @brief      Sets the preference value by key.
  * @details This function sets the preference value assigned with a specified
index de231ca7e40e5c8dc57de9d7f627d4c9c783ee09..40671ddf6b86e46185339a8ae7dbcd2792fd21f8 100644 (file)
@@ -17,6 +17,7 @@
 #ifndef __MAPS_ROUTE_H__
 #define __MAPS_ROUTE_H__
 
+#include <time.h>
 #include <tizen_type.h>
 #include <maps_area.h>
 #include <maps_route_segment.h>
index baceecb2dc4ee37cda1eaa79e42e14ec9a251546..62811d9c9579eaa1330c5e559b41805f0374db37 100644 (file)
@@ -389,6 +389,28 @@ int maps_view_object_get_visible(const maps_view_object_h object, bool *visible)
  */
 int maps_view_object_polyline_set_polyline(maps_view_object_h polyline, maps_coordinates_list_h points);
 
+/**
+ * @brief      Appends a point to the polyline.
+ * @details This function appends a point to the polyline.
+ * @since_tizen @if MOBILE 3.0 @elseif WEARABLE 2.3.2 @endif
+ *
+ * @param[in]  polyline        The polyline object handle
+ * @param[in]  point           The point to append
+ * @return     0 on success, otherwise a negative error value
+ * @retval     #MAPS_ERROR_NONE Successful
+ * @retval     #MAPS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @pre @a polyline is created using maps_view_object_create_polyline().
+ * @pre @a point is created using maps_coordinates_create().
+ *
+ * @see #maps_view_object_h
+ * @see #maps_coordinates_h
+ * @see maps_coordinates_create()
+ * @see maps_view_object_create_polyline()
+ * @see maps_view_object_polyline_foreach_point()
+ */
+int maps_view_object_polyline_append_point(maps_view_object_h polyline, maps_coordinates_h point);
+
 /**
  * @brief      Retrieves all points, added to the polyline.
  * @details This function retrieves all points, added to the polyline.
index 674c47398d57ad67f081c1f5860f79739263a1fc..467908a74352731664efa93675e79e5f0fb72b87 100644 (file)
@@ -56,7 +56,8 @@ static bool __isnamed_preference(const char *key)
                g_str_hash("MAPS_PREFERENCE_ROUTE_TRANSPORT_MODE"),
                g_str_hash("MAPS_PREFERENCE_ROUTE_FEATURE_WEIGHT"),
                g_str_hash("MAPS_PREFERENCE_ROUTE_FEATURE"),
-               g_str_hash("MAPS_PREFERENCE_ROUTE_ALTERNATIVES")
+               g_str_hash("MAPS_PREFERENCE_ROUTE_ALTERNATIVES"),
+               g_str_hash("MAPS_PREFERENCE_ROUTE_DEPARTURE_TIME"),
        };
        const int size = sizeof(names) / sizeof(names[0]);
 
@@ -114,6 +115,10 @@ EXPORT_API int maps_preference_create(maps_preference_h *preference)
                if (error != MAPS_ERROR_NONE)
                        break;
 
+               error = maps_item_hashtable_set_int(*preference, "MAPS_PREFERENCE_ROUTE_DEPARTURE_TIME", 0);
+               if (error != MAPS_ERROR_NONE)
+                       break;
+
                return MAPS_ERROR_NONE;
        } while (0);
 
@@ -213,19 +218,26 @@ EXPORT_API int maps_preference_get_route_feature(const maps_preference_h prefere
 EXPORT_API int maps_preference_get_route_alternatives_enabled(
                                                                const maps_preference_h preference, bool *enable)
 {
-       if (!preference)
+       if (!preference || !enable)
                return MAPS_ERROR_INVALID_PARAMETER;
-
-       int alternatives;
-       int error = maps_item_hashtable_get_int(preference, "MAPS_PREFERENCE_ROUTE_ALTERNATIVES", &alternatives);
+       int alternatives = 0;
+       int error = maps_item_hashtable_get_int(preference,
+               "MAPS_PREFERENCE_ROUTE_ALTERNATIVES", &alternatives);
        if (error != MAPS_ERROR_NONE)
                return error;
-
        *enable = (alternatives == _DEFAULT_ALTERNATIVES_SIZE) ? true :false;
-
        return MAPS_ERROR_NONE;
 }
 
+EXPORT_API int maps_preference_get_route_departure_time(const maps_preference_h preference,
+                                                               time_t *time)
+{
+       if (!preference || !time)
+               return MAPS_ERROR_INVALID_PARAMETER;
+       return maps_item_hashtable_get_int(preference,
+               "MAPS_PREFERENCE_ROUTE_DEPARTURE_TIME", (int *)time);
+}
+
 EXPORT_API int maps_preference_get(const maps_preference_h preference,
                                   const char *key, char **value)
 {
@@ -338,12 +350,18 @@ EXPORT_API int maps_preference_set_route_alternatives_enabled(maps_preference_h
 {
        if (!preference)
                return MAPS_ERROR_INVALID_PARAMETER;
+       int alternatives = _DEFAULT_ALTERNATIVES_SIZE * enable;
+       return maps_item_hashtable_set_int(preference,
+               "MAPS_PREFERENCE_ROUTE_ALTERNATIVES", alternatives);
+}
 
-       int alternatives = 0;
-       if (enable)
-               alternatives = _DEFAULT_ALTERNATIVES_SIZE;
-
-       return maps_item_hashtable_set_int(preference, "MAPS_PREFERENCE_ROUTE_ALTERNATIVES", alternatives);
+EXPORT_API int maps_preference_set_route_departure_time(const maps_preference_h preference,
+                                                               time_t time)
+{
+       if (!preference)
+               return MAPS_ERROR_INVALID_PARAMETER;
+       return maps_item_hashtable_set_int(preference,
+               "MAPS_PREFERENCE_ROUTE_DEPARTURE_TIME", (int)time);
 }
 
 EXPORT_API int maps_preference_set_property(maps_preference_h preference,
index 6aafe452cf41b652f8bcbdd8a58fbfb718e5ba98..04aaa235e3b2fa1c8caabe8b655d3d6d39843a5b 100644 (file)
@@ -608,6 +608,37 @@ EXPORT_API int maps_view_object_polyline_set_polyline(maps_view_object_h polylin
        return MAPS_ERROR_NONE;
 }
 
+EXPORT_API int maps_view_object_polyline_append_point(maps_view_object_h polyline,
+                                                               maps_coordinates_h point)
+{
+       if (!polyline || !point)
+               return MAPS_ERROR_INVALID_PARAMETER;
+
+       /* Get the polyline data pointer */
+       maps_view_polyline_data_s *p = __get_polyline_data(polyline);
+       if (!p)
+               return MAPS_ERROR_INVALID_PARAMETER;
+
+       /* Set new polyline trajectory */
+       int error = MAPS_ERROR_NONE;
+       do {
+               if (!p->points) {
+                       error = maps_coordinates_list_create(&p->points);
+                       if (error != MAPS_ERROR_NONE)
+                               break;
+               }
+
+               error = maps_coordinates_list_append(p->points, point);
+               if (error != MAPS_ERROR_NONE)
+                       break;
+
+               /* Notify view, that the object specific preferences is changed */
+               _maps_view_on_object_operation(__get_view(polyline), polyline, MAPS_VIEW_OBJECT_CHANGE);
+       } while(0);
+
+       return error;
+}
+
 EXPORT_API int maps_view_object_polyline_foreach_point(maps_view_object_h polyline,
                                                                maps_coordinates_cb callback, void *user_data)
 {