Skip to content
Snippets Groups Projects
Commit de97b529 authored by Raphael Sturgis's avatar Raphael Sturgis
Browse files

Merge branch '21-image-creation-bugs-with-0-size-windows' into 'develop'

Resolve "Image creation bugs with 0 size windows"

See merge request !11
parents eace3b29 76df9c7d
No related branches found
No related tags found
2 merge requests!12version 0.2a,!11Resolve "Image creation bugs with 0 size windows"
......@@ -236,6 +236,13 @@ class AISTrajectory(AISPoints):
positions = self.df[['longitude', 'latitude']].to_numpy()
min_lon, max_lon = (min(positions[:, 0]), max(positions[:, 0]))
min_lat, max_lat = (min(positions[:, 1]), max(positions[:, 1]))
if min_lat == max_lat:
min_lat -= 1
max_lat += 1
if min_lon == max_lon:
min_lon -= 1
max_lon += 1
for longitude, latitude in positions:
x_coord, y_coord = get_coord(latitude, longitude, height, width, min_lat, max_lat, min_lon, max_lon)
......
......@@ -453,4 +453,54 @@ class TestAISTrajectory(unittest.TestCase):
[0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1],
[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1]])
np.testing.assert_array_equal(result, expected)
def test_generate_array_from_positions_single_point(self):
trajectory = AISTrajectory(
pd.DataFrame(
{
"latitude": [5],
"longitude": [20],
"ts_sec": [0]
}
)
)
result = trajectory.generate_array_from_positions(height=9, width=9, link=False, bounding_box='fit',
features=None).reshape((9, 9))
expected = np.array([[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0]])
np.testing.assert_array_equal(result, expected)
def test_generate_array_from_positions_overlapping_points(self):
trajectory = AISTrajectory(
pd.DataFrame(
{
"latitude": [5, 5, 5, 5],
"longitude": [20, 20, 20, 20],
"ts_sec": [0, 1, 2, 3]
}
)
)
result = trajectory.generate_array_from_positions(height=9, width=9, link=False, bounding_box='fit',
features=None).reshape((9, 9))
expected = np.array([[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0]])
np.testing.assert_array_equal(result, expected)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment