-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/odlc search grid #62
base: develop
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,19 @@ | |
Provides plotting functionality for visualizing coordinate data | ||
""" | ||
|
||
from typing import List, Dict, Tuple | ||
from typing import List, Tuple | ||
import matplotlib.pyplot as plt | ||
|
||
|
||
def plot_data(search_paths) -> None: | ||
def plot_data(search_paths: List[List[Tuple[float, float]]]) -> None: | ||
"""Simple plotter function to plot the search paths | ||
|
||
Parameters | ||
---------- | ||
search_paths : List[Tuple[float, float]] | ||
A list of search paths to be plotted | ||
""" | ||
|
||
for path in search_paths: | ||
x, y = [], [] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't forget your type hints; label what exactly these two lists are and what they contain, similar in format to the return type in your docstring. |
||
for point in path: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
""" | ||
Functions for generating a search path for standard odlc objects | ||
Functions for generating search paths to cover an area for finding the standard odlc objects | ||
""" | ||
|
||
from typing import List, Dict, Tuple | ||
|
||
from shapely.geometry import Point, Polygon | ||
from shapely.ops import nearest_points | ||
from shapely.geometry import Polygon | ||
import utm | ||
|
||
|
||
|
@@ -50,23 +48,39 @@ def all_latlon_to_utm(list_of_coords: List[Dict[str, float]]) -> List[Dict[str, | |
return list_of_coords | ||
|
||
|
||
# use height/2 of camera image as buffer distance | ||
def generate_search_path(search_area_points, buffer_distance): | ||
poly_points = [(point["utm_x"], point["utm_y"]) for point in search_area_points] | ||
def generate_search_paths( | ||
search_area_points: List[Dict[str, float]], buffer_distance: int | ||
) -> List[Tuple[float, float]]: | ||
"""Generates a list of search paths of increasingly smaller sizes until the whole area | ||
of the original shape has been covered | ||
|
||
Parameters | ||
---------- | ||
search_area_points : Dict[str, float] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The parameter says that this is a List[Dict[str, float]], I think you forgot the first List[] |
||
A list of coordinates in dictionary form that contain utm coordinate data | ||
buffer_distance : int | ||
The distance that each search path will be apart from the previous one. | ||
For complete photographic coverage of the area, this should be equal to half the height | ||
of the area the camera covers on the ground given the current altitude. | ||
|
||
Returns | ||
------- | ||
List[Tuple[float, float]] | ||
A list of concentric search paths that cover the area of the polygon | ||
""" | ||
|
||
# convert to shapely polygon for buffer operations | ||
poly_points = [(point["utm_x"], point["utm_y"]) for point in search_area_points] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Type hint for this guy as well |
||
boundary_shape = Polygon(poly_points) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Python will also support a type hint of an object from an imported module, I know this seems redundant since the function is literally called Polygon, however you still need a type hint for the object you create here. |
||
|
||
search_paths = [] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You already know; type hints for this new list |
||
search_paths.append( | ||
list(zip(*boundary_shape.exterior.coords.xy)) # pylint: disable=maybe-no-member | ||
) | ||
|
||
while True: | ||
boundary_shape = boundary_shape.buffer(buffer_distance, single_sided=True) | ||
if boundary_shape.area <= 0: | ||
break | ||
# shrink boundary by a fixed amount until the area it covers is 0 | ||
# add the smaller boundary to our list of search paths on each iteration | ||
while boundary_shape.area > 0: | ||
search_paths.append( | ||
list(zip(*boundary_shape.exterior.coords.xy)) # pylint: disable=maybe-no-member | ||
tuple(zip(*boundary_shape.exterior.coords.xy)) # pylint: disable=maybe-no-member | ||
) | ||
boundary_shape = boundary_shape.buffer(buffer_distance, single_sided=True) | ||
|
||
return search_paths |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This constant needs a type hint.