From dd3d00ea975c7cbfd343f1a020f3c486be03bc8f Mon Sep 17 00:00:00 2001 From: Jonathan Smith Date: Thu, 22 Feb 2024 13:33:30 +0000 Subject: [PATCH] Updating so if the waypoint is on the edge of the mesh boundary then the point is still included. --- polar_route/route_planner.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/polar_route/route_planner.py b/polar_route/route_planner.py index 92f22eab..13d27c70 100644 --- a/polar_route/route_planner.py +++ b/polar_route/route_planner.py @@ -126,10 +126,14 @@ def _mesh_boundary_polygon(mesh): ''' Creates a polygon from the mesh boundary ''' - lat_min = mesh['config']['mesh_info']['region']['lat_min'] - lat_max = mesh['config']['mesh_info']['region']['lat_max'] - long_min = mesh['config']['mesh_info']['region']['long_min'] - long_max = mesh['config']['mesh_info']['region']['long_max'] + + # Defining a tiny value + tiny_value = 1e-10 + + lat_min = mesh['config']['mesh_info']['region']['lat_min']-tiny_value + lat_max = mesh['config']['mesh_info']['region']['lat_max']+tiny_value + long_min = mesh['config']['mesh_info']['region']['long_min']-tiny_value + long_max = mesh['config']['mesh_info']['region']['long_max']+tiny_value p1 = Point([long_min, lat_min]) p2 = Point([long_min, lat_max]) p3 = Point([long_max, lat_max]) @@ -302,6 +306,9 @@ def __init__(self, mesh, config, waypoints, cost_func=NewtonianDistance): # Only allow waypoints within an existing mesh assert(point.within(mesh_boundary)), \ f"Waypoint {row['Name']} outside of mesh boundary! {point}" + + + adjusted_point = _adjust_waypoints(point, self.mesh['cellboxes']) waypoints_df['Long'][idx] = adjusted_point.x