From 29e4a2425534dd70354584a0999b852b7d3c3809 Mon Sep 17 00:00:00 2001 From: chakradhar Date: Tue, 15 Sep 2020 10:45:35 +0530 Subject: [PATCH] Fix for corner cases Change-Id: I0158c9d07a074314efeb7d080b27a16faa9ea804 --- location/manager/location-boundary.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/location/manager/location-boundary.c b/location/manager/location-boundary.c index cbdd726..05a2b6c 100644 --- a/location/manager/location-boundary.c +++ b/location/manager/location-boundary.c @@ -381,10 +381,10 @@ location_boundary_on_path(LocationBoundary *boundary, LocationPosition *position px = x1 - x2; norm = y1 * y1 + px * px; - u = ( y3 * y1 + ( x3 - x2 ) * px ) / norm; if(norm <= 0){ u = 0; }else{ + u = ( y3 * y1 + ( x3 - x2 ) * px ) / norm; if( u > 1){ u = 1; }else if (u < 0){ @@ -420,7 +420,7 @@ location_boundary_on_path(LocationBoundary *boundary, LocationPosition *position center.longitude = boundary->circle.center->longitude; location_get_distance(¢er, position, &distance); - if (distance < boundary->circle.radius + tolerance) { + if (distance < boundary->circle.radius + tolerance && distance > boundary->circle.radius - tolerance) { return TRUE; } break; @@ -467,10 +467,10 @@ location_boundary_on_path(LocationBoundary *boundary, LocationPosition *position px = x1 - x2; norm = y1 * y1 + px * px; - u = ( y3 * y1 + ( x3 - x2 ) * px ) / norm; if(norm <= 0){ u = 0; }else{ + u = ( y3 * y1 + ( x3 - x2 ) * px ) / norm; if( u > 1){ u = 1; }else if (u < 0){ @@ -504,7 +504,6 @@ location_boundary_on_path(LocationBoundary *boundary, LocationPosition *position return FALSE; } - EXPORT_API int location_boundary_add(const LocationObject *obj, const LocationBoundary *boundary) { -- 2.7.4