X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Flocation_bounds.c;h=b4c0433ee2cfe28a997c8491b507a21330bbe40c;hb=HEAD;hp=3106db01f6c42079607e390079c3b1356f252fa1;hpb=d6b76af4be4ae1f32410f72f5cce7b6d9ee42d52;p=platform%2Fcore%2Fapi%2Flocation-manager.git diff --git a/src/location_bounds.c b/src/location_bounds.c index 3106db0..b4c0433 100644 --- a/src/location_bounds.c +++ b/src/location_bounds.c @@ -252,6 +252,47 @@ EXPORT_API bool location_bounds_contains_coordinates(location_bounds_h bounds, l return result; } +EXPORT_API bool location_bounds_contains_coordinates_on_edge(location_bounds_h bounds, location_coords_s coords, double tolerance) +{ + if (__is_location_supported() == LOCATIONS_ERROR_NOT_SUPPORTED) { + //LCOV_EXCL_START + set_last_result(LOCATIONS_ERROR_NOT_SUPPORTED); + return FALSE; + //LCOV_EXCL_STOP + } + + if (!bounds) { + set_last_result(LOCATION_BOUNDS_ERROR_INVALID_PARAMETER); + return FALSE; + } + + if (coords.latitude < -90 || coords.latitude > 90 || coords.longitude < -180 || coords.longitude > 180) { + set_last_result(LOCATION_BOUNDS_ERROR_INVALID_PARAMETER); + return FALSE; + } + + if (tolerance < 0.0) { + set_last_result(LOCATION_BOUNDS_ERROR_INVALID_PARAMETER); + return FALSE; + } + + LocationPosition *pos = location_position_new(0, coords.latitude, coords.longitude, 0, LOCATION_STATUS_2D_FIX); + if (pos == NULL) { + //LCOV_EXCL_START + LOCATIONS_LOGE("LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY(0x%08x) : fail to location_position_new", LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY); + set_last_result(LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY); + return FALSE; + //LCOV_EXCL_STOP + } + location_bounds_s *handle = (location_bounds_s *) bounds; + gboolean on_path = location_boundary_on_path(handle->boundary, pos, tolerance); + location_position_free(pos); + bool result = on_path ? TRUE : FALSE; + + set_last_result(LOCATION_BOUNDS_ERROR_NONE); + return result; +} + EXPORT_API int location_bounds_get_type(location_bounds_h bounds, location_bounds_type_e *type) { LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported());