# CrossCompute
obstacle_table_path = 'obstacles.csv'
source_xy = 0, 0
target_xy = 9, 9
target_folder = '/tmp'
from pandas import read_csv
from shapely import wkt
from shapely.geometry import MultiPolygon
obstacle_table = read_csv(obstacle_table_path)
obstacle_polygons = [wkt.loads(x) for x in obstacle_table['WKT']]
MultiPolygon(obstacle_polygons)
# !!! Put a pathfinding algorithm here
from shapely.geometry import LineString
line = LineString([
(0, 0),
(5, 0),
(5, 5),
(3, 5),
(3, 9),
(9, 9),
])
line
from shapely.geometry import GeometryCollection, Point
GeometryCollection(obstacle_polygons + [
Point(source_xy),
Point(target_xy),
line,
])
from pandas import DataFrame
waypoint_table = DataFrame(list(line.coords), columns=['x', 'y'])
waypoint_table
from os.path import join
waypoint_table_path = join(target_folder, 'waypoints.csv')
waypoint_table.to_csv(waypoint_table_path, index=False)