diff --git a/skais/tests/ais/test_ais_trajectory.py b/skais/tests/ais/test_ais_trajectory.py index fe8efc4c087776701515b8036ae9ecf4939e3b27..6f2b6fa628eb4f52844fb2e07a869f223222e6ea 100644 --- a/skais/tests/ais/test_ais_trajectory.py +++ b/skais/tests/ais/test_ais_trajectory.py @@ -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