--- /dev/null
+Kangho Hur <kanho.hur@samsung.com>
+Byungyoo Lee <bw1212.lee@samsung.com>
+Youngae Kang <youngae.kang@samsung.com>
+Minjune Kim <sena06.kim@samsung.com>
+Genie Kim <daejins.kim@samsung.com>
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+SET(fw_name "capi-location-route")
+
+PROJECT(${fw_name})
+
+SET(CMAKE_INSTALL_PREFIX /usr)
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+
+SET(INC_DIR include)
+INCLUDE_DIRECTORIES(${INC_DIR})
+
+SET(dependents "dlog location capi-base-common capi-location-manager")
+SET(pc_dependents "capi-base-common capi-location-manager")
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${fw_name} REQUIRED ${dependents})
+FOREACH(flag ${${fw_name}_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+
+IF("${ARCH}" STREQUAL "arm")
+ ADD_DEFINITIONS("-DTARGET")
+ENDIF("${ARCH}" STREQUAL "arm")
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+ADD_DEFINITIONS("-DTIZEN_DEBUG")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=/usr/lib")
+
+aux_source_directory(src SOURCES)
+ADD_LIBRARY(${fw_name} SHARED ${SOURCES})
+
+SET_TARGET_PROPERTIES(${fw_name}
+ PROPERTIES
+ VERSION ${FULLVER}
+ SOVERSION ${MAJORVER}
+ CLEAN_DIRECT_OUTPUT 1
+)
+
+TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS})
+
+INSTALL(TARGETS ${fw_name} DESTINATION lib)
+INSTALL(
+ DIRECTORY ${INC_DIR}/ DESTINATION include/location
+ FILES_MATCHING
+ PATTERN "*_private.h" EXCLUDE
+ PATTERN "${INC_DIR}/*.h"
+ )
+
+SET(PC_NAME ${fw_name})
+SET(PC_REQUIRED ${pc_dependents})
+SET(PC_LDFLAGS -l${fw_name})
+SET(PC_CFLAGS -I\${includedir}/location)
+
+CONFIGURE_FILE(
+ ${fw_name}.pc.in
+ ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc
+ @ONLY
+)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION lib/pkgconfig)
+
+ADD_SUBDIRECTORY(test)
+
+IF(UNIX)
+
+ADD_CUSTOM_TARGET (distclean @echo cleaning for source distribution)
+ADD_CUSTOM_COMMAND(
+ DEPENDS clean
+ COMMENT "distribution clean"
+ COMMAND find
+ ARGS .
+ -not -name config.cmake -and \(
+ -name tester.c -or
+ -name Testing -or
+ -name CMakeFiles -or
+ -name cmake.depends -or
+ -name cmake.check_depends -or
+ -name CMakeCache.txt -or
+ -name cmake.check_cache -or
+ -name *.cmake -or
+ -name Makefile -or
+ -name core -or
+ -name core.* -or
+ -name gmon.out -or
+ -name install_manifest.txt -or
+ -name *.pc -or
+ -name *~ \)
+ | grep -v TC | xargs rm -rf
+ TARGET distclean
+ VERBATIM
+)
+
+ENDIF(UNIX)
--- /dev/null
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+\r
+ Apache License\r
+ Version 2.0, January 2004\r
+ http://www.apache.org/licenses/\r
+\r
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\r
+\r
+ 1. Definitions.\r
+\r
+ "License" shall mean the terms and conditions for use, reproduction,\r
+ and distribution as defined by Sections 1 through 9 of this document.\r
+\r
+ "Licensor" shall mean the copyright owner or entity authorized by\r
+ the copyright owner that is granting the License.\r
+\r
+ "Legal Entity" shall mean the union of the acting entity and all\r
+ other entities that control, are controlled by, or are under common\r
+ control with that entity. For the purposes of this definition,\r
+ "control" means (i) the power, direct or indirect, to cause the\r
+ direction or management of such entity, whether by contract or\r
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the\r
+ outstanding shares, or (iii) beneficial ownership of such entity.\r
+\r
+ "You" (or "Your") shall mean an individual or Legal Entity\r
+ exercising permissions granted by this License.\r
+\r
+ "Source" form shall mean the preferred form for making modifications,\r
+ including but not limited to software source code, documentation\r
+ source, and configuration files.\r
+\r
+ "Object" form shall mean any form resulting from mechanical\r
+ transformation or translation of a Source form, including but\r
+ not limited to compiled object code, generated documentation,\r
+ and conversions to other media types.\r
+\r
+ "Work" shall mean the work of authorship, whether in Source or\r
+ Object form, made available under the License, as indicated by a\r
+ copyright notice that is included in or attached to the work\r
+ (an example is provided in the Appendix below).\r
+\r
+ "Derivative Works" shall mean any work, whether in Source or Object\r
+ form, that is based on (or derived from) the Work and for which the\r
+ editorial revisions, annotations, elaborations, or other modifications\r
+ represent, as a whole, an original work of authorship. For the purposes\r
+ of this License, Derivative Works shall not include works that remain\r
+ separable from, or merely link (or bind by name) to the interfaces of,\r
+ the Work and Derivative Works thereof.\r
+\r
+ "Contribution" shall mean any work of authorship, including\r
+ the original version of the Work and any modifications or additions\r
+ to that Work or Derivative Works thereof, that is intentionally\r
+ submitted to Licensor for inclusion in the Work by the copyright owner\r
+ or by an individual or Legal Entity authorized to submit on behalf of\r
+ the copyright owner. For the purposes of this definition, "submitted"\r
+ means any form of electronic, verbal, or written communication sent\r
+ to the Licensor or its representatives, including but not limited to\r
+ communication on electronic mailing lists, source code control systems,\r
+ and issue tracking systems that are managed by, or on behalf of, the\r
+ Licensor for the purpose of discussing and improving the Work, but\r
+ excluding communication that is conspicuously marked or otherwise\r
+ designated in writing by the copyright owner as "Not a Contribution."\r
+\r
+ "Contributor" shall mean Licensor and any individual or Legal Entity\r
+ on behalf of whom a Contribution has been received by Licensor and\r
+ subsequently incorporated within the Work.\r
+\r
+ 2. Grant of Copyright License. Subject to the terms and conditions of\r
+ this License, each Contributor hereby grants to You a perpetual,\r
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+ copyright license to reproduce, prepare Derivative Works of,\r
+ publicly display, publicly perform, sublicense, and distribute the\r
+ Work and such Derivative Works in Source or Object form.\r
+\r
+ 3. Grant of Patent License. Subject to the terms and conditions of\r
+ this License, each Contributor hereby grants to You a perpetual,\r
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+ (except as stated in this section) patent license to make, have made,\r
+ use, offer to sell, sell, import, and otherwise transfer the Work,\r
+ where such license applies only to those patent claims licensable\r
+ by such Contributor that are necessarily infringed by their\r
+ Contribution(s) alone or by combination of their Contribution(s)\r
+ with the Work to which such Contribution(s) was submitted. If You\r
+ institute patent litigation against any entity (including a\r
+ cross-claim or counterclaim in a lawsuit) alleging that the Work\r
+ or a Contribution incorporated within the Work constitutes direct\r
+ or contributory patent infringement, then any patent licenses\r
+ granted to You under this License for that Work shall terminate\r
+ as of the date such litigation is filed.\r
+\r
+ 4. Redistribution. You may reproduce and distribute copies of the\r
+ Work or Derivative Works thereof in any medium, with or without\r
+ modifications, and in Source or Object form, provided that You\r
+ meet the following conditions:\r
+\r
+ (a) You must give any other recipients of the Work or\r
+ Derivative Works a copy of this License; and\r
+\r
+ (b) You must cause any modified files to carry prominent notices\r
+ stating that You changed the files; and\r
+\r
+ (c) You must retain, in the Source form of any Derivative Works\r
+ that You distribute, all copyright, patent, trademark, and\r
+ attribution notices from the Source form of the Work,\r
+ excluding those notices that do not pertain to any part of\r
+ the Derivative Works; and\r
+\r
+ (d) If the Work includes a "NOTICE" text file as part of its\r
+ distribution, then any Derivative Works that You distribute must\r
+ include a readable copy of the attribution notices contained\r
+ within such NOTICE file, excluding those notices that do not\r
+ pertain to any part of the Derivative Works, in at least one\r
+ of the following places: within a NOTICE text file distributed\r
+ as part of the Derivative Works; within the Source form or\r
+ documentation, if provided along with the Derivative Works; or,\r
+ within a display generated by the Derivative Works, if and\r
+ wherever such third-party notices normally appear. The contents\r
+ of the NOTICE file are for informational purposes only and\r
+ do not modify the License. You may add Your own attribution\r
+ notices within Derivative Works that You distribute, alongside\r
+ or as an addendum to the NOTICE text from the Work, provided\r
+ that such additional attribution notices cannot be construed\r
+ as modifying the License.\r
+\r
+ You may add Your own copyright statement to Your modifications and\r
+ may provide additional or different license terms and conditions\r
+ for use, reproduction, or distribution of Your modifications, or\r
+ for any such Derivative Works as a whole, provided Your use,\r
+ reproduction, and distribution of the Work otherwise complies with\r
+ the conditions stated in this License.\r
+\r
+ 5. Submission of Contributions. Unless You explicitly state otherwise,\r
+ any Contribution intentionally submitted for inclusion in the Work\r
+ by You to the Licensor shall be under the terms and conditions of\r
+ this License, without any additional terms or conditions.\r
+ Notwithstanding the above, nothing herein shall supersede or modify\r
+ the terms of any separate license agreement you may have executed\r
+ with Licensor regarding such Contributions.\r
+\r
+ 6. Trademarks. This License does not grant permission to use the trade\r
+ names, trademarks, service marks, or product names of the Licensor,\r
+ except as required for reasonable and customary use in describing the\r
+ origin of the Work and reproducing the content of the NOTICE file.\r
+\r
+ 7. Disclaimer of Warranty. Unless required by applicable law or\r
+ agreed to in writing, Licensor provides the Work (and each\r
+ Contributor provides its Contributions) on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\r
+ implied, including, without limitation, any warranties or conditions\r
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\r
+ PARTICULAR PURPOSE. You are solely responsible for determining the\r
+ appropriateness of using or redistributing the Work and assume any\r
+ risks associated with Your exercise of permissions under this License.\r
+\r
+ 8. Limitation of Liability. In no event and under no legal theory,\r
+ whether in tort (including negligence), contract, or otherwise,\r
+ unless required by applicable law (such as deliberate and grossly\r
+ negligent acts) or agreed to in writing, shall any Contributor be\r
+ liable to You for damages, including any direct, indirect, special,\r
+ incidental, or consequential damages of any character arising as a\r
+ result of this License or out of the use or inability to use the\r
+ Work (including but not limited to damages for loss of goodwill,\r
+ work stoppage, computer failure or malfunction, or any and all\r
+ other commercial damages or losses), even if such Contributor\r
+ has been advised of the possibility of such damages.\r
+\r
+ 9. Accepting Warranty or Additional Liability. While redistributing\r
+ the Work or Derivative Works thereof, You may choose to offer,\r
+ and charge a fee for, acceptance of support, warranty, indemnity,\r
+ or other liability obligations and/or rights consistent with this\r
+ License. However, in accepting such obligations, You may act only\r
+ on Your own behalf and on Your sole responsibility, not on behalf\r
+ of any other Contributor, and only if You agree to indemnify,\r
+ defend, and hold each Contributor harmless for any liability\r
+ incurred by, or claims asserted against, such Contributor by reason\r
+ of your accepting any such warranty or additional liability.\r
+\r
+ END OF TERMS AND CONDITIONS\r
+\r
+ APPENDIX: How to apply the Apache License to your work.\r
+\r
+ To apply the Apache License to your work, attach the following\r
+ boilerplate notice, with the fields enclosed by brackets "[]"\r
+ replaced with your own identifying information. (Don't include\r
+ the brackets!) The text should be enclosed in the appropriate\r
+ comment syntax for the file format. We also recommend that a\r
+ file or class name and description of purpose be included on the\r
+ same "printed page" as the copyright notice for easier\r
+ identification within third-party archives.\r
+\r
+ Copyright [yyyy] [name of copyright owner]\r
+\r
+ Licensed under the Apache License, Version 2.0 (the "License");\r
+ you may not use this file except in compliance with the License.\r
+ You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+\r
+\r
+\r
--- /dev/null
+<manifest>
+ <request>
+ <domain name="_"/>
+ </request>
+</manifest>
--- /dev/null
+# Package Information for pkg-config
+
+prefix=@PREFIX@
+exec_prefix=/usr
+libdir=/usr/lib
+includedir=/usr/include/location
+
+Name: @PC_NAME@
+Description: @PACKAGE_DESCRIPTION@
+Version: @VERSION@
+Requires: @PC_REQUIRED@
+Libs: -L${libdir} @PC_LDFLAGS@
+Cflags: -I${includedir}
--- /dev/null
+/*
+* Copyright (c) 2011-2013 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 __TIZEN_LOCATION_ROUTE_H__
+#define __TIZEN_LOCATION_ROUTE_H__
+
+#include <location_bounds.h>
+
+#include "route_handle.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**
+ * @addtogroup CAPI_LOCATION_ROUTE_MODULE
+ * @{
+ */
+
+/**
+ * @brief Called repeatedly when you get the list of a pair of key and value in properties.
+ * @remarks @a key and @a value are valid only in this function.
+ * @param[in] key The property key of route
+ * @param[in] value The property value of route
+ * @param[in] user_data The user data passed from foreach function
+ * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop
+ * @see route_foreach_properties()
+ */
+typedef bool(*route_property_cb)(const char *key, const char *value, void *user_data);
+
+/**
+ * @brief Called repeatedly when you get the list of segments.
+ * @remarks @a segment is valid only in this function.
+ * @param[in] segment The segment of route
+ * @param[in] user_data The user data passed from foreach function
+ * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop
+ * @see route_foreach_segments()
+ */
+typedef bool(*route_segment_cb)(route_segment_h segment, void *user_data);
+
+/**
+ * @brief Enumerations of distance unit
+ */
+typedef enum
+{
+ ROUTE_DISTANCE_UNIT_M = 0, /**< Meter */
+ ROUTE_DISTANCE_UNIT_KM = 1, /**< Kilometer */
+ ROUTE_DISTANCE_UNIT_FT = 2, /**< Feet */
+ ROUTE_DISTANCE_UNIT_YD = 3, /**< Yard */
+ ROUTE_DISTANCE_UNIT_MI = 4, /**< Mile */
+} route_distance_unit_e;
+
+/**
+ * @}
+ */
+
+/**
+ * @addtogroup CAPI_LOCATION_ROUTE_SEGMENT_MODULE
+ * @{
+ */
+
+/**
+ * @brief Called repeatedly when you get the list of a pair of key and value in properties.
+ * @remarks @a key and @a value are valid only in this function.
+ * @param[in] key The property key of route segment
+ * @param[in] value The property value of route segment
+ * @param[in] user_data The user data passed from foreach function
+ * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop
+ * @see route_segment_foreach_properties()
+ */
+typedef bool(*route_segment_property_cb)(const char *key, const char *value, void *user_data);
+
+/**
+ * @brief Called repeatedly when you get the list of steps.
+ * @remarks @a step is valid only in this function.
+ * @param[in] step The step of route segment
+ * @param[in] user_data The user data passed from foreach function
+ * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop
+ * @see route_segment_foreach_steps()
+ */
+typedef bool(*route_segment_step_cb)(route_step_h step, void *user_data);
+
+/**
+ * @}
+ */
+
+/**
+ * @addtogroup CAPI_LOCATION_ROUTE_STEP_MODULE
+ * @{
+ */
+
+/**
+ * @brief Called repeatedly when you get the list of geometries in route step.
+ * @remarks @a geometry is valid only in this function.
+ * @param[in] geometry The geometry of route step
+ * @param[in] user_data The user data passed from foreach function
+ * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop
+ * @see route_step_foreach_geometries()
+ */
+typedef bool(*route_step_geometry_cb)(location_coords_s* geometry, void *user_data);
+
+/**
+ * @brief Called repeatedly when you get the list of a pair of key and value in properties.
+ * @remarks @a key and @a value are valid only in this function.
+ * @param[in] key The property key of route step
+ * @param[in] value The property value of route step
+ * @param[in] user_data The user data passed from foreach function
+ * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop
+ * @see route_step_foreach_properties()
+ */
+typedef bool(*route_step_property_cb)(const char *key, const char *value, void *user_data);
+
+/**
+ * @}
+ */
+
+/**
+ * @addtogroup CAPI_LOCATION_ROUTE_MODULE
+ * @{
+ */
+
+/**
+ * @brief Clones the handle of route.
+ * @remarks The @a cloned_route must be released route_destroy() by you.
+ * @param[out] cloned_route A cloned route handle
+ * @param[in] origin The original route handle
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ROUTE_ERROR_OUT_OF_MEMORY Out of memory
+ * @see route_destroy()
+ */
+int route_clone(route_h* cloned_route, route_h origin);
+
+/**
+ * @brief Destroys the handle of route.
+ * @param[in] route The route handle
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_clone()
+ */
+int route_destroy(route_h route);
+
+/**
+ * @brief Gets the request ID.
+ * @param[in] route The route handle
+ * @param[out] request_id The request ID of route handle
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_service_find()
+ */
+int route_get_request_id(route_h route, int* id);
+
+/**
+ * @brief Gets the origin of route.
+ * @param[in] route The route handle
+ * @param[out] origin The origin of route
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_get_destination()
+ */
+int route_get_origin(route_h route, location_coords_s* origin);
+
+/**
+ * @brief Gets the destination.
+ * @param[in] route The route handle
+ * @param[out] destination The destination of route
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_get_origin()
+ */
+int route_get_destination(route_h route, location_coords_s* destination);
+
+/**
+ * @brief Gets the bounding box of route geometry.
+ * @param[in] route The route handle
+ * @param[out] top_left The top left coords of bounding box
+ * @param[out] bottom_right The bottom right coords of bounding box
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int route_get_geometry_bounding_box(route_h route, location_coords_s* top_left, location_coords_s* bottom_right);
+
+/**
+ * @brief Gets the distance unit of route.
+ * @param[in] route The route handle
+ * @param[out] unit The distance unit used in route
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_get_total_duration()
+ */
+int route_get_distance_unit(route_h route, route_distance_unit_e* unit);
+
+/**
+ * @brief Gets the distance of route.
+ * @param[in] route The route handle
+ * @param[out] distance The distance of route. You can get the distance unit by route_get_distance_unit().
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_get_total_duration()
+ */
+int route_get_total_distance(route_h route, double* distance);
+
+/**
+ * @brief Gets the duration unit of route.
+ * @param[in] route The route handle
+ * @param[out] duration The duration
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_get_total_distance()
+ */
+int route_get_total_duration(route_h route, long* duration);
+
+/**
+ * @brief Gets the list of a pair of key and value in properties.
+ * @param[in] route The route handle
+ * @param[in] callback The callback function to invoke
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_property_cb()
+ */
+int route_foreach_properties(route_h route, route_property_cb callback, void* user_data);
+
+/**
+ * @brief Gets the list of segments.
+ * @param[in] route The route handle
+ * @param[in] callback The callback function to invoke
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_segment_cb()
+ */
+int route_foreach_segments(route_h route, route_segment_cb callback, void* user_data);
+
+/**
+ * @}
+ */
+
+/**
+ * @addtogroup CAPI_LOCATION_ROUTE_SEGMENT_MODULE
+ * @{
+ */
+
+/**
+ * @brief Clones the handle of route segment.
+ * @remarks The @a cloned_segment must be released route_segment_destroy() by you.
+ * @param[out] cloned_segment A cloned handle of route segment
+ * @param[in] origin The original handle of route segment
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ROUTE_ERROR_OUT_OF_MEMORY Out of memory
+ * @see route_segment_destroy()
+ */
+int route_segment_clone(route_segment_h* cloned_segment, route_segment_h origin);
+
+/**
+ * @brief Destroys the handle of route segment.
+ * @param[in] segment The handle of route segment
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_segment_clone()
+ */
+int route_segment_destroy(route_segment_h segment);
+
+/**
+ * @brief Gets the origin.
+ * @param[in] segment The handle of route segment
+ * @param[out] origin The origin of route segment
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_segment_get_destination()
+ */
+int route_segment_get_origin(route_segment_h segment, location_coords_s* origin);
+
+/**
+ * @brief Gets the destination.
+ * @param[in] segment The handle of route segment
+ * @param[out] destination The destination of route segment
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_segment_get_origin()
+ */
+int route_segment_get_destination(route_segment_h segment, location_coords_s* destination);
+
+/**
+ * @brief Gets the bounding box of route segment geometry.
+ * @param[in] segment The handle of route segment
+ * @param[out] top_left The top left coords of bounding box
+ * @param[out] bottom_right The bottom right coords of bounding box
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int route_segment_get_geometry_bounding_box(route_segment_h segment, location_coords_s* top_left, location_coords_s* bottom_right);
+
+/**
+ * @brief Gets the distance of route segment.
+ * @param[in] segment The handle of route segment
+ * @param[out] distance The distance of route. You can get the distance unit by route_get_distance_unit().
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_segment_get_duration()
+ */
+int route_segment_get_distance(route_segment_h segment, double* distance);
+
+/**
+ * @brief Gets the duration unit of route.
+ * @param[in] segment The handle of route segment
+ * @param[out] duration The duration
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_segment_get_distance()
+ */
+int route_segment_get_duration(route_segment_h segment, long* duration);
+
+/**
+ * @brief Gets the list of a pair of key and value in properties.
+ * @param[in] segment The handle of route segment
+ * @param[in] callback The callback function to invoke
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_segment_property_cb()
+ */
+int route_segment_foreach_properties(route_segment_h segment, route_segment_property_cb callback, void* user_data);
+
+/**
+ * @brief Gets the list of segments.
+ * @param[in] segment The handle of route segment
+ * @param[in] callback The callback function to invoke
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_segment_step_cb()
+ */
+int route_segment_foreach_steps(route_segment_h segment, route_segment_step_cb callback, void* user_data);
+
+/**
+ * @}
+ */
+
+/**
+ * @addtogroup CAPI_LOCATION_ROUTE_STEP_MODULE
+ * @{
+ */
+
+/**
+ * @brief Clones the handle of route step.
+ * @remarks The @a cloned_step must be released route_step_destroy() by you.
+ * @param[out] cloned_step A cloned handle of route step
+ * @param[in] origin The original handle route step
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ROUTE_ERROR_OUT_OF_MEMORY Out of memory
+ * @see route_step_destroy()
+ */
+int route_step_clone(route_step_h* cloned_step, route_step_h origin);
+
+/**
+ * @brief Destroys the handle of route step.
+ * @param[in] step The handle of route step
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_step_clone()
+ */
+int route_step_destroy(route_step_h step);
+
+/**
+ * @brief Gets the origin.
+ * @param[in] step The handle of route step
+ * @param[out] origin The origin of route step
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_step_get_destination()
+ */
+int route_step_get_origin(route_step_h step, location_coords_s* origin);
+
+/**
+ * @brief Gets the destination.
+ * @param[in] step The handle of route step
+ * @param[out] destination The destination of route step
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_segment_get_origin()
+ */
+int route_step_get_destination(route_step_h step, location_coords_s* destination);
+
+/**
+ * @brief Gets the bounding box of route step geometry.
+ * @param[in] step The handle of route step
+ * @param[out] top_left The top left coords of bounding box
+ * @param[out] bottom_right The bottom right coords of bounding box
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int route_step_get_geometry_bounding_box(route_step_h step, location_coords_s* top_left, location_coords_s* bottom_right);
+
+/**
+ * @brief Gets the distance of route step.
+ * @param[in] step The handle of route step
+ * @param[out] distance The distance of route. You can get the distance unit by route_get_distance_unit().
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_step_get_duration()
+ */
+int route_step_get_distance(route_step_h step, double* distance);
+
+/**
+ * @brief Gets the duration unit of route.
+ * @param[in] step The handle of route step
+ * @param[out] duration The duration
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_step_get_distance()
+ */
+int route_step_get_duration(route_step_h step, long* duration);
+
+/**
+ * @brief Gets the transport mode.
+ * @remarks @a mode must be released with @c free() by you.
+ * @param[in] step The handle of route step
+ * @param[out] mode The transport mode
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_preference_foreach_available_transport_modes()
+ */
+int route_step_get_transport_mode(route_step_h step, char** mode);
+
+/**
+ * @brief Gets the instruction of route step.
+ * @remarks @a instruction must be released with @c free() by you.
+ * @param[in] step The handle of route step
+ * @param[out] instruction The instruction of step
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int route_step_get_instruction(route_step_h step, char** instruction);
+
+/**
+ * @brief Gets the list of geometries in route step.
+ * @param[in] step The handle of route step
+ * @param[in] callback The callback function to invoke
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_step_geometry_cb()
+ */
+int route_step_foreach_geometries(route_step_h step, route_step_geometry_cb callback, void* user_data);
+
+/**
+ * @brief Gets the list of a pair of key and value in properties.
+ * @param[in] step The handle of route step
+ * @param[in] callback The callback function to invoke
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_step_property_cb()
+ */
+int route_step_foreach_properties(route_step_h step, route_step_property_cb callback, void* user_data);
+
+/**
+ * @}
+ */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_LOCATION_ROUTE_H__ */
--- /dev/null
+/*
+* Copyright (c) 2011-2013 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 __TIZEN_LOCATION_ROUTE_HANDLE_H__
+#define __TIZEN_LOCATION_ROUTE_HANDLE_H__
+
+#include <tizen_type.h>
+#include <tizen_error.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @addtogroup CAPI_LOCATION_ROUTE_SERVICE_MODULE
+ * @{
+ */
+
+typedef enum
+{
+ ROUTE_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
+ ROUTE_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
+ ROUTE_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
+ ROUTE_ERROR_NETWORK_FAILED = TIZEN_ERROR_LOCATION_CLASS | 0x0111, /**< Network unavailable*/
+ ROUTE_ERROR_SERVICE_NOT_AVAILABLE = TIZEN_ERROR_LOCATION_CLASS | 0x0112, /**< Service unavailable */
+ ROUTE_ERROR_SERVICE_NOT_SUPPORTED = TIZEN_ERROR_LOCATION_CLASS | 0x0113, /**< Not supproted */
+ ROUTE_ERROR_RESULT_NOT_FOUND = TIZEN_ERROR_LOCATION_CLASS | 0x0114, /**< Result not found */
+} route_error_e;
+
+/**
+ * @brief The handle of route service
+ */
+typedef void* route_service_h;
+
+/**
+ * @brief The handle of route preference
+ */
+typedef void* route_preference_h;
+
+/**
+ * @brief The handle of route
+ */
+typedef void* route_h;
+
+/**
+ * @}
+ */
+
+/**
+ * @addtogroup CAPI_LOCATION_ROUTE_MODULE
+ * @{
+ */
+
+/**
+ * @brief The handle of route segment
+ */
+typedef void* route_segment_h;
+
+/**
+ * @}
+ */
+
+/**
+ * @addtogroup CAPI_LOCATION_ROUTE_SEGMENT_MODULE
+ * @{
+ */
+
+/**
+ * @brief The handle of route step
+ */
+typedef void* route_step_h;
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //__TIZEN_LOCATION_ROUTE_HANDLE_H__
+
--- /dev/null
+/*
+* Copyright (c) 2011-2013 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 __TIZEN_LOCATION_ROUTE_PREFERENCE_H__
+#define __TIZEN_LOCATION_ROUTE_PREFERENCE_H__
+
+#include <location_bounds.h>
+
+#include "route_handle.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**
+ * @addtogroup CAPI_LOCATION_ROUTE_PREF_MODULE
+ * @{
+ */
+
+/**
+ * @brief Called repeatedly when you get the properties.
+ * @remarks @a key and @a value are valid only in this function.
+ * @param[in] key The property key of route preference
+ * @param[in] value The property value of route preference
+ * @param[in] user_data The user data passed from foreach function
+ * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop
+ * @see location_preference_foreach_available_properties()
+ */
+typedef bool(*route_preference_property_cb)(const char* key, const char* value, void* user_data);
+
+/**
+ * @brief Called repeatedly when you get the addresses to avoid.
+ * @remarks @a address is valid only in this function.
+ * @param[in] address The address to avoid
+ * @param[in] user_data The user data passed from foreach function
+ * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop
+ * @see route_preference_foreach_addresses_to_avoid()
+ */
+typedef bool(*route_preference_address_to_avoid_cb)(const char* address, void* user_data);
+
+/**
+ * @brief Called repeatedly when you get the areas to avoid.
+ * @remarks @a area is valid only in this function.
+ * @param[in] area The area to avoid
+ * @param[in] user_data The user data passed from foreach function
+ * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop
+ * @see route_preference_foreach_areas_to_avoid()
+ */
+typedef bool(*route_preference_area_to_avoid_cb)(location_bounds_h area, void* user_data);
+
+/**
+ * @brief Called repeatedly when you get the constraints.
+ * @remarks @a constraint is valid only in this function.
+ * @param[in] constraint The contraint
+ * @param[in] user_data The user data passed from foreach function
+ * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop
+ * @see route_preference_foreach_constraints()
+ */
+typedef bool(*route_preference_constraint_cb)(const char* constraint, void* user_data);
+
+/**
+ * @}
+ */
+
+/**
+ * @addtogroup CAPI_LOCATION_ROUTE_PREF_CAPABILITY_MODULE
+ * @{
+ */
+
+/**
+ * @brief Called repeatedly when you get the available property keys.
+ * @remarks @a key is valid only in this function.
+ * @param[in] key The available property key of route preference
+ * @param[in] user_data The user data passed from foreach function
+ * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop
+ * @see route_preference_foreach_available_property_keys()
+ */
+typedef bool(*route_preference_available_property_key_cb)(const char* key, void* user_data);
+
+/**
+ * @brief Called repeatedly when you get the available property values.
+ * @remarks @a value is valid only in this function.
+ * @param[in] value The available property value of route preference
+ * @param[in] user_data The user data passed from foreach function
+ * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop
+ * @see route_preference_foreach_available_property_values()
+ */
+typedef bool(*route_preference_available_property_value_cb)(const char* value, void* user_data);
+
+/**
+ * @brief Called repeatedly when you get the available constraints.
+ * @remarks @a constraint is valid only in this function.
+ * @param[in] constraint The available constraint of route preference
+ * @param[in] user_data The user data passed from foreach function
+ * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop
+ * @see route_preference_foreach_available_constraints()
+ */
+typedef bool(*route_preference_available_constraint_cb)(const char* constraint, void* user_data);
+
+/**
+ * @brief Called repeatedly when you get the available route goals.
+ * @remarks @a goal is valid only in this function.
+ * @param[in] goal The available route goal
+ * @param[in] user_data The user data passed from foreach function
+ * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop
+ * @see route_preference_foreach_available_goals()
+ */
+typedef bool(*route_preference_available_goal_cb)(const char* goal, void* user_data);
+
+/**
+ * @brief Called repeatedly when you get the available transport modes.
+ * @remarks @a mode is valid only in this function.
+ * @param[in] mode The available transport mode
+ * @param[in] user_data The user data passed from foreach function
+ * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop
+ * @see route_preference_foreach_available_transport_modes()
+ */
+typedef bool(*route_preference_available_transport_mode_cb)(const char* mode, void* user_data);
+
+/**
+ * @}
+ */
+
+/**
+ * @addtogroup CAPI_LOCATION_ROUTE_PREF_MODULE
+ * @{
+ */
+
+/**
+ * @brief Creates a handle of route preference.
+ * @remarks The @a preference must be released route_preference_destroy() by you.
+ * @param[out] route A handle of a new route preference handle on success
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_preference_destroy()
+ */
+int route_preference_create(route_preference_h* preference);
+
+/**
+ * @brief Destroys the handle of route preference and releases all its resources.
+ * @param[in] preference The route preference handle to destroy
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_preference_create()
+ */
+int route_preference_destroy(route_preference_h preference);
+
+/**
+ * @brief Gets the list of addresses to avoid.
+ * @param[in] preference The handle of route preference
+ * @param[in] callback The callback function to invoke
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_preference_address_to_avoid_cb()
+ * @see route_preference_is_address_to_avoid_supported()
+ * @see route_preference_add_address_to_avoid()
+ */
+int route_preference_foreach_addresses_to_avoid(route_preference_h preference, route_preference_address_to_avoid_cb callback, void* user_data);
+
+/**
+ * @brief Gets the list of areas to avoid.
+ * @param[in] preference The handle of route preference
+ * @param[in] callback The callback function to invoke
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_preference_area_to_avoid_cb()
+ */
+int route_preference_foreach_areas_to_avoid(route_preference_h preference, route_preference_area_to_avoid_cb callback, void* user_data);
+
+/**
+ * @brief Gets the list of constraints.
+ * @param[in] preference The handle of route preference
+ * @param[in] callback The callback function to invoke
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_preference_constraint_cb()
+ */
+int route_preference_foreach_constraints(route_preference_h preference, route_preference_constraint_cb callback, void* user_data);
+
+/**
+ * @brief Gets the list of a pair of key and value in route preference.
+ * @param[in] preference The handle of route preference
+ * @param[in] callback The callback function to invoke
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_preference_property_cb()
+ */
+int route_preference_foreach_properties(route_preference_h preference, route_preference_property_cb callback, void* user_data);
+
+/**
+ * @brief Gets the bounding box of route geometry.
+ * @param[in] preference The handle of route preference
+ * @param[out] top_left The coords of top left
+ * @param[out] bottom_right The coords of bottom right
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_preference_set_geometry_bounding_box()
+ * @see route_preference_is_geometry_bounding_box_supported()
+ */
+int route_preference_get_geometry_bounding_box(route_preference_h preference, location_coords_s* top_left, location_coords_s* bottom_right);
+
+/**
+ * @brief Gets the max results to be returned.
+ * @param[in] preference The handle of route preference
+ * @param[out] max_results The max results to be returned
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_preference_set_max_results()
+ */
+int route_preference_get_max_results(route_preference_h preference, int* max_results);
+
+/**
+ * @brief Gets the route goal.
+ * @remarks @a goal must be released with @c free() by you.
+ * @param[in] preference The handle of route preference
+ * @param[out] goal The route goal
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_preference_set_goal()
+ * @see route_preference_foreach_available_goals()
+ */
+int route_preference_get_goal(route_preference_h preference, char** goal);
+
+/**
+ * @brief Gets the transport mode.
+ * @remarks @a mode must be released with @c free() by you.
+ * @param[in] preference The handle of route preference
+ * @param[out] mode The transport mode
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_preference_set_transport_mode()
+ * @see route_preference_foreach_available_transport_modes()
+ */
+int route_preference_get_transport_mode(route_preference_h preference, char** mode);
+
+/**
+ * @brief Gets the preference for providing the route geometry.
+ * @param[in] preference The handle of route preference
+ * @return @a true if geomtry is used, otherwise @a false.
+ * @see route_preference_set_geometry_used()
+ * @see route_preference_is_geometry_supported()
+ */
+bool route_preference_is_geometry_used(route_preference_h preference);
+
+/**
+ * @brief Gets the preference for providing the instruction bounding box.
+ * @param[in] preference The handle of route preference
+ * @return @a true if instruction bounding box is used, otherwise @a false.
+ * @see route_preference_set_instruction_bounding_box_used()
+ * @see route_preference_is_instruction_bounding_box_supported()
+ */
+bool route_preference_is_instruction_bounding_box_used(route_preference_h preference);
+
+/**
+ * @brief Gets the preference for providing the instruction geometry.
+ * @param[in] preference The handle of route preference
+ * @return @a true if instruction geometry is used, otherwise @a false.
+ * @see route_preference_set_instruction_geometry_used()
+ * @see route_preference_is_instruction_geometry_supported()
+ */
+bool route_preference_is_instruction_geometry_used(route_preference_h preference);
+
+/**
+ * @brief Gets the preference for providing the instruction.
+ * @param[in] preference The handle of route preference
+ * @return @a true if instruction is used, otherwise @a false.
+ * @see route_preference_set_instruction_used()
+ * @see route_preference_is_instruction_supported()
+ */
+bool route_preference_is_instruction_used(route_preference_h preference);
+
+/**
+ * @brief Gets the preference for using traffic data.
+ * @param[in] preference The handle of route preference
+ * @return @a true if traffic data is used, otherwise @a false.
+ * @see route_preference_set_traffic_data_used()
+ * @see route_preference_is_traffic_data_supported()
+ */
+bool route_preference_is_traffic_data_used(route_preference_h preference);
+
+/**
+ * @brief Gets the value of route preference.
+ * @param[in] preference The handle of route preference
+ * @param[in] key The property key
+ * @param[out] value The property value
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_preference_set()
+ * @see route_preference_foreach_available_property_keys()
+ */
+int route_preference_get(route_preference_h preference, const char* key, char** value);
+
+/**
+ * @brief Sets the value of route preference.
+ * @param[in] preference The handle of route preference
+ * @param[in] key The property key
+ * @param[out] value The property value
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_preference_get()
+ * @see route_preference_foreach_available_property_keys()
+ * @see route_preference_foreach_available_property_values()
+ */
+int route_preference_set(route_preference_h preference, const char* key, const char* value);
+
+/**
+ * @brief Adds the address to avoid.
+ * @param[in] preference The handle of route preference
+ * @param[in] address The addresses to avoid
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_preference_is_address_to_avoid_supported()
+ * @see route_preference_foreach_addresses_to_avoid()
+ */
+int route_preference_add_address_to_avoid(route_preference_h preference, const char* address);
+
+/**
+ * @brief Clears the addresses to avoid.
+ * @param[in] preference The handle of route preference
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_preference_is_address_to_avoid_supported()
+ * @see route_preference_foreach_addresses_to_avoid()
+ */
+int route_preference_clear_addresses_to_avoid(route_preference_h preference);
+
+/**
+ * @brief Adds the area to avoid.
+ * @param[in] preference The handle of route preference
+ * @param[in] area The area to avoid
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_preference_foreach_areas_to_avoid()
+ * @see route_preference_is_area_to_avoid_supported()
+ */
+int route_preference_add_area_to_avoid(route_preference_h preference, location_bounds_h area);
+
+/**
+ * @brief Clears the area to avoid.
+ * @param[in] preference The handle of route preference
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_preference_foreach_areas_to_avoid()
+ * @see route_preference_is_area_to_avoid_supported()
+ */
+int route_preference_clear_areas_to_avoid(route_preference_h preference);
+
+/**
+ * @brief Adds the constraints.
+ * @param[in] preference The handle of route preference
+ * @param[in] constraint_list The constraint
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_preference_get_constraints()
+ * @see route_preference_foreach_available_constraints()
+ */
+int route_preference_add_constraint(route_preference_h preference, const char* constraint);
+
+/**
+ * @brief Clears the constraints.
+ * @param[in] preference The handle of route preference
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_preference_get_constraints()
+ * @see route_preference_foreach_available_constraints()
+ */
+int route_preference_clear_constraints(route_preference_h preference);
+
+/**
+ * @brief Sets the bounding box of route geometry.
+ * @param[in] preference The handle of route preference
+ * @param[in] top_left The coords of top left
+ * @param[in] bottom_right The list of bottom right
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_preference_get_geometry_bounding_box()
+ * @see route_preference_is_geometry_bounding_box_supported()
+ */
+int route_preference_set_geometry_bounding_box(route_preference_h preference, location_coords_s top_left, location_coords_s bottom_right);
+
+/**
+ * @brief Sets the max results to be returned.
+ * @param[in] preference The handle of route preference
+ * @param[in] max_results The max results to be returned
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_preference_get_max_results()
+ */
+int route_preference_set_max_results(route_preference_h preference, int max_results);
+
+/**
+ * @brief Sets the route goal.
+ * @param[in] preference The handle of route preference
+ * @param[in] goal The route goal
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_preference_get_goal()
+ * @see route_preference_foreach_available_goals()
+ */
+int route_preference_set_goal(route_preference_h preference, const char* goal);
+
+/**
+ * @brief Sets the transport mode.
+ * @param[in] preference The handle of route preference
+ * @param[in] mode The transport mode
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_preference_get_transport_mode()
+ * @see route_preference_foreach_available_transport_modes()
+ */
+int route_preference_set_transport_mode(route_preference_h preference, const char* mode);
+
+/**
+ * @brief Sets the preference for providing the route geometry.
+ * @param[in] preference The handle of route preference
+ * @param[in] used @a true if used, otherwise @a false
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_preference_is_geometry_used()
+ * @see route_preference_is_geometry_supported()
+ */
+int route_preference_set_geometry_used(route_preference_h preference, bool used);
+
+/**
+ * @brief Sets the preference for providing the instruction bounding box.
+ * @param[in] preference The handle of route preference
+ * @param[in] used @a true if used, otherwise @a false
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_preference_is_instruction_bounding_box_used()
+ * @see route_preference_is_instruction_bounding_box_supported()
+ */
+int route_preference_set_instruction_bounding_box_used(route_preference_h preference, bool used);
+
+/**
+ * @brief Sets the preference for providing the instruction geometry.
+ * @param[in] preference The handle of route preference
+ * @param[in] used @a true if used, otherwise @a false
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_preference_is_instruction_geometry_used()
+ * @see route_preference_is_instruction_geometry_supported()
+ */
+int route_preference_set_instruction_geometry_used(route_preference_h preference, bool used);
+
+/**
+ * @brief Sets the preference for providing the instruction.
+ * @param[in] preference The handle of route preference
+ * @param[in] used @a true if used, otherwise @a false
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_preference_is_instruction_used()
+ * @see route_preference_is_instruction_supported()
+ */
+int route_preference_set_instruction_used(route_preference_h preference, bool used);
+
+/**
+ * @brief Sets the preference for using the traffic data.
+ * @param[in] preference The handle of route preference
+ * @param[in] used @a true if used, otherwise @a false
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_preference_is_traffic_data_used()
+ * @see route_preference_is_traffic_data_supported()
+ */
+int route_preference_set_traffic_data_used(route_preference_h preference, bool used);
+
+/**
+ * @}
+ */
+
+/**
+ * @addtogroup CAPI_LOCATION_ROUTE_PREF_CAPABILITY_MODULE
+ * @{
+ */
+
+/**
+ * @brief Checks whether the given bound type is supported as area to avoid.
+ * @param[in] service The handle of route service
+ * @param[in] type The type of location bound
+ * @return @a true if area to avoid is supported, otherwise @a false.
+ * @see route_preference_add_area_to_avoid()
+ * @see route_preference_foreach_areas_to_avoid()
+ */
+bool route_preference_is_area_to_avoid_supported(route_service_h service, location_bounds_type_e type);
+
+/**
+ * @brief Checks whether the address to avoid is supported.
+ * @param[in] service The handle of route service
+ * @return @a true if address to avoid is supported, otherwise @a false.
+ * @see route_preference_foreach_addresses_to_avoid()
+ * @see route_preference_add_address_to_avoid()
+ */
+bool route_preference_is_address_to_avoid_supported(route_service_h service);
+
+/**
+ * @brief Checks whether the bounding box of route geometry is supported.
+ * @param[in] service The handle of route service
+ * @return @a true if geometry bounding box is supported, otherwise @a false.
+ * @see route_preference_set_geometry_bounding_box()
+ * @see route_preference_get_geometry_bounding_box()
+ */
+bool route_preference_is_geometry_bounding_box_supported(route_service_h service);
+
+/**
+ * @brief Checks whether the route geometry is supported.
+ * @param[in] service The handle of route service
+ * @return @a true if geometry is supported, otherwise @a false.
+ * @see route_preference_set_geometry_used()
+ * @see route_preference_is_geometry_used()
+ */
+bool route_preference_is_geometry_supported(route_service_h service);
+
+/**
+ * @brief Checks whether the instruction geometry is supported.
+ * @param[in] service The handle of route service
+ * @return @a true if instruction geometry is supported, otherwise @a false.
+ * @see route_preference_is_instruction_geometry_used()
+ * @see route_preference_set_instruction_geometry_used()
+ */
+bool route_preference_is_instruction_geometry_supported(route_service_h service);
+
+/**
+ * @brief Checks whether the instruction bounding box is supported.
+ * @param[in] service The handle of route service
+ * @return @a true if instruction bounding box is supported, otherwise @a false.
+ * @see route_preference_set_instruction_bounding_box_used()
+ * @see route_preference_is_instruction_bounding_box_used()
+ */
+bool route_preference_is_instruction_bounding_box_supported(route_service_h service);
+
+/**
+ * @brief Checks whether the instruction is supported.
+ * @param[in] service The handle of route service
+ * @return @a true if instruction is supported, otherwise @a false.
+ * @see route_preference_set_instruction_used()
+ * @see route_preference_is_instruction_used()
+ */
+bool route_preference_is_instruction_supported(route_service_h service);
+
+/**
+ * @brief Checks whether the traffic data is supported.
+ * @param[in] service The handle of route service
+ * @return @a true if traffic data is supported, otherwise @a false.
+ * @see route_preference_set_traffic_data_used()
+ * @see route_preference_is_traffic_data_used()
+ */
+bool route_preference_is_traffic_data_supported(route_service_h service);
+
+/**
+ * @brief Gets the list of available constraints.
+ * @param[in] service The handle of route service
+ * @param[in] callback The callback function to invoke
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_preference_add_constraint()
+ * @see route_preference_foreach_constraints()
+ */
+int route_preference_foreach_available_constraints(route_service_h service, route_preference_available_constraint_cb callback, void* user_data);
+
+/**
+ * @brief Gets the list of available route goals.
+ * @param[in] service The handle of route service
+ * @param[in] callback The callback function to invoke
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_preference_get_goal()
+ * @see route_preference_set_goal()
+ */
+int route_preference_foreach_available_goals(route_service_h service, route_preference_available_goal_cb callback, void* user_data);
+
+/**
+ * @brief Gets the list of available transport mode.
+ * @param[in] service The handle of route service
+ * @param[in] callback The callback function to invoke
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_preference_set_transport_mode()
+ * @see route_preference_get_transport_mode()
+ */
+int route_preference_foreach_available_transport_modes(route_service_h service, route_preference_available_transport_mode_cb callback, void* user_data);
+
+/**
+ * @brief Gets the list of available keys in route preference.
+ * @param[in] service The handle of route service
+ * @param[in] callback The callback function to invoke
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_preference_set()
+ * @see route_preference_get()
+ * @see route_preference_foreach_available_property_values()
+ */
+int route_preference_foreach_available_property_keys(route_service_h service, route_preference_available_property_key_cb callback, void* user_data);
+
+/**
+ * @brief Gets the list of available values in route preference.
+ * @param[in] service The handle of route service
+ * @param[in] callback The callback function to invoke
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_preference_foreach_properties()
+ * @see route_preference_foreach_available_property_keys()
+ * @see route_preference_set()
+ */
+int route_preference_foreach_available_property_values(route_service_h service, const char* key, route_preference_available_property_value_cb callback, void* user_data);
+
+/**
+ * @}
+ */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_LOCATION_ROUTE_PREFERENCE_H__ */
--- /dev/null
+/*
+* Copyright (c) 2011-2013 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 __TIZEN_LOCATION_ROUTE_PRIVATE_H__
+#define __TIZEN_LOCATION_ROUTE_PRIVATE_H__
+
+#include <location.h>
+#include <location-map-service.h>
+
+#include "route_preference.h"
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "CAPI_LOCATION_ROUTE"
+
+/*
+ * Internal macros
+ */
+
+#define ROUTE_LOGD(fmt,args...) LOGD(fmt, ##args)
+#define ROUTE_LOGW(fmt,args...) LOGW(fmt, ##args)
+#define ROUTE_LOGI(fmt,args...) LOGI(fmt, ##args)
+#define ROUTE_LOGE(fmt,args...) LOGE(fmt, ##args)
+
+#define ROUTE_CHECK_CONDITION(condition, error, msg) \
+ do { \
+ if( !(condition) ){ \
+ ROUTE_LOGE("%s(0x%08x)", msg, error); \
+ return error; \
+ } \
+ } while (0)
+
+#define ROUTE_PRINT_ERROR_CODE_RETURN(code) \
+ do{ \
+ ROUTE_LOGE("%s(0x%08x)", #code, code); \
+ return code; \
+ } while (0)
+
+#define ROUTE_NULL_ARG_CHECK_RETURN_FALSE(arg)\
+ do { \
+ if(arg != NULL) { \
+ } else { \
+ ROUTE_LOGE("ROUTE_ERROR_INVALID_PARAMETER"); \
+ return false; }; \
+ } while (0)
+
+#define ROUTE_NULL_ARG_CHECK(arg)\
+ ROUTE_CHECK_CONDITION( (arg != NULL), ROUTE_ERROR_INVALID_PARAMETER, "ROUTE_ERROR_INVALID_PARAMETER")
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+typedef struct _route_service_s{
+ LocationMapObject* object;
+ route_preference_h route_preference;
+} route_service_s;
+
+typedef struct _route_preference_s{
+ LocationRoutePreference* preference;
+} route_preference_s;
+
+typedef struct _route_s{
+ LocationRoute* route;
+ int request_id;
+} route_s;
+
+typedef struct _route_segment_s{
+ LocationRouteSegment* segment;
+} route_segment_s;
+
+typedef struct _route_step_s{
+ LocationRouteStep* step;
+} route_step_s;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //__TIZEN_LOCATION_ROUTE_PRIVATE_H__
+
--- /dev/null
+/*
+* Copyright (c) 2011-2013 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 __TIZEN_LOCATION_ROUTE_SERVICE_H__
+#define __TIZEN_LOCATION_ROUTE_SERVICE_H__
+
+#include <location_bounds.h>
+
+#include "route_handle.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @addtogroup CAPI_LOCATION_ROUTE_SERVICE_MODULE
+ * @{
+ */
+
+/**
+ * @brief Called when the requested routes are found by route_service_find().
+ * @remarks @a route is valid only in this function. In order to use the route outside this function, you must copy the route with route_clone(). \n
+ * If route_service_find() failed, this callback function is called only once with 0 total and NULL route.
+ * @param[in] route_error_e The reuslt of request
+ * @param[in] request_id The identification of request
+ * @param[in] total The total number of result
+ * @param[in] route The route data
+ * @param[in] user_data The user data passed from the request function
+ * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop
+ * @pre route_service_find() will invoke this callback.
+ * @see route_service_find()
+ */
+typedef bool(*route_service_found_cb)(route_error_e error, int index, int total, route_h route, void* user_data);
+
+/**
+ * @brief Creates a new handle of route service.
+ * @remarks The @a service must be released route_service_destroy() by you.
+ * @param[out] service A handle of a new route service on success
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ROUTE_ERROR_SERVICE_NOT_AVAILABLE Service not available
+ * @see route_service_destroy()
+ */
+int route_service_create(route_service_h* service);
+
+/**
+ * @brief Destroys the handle of route service and releases all its resources.
+ * @param[in] service The route service handle to destroy
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_service_create()
+ */
+int route_service_destroy(route_service_h service);
+
+/**
+ * @brief Gets the route preference.
+ * @param[in] service The handle of route service
+ * @param[out] preference The handle of route preference
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_service_set_preference()
+ */
+int route_service_get_preference(route_service_h service, route_preference_h* preference);
+
+/**
+ * @brief Sets the route preference.
+ * @param[in] service The handle of route service
+ * @param[in] preference The handle of route preference
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_service_get_preference()
+ */
+int route_service_set_preference(route_service_h service, route_preference_h preference);
+
+/**
+ * @brief Requests to find the route, asynchronously.
+ * @param[in] service The handle of route service
+ * @param[in] origin The starting point
+ * @param[in] destination The destination
+ * @param[in] waypoint_list The list of waypoints to go through
+ * @param[in] waypoint_num The number of waypoints to go through
+ * @param[in] callback The result callback
+ * @param[in] user_data The user data to be passed to the callback function
+ * @param[out] request_id The request ID
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ROUTE_ERROR_SERVICE_UNAVILABLE Service unavailabe
+ * @see route_service_cancel()
+ * @see route_service_found_cb()
+ */
+int route_service_find(route_service_h service, location_coords_s origin, location_coords_s destination, location_coords_s* waypoint_list, int waypoint_num, route_service_found_cb callback, void* user_data, int* request_id);
+
+/**
+ * @brief Cancels the request.
+ * @param[in] service The handle of route service
+ * @param[out] request_id The request ID which is got from route_service_find()
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #ROUTE_ERROR_NONE Successful
+ * @retval #ROUTE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see route_service_find()
+ */
+int route_service_cancel(route_service_h service, int request_id);
+
+/**
+ * @}
+ */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_LOCATION_ROUTE_SERVICE_H__ */
--- /dev/null
+Name: capi-location-route
+Summary: A Location Route library in Tizen Native API
+Version: 0.1.3
+Release: 1
+Group: System/Libraries
+License: Apache Licensc, Version 2.0
+Source0: %{name}-%{version}.tar.gz
+BuildRequires: cmake
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(location)
+BuildRequires: pkgconfig(capi-base-common)
+BuildRequires: pkgconfig(capi-location-manager)
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+
+%description
+
+
+%package devel
+Summary: A Location Route library in Tizen Native API (Development)
+Group: TO_BE/FILLED_IN
+Requires: %{name} = %{version}-%{release}
+
+%description devel
+
+
+%prep
+%setup -q
+
+
+%build
+MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
+cmake . -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
+
+
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+
+%files
+%manifest capi-location-route.manifest
+%{_libdir}/libcapi-location-route.so.*
+
+%files devel
+%{_includedir}/location/*.h
+%{_libdir}/pkgconfig/*.pc
+%{_libdir}/libcapi-location-route.so
--- /dev/null
+/*
+* Copyright (c) 2011-2013 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 <location/location.h>
+#include <location/location-types.h>
+#include <location/location-map-service.h>
+
+#include "route.h"
+#include "route_service.h"
+#include "route_private.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+/*
+ * Route module
+ */
+int route_clone(route_h * cloned_route, route_h origin)
+{
+ ROUTE_NULL_ARG_CHECK(cloned_route);
+ ROUTE_NULL_ARG_CHECK(origin);
+
+ route_s *handle = (route_s *) origin;
+ if (NULL == handle->route) {
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_INVALID_PARAMETER);
+ }
+
+ route_s *cloned = (route_s *) malloc(sizeof(route_s));
+ if (cloned == NULL) {
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_OUT_OF_MEMORY);
+ }
+
+ cloned->route = location_route_copy(handle->route);
+ if (cloned->route == NULL) {
+ free(cloned);
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_OUT_OF_MEMORY);
+ }
+ cloned->request_id = handle->request_id;
+
+ *cloned_route = (route_h) cloned;
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_destroy(route_h route)
+{
+ ROUTE_NULL_ARG_CHECK(route);
+
+ route_s *handle = (route_s *) route;
+ location_route_free(handle->route);
+ handle->request_id = 0;
+ free(handle);
+ handle = NULL;
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_get_request_id(route_h route, int *id)
+{
+ ROUTE_NULL_ARG_CHECK(route);
+ ROUTE_NULL_ARG_CHECK(id);
+
+ route_s *handle = (route_s *) route;
+ *id = handle->request_id;
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_get_origin(route_h route, location_coords_s * origin)
+{
+ ROUTE_NULL_ARG_CHECK(route);
+ ROUTE_NULL_ARG_CHECK(origin);
+
+ route_s *handle = (route_s *) route;
+ LocationPosition *start = location_route_get_origin(handle->route);
+ if (start == NULL) {
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_RESULT_NOT_FOUND);
+ }
+
+ origin->latitude = start->latitude;
+ origin->longitude = start->longitude;
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_get_destination(route_h route, location_coords_s * destination)
+{
+ ROUTE_NULL_ARG_CHECK(route);
+ ROUTE_NULL_ARG_CHECK(destination);
+
+ route_s *handle = (route_s *) route;
+ LocationPosition *end = location_route_get_destination(handle->route);
+ if (end == NULL) {
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_RESULT_NOT_FOUND);
+ }
+
+ destination->latitude = end->latitude;
+ destination->longitude = end->longitude;
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_get_geometry_bounding_box(route_h route, location_coords_s * top_left, location_coords_s * bottom_right)
+{
+ ROUTE_NULL_ARG_CHECK(route);
+ ROUTE_NULL_ARG_CHECK(top_left);
+ ROUTE_NULL_ARG_CHECK(bottom_right);
+
+ route_s *handle = (route_s *) route;
+ LocationBoundary *bbox = location_route_get_bounding_box(handle->route);
+ if (bbox == NULL) {
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_RESULT_NOT_FOUND);
+ }
+
+ top_left->latitude = bbox->rect.left_top->latitude;
+ top_left->longitude = bbox->rect.left_top->longitude;
+ bottom_right->latitude = bbox->rect.right_bottom->latitude;
+ bottom_right->longitude = bbox->rect.right_bottom->longitude;
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_get_distance_unit(route_h route, route_distance_unit_e * unit)
+{
+ ROUTE_NULL_ARG_CHECK(route);
+ ROUTE_NULL_ARG_CHECK(unit);
+
+ char *M = "M";
+ char *KM = "KM";
+ char *FT = "FT";
+ char *YD = "YD";
+ char *MI = "MI";
+
+ route_s *handle = (route_s *) route;
+ char *dist_unit = (char *)location_route_get_distance_unit(handle->route);
+ if (dist_unit == NULL) {
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_SERVICE_NOT_AVAILABLE);
+ }
+
+ if (strcmp(dist_unit, M) == 0) {
+ *unit = ROUTE_DISTANCE_UNIT_M;
+ } else if (strcmp(dist_unit, KM) == 0) {
+ *unit = ROUTE_DISTANCE_UNIT_KM;
+ } else if (strcmp(dist_unit, FT) == 0) {
+ *unit = ROUTE_DISTANCE_UNIT_FT;
+ } else if (strcmp(dist_unit, YD) == 0) {
+ *unit = ROUTE_DISTANCE_UNIT_YD;
+ } else if (strcmp(dist_unit, MI) == 0) {
+ *unit = ROUTE_DISTANCE_UNIT_MI;
+ }
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_get_total_distance(route_h route, double *distance)
+{
+ ROUTE_NULL_ARG_CHECK(route);
+ ROUTE_NULL_ARG_CHECK(distance);
+
+ route_s *handle = (route_s *) route;
+ double dist = (double)location_route_get_total_distance(handle->route);
+
+ *distance = dist;
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_get_total_duration(route_h route, long *duration)
+{
+ ROUTE_NULL_ARG_CHECK(route);
+ ROUTE_NULL_ARG_CHECK(duration);
+
+ route_s *handle = (route_s *) route;
+ long dur = (long)location_route_get_total_duration(handle->route);
+
+ *duration = dur;
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_foreach_properties(route_h route, route_property_cb callback, void *user_data)
+{
+ ROUTE_NULL_ARG_CHECK(route);
+ ROUTE_NULL_ARG_CHECK(callback);
+
+ route_s *handle = (route_s *) route;
+ GList *key_list = location_route_get_property_key(handle->route);
+
+ while (key_list) {
+ char *key = key_list->data;
+ char *value = NULL;
+ if (key != NULL && (value = (char *)location_route_get_property(handle->route, key)) != NULL) {
+ if (callback(key, value, user_data) == false) {
+ break;
+ }
+ }
+ key_list = key_list->next;
+ }
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_foreach_segments(route_h route, route_segment_cb callback, void *user_data)
+{
+ ROUTE_NULL_ARG_CHECK(route);
+ ROUTE_NULL_ARG_CHECK(callback);
+
+ route_s *handle = (route_s *) route;
+ GList *seg_list = location_route_get_route_segment(handle->route);
+
+ while (seg_list) {
+ route_segment_s *segment = (route_segment_s *) malloc(sizeof(route_segment_s));
+ segment->segment = seg_list->data;
+
+ if (callback(segment, user_data) == false) {
+ free(segment);
+ break;
+ }
+ seg_list = seg_list->next;
+ free(segment);
+ }
+
+ return ROUTE_ERROR_NONE;
+}
+
+/*
+ * Route segment module
+ */
+int route_segment_clone(route_segment_h * cloned_segment, route_segment_h origin)
+{
+ ROUTE_NULL_ARG_CHECK(cloned_segment);
+ ROUTE_NULL_ARG_CHECK(origin);
+
+ route_segment_s *handle = (route_segment_s *) origin;
+ if (NULL == handle->segment) {
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_INVALID_PARAMETER);
+ }
+
+ route_segment_s *cloned = (route_segment_s *) malloc(sizeof(route_segment_s));
+ if (cloned == NULL) {
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_OUT_OF_MEMORY);
+ }
+
+ cloned->segment = location_route_segment_copy(handle->segment);
+ if (cloned->segment == NULL) {
+ free(cloned);
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_OUT_OF_MEMORY);
+ }
+
+ *cloned_segment = (route_segment_h) cloned;
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_segment_destroy(route_segment_h segment)
+{
+ ROUTE_NULL_ARG_CHECK(segment);
+
+ route_segment_s *handle = (route_segment_s *) segment;
+ location_route_segment_free(handle->segment);
+ free(handle);
+ handle = NULL;
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_segment_get_origin(route_segment_h segment, location_coords_s * origin)
+{
+ ROUTE_NULL_ARG_CHECK(segment);
+ ROUTE_NULL_ARG_CHECK(origin);
+
+ route_segment_s *handle = (route_segment_s *) segment;
+ LocationPosition *start = location_route_segment_get_start_point(handle->segment);
+ if (start == NULL) {
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_RESULT_NOT_FOUND);
+ }
+
+ origin->latitude = start->latitude;
+ origin->longitude = start->longitude;
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_segment_get_destination(route_segment_h segment, location_coords_s * destination)
+{
+ ROUTE_NULL_ARG_CHECK(segment);
+ ROUTE_NULL_ARG_CHECK(destination);
+
+ route_segment_s *handle = (route_segment_s *) segment;
+ LocationPosition *end = location_route_segment_get_end_point(handle->segment);
+ if (end == NULL) {
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_RESULT_NOT_FOUND);
+ }
+
+ destination->latitude = end->latitude;
+ destination->longitude = end->longitude;
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_segment_get_geometry_bounding_box(route_segment_h segment,
+ location_coords_s * top_left, location_coords_s * bottom_right)
+{
+ ROUTE_NULL_ARG_CHECK(segment);
+ ROUTE_NULL_ARG_CHECK(top_left);
+ ROUTE_NULL_ARG_CHECK(bottom_right);
+
+ route_segment_s *handle = (route_segment_s *) segment;
+ LocationBoundary *bbox = location_route_segment_get_bounding_box(handle->segment);
+ if (bbox == NULL) {
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_RESULT_NOT_FOUND);
+ }
+
+ top_left->latitude = bbox->rect.left_top->latitude;
+ top_left->longitude = bbox->rect.left_top->longitude;
+ bottom_right->latitude = bbox->rect.right_bottom->latitude;
+ bottom_right->longitude = bbox->rect.right_bottom->longitude;
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_segment_get_distance(route_segment_h segment, double *distance)
+{
+ ROUTE_NULL_ARG_CHECK(segment);
+ ROUTE_NULL_ARG_CHECK(distance);
+
+ route_segment_s *handle = (route_segment_s *) segment;
+ double dist = (double)location_route_segment_get_distance(handle->segment);
+
+ *distance = dist;
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_segment_get_duration(route_segment_h segment, long *duration)
+{
+ ROUTE_NULL_ARG_CHECK(segment);
+ ROUTE_NULL_ARG_CHECK(duration);
+
+ route_segment_s *handle = (route_segment_s *) segment;
+ long dur = (long)location_route_segment_get_duration(handle->segment);
+
+ *duration = dur;
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_segment_foreach_properties(route_segment_h segment, route_segment_property_cb callback, void *user_data)
+{
+ ROUTE_NULL_ARG_CHECK(segment);
+ ROUTE_NULL_ARG_CHECK(callback);
+
+ route_segment_s *handle = (route_segment_s *) segment;
+ GList *key_list = location_route_segment_get_property_key(handle->segment);
+
+ while (key_list) {
+ char *key = key_list->data;
+ char *value = NULL;
+ if (key != NULL && (value = (char *)location_route_segment_get_property(handle->segment, key)) != NULL) {
+ if (callback(key, value, user_data) == false) {
+ break;
+ }
+ }
+ key_list = key_list->next;
+ }
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_segment_foreach_steps(route_segment_h segment, route_segment_step_cb callback, void *user_data)
+{
+ ROUTE_NULL_ARG_CHECK(segment);
+ ROUTE_NULL_ARG_CHECK(callback);
+
+ route_segment_s *handle = (route_segment_s *) segment;
+ GList *step_list = location_route_segment_get_route_step(handle->segment);
+
+ while (step_list) {
+ route_step_s *step = (route_step_s *) malloc(sizeof(route_step_s));
+ step->step = step_list->data;
+
+ if (callback(step, user_data) == false) {
+ free(step);
+ break;
+ }
+ step_list = step_list->next;
+ free(step);
+ }
+
+ return ROUTE_ERROR_NONE;
+}
+
+/*
+ * Route step module
+ */
+int route_step_clone(route_step_h * cloned_step, route_step_h origin)
+{
+ ROUTE_NULL_ARG_CHECK(cloned_step);
+ ROUTE_NULL_ARG_CHECK(origin);
+
+ route_step_s *handle = (route_step_s *) origin;
+ if (NULL == handle->step) {
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_INVALID_PARAMETER);
+ }
+
+ route_step_s *cloned = (route_step_s *) malloc(sizeof(route_step_s));
+ if (cloned == NULL) {
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_OUT_OF_MEMORY);
+ }
+
+ cloned->step = location_route_step_copy(handle->step);
+ if (cloned->step == NULL) {
+ free(cloned);
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_OUT_OF_MEMORY);
+ }
+
+ *cloned_step = (route_step_h) cloned;
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_step_destroy(route_step_h step)
+{
+ ROUTE_NULL_ARG_CHECK(step);
+
+ route_step_s *handle = (route_step_s *) step;
+ location_route_step_free(handle->step);
+ free(handle);
+ handle = NULL;
+
+ return ROUTE_ERROR_NONE;
+
+}
+
+int route_step_get_origin(route_step_h step, location_coords_s * origin)
+{
+ ROUTE_NULL_ARG_CHECK(step);
+ ROUTE_NULL_ARG_CHECK(origin);
+
+ route_step_s *handle = (route_step_s *) step;
+ LocationPosition *start = location_route_step_get_start_point(handle->step);
+ if (start == NULL) {
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_RESULT_NOT_FOUND);
+ }
+
+ origin->latitude = start->latitude;
+ origin->longitude = start->longitude;
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_step_get_destination(route_step_h step, location_coords_s * destination)
+{
+ ROUTE_NULL_ARG_CHECK(step);
+ ROUTE_NULL_ARG_CHECK(destination);
+
+ route_step_s *handle = (route_step_s *) step;
+ LocationPosition *end = location_route_step_get_end_point(handle->step);
+ if (end == NULL) {
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_RESULT_NOT_FOUND);
+ }
+
+ destination->latitude = end->latitude;
+ destination->longitude = end->longitude;
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_step_get_geometry_bounding_box(route_step_h step, location_coords_s * top_left, location_coords_s * bottom_right)
+{
+ ROUTE_NULL_ARG_CHECK(step);
+ ROUTE_NULL_ARG_CHECK(top_left);
+ ROUTE_NULL_ARG_CHECK(bottom_right);
+
+ route_step_s *handle = (route_step_s *) step;
+ LocationBoundary *bbox = location_route_step_get_bounding_box(handle->step);
+ if (bbox == NULL) {
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_RESULT_NOT_FOUND);
+ }
+
+ top_left->latitude = bbox->rect.left_top->latitude;
+ top_left->longitude = bbox->rect.left_top->longitude;
+ bottom_right->latitude = bbox->rect.right_bottom->latitude;
+ bottom_right->longitude = bbox->rect.right_bottom->longitude;
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_step_get_distance(route_step_h step, double *distance)
+{
+ ROUTE_NULL_ARG_CHECK(step);
+ ROUTE_NULL_ARG_CHECK(distance);
+
+ route_step_s *handle = (route_step_s *) step;
+ double dist = (double)location_route_step_get_distance(handle->step);
+
+ *distance = dist;
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_step_get_duration(route_step_h step, long *duration)
+{
+ ROUTE_NULL_ARG_CHECK(step);
+ ROUTE_NULL_ARG_CHECK(duration);
+
+ route_step_s *handle = (route_step_s *) step;
+ long dur = (long)location_route_step_get_duration(handle->step);
+
+ *duration = dur;
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_step_get_transport_mode(route_step_h step, char** mode)
+{
+ ROUTE_NULL_ARG_CHECK(step);
+ ROUTE_NULL_ARG_CHECK(mode);
+
+ route_step_s *handle = (route_step_s *) step;
+ char *transport = (char *)location_route_step_get_transport_mode(handle->step);
+
+ if (transport == NULL) {
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_RESULT_NOT_FOUND);
+ }
+
+ *mode = strdup(transport);
+ if (*mode == NULL) {
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_OUT_OF_MEMORY);
+ }
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_step_get_instruction(route_step_h step, char **instruction)
+{
+ ROUTE_NULL_ARG_CHECK(step);
+ ROUTE_NULL_ARG_CHECK(instruction);
+
+ route_step_s *handle = (route_step_s *) step;
+ char *inst = (char *)location_route_step_get_instruction(handle->step);
+
+ if (inst == NULL) {
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_RESULT_NOT_FOUND);
+ }
+
+ *instruction = strdup(inst);
+ if (*instruction == NULL) {
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_OUT_OF_MEMORY);
+ }
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_step_foreach_geometries(route_step_h step, route_step_geometry_cb callback, void *user_data)
+{
+ ROUTE_NULL_ARG_CHECK(step);
+ ROUTE_NULL_ARG_CHECK(callback);
+
+ route_step_s *handle = (route_step_s *) step;
+ GList *geometry_list = location_route_step_get_geometry(handle->step);
+
+ while (geometry_list) {
+ location_coords_s *geometry = (location_coords_s *) malloc(sizeof(location_coords_s));;
+ LocationPosition *pos;
+ pos = geometry_list->data;
+ geometry->latitude = pos->latitude;
+ geometry->longitude = pos->longitude;
+
+ if (callback(geometry, user_data) == false) {
+ free(geometry);
+ break;
+ }
+ geometry_list = geometry_list->next;
+ free(geometry);
+ }
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_step_foreach_properties(route_step_h step, route_step_property_cb callback, void *user_data)
+{
+ ROUTE_NULL_ARG_CHECK(step);
+ ROUTE_NULL_ARG_CHECK(callback);
+
+ route_step_s *handle = (route_step_s *) step;
+ GList *key_list = location_route_step_get_property_key(handle->step);
+
+ while (key_list) {
+ char *key = key_list->data;
+ char *value = NULL;
+ if (key != NULL && (value = (char *)location_route_step_get_property(handle->step, key)) != NULL) {
+ if (callback(key, value, user_data) == false) {
+ break;
+ }
+ }
+ key_list = key_list->next;
+ }
+
+ return ROUTE_ERROR_NONE;
+}
--- /dev/null
+/*
+* Copyright (c) 2011-2013 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 <location/location.h>
+#include <location/location-types.h>
+#include <location/location-map-service.h>
+
+#include "route_private.h"
+#include "route_preference.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+/*
+ * Internal implementation
+ */
+static int _convert_error_code(int code)
+{
+ int ret;
+ char *msg = "ROUTE_ERROR_NONE";
+ switch (code) {
+ case LOCATION_ERROR_NONE:
+ ret = ROUTE_ERROR_NONE;
+ msg = "ROUTE_ERROR_NONE";
+ break;
+ case LOCATION_ERROR_PARAMETER:
+ ret = ROUTE_ERROR_INVALID_PARAMETER;
+ msg = "ROUTE_ERROR_INVALID_PARAMETER";
+ break;
+ case LOCATION_ERROR_NETWORK_FAILED:
+ case LOCATION_ERROR_NETWORK_NOT_CONNECTED:
+ ret = ROUTE_ERROR_NETWORK_FAILED;
+ msg = "ROUTE_ERROR_NETWORK_FAILED";
+ break;
+ case LOCATION_ERROR_NOT_FOUND:
+ ret = ROUTE_ERROR_RESULT_NOT_FOUND;
+ msg = "ROUTE_ERROR_RESULT_NOT_FOUND";
+ break;
+ case LOCATION_ERROR_NOT_SUPPORTED:
+ ret = ROUTE_ERROR_SERVICE_NOT_SUPPORTED;
+ msg = "ROUTE_ERROR_SERVICE_NOT_SUPPORTED";
+ break;
+ case LOCATION_ERROR_NOT_ALLOWED:
+ case LOCATION_ERROR_NOT_AVAILABLE:
+ case LOCATION_ERROR_CONFIGURATION:
+ case LOCATION_ERROR_UNKNOWN:
+ default:
+ msg = "ROUTE_ERROR_SERVICE_NOT_AVAILABLE";
+ ret = ROUTE_ERROR_SERVICE_NOT_AVAILABLE;
+ }
+ ROUTE_LOGE("%s(0x%08x) : core fw error(0x%x)", msg, ret, code);
+ return ret;
+}
+
+/*
+ * Route preference
+ */
+int route_preference_create(route_preference_h * preference)
+{
+ ROUTE_NULL_ARG_CHECK(preference);
+
+ route_preference_s *handle = (route_preference_s *) malloc(sizeof(route_preference_s));
+ if (handle == NULL) {
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_OUT_OF_MEMORY);
+ }
+ memset(handle, 0, sizeof(route_preference_s));
+
+ handle->preference = location_route_pref_new();
+
+ if (handle->preference == NULL) {
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_SERVICE_NOT_AVAILABLE);
+ }
+
+ *preference = (route_preference_h) handle;
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_preference_destroy(route_preference_h preference)
+{
+ ROUTE_NULL_ARG_CHECK(preference);
+
+ route_preference_s *handle = (route_preference_s *) preference;
+
+ if (handle->preference) {
+ location_route_pref_free(handle->preference);
+ }
+ free(handle);
+ handle = NULL;
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_preference_foreach_addresses_to_avoid(route_preference_h preference, route_preference_address_to_avoid_cb callback,
+ void *user_data)
+{
+ ROUTE_NULL_ARG_CHECK(preference);
+ ROUTE_NULL_ARG_CHECK(callback);
+
+ route_preference_s *handle = (route_preference_s *) preference;
+ GList *addr_list = location_route_pref_get_freeformed_addr_to_avoid(handle->preference);
+
+ while (addr_list) {
+ gchar *address = addr_list->data;
+ if (address != NULL && !callback(address, user_data)) {
+ break;
+ }
+ addr_list = addr_list->next;
+ }
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_preference_foreach_areas_to_avoid(route_preference_h preference, route_preference_area_to_avoid_cb callback,
+ void *user_data)
+{
+ ROUTE_NULL_ARG_CHECK(preference);
+ ROUTE_NULL_ARG_CHECK(callback);
+
+ route_preference_s *handle = (route_preference_s *) preference;
+ GList *area_list = location_route_pref_get_area_to_avoid(handle->preference);
+ LocationBoundary *area;
+
+ while (area_list) {
+ area = area_list->data;
+ if (area != NULL && !callback((location_bounds_h) area, user_data)) {
+ break;
+ }
+ area_list = area_list->next;
+ }
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_preference_foreach_constraints(route_preference_h preference, route_preference_constraint_cb callback,
+ void *user_data)
+{
+ ROUTE_NULL_ARG_CHECK(preference);
+ ROUTE_NULL_ARG_CHECK(callback);
+
+ route_preference_s *handle = (route_preference_s *) preference;
+ GList *constraint_list = location_route_pref_get_feature_to_avoid(handle->preference);
+
+ while (constraint_list) {
+ char *constraint = (char *)constraint_list->data;
+ if (constraint != NULL && !callback(constraint, user_data)) {
+ break;
+ }
+ constraint_list = constraint_list->next;
+ }
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_preference_foreach_properties(route_preference_h preference, route_preference_property_cb callback, void *user_data)
+{
+ ROUTE_NULL_ARG_CHECK(preference);
+ ROUTE_NULL_ARG_CHECK(callback);
+
+ route_preference_s *handle = (route_preference_s *) preference;
+ GList *key_list = location_route_pref_get_property_key(handle->preference);
+
+ while (key_list) {
+ char *key = key_list->data;
+ char *value = NULL;
+ if (key != NULL && (value = (char *)location_route_pref_get_property(handle->preference, key)) != NULL) {
+ if (callback(key, value, user_data) == false) {
+ break;
+ }
+ }
+ key_list = key_list->next;
+ }
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_preference_get_geometry_bounding_box(route_preference_h preference, location_coords_s * top_left,
+ location_coords_s * bottom_right)
+{
+ ROUTE_NULL_ARG_CHECK(preference);
+ ROUTE_NULL_ARG_CHECK(top_left);
+ ROUTE_NULL_ARG_CHECK(bottom_right);
+
+ route_preference_s *handle = (route_preference_s *) preference;
+ LocationBoundary *bbox = location_route_pref_get_bounding_box(handle->preference);
+
+ if (bbox == NULL) {
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_RESULT_NOT_FOUND);
+ }
+
+ top_left->latitude = bbox->rect.left_top->latitude;
+ top_left->longitude = bbox->rect.left_top->longitude;
+ bottom_right->latitude = bbox->rect.right_bottom->latitude;
+ bottom_right->longitude = bbox->rect.right_bottom->longitude;
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_preference_get_max_results(route_preference_h preference, int *max_results)
+{
+ ROUTE_NULL_ARG_CHECK(preference);
+ ROUTE_NULL_ARG_CHECK(max_results);
+
+ route_preference_s *handle = (route_preference_s *) preference;
+ int result = (int)location_route_pref_get_max_result(handle->preference);
+
+ *max_results = result;
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_preference_get_goal(route_preference_h preference, char **goal)
+{
+ ROUTE_NULL_ARG_CHECK(preference);
+ ROUTE_NULL_ARG_CHECK(goal);
+
+ route_preference_s *handle = (route_preference_s *) preference;
+ char *route_type = (char *)location_route_pref_get_route_type(handle->preference);
+
+ if (route_type == NULL) {
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_RESULT_NOT_FOUND);
+ }
+
+ *goal = strdup(route_type);
+ if (*goal == NULL) {
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_OUT_OF_MEMORY);
+ }
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_preference_get_transport_mode(route_preference_h preference, char **mode)
+{
+ ROUTE_NULL_ARG_CHECK(preference);
+ ROUTE_NULL_ARG_CHECK(mode);
+
+ route_preference_s *handle = (route_preference_s *) preference;
+ char *transport = (char *)location_route_pref_get_transport_mode(handle->preference);
+
+ if (transport == NULL) {
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_RESULT_NOT_FOUND);
+ }
+
+ *mode = strdup(transport);
+ if (*mode == NULL) {
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_OUT_OF_MEMORY);
+ }
+
+ return ROUTE_ERROR_NONE;
+}
+
+bool route_preference_is_geometry_used(route_preference_h preference)
+{
+ ROUTE_NULL_ARG_CHECK_RETURN_FALSE(preference);
+
+ route_preference_s *handle = (route_preference_s *) preference;
+ bool ret = (bool) location_route_pref_get_geometry_used(handle->preference);
+
+ return ret;
+}
+
+bool route_preference_is_instruction_bounding_box_used(route_preference_h preference)
+{
+ ROUTE_NULL_ARG_CHECK_RETURN_FALSE(preference);
+
+ route_preference_s *handle = (route_preference_s *) preference;
+ bool ret = (bool) location_route_pref_get_instruction_bounding_box_used(handle->preference);
+
+ return ret;
+}
+
+bool route_preference_is_instruction_geometry_used(route_preference_h preference)
+{
+ ROUTE_NULL_ARG_CHECK_RETURN_FALSE(preference);
+
+ route_preference_s *handle = (route_preference_s *) preference;
+ bool ret = (bool) location_route_pref_get_instruction_geometry_used(handle->preference);
+
+ return ret;
+}
+
+bool route_preference_is_instruction_used(route_preference_h preference)
+{
+ ROUTE_NULL_ARG_CHECK_RETURN_FALSE(preference);
+
+ route_preference_s *handle = (route_preference_s *) preference;
+ bool ret = (bool) location_route_pref_get_instruction_used(handle->preference);
+
+ return ret;
+}
+
+bool route_preference_is_traffic_data_used(route_preference_h preference)
+{
+ ROUTE_NULL_ARG_CHECK_RETURN_FALSE(preference);
+
+ route_preference_s *handle = (route_preference_s *) preference;
+ bool ret = (bool) location_route_pref_get_traffic_data_used(handle->preference);
+
+ return ret;
+}
+
+int route_preference_get(route_preference_h preference, const char *key, char **value)
+{
+ ROUTE_NULL_ARG_CHECK(preference);
+ ROUTE_NULL_ARG_CHECK(key);
+ ROUTE_NULL_ARG_CHECK(value);
+
+ route_preference_s *handle = (route_preference_s *) preference;
+ char *val = (char *)location_route_pref_get_property(handle->preference, (gconstpointer) key);
+ if (val == NULL) {
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_SERVICE_NOT_AVAILABLE);
+ }
+ *value = strdup(val);
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_preference_set(route_preference_h preference, const char *key, const char *value)
+{
+ ROUTE_NULL_ARG_CHECK(preference);
+ ROUTE_NULL_ARG_CHECK(key);
+ ROUTE_NULL_ARG_CHECK(value);
+
+ route_preference_s *handle = (route_preference_s *) preference;
+ bool ret = (bool) location_route_pref_set_property(handle->preference, (gconstpointer) key,
+ (gconstpointer) value);
+ if (!ret) {
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_SERVICE_NOT_AVAILABLE);
+ }
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_preference_add_address_to_avoid(route_preference_h preference, const char *address)
+{
+ ROUTE_NULL_ARG_CHECK(preference);
+ ROUTE_NULL_ARG_CHECK(address);
+
+ route_preference_s *handle = (route_preference_s *) preference;
+ GList *addr_list = location_route_pref_get_freeformed_addr_to_avoid(handle->preference);
+ addr_list = g_list_append(addr_list, (gpointer) address);
+
+ bool ret = (bool) location_route_pref_set_freeformed_addr_to_avoid(handle->preference, addr_list);
+ if (!ret) {
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_SERVICE_NOT_AVAILABLE);
+ }
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_preference_clear_addresses_to_avoid(route_preference_h preference)
+{
+ ROUTE_NULL_ARG_CHECK(preference);
+
+ route_preference_s *handle = (route_preference_s *) preference;
+ GList *addr_list = NULL;
+
+ bool ret = (bool) location_route_pref_set_freeformed_addr_to_avoid(handle->preference, addr_list);
+ if (!ret) {
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_SERVICE_NOT_AVAILABLE);
+ }
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_preference_add_area_to_avoid(route_preference_h preference, location_bounds_h area)
+{
+ ROUTE_NULL_ARG_CHECK(preference);
+ ROUTE_NULL_ARG_CHECK(area);
+
+ route_preference_s *handle = (route_preference_s *) preference;
+ GList *area_list = location_route_pref_get_area_to_avoid(handle->preference);
+ area_list = g_list_append(area_list, (gpointer) area);
+
+ bool ret = (bool) location_route_pref_set_area_to_avoid(handle->preference, area_list);
+ if (!ret) {
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_SERVICE_NOT_AVAILABLE);
+ }
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_preference_clear_areas_to_avoid(route_preference_h preference)
+{
+ ROUTE_NULL_ARG_CHECK(preference);
+
+ route_preference_s *handle = (route_preference_s *) preference;
+ GList *area_list = NULL;
+
+ bool ret = (bool) location_route_pref_set_area_to_avoid(handle->preference, area_list);
+ if (!ret) {
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_SERVICE_NOT_AVAILABLE);
+ }
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_preference_add_constraint(route_preference_h preference, const char *constraint)
+{
+ ROUTE_NULL_ARG_CHECK(preference);
+ ROUTE_NULL_ARG_CHECK(constraint);
+
+ route_preference_s *handle = (route_preference_s *) preference;
+ GList *constraint_list = location_route_pref_get_feature_to_avoid(handle->preference);
+ constraint_list = g_list_append(constraint_list, (gpointer) constraint);
+
+ bool ret = (bool) location_route_pref_set_feature_to_avoid(handle->preference, constraint_list);
+ if (!ret) {
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_SERVICE_NOT_AVAILABLE);
+ }
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_preference_clear_constraints(route_preference_h preference)
+{
+ ROUTE_NULL_ARG_CHECK(preference);
+
+ route_preference_s *handle = (route_preference_s *) preference;
+ GList *constraint_list = NULL;
+
+ bool ret = (bool) location_route_pref_set_feature_to_avoid(handle->preference, constraint_list);
+ if (!ret) {
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_SERVICE_NOT_AVAILABLE);
+ }
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_preference_set_geometry_bounding_box(route_preference_h preference, location_coords_s top_left,
+ location_coords_s bottom_right)
+{
+ ROUTE_NULL_ARG_CHECK(preference);
+ ROUTE_CHECK_CONDITION(top_left.latitude>=-90 && top_left.latitude<=90 ,ROUTE_ERROR_INVALID_PARAMETER,"latitude should be -90 <= latitude <= 90");
+ ROUTE_CHECK_CONDITION(top_left.longitude>=-180 && top_left.longitude<=180,ROUTE_ERROR_INVALID_PARAMETER,"longitude should be -180 <= latitude <= 180");
+ ROUTE_CHECK_CONDITION(bottom_right.latitude>=-90 && bottom_right.latitude<=90 ,ROUTE_ERROR_INVALID_PARAMETER,"latitude should be -90 <= latitude <= 90");
+ ROUTE_CHECK_CONDITION(bottom_right.longitude>=-180 && bottom_right.longitude<=180,ROUTE_ERROR_INVALID_PARAMETER,"longitude should be -180 <= latitude <= 180");
+
+ route_preference_s *handle = (route_preference_s *) preference;
+ LocationPosition *tl = location_position_new(0, top_left.latitude, top_left.longitude, 0, LOCATION_STATUS_2D_FIX);
+ if (tl == NULL) {
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_SERVICE_NOT_AVAILABLE);
+ }
+ LocationPosition *br =
+ location_position_new(0, bottom_right.latitude, bottom_right.longitude, 0, LOCATION_STATUS_2D_FIX);
+ if (br == NULL) {
+ location_position_free(tl);
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_SERVICE_NOT_AVAILABLE);
+ }
+
+ LocationBoundary *bbox = location_boundary_new_for_rect(tl, br);
+
+ bool ret = (bool) location_route_pref_set_bounding_box(handle->preference, bbox);
+ if (!ret) {
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_SERVICE_NOT_AVAILABLE);
+ }
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_preference_set_max_results(route_preference_h preference, int max_results)
+{
+ ROUTE_NULL_ARG_CHECK(preference);
+
+ route_preference_s *handle = (route_preference_s *) preference;
+ bool ret = (bool) location_route_pref_set_max_result(handle->preference, (guint) max_results);
+ if (!ret) {
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_SERVICE_NOT_AVAILABLE);
+ }
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_preference_set_goal(route_preference_h preference, const char *goal)
+{
+ ROUTE_NULL_ARG_CHECK(preference);
+ ROUTE_NULL_ARG_CHECK(goal);
+
+ route_preference_s *handle = (route_preference_s *) preference;
+ bool ret = (bool) location_route_pref_set_route_type(handle->preference, (gchar *) goal);
+ if (!ret) {
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_SERVICE_NOT_AVAILABLE);
+ }
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_preference_set_transport_mode(route_preference_h preference, const char *mode)
+{
+ ROUTE_NULL_ARG_CHECK(preference);
+ ROUTE_NULL_ARG_CHECK(mode);
+
+ route_preference_s *handle = (route_preference_s *) preference;
+ bool ret = (bool) location_route_pref_set_transport_mode(handle->preference, (gchar *) mode);
+ if (!ret) {
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_SERVICE_NOT_AVAILABLE);
+ }
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_preference_set_geometry_used(route_preference_h preference, bool used)
+{
+ ROUTE_NULL_ARG_CHECK(preference);
+
+ route_preference_s *handle = (route_preference_s *) preference;
+ bool ret = (bool) location_route_pref_set_geometry_used(handle->preference, (gboolean) used);
+ if (!ret) {
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_SERVICE_NOT_AVAILABLE);
+ }
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_preference_set_instruction_bounding_box_used(route_preference_h preference, bool used)
+{
+ ROUTE_NULL_ARG_CHECK(preference);
+
+ route_preference_s *handle = (route_preference_s *) preference;
+ bool ret = (bool) location_route_pref_set_instruction_bounding_box_used(handle->preference,
+ (gboolean) used);
+ if (!ret) {
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_SERVICE_NOT_AVAILABLE);
+ }
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_preference_set_instruction_geometry_used(route_preference_h preference, bool used)
+{
+ ROUTE_NULL_ARG_CHECK(preference);
+
+ route_preference_s *handle = (route_preference_s *) preference;
+ bool ret = (bool) location_route_pref_set_instruction_geometry_used(handle->preference,
+ (gboolean) used);
+ if (!ret) {
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_SERVICE_NOT_AVAILABLE);
+ }
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_preference_set_instruction_used(route_preference_h preference, bool used)
+{
+ ROUTE_NULL_ARG_CHECK(preference);
+
+ route_preference_s *handle = (route_preference_s *) preference;
+ bool ret = (bool) location_route_pref_set_instruction_used(handle->preference, (gboolean) used);
+ if (!ret) {
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_SERVICE_NOT_AVAILABLE);
+ }
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_preference_set_traffic_data_used(route_preference_h preference, bool used)
+{
+ ROUTE_NULL_ARG_CHECK(preference);
+
+ route_preference_s *handle = (route_preference_s *) preference;
+ bool ret = (bool) location_route_pref_set_traffic_data_used(handle->preference, (gboolean) used);
+ if (!ret) {
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_SERVICE_NOT_AVAILABLE);
+ }
+
+ return ROUTE_ERROR_NONE;
+}
+
+bool route_preference_is_area_to_avoid_supported(route_service_h service, location_bounds_type_e type)
+{
+ ROUTE_NULL_ARG_CHECK_RETURN_FALSE(service);
+
+ route_service_s *handle = (route_service_s *) service;
+ bool ret = false;
+ switch (type) {
+ case LOCATION_BOUNDS_RECT:
+ ret =
+ (bool) location_map_is_supported_provider_capability(handle->object,
+ MAP_SERVICE_ROUTE_REQUEST_RECT_AREA_TO_AVOID);
+ break;
+ case LOCATION_BOUNDS_CIRCLE:
+ ret =
+ (bool) location_map_is_supported_provider_capability(handle->object,
+ MAP_SERVICE_ROUTE_REQUEST_CIRCLE_AREA_TO_AVOID);
+ break;
+ case LOCATION_BOUNDS_POLYGON:
+ ret =
+ (bool) location_map_is_supported_provider_capability(handle->object,
+ MAP_SERVICE_ROUTE_REQUEST_POLYGON_AREA_TO_AVOID);
+ break;
+ default:
+ ROUTE_LOGE("Unknown location_bounds_type_e : %d", type);
+ break;
+ }
+
+ return ret;
+}
+
+bool route_preference_is_address_to_avoid_supported(route_service_h service)
+{
+ ROUTE_NULL_ARG_CHECK_RETURN_FALSE(service);
+
+ route_service_s *handle = (route_service_s *) service;
+ bool ret = (bool) location_map_is_supported_provider_capability(handle->object,
+ MAP_SERVICE_ROUTE_REQUEST_FREEFORM_ADDR_TO_AVOID);
+
+ return ret;
+}
+
+bool route_preference_is_geometry_bounding_box_supported(route_service_h service)
+{
+ ROUTE_NULL_ARG_CHECK_RETURN_FALSE(service);
+
+ route_service_s *handle = (route_service_s *) service;
+ bool ret =
+ (bool) location_map_is_supported_provider_capability(handle->object, MAP_SERVICE_ROUTE_PREF_GEOMETRY_BOUNDING_BOX);
+
+ return ret;
+}
+
+bool route_preference_is_geometry_supported(route_service_h service)
+{
+ ROUTE_NULL_ARG_CHECK_RETURN_FALSE(service);
+
+ route_service_s *handle = (route_service_s *) service;
+ bool ret =
+ (bool) location_map_is_supported_provider_capability(handle->object, MAP_SERVICE_ROUTE_PREF_GEOMETRY_RETRIEVAL);
+
+ return ret;
+}
+
+bool route_preference_is_instruction_geometry_supported(route_service_h service)
+{
+ ROUTE_NULL_ARG_CHECK_RETURN_FALSE(service);
+
+ route_service_s *handle = (route_service_s *) service;
+ bool ret =
+ (bool) location_map_is_supported_provider_capability(handle->object, MAP_SERVICE_ROUTE_PREF_INSTRUCTION_GEOMETRY);
+
+ return ret;
+}
+
+bool route_preference_is_instruction_bounding_box_supported(route_service_h service)
+{
+ ROUTE_NULL_ARG_CHECK_RETURN_FALSE(service);
+
+ route_service_s *handle = (route_service_s *) service;
+ bool ret = (bool) location_map_is_supported_provider_capability(handle->object,
+ MAP_SERVICE_ROUTE_PREF_INSTRUCTION_BOUNDING_BOX);
+
+ return ret;
+}
+
+bool route_preference_is_instruction_supported(route_service_h service)
+{
+ ROUTE_NULL_ARG_CHECK_RETURN_FALSE(service);
+
+ route_service_s *handle = (route_service_s *) service;
+ bool ret =
+ (bool) location_map_is_supported_provider_capability(handle->object, MAP_SERVICE_ROUTE_PREF_INSTRUCTION_RETRIEVAL);
+
+ return ret;
+}
+
+bool route_preference_is_traffic_data_supported(route_service_h service)
+{
+ ROUTE_NULL_ARG_CHECK_RETURN_FALSE(service);
+
+ route_service_s *handle = (route_service_s *) service;
+ bool ret =
+ (bool) location_map_is_supported_provider_capability(handle->object, MAP_SERVICE_ROUTE_PREF_REALTIME_TRAFFIC);
+
+ return ret;
+}
+
+int route_preference_foreach_available_constraints(route_service_h service, route_preference_available_constraint_cb callback,
+ void *user_data)
+{
+ ROUTE_NULL_ARG_CHECK(service);
+ ROUTE_NULL_ARG_CHECK(callback);
+
+ route_service_s *handle = (route_service_s *) service;
+ LocationMapServiceType type = MAP_SERVICE_ROUTE_REQUEST_FEATURE_TO_AVOID;
+ GList *constraint_list = NULL;
+ int ret = location_map_get_provider_capability_key(handle->object, type, &constraint_list);
+ if (ret) {
+ return _convert_error_code(ret);
+ }
+
+ while (constraint_list) {
+ char *constraint = (char *)constraint_list->data;
+ if (constraint != NULL && !callback(constraint, user_data)) {
+ break;
+ }
+ constraint_list = constraint_list->next;
+ }
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_preference_foreach_available_goals(route_service_h service, route_preference_available_goal_cb callback,
+ void *user_data)
+{
+ ROUTE_NULL_ARG_CHECK(service);
+ ROUTE_NULL_ARG_CHECK(callback);
+
+ route_service_s *handle = (route_service_s *) service;
+ LocationMapServiceType type = MAP_SERVICE_ROUTE_PREF_TYPE;
+ GList *goal_list = NULL;
+ int ret = location_map_get_provider_capability_key(handle->object, type, &goal_list);
+ if (ret) {
+ return _convert_error_code(ret);
+ }
+
+ while (goal_list) {
+ char *goal = (char *)goal_list->data;
+ if (goal != NULL && !callback(goal, user_data)) {
+ break;
+ }
+ goal_list = goal_list->next;
+ }
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_preference_foreach_available_transport_modes(route_service_h service,
+ route_preference_available_transport_mode_cb callback, void *user_data)
+{
+ ROUTE_NULL_ARG_CHECK(service);
+ ROUTE_NULL_ARG_CHECK(callback);
+
+ route_service_s *handle = (route_service_s *) service;
+ LocationMapServiceType type = MAP_SERVICE_ROUTE_PREF_TRANSPORT_MODE;
+ GList *mode_list = NULL;
+ int ret = location_map_get_provider_capability_key(handle->object, type, &mode_list);
+ if (ret) {
+ return _convert_error_code(ret);
+ }
+
+ while (mode_list) {
+ char *mode = (char *)mode_list->data;
+ if (mode != NULL && !callback(mode, user_data)) {
+ break;
+ }
+ mode_list = mode_list->next;
+ }
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_preference_foreach_available_property_keys(route_service_h service,
+ route_preference_available_property_key_cb callback, void *user_data)
+{
+ ROUTE_NULL_ARG_CHECK(service);
+ ROUTE_NULL_ARG_CHECK(callback);
+
+ route_service_s *handle = (route_service_s *) service;
+ LocationMapServiceType type = MAP_SERVICE_ROUTE_PREF_PROPERTY;
+ GList *key_list = NULL;
+ int ret = location_map_get_provider_capability_key(handle->object, type, &key_list);
+ if (ret) {
+ return _convert_error_code(ret);
+ }
+
+ while (key_list) {
+ char *key = (char *)key_list->data;
+ if (key != NULL && !callback(key, user_data)) {
+ break;
+ }
+ key_list = key_list->next;
+ }
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_preference_foreach_available_property_values(route_service_h service, const char *key,
+ route_preference_available_property_value_cb callback, void *user_data)
+{
+ ROUTE_NULL_ARG_CHECK(service);
+ ROUTE_NULL_ARG_CHECK(key);
+ ROUTE_NULL_ARG_CHECK(callback);
+
+ route_service_s *handle = (route_service_s *) service;
+ LocationMapServiceType type = MAP_SERVICE_ROUTE_PREF_PROPERTY;
+ GList *key_list = NULL;
+ int ret = location_map_get_provider_capability_key(handle->object, type, &key_list);
+ if (ret) {
+ return _convert_error_code(ret);
+ }
+
+ while (key_list) {
+ char *key = (char *)key_list->data;
+ char *value = (char *)location_route_pref_get_property(handle->route_preference, (gconstpointer) key);
+ if (key != NULL && value != NULL && !callback(value, user_data)) {
+ break;
+ }
+ key_list = key_list->next;
+ }
+
+ return ROUTE_ERROR_NONE;
+}
--- /dev/null
+/*
+* Copyright (c) 2011-2013 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 <location/location.h>
+#include <location/location-types.h>
+#include <location/location-map-service.h>
+
+#include "route_service.h"
+#include "route_preference.h"
+#include "route_private.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+typedef struct {
+ void *data;
+ route_service_found_cb callback;
+} __callback_data;
+
+/*
+ * Internal implementation
+ */
+static int _convert_error_code(int code)
+{
+ int ret;
+ char *msg = "ROUTE_ERROR_NONE";
+ switch (code) {
+ case LOCATION_ERROR_NONE:
+ ret = ROUTE_ERROR_NONE;
+ msg = "ROUTE_ERROR_NONE";
+ break;
+ case LOCATION_ERROR_PARAMETER:
+ ret = ROUTE_ERROR_INVALID_PARAMETER;
+ msg = "ROUTE_ERROR_INVALID_PARAMETER";
+ break;
+ case LOCATION_ERROR_NETWORK_FAILED:
+ case LOCATION_ERROR_NETWORK_NOT_CONNECTED:
+ ret = ROUTE_ERROR_NETWORK_FAILED;
+ msg = "ROUTE_ERROR_NETWORK_FAILED";
+ break;
+ case LOCATION_ERROR_NOT_FOUND:
+ ret = ROUTE_ERROR_RESULT_NOT_FOUND;
+ msg = "ROUTE_ERROR_RESULT_NOT_FOUND";
+ break;
+ case LOCATION_ERROR_NOT_SUPPORTED:
+ ret = ROUTE_ERROR_SERVICE_NOT_SUPPORTED;
+ msg = "ROUTE_ERROR_SERVICE_NOT_SUPPORTED";
+ break;
+ case LOCATION_ERROR_NOT_ALLOWED:
+ case LOCATION_ERROR_NOT_AVAILABLE:
+ case LOCATION_ERROR_CONFIGURATION:
+ case LOCATION_ERROR_UNKNOWN:
+ default:
+ msg = "ROUTE_ERROR_SERVICE_NOT_AVAILABLE";
+ ret = ROUTE_ERROR_SERVICE_NOT_AVAILABLE;
+ }
+ ROUTE_LOGE("%s(0x%08x) : core fw error(0x%x)", msg, ret, code);
+ return ret;
+}
+
+static void __free_waypoint(gpointer data)
+{
+ LocationPosition *pos = (LocationPosition *) data;
+ if (pos) {
+ location_position_free(pos);
+ }
+}
+
+/*
+ * Route service
+ */
+static void __LocationRouteCB(LocationError error, guint req_id, GList * route_list, gchar * error_code, gchar * error_msg,
+ gpointer userdata)
+{
+ __callback_data *calldata = (__callback_data *) userdata;
+ if (calldata == NULL || calldata->callback == NULL) {
+ return;
+ }
+
+ int ret = _convert_error_code(error);
+ GList *routes_list = route_list;
+ int index = 0;
+ int total = 0;
+
+ if (routes_list == NULL || ret != 0) {
+ calldata->callback(ret, index, total, NULL, calldata->data);
+ free(calldata);
+ return;
+ }
+
+ total = g_list_length(routes_list);
+ while (routes_list) {
+ route_s *route = (route_s *) malloc(sizeof(route_s));
+ if (route == NULL) {
+ break;
+ }
+ route->route = routes_list->data;
+ route->request_id = req_id;
+ if (calldata->callback(ret, index++, total, route, calldata->data) == false) {
+ free(route);
+ break;
+ }
+ routes_list = routes_list->next;
+ free(route);
+ }
+ free(calldata);
+}
+
+int route_service_create(route_service_h * service)
+{
+ ROUTE_NULL_ARG_CHECK(service);
+
+ int ret = location_init();
+ if (ret != LOCATION_ERROR_NONE) {
+ ROUTE_LOGE("Fail to location_init");
+ return _convert_error_code(ret);
+ }
+
+ route_service_s *handle = (route_service_s *) malloc(sizeof(route_service_s));
+ if (handle == NULL) {
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_OUT_OF_MEMORY);
+ }
+ memset(handle, 0, sizeof(route_service_s));
+
+ if (ROUTE_ERROR_NONE != route_preference_create(&handle->route_preference)) {
+ free(handle);
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_OUT_OF_MEMORY);
+ }
+
+ handle->object = location_map_new(NULL);
+ if (handle->object == NULL) {
+ free(handle);
+ ROUTE_LOGE("Fail to location_map_new");
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_SERVICE_NOT_AVAILABLE);
+ }
+
+ *service = (route_service_h) handle;
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_service_destroy(route_service_h service)
+{
+ ROUTE_NULL_ARG_CHECK(service);
+
+ route_service_s *handle = (route_service_s *) service;
+
+ if (handle->route_preference) {
+ route_preference_destroy(handle->route_preference);
+ }
+
+ int ret = location_map_free(handle->object);
+ if (ret != LOCATION_ERROR_NONE) {
+ return _convert_error_code(ret);
+ }
+ free(handle);
+ handle = NULL;
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_service_get_preference(route_service_h service, route_preference_h * preference)
+{
+ ROUTE_NULL_ARG_CHECK(service);
+ ROUTE_NULL_ARG_CHECK(preference);
+
+ route_service_s *handle = (route_service_s *) service;
+
+ if (handle->route_preference == NULL) {
+ route_preference_create(&handle->route_preference);
+ }
+ *preference = handle->route_preference;
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_service_set_preference(route_service_h service, route_preference_h preference)
+{
+ ROUTE_NULL_ARG_CHECK(service);
+ ROUTE_NULL_ARG_CHECK(preference);
+
+ route_service_s *handle = (route_service_s *) service;
+
+ if (handle->route_preference) {
+ route_preference_destroy(handle->route_preference);
+ handle->route_preference = preference;
+ }
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_service_find(route_service_h service, location_coords_s origin, location_coords_s destination,
+ location_coords_s * waypoint_list, int waypoint_num, route_service_found_cb callback, void *user_data,
+ int *request_id)
+{
+ ROUTE_NULL_ARG_CHECK(service);
+ ROUTE_NULL_ARG_CHECK(callback);
+ ROUTE_CHECK_CONDITION(origin.latitude>=-90 && origin.latitude<=90 ,ROUTE_ERROR_INVALID_PARAMETER,"latitude should be -90 <= latitude <= 90");
+ ROUTE_CHECK_CONDITION(origin.longitude>=-180 && origin.longitude<=180,ROUTE_ERROR_INVALID_PARAMETER,"longitude should be -180 <= latitude <= 180");
+ ROUTE_CHECK_CONDITION(destination.latitude>=-90 && destination.latitude<=90 ,ROUTE_ERROR_INVALID_PARAMETER,"latitude should be -90 <= latitude <= 90");
+ ROUTE_CHECK_CONDITION(destination.longitude>=-180 && destination.longitude<=180,ROUTE_ERROR_INVALID_PARAMETER,"longitude should be -180 <= latitude <= 180");
+
+ LocationPosition start;
+ LocationPosition end;
+ unsigned int reqid;
+ int ret;
+ int i;
+
+ route_service_s *handle = (route_service_s *) service;
+ route_preference_s *pref = (route_preference_s *) handle->route_preference;
+
+ start.latitude = origin.latitude;
+ start.longitude = origin.longitude;
+ start.altitude = 0;
+ start.status = LOCATION_STATUS_2D_FIX;
+
+ end.latitude = destination.latitude;
+ end.longitude = destination.longitude;
+ end.altitude = 0;
+ end.status = LOCATION_STATUS_2D_FIX;
+
+ GList *waypoint = NULL;
+ LocationPosition *via_pos = NULL;
+
+ for (i = 0; i < waypoint_num; i++) {
+ via_pos =
+ location_position_new(0, waypoint_list->latitude, waypoint_list->longitude, 0, LOCATION_STATUS_2D_FIX);
+ if (via_pos == NULL) {
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_RESULT_NOT_FOUND);
+ } else {
+ waypoint_list++;
+ waypoint = g_list_append(waypoint, (gpointer) via_pos);
+ }
+ location_position_free(via_pos);
+ }
+
+ __callback_data *calldata = (__callback_data *) malloc(sizeof(__callback_data));
+ if (calldata == NULL) {
+ ROUTE_PRINT_ERROR_CODE_RETURN(ROUTE_ERROR_OUT_OF_MEMORY);
+ }
+
+ calldata->callback = callback;
+ calldata->data = user_data;
+
+ ret = location_map_request_route(handle->object, &start, &end, waypoint, pref->preference, __LocationRouteCB, calldata,
+ &reqid);
+ if (ret != LOCATION_ERROR_NONE) {
+ free(calldata);
+ g_list_free_full(waypoint, __free_waypoint);
+ return _convert_error_code(ret);
+ }
+
+ if (request_id) {
+ *request_id = reqid;
+ }
+
+ return ROUTE_ERROR_NONE;
+}
+
+int route_service_cancel(route_service_h service, int request_id)
+{
+ ROUTE_NULL_ARG_CHECK(service);
+ ROUTE_CHECK_CONDITION(request_id>0,ROUTE_ERROR_INVALID_PARAMETER,"request id should be > 0");
+
+ int ret;
+
+ route_service_s *handle = (route_service_s *) service;
+
+ ret = location_map_cancel_route_request(handle->object, request_id);
+
+ if (ret != LOCATION_ERROR_NONE) {
+ return _convert_error_code(ret);
+ }
+
+ return ROUTE_ERROR_NONE;
+}
--- /dev/null
+SET(fw_test "${fw_name}-test")
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${fw_test} REQUIRED )
+FOREACH(flag ${${fw_test}_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall -Werror")
+
+aux_source_directory(. sources)
+FOREACH(src ${sources})
+ GET_FILENAME_COMPONENT(src_name ${src} NAME_WE)
+ MESSAGE("${src_name}")
+ ADD_EXECUTABLE(${src_name} ${src})
+ TARGET_LINK_LIBRARIES(${src_name} ${fw_name} ${${fw_test}_LDFLAGS})
+ENDFOREACH()
+
--- /dev/null
+/*
+* Copyright (c) 2011-2013 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 <string.h>
+#include <glib.h>
+
+#include <location_bounds.h>
+#include <route_service.h>
+#include <route_preference.h>
+#include <route.h>
+
+route_service_h service;
+
+#define ROUTE_TEST_PRINT_RETURN(api, ret) \
+ if (ret == 0) { } else \
+ { printf("Error [%s] return (0x%08x)\n", api, ret); }; \
+
+
+#define ROUTE_TEST_PRINT_BOOL(api, bret) \
+ if (bret) \
+ { printf("[TRUE ] %s\n", api); } else \
+ { printf("[FASLE] %s\n", api); }; \
+
+static bool route_preference_available_property_value_callback(const char *value, void *user_data)
+{
+ printf("===== route_preference_available_property_value_callback ======\n");
+
+ if (value == NULL) {
+ printf("value is NULL\n");
+ return FALSE;
+ }
+
+ printf("value : %s\n", value);
+ return TRUE;
+}
+
+static bool route_preference_available_property_key_callback(const char *key, void *user_data)
+{
+ printf("===== route_preference_available_property_key_callback ======\n");
+
+ if (key == NULL) {
+ printf("key is NULL\n");
+ return FALSE;
+ }
+
+ printf("key : %s\n", key);
+
+ int ret =
+ route_preference_foreach_available_property_values(service, key, route_preference_available_property_value_callback,
+ NULL);
+ ROUTE_TEST_PRINT_RETURN("route_preference_foreach_available_property_values", ret);
+ return TRUE;
+}
+
+static bool route_preference_available_constraint_callback(const char *constraint, void *user_data)
+{
+ printf("===== route_preference_available_constraint_callback ======\n");
+
+ if (constraint == NULL) {
+ printf("constraint is NULL\n");
+ return FALSE;
+ }
+
+ printf("constraint : %s\n", constraint);
+ return TRUE;
+
+}
+
+static bool route_preference_available_goal_callback(const char *goal, void *user_data)
+{
+ printf("===== route_preference_available_goal_callback ======\n");
+
+ if (goal == NULL) {
+ printf("goal is NULL\n");
+ return FALSE;
+ }
+
+ printf("goal : %s\n", goal);
+ return TRUE;
+}
+
+static bool route_preference_available_transport_mode_callback(const char *mode, void *user_data)
+{
+ printf("===== route_preference_available_transport_mode_callback ======\n");
+
+ if (mode == NULL) {
+ printf("mode is NULL\n");
+ return FALSE;
+ }
+
+ printf("mode : %s\n", mode);
+ return TRUE;
+
+}
+
+static bool route_preference_property_callback(const char *key, const char *value, void *user_data)
+{
+ printf("===== route_preference_property_callback ======\n");
+
+ if (key == NULL) {
+ printf("key is NULL\n");
+ return FALSE;
+ }
+
+ printf("key : %s value : %s\n", key, value);
+ return TRUE;
+}
+
+static bool route_preference_address_to_avoid_callback(const char *address, void *user_data)
+{
+ printf("===== route_preference_address_to_avoid_callback ======\n");
+
+ if (address == NULL) {
+ printf("address is NULL\n");
+ return FALSE;
+ }
+
+ printf("address : %s\n", address);
+ return TRUE;
+}
+
+static bool route_preference_area_to_avoid_callback(location_bounds_h area, void *user_data)
+{
+ printf("===== route_preference_area_to_avoid_callback ======\n");
+
+ if (area == NULL) {
+ printf("arer is NULL\n");
+ return FALSE;
+ }
+
+ location_bounds_type_e type;
+ location_bounds_get_type(area, &type);
+
+ if (type == LOCATION_BOUNDS_CIRCLE) {
+ location_coords_s center;
+ double radius;
+ location_bounds_get_circle_coords(area, ¢er, &radius);
+ printf("center : %lf, %lf radius : %lf\n", center.latitude, center.longitude, radius);
+ } else if (type == LOCATION_BOUNDS_RECT) {
+ location_coords_s top_left;
+ location_coords_s bottom_right;
+ location_bounds_get_rect_coords(area, &top_left, &bottom_right);
+ printf("top_left : %lf, %lf bottom_right : %lf, %lf\n", top_left.latitude, top_left.longitude,
+ bottom_right.latitude, bottom_right.longitude);
+ } else if (type == LOCATION_BOUNDS_POLYGON) {
+ printf("LOCATION_BOUNDS_POLYGON type\n");
+ }
+
+ return TRUE;
+}
+
+static bool route_preference_constraint_callback(const char *constraint, void *user_data)
+{
+ printf("===== route_preference_constraint_callback ======\n");
+
+ if (constraint == NULL) {
+ printf("constraint is NULL\n");
+ return FALSE;
+ }
+
+ printf("constraint : %s\n", constraint);
+ return TRUE;
+}
+
+void route_preference_test(route_preference_h pref)
+{
+ int ret;
+ bool bret;
+
+ ret = route_preference_create(&pref);
+ ROUTE_TEST_PRINT_RETURN("route_preference_create", ret);
+
+ // capability
+ location_bounds_type_e type = LOCATION_BOUNDS_RECT;
+ bret = route_preference_is_area_to_avoid_supported(service, type);
+ ROUTE_TEST_PRINT_BOOL("route_preference_is_area_to_avoid_supported [RECT]", bret);
+
+ type = LOCATION_BOUNDS_CIRCLE;
+ bret = route_preference_is_area_to_avoid_supported(service, type);
+ ROUTE_TEST_PRINT_BOOL("route_preference_is_area_to_avoid_supported [CIRCLE]", bret);
+
+ type = LOCATION_BOUNDS_POLYGON;
+ bret = route_preference_is_area_to_avoid_supported(service, type);
+ ROUTE_TEST_PRINT_BOOL("route_preference_is_area_to_avoid_supported [POLYGON]", bret);
+
+ bret = route_preference_is_address_to_avoid_supported(service);
+ ROUTE_TEST_PRINT_BOOL("route_preference_is_address_to_avoid_supported", bret);
+
+ bret = route_preference_is_geometry_bounding_box_supported(service);
+ ROUTE_TEST_PRINT_BOOL("route_preference_is_geometry_bounding_box_supported", bret);
+
+ bret = route_preference_is_geometry_supported(service);
+ ROUTE_TEST_PRINT_BOOL("route_preference_is_geometry_supported", bret);
+
+ bret = route_preference_is_instruction_geometry_supported(service);
+ ROUTE_TEST_PRINT_BOOL("route_preference_is_instruction_geometry_supported", bret);
+
+ bret = route_preference_is_instruction_bounding_box_supported(service);
+ ROUTE_TEST_PRINT_BOOL("route_preference_is_instruction_bounding_box_supported", bret);
+
+ bret = route_preference_is_instruction_supported(service);
+ ROUTE_TEST_PRINT_BOOL("route_preference_is_instruction_supported", bret);
+
+ bret = route_preference_is_traffic_data_supported(service);
+ ROUTE_TEST_PRINT_BOOL("route_preference_is_traffic_data_supported", bret);
+
+ ret = route_preference_foreach_available_constraints(service, route_preference_available_constraint_callback, NULL);
+ ROUTE_TEST_PRINT_RETURN("route_preference_foreach_available_constraints", ret);
+
+ ret = route_preference_foreach_available_goals(service, route_preference_available_goal_callback, NULL);
+ ROUTE_TEST_PRINT_RETURN("route_preference_foreach_available_goals", ret);
+
+ ret =
+ route_preference_foreach_available_transport_modes(service, route_preference_available_transport_mode_callback,
+ NULL);
+ ROUTE_TEST_PRINT_RETURN("route_preference_foreach_available_transport_modes", ret);
+
+ ret = route_preference_foreach_available_property_keys(service, route_preference_available_property_key_callback, NULL);
+ ROUTE_TEST_PRINT_RETURN("route_preference_foreach_available_property_keys", ret);
+
+ // set preference
+ char *address = "39 Namdaemunno Jung-Gu, Seoul, 100-794, Korea";
+ ret = route_preference_add_address_to_avoid(pref, address);
+ ROUTE_TEST_PRINT_RETURN("route_preference_add_address_to_avoid", ret);
+
+ location_coords_s tl;
+ tl.latitude = 37.562;
+ tl.longitude = 126.980661;
+ location_coords_s br;
+ br.latitude = 37.561;
+ br.longitude = 126.990;
+ location_bounds_h area;
+ ret = location_bounds_create_rect(tl, br, &area);
+ ROUTE_TEST_PRINT_RETURN("location_bounds_create_rect", ret);
+ ret = route_preference_add_area_to_avoid(pref, area);
+ ROUTE_TEST_PRINT_RETURN("route_preference_add_area_to_avoid", ret);
+
+ char *constraint = "BRIDGES";
+ ret = route_preference_add_constraint(pref, constraint);
+ ROUTE_TEST_PRINT_RETURN("route_preference_add_constraint", ret);
+
+ ret = route_preference_set_geometry_bounding_box(pref, tl, br);
+ ROUTE_TEST_PRINT_RETURN("route_preference_add_constraint", ret);
+
+ int max_results = 10;
+ ret = route_preference_set_max_results(pref, max_results);
+ ROUTE_TEST_PRINT_RETURN("route_preference_set_max_results", ret);
+
+ char *goal = "FASTEST";
+ ret = route_preference_set_goal(pref, goal);
+ ROUTE_TEST_PRINT_RETURN("route_preference_set_goal", ret);
+
+ char *mode = "Vehicle";
+ ret = route_preference_set_transport_mode(pref, mode);
+ ROUTE_TEST_PRINT_RETURN("route_preference_set_transport_mode", ret);
+
+ bool used = TRUE;
+ ret = route_preference_set_geometry_used(pref, used);
+ ROUTE_TEST_PRINT_RETURN("route_preference_set_geometry_used", ret);
+
+ ret = route_preference_set_instruction_bounding_box_used(pref, used);
+ ROUTE_TEST_PRINT_RETURN("route_preference_set_instruction_bounding_box_used", ret);
+
+ ret = route_preference_set_instruction_geometry_used(pref, used);
+ ROUTE_TEST_PRINT_RETURN("route_preference_set_instruction_geometry_used", ret);
+
+ ret = route_preference_set_instruction_used(pref, used);
+ ROUTE_TEST_PRINT_RETURN("route_preference_set_instruction_used", ret);
+
+ ret = route_preference_set_traffic_data_used(pref, used);
+ ROUTE_TEST_PRINT_RETURN("route_preference_set_instruction_used", ret);
+
+ // get preference
+ ret = route_preference_foreach_addresses_to_avoid(pref, route_preference_address_to_avoid_callback, NULL);
+ ROUTE_TEST_PRINT_RETURN("route_preference_foreach_addresses_to_avoid", ret);
+
+ ret = route_preference_foreach_areas_to_avoid(pref, route_preference_area_to_avoid_callback, NULL);
+ ROUTE_TEST_PRINT_RETURN("route_preference_foreach_areas_to_avoid", ret);
+
+ ret = route_preference_foreach_constraints(pref, route_preference_constraint_callback, NULL);
+ ROUTE_TEST_PRINT_RETURN("route_preference_foreach_constraints", ret);
+
+ ret = route_preference_foreach_properties(pref, route_preference_property_callback, NULL);
+ ROUTE_TEST_PRINT_RETURN("route_preference_foreach_properties", ret);
+
+ memset(&tl, 0, sizeof(location_coords_s));
+ memset(&br, 0, sizeof(location_coords_s));
+ ret = route_preference_get_geometry_bounding_box(pref, &tl, &br);
+ ROUTE_TEST_PRINT_RETURN("route_preference_foreach_properties", ret);
+ printf("geometry tl lat : %f long : %f\n", tl.latitude, tl.longitude);
+ printf("geometry br lat : %f long : %f\n", br.latitude, br.longitude);
+
+ max_results = 0;
+ ret = route_preference_get_max_results(pref, &max_results);
+ ROUTE_TEST_PRINT_RETURN("route_preference_get_max_results", ret);
+ printf("max_results : %d\n", max_results);
+
+ char *get_goal;
+ ret = route_preference_get_goal(pref, &get_goal);
+ ROUTE_TEST_PRINT_RETURN("route_preference_get_goal", ret);
+ printf("get goal : %s\n", get_goal);
+
+ char *get_mode;
+ ret = route_preference_get_transport_mode(pref, &get_mode);
+ ROUTE_TEST_PRINT_RETURN("route_preference_get_transport_mode", ret);
+ printf("get mode : %s\n", get_mode);
+
+ // clear preference
+ ret = route_preference_clear_addresses_to_avoid(pref);
+ ROUTE_TEST_PRINT_RETURN("route_preference_clear_addresses_to_avoid", ret);
+
+ ret = route_preference_clear_areas_to_avoid(pref);
+ ROUTE_TEST_PRINT_RETURN("route_preference_clear_areas_to_avoid", ret);
+
+ ret = route_preference_clear_constraints(pref);
+ ROUTE_TEST_PRINT_RETURN("route_preference_clear_constraints", ret);
+
+ ret = route_preference_destroy(pref);
+ //ROUTE_TEST_PRINT_RETURN("route_preference_destroy", ret);
+}
+
+void route_set_preference(route_service_h pref)
+{
+ int ret;
+
+ char *goal = "FASTEST";
+ ret = route_preference_set_goal(pref, goal);
+ ROUTE_TEST_PRINT_RETURN("route_preference_set_goal", ret);
+}
+
+static bool route_step_geometry_callback(location_coords_s * geometry, void *user_data)
+{
+ printf("===== route_step_geometry_callback ======\n");
+
+ if (geometry == NULL) {
+ printf("geometry is NULL\n");
+ return FALSE;
+ }
+
+ printf("geometry lat : %f long : %f\n", geometry->latitude, geometry->longitude);
+ return TRUE;
+}
+
+static bool route_step_property_callback(const char *key, const char *value, void *user_data)
+{
+ printf("===== route_step_property_callback ======\n");
+
+ if (key == NULL) {
+ printf("key is NULL\n");
+ return FALSE;
+ }
+
+ printf("key : %s value : %s\n", key, value);
+ return TRUE;
+}
+
+void route_step_information(route_step_h step)
+{
+ int ret;
+ location_coords_s origin, destination;
+ location_coords_s tl, br;
+ double distance;
+ long duration;
+ char *instruction;
+
+ ret = route_step_get_origin(step, &origin);
+ ROUTE_TEST_PRINT_RETURN("route_step_get_origin", ret);
+ printf("origin lat : %f long : %f\n", origin.latitude, origin.longitude);
+
+ ret = route_step_get_destination(step, &destination);
+ ROUTE_TEST_PRINT_RETURN("route_step_get_destination", ret);
+ printf("destination lat : %f long : %f\n", destination.latitude, destination.longitude);
+
+ ret = route_step_get_geometry_bounding_box(step, &tl, &br);
+ ROUTE_TEST_PRINT_RETURN("route_step_get_geometry_bounding_box", ret);
+ printf("bbox tl lat : %f long : %f\n", tl.latitude, tl.longitude);
+ printf("bbox br lat : %f long : %f\n", br.latitude, br.longitude);
+
+ ret = route_step_get_distance(step, &distance);
+ ROUTE_TEST_PRINT_RETURN("route_step_get_distance", ret);
+ printf("distance : %f\n", distance);
+
+ ret = route_step_get_duration(step, &duration);
+ ROUTE_TEST_PRINT_RETURN("route_step_get_duration", ret);
+ printf("duration : %ld\n", duration);
+
+ ret = route_step_get_instruction(step, &instruction);
+ ROUTE_TEST_PRINT_RETURN("route_step_get_instruction", ret);
+ printf("instruction : %s\n", instruction);
+
+ ret = route_step_foreach_geometries(step, route_step_geometry_callback, NULL);
+ ROUTE_TEST_PRINT_RETURN("oute_step_foreach_geometries", ret);
+
+ ret = route_step_foreach_properties(step, route_step_property_callback, NULL);
+ ROUTE_TEST_PRINT_RETURN("route_step_foreach_properties", ret);
+}
+
+static bool route_segment_property_callback(const char *key, const char *value, void *user_data)
+{
+ printf("===== route_segment_property_callback ======\n");
+
+ if (key == NULL) {
+ printf("key is NULL\n");
+ return FALSE;
+ }
+
+ printf("key : %s value : %s\n", key, value);
+ return TRUE;
+}
+
+static bool route_segment_step_callback(route_step_h step, void *user_data)
+{
+ printf("===== route_segment_step_callback ======\n");
+
+ if (step == NULL) {
+ printf("step is NULL\n");
+ return FALSE;
+ }
+
+ int ret;
+ route_step_h cloned_step;
+
+ ret = route_step_clone(&cloned_step, step);
+ ROUTE_TEST_PRINT_RETURN("route_step_clone", ret);
+
+ route_step_information(cloned_step);
+
+ ret = route_step_destroy(cloned_step);
+ ROUTE_TEST_PRINT_RETURN("route_step_destroy", ret);
+
+ return TRUE;
+}
+
+void route_segment_information(route_segment_h segment)
+{
+ int ret;
+ location_coords_s origin, destination;
+ location_coords_s tl, br;
+ double distance;
+ long duration;
+
+ ret = route_segment_get_origin(segment, &origin);
+ ROUTE_TEST_PRINT_RETURN("route_segment_get_origin", ret);
+ printf("origin lat : %f long : %f\n", origin.latitude, origin.longitude);
+
+ ret = route_segment_get_destination(segment, &destination);
+ ROUTE_TEST_PRINT_RETURN("route_segment_get_destination", ret);
+ printf("destination lat : %f long : %f\n", destination.latitude, destination.longitude);
+
+ ret = route_segment_get_geometry_bounding_box(segment, &tl, &br);
+ ROUTE_TEST_PRINT_RETURN("route_segment_get_geometry_bounding_box", ret);
+ printf("bbox tl lat : %f long : %f\n", tl.latitude, tl.longitude);
+ printf("bbox br lat : %f long : %f\n", br.latitude, br.longitude);
+
+ ret = route_segment_get_distance(segment, &distance);
+ ROUTE_TEST_PRINT_RETURN("route_segment_get_distance", ret);
+ printf("distance : %f\n", distance);
+
+ ret = route_segment_get_duration(segment, &duration);
+ ROUTE_TEST_PRINT_RETURN("route_segment_get_duration", ret);
+ printf("duration : %ld\n", duration);
+
+ ret = route_segment_foreach_properties(segment, route_segment_property_callback, NULL);
+ ROUTE_TEST_PRINT_RETURN("route_segment_foreach_properties", ret);
+
+ ret = route_segment_foreach_steps(segment, route_segment_step_callback, NULL);
+ ROUTE_TEST_PRINT_RETURN("route_segment_foreach_steps", ret);
+}
+
+static bool route_property_callback(const char *key, const char *value, void *user_data)
+{
+ printf("===== route_property_callback ======\n");
+
+ if (key == NULL) {
+ printf("key is NULL\n");
+ return FALSE;
+ }
+
+ printf("key : %s value : %s\n", key, value);
+ return TRUE;
+}
+
+static bool route_segment_callback(route_segment_h segment, void *user_data)
+{
+ printf("===== route_segment_callback ======\n");
+
+ if (segment == NULL) {
+ printf("segment is NULL\n");
+ return FALSE;
+ }
+
+ int ret;
+ route_segment_h cloned_segment;
+
+ ret = route_segment_clone(&cloned_segment, segment);
+ ROUTE_TEST_PRINT_RETURN("route_segment_clone", ret);
+
+ route_segment_information(cloned_segment);
+
+ ret = route_segment_destroy(cloned_segment);
+ ROUTE_TEST_PRINT_RETURN("route_segment_destroy", ret);
+
+ return TRUE;
+}
+
+void route_information(route_h route)
+{
+ int ret;
+ int request_id;
+ location_coords_s origin, destination;
+ location_coords_s tl, br;
+ route_distance_unit_e unit;
+ double distance;
+ long duration;
+
+ ret = route_get_request_id(route, &request_id);
+ ROUTE_TEST_PRINT_RETURN("route_get_request_id", ret);
+ printf("request_id : %d\n", request_id);
+
+ ret = route_get_origin(route, &origin);
+ ROUTE_TEST_PRINT_RETURN("route_get_origin", ret);
+ printf("origin lat : %f long : %f\n", origin.latitude, origin.longitude);
+
+ ret = route_get_destination(route, &destination);
+ ROUTE_TEST_PRINT_RETURN("route_get_destination", ret);
+ printf("destination lat : %f long : %f\n", destination.latitude, destination.longitude);
+
+ ret = route_get_geometry_bounding_box(route, &tl, &br);
+ ROUTE_TEST_PRINT_RETURN("route_get_geometry_bounding_box", ret);
+ printf("bbox.tl lat : %f long : %f\n", tl.latitude, tl.longitude);
+ printf("bbox.br lat : %f long : %f\n", br.latitude, br.longitude);
+
+ ret = route_get_distance_unit(route, &unit);
+ ROUTE_TEST_PRINT_RETURN("route_get_distance_unit", ret);
+ printf("distance unit : %d\n", unit);
+
+ ret = route_get_total_distance(route, &distance);
+ ROUTE_TEST_PRINT_RETURN("route_get_total_distance", ret);
+ printf("distance : %f\n", distance);
+
+ ret = route_get_total_duration(route, &duration);
+ ROUTE_TEST_PRINT_RETURN("route_get_total_duration", ret);
+ printf("duration : %ld\n", duration);
+
+ ret = route_foreach_properties(route, route_property_callback, NULL);
+ ROUTE_TEST_PRINT_RETURN("route_foreach_properties", ret);
+
+ ret = route_foreach_segments(route, route_segment_callback, NULL);
+ ROUTE_TEST_PRINT_RETURN("route_foreach_segments", ret);
+
+}
+
+static bool route_service_found_callback(route_error_e error, int index, int total, route_h route, void *user_data)
+{
+ printf("===== route_service_found_callback ======\n");
+ if (error != ROUTE_ERROR_NONE) {
+ printf("Failed : %d\n", error);
+ return FALSE;
+ }
+
+ int ret;
+ int req_id;
+ route_h cloned_route;
+
+ ret = route_clone(&cloned_route, route);
+ ROUTE_TEST_PRINT_RETURN("route_clone", ret);
+
+ printf("index[%d]/total[%d]\n", index, total);
+
+ route_information(cloned_route);
+
+ ret = route_destroy(cloned_route);
+ ROUTE_TEST_PRINT_RETURN("route_destroy", ret);
+
+ ret = route_get_request_id(route, &req_id);
+ ROUTE_TEST_PRINT_RETURN("route_get_request_id", ret);
+
+ ret = route_service_cancel(service, req_id);
+ ROUTE_TEST_PRINT_RETURN("route_service_cancel", ret);
+
+ return TRUE;
+}
+
+void route_service_test()
+{
+ int ret;
+ location_coords_s origin, destination;
+ int request_id;
+ route_preference_h service_pref;
+
+ ret = route_service_create(&service);
+ ROUTE_TEST_PRINT_RETURN("route_service_create", ret);
+
+ route_preference_create(&service_pref);
+ ROUTE_TEST_PRINT_RETURN("route_preference_create", ret);
+
+ route_set_preference(service_pref);
+
+ origin.latitude = 37.564263;
+ origin.longitude = 126.974676;
+ destination.latitude = 37.55712;
+ destination.longitude = 126.99241;
+
+ //ret = route_service_get_preference(service, &service_pref);
+ //ROUTE_TEST_PRINT_RETURN("route_service_get_preference", ret);
+
+ ret = route_service_set_preference(service, service_pref);
+ ROUTE_TEST_PRINT_RETURN("route_service_set_preference", ret);
+
+ ret = route_service_find(service, origin, destination, NULL, 0, route_service_found_callback, NULL, &request_id);
+ ROUTE_TEST_PRINT_RETURN("route_service_find", ret);
+
+ route_preference_test(service_pref);
+
+ if (service_pref) {
+ route_preference_destroy(service_pref);
+ }
+}
+
+static GMainLoop *g_mainloop = NULL;
+
+static gboolean exit_program(gpointer data)
+{
+ if (service == NULL) {
+ printf("service == NULL\n");
+ } else {
+ int ret = route_service_destroy(service);
+ ROUTE_TEST_PRINT_RETURN("route_service_destroy", ret);
+ }
+ g_main_loop_quit(g_mainloop);
+ return FALSE;
+}
+
+int main(int argc, char **argv)
+{
+ g_setenv("PKG_NAME", "com.samsung.location-test", 1);
+ g_mainloop = g_main_loop_new(NULL, 0);
+ route_service_test();
+ g_timeout_add_seconds(1800, exit_program, NULL);
+ g_main_loop_run(g_mainloop);
+ return 0;
+}