From 11298d357e0ef40443980d02f0020eed93bc56bf Mon Sep 17 00:00:00 2001
From: Raphael <raphael.sturgis@gmail.com>
Date: Wed, 23 Mar 2022 14:27:32 +0100
Subject: [PATCH] added tests for overlapping and single points

---
 skais/tests/ais/test_ais_trajectory.py | 50 ++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/skais/tests/ais/test_ais_trajectory.py b/skais/tests/ais/test_ais_trajectory.py
index fe8efc4..6f2b6fa 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
-- 
GitLab