From 58f07b32f0dbaf1071952657265fa45c0be68b1a Mon Sep 17 00:00:00 2001
From: Dan Jones <danjon@noc.ac.uk>
Date: Thu, 12 Sep 2024 09:16:40 +0100
Subject: [PATCH] refactor: move waypoint_status schema

---
 formats/platform_status.py | 101 ------------------------------------
 formats/waypoint_status.py | 102 +++++++++++++++++++++++++++++++++++++
 generate_schema_config.py  |   3 +-
 3 files changed, 104 insertions(+), 102 deletions(-)
 create mode 100644 formats/waypoint_status.py

diff --git a/formats/platform_status.py b/formats/platform_status.py
index 0a12615..4a512cc 100644
--- a/formats/platform_status.py
+++ b/formats/platform_status.py
@@ -275,104 +275,3 @@ platform_status_schema = {
         "platform_timestamp",
     ],
 }
-
-waypoint_status_schema = {
-    "type": "object",
-    "properties": {
-        "message_type": {
-            "type": "string",
-            "description": "Type of message",
-            "example": "waypoint_status",
-            "enum": ["waypoint_status"],
-        },
-        "status_source": {
-            "type": "string",
-            "enum": ["onboard_platform", "simulated", "autonomy"],
-            "description": "Indicate if this status message is from the"
-            + " platform or USBL",
-            "example": "usbl",
-        },
-    },
-    "allOf": [platform_status_core_fields_schema],
-    "oneOf": [
-        {
-            "type": "object",
-            "properties": {
-                "position": {
-                    "$ref": "https://geojson.org/schema/Point.json",
-                },
-                "waypoint": {
-                    "$ref": "https://geojson.org/schema/Point.json",
-                },
-            },
-            "required": [
-                "waypoint",
-            ],
-        },
-        {
-            "type": "object",
-            "properties": {
-                "latitude": {
-                    "type": "number",
-                    "format": "float",
-                    "description": "Latitude (Y-coordinate) in decimal degrees.",
-                    "example": 178.2,
-                },
-                "longitude": {
-                    "type": "number",
-                    "format": "float",
-                    "description": "Longitude (X-coordinate) in decimal degrees.",
-                    "example": -10.122,
-                },
-                "depth": {
-                    "type": "number",
-                    "format": "float",
-                    "description": "Target depth in metres",
-                    "example": 50.0,
-                    "default": 0.0,
-                },
-                "altitude": {
-                    "type": "number",
-                    "format": "float",
-                    "description": "Target altitude in metres",
-                    "example": 20.0,
-                },
-                "waypoint_latitude": {
-                    "type": "number",
-                    "format": "float",
-                    "description": "Latitude (Y-coordinate) in decimal degrees.",
-                    "example": 178.2,
-                },
-                "waypoint_longitude": {
-                    "type": "number",
-                    "format": "float",
-                    "description": "Longitude (X-coordinate) in decimal degrees.",
-                    "example": -10.122,
-                },
-                "waypoint_depth": {
-                    "type": "number",
-                    "format": "float",
-                    "description": "Target depth in metres",
-                    "example": 50.0,
-                    "default": 0.0,
-                },
-                "waypoint_altitude": {
-                    "type": "number",
-                    "format": "float",
-                    "description": "Target altitude in metres",
-                    "example": 20.0,
-                },
-            },
-            "required": [
-                "waypoint_latitude",
-                "waypoint_longitude",
-            ],
-        },
-    ],
-    "required": [
-        "message_type",
-        "platform_ID",
-        "status_source",
-        "platform_timestamp",
-    ],
-}
diff --git a/formats/waypoint_status.py b/formats/waypoint_status.py
new file mode 100644
index 0000000..00a91b2
--- /dev/null
+++ b/formats/waypoint_status.py
@@ -0,0 +1,102 @@
+from formats.platform_status import platform_status_core_fields_schema
+
+waypoint_status_schema = {
+    "type": "object",
+    "properties": {
+        "message_type": {
+            "type": "string",
+            "description": "Type of message",
+            "example": "waypoint_status",
+            "enum": ["waypoint_status"],
+        },
+        "status_source": {
+            "type": "string",
+            "enum": ["onboard_platform", "simulated", "autonomy"],
+            "description": "Indicate if this status message is from the"
+            + " platform or USBL",
+            "example": "usbl",
+        },
+    },
+    "allOf": [platform_status_core_fields_schema],
+    "oneOf": [
+        {
+            "type": "object",
+            "properties": {
+                "position": {
+                    "$ref": "https://geojson.org/schema/Point.json",
+                },
+                "waypoint": {
+                    "$ref": "https://geojson.org/schema/Point.json",
+                },
+            },
+            "required": [
+                "waypoint",
+            ],
+        },
+        {
+            "type": "object",
+            "properties": {
+                "latitude": {
+                    "type": "number",
+                    "format": "float",
+                    "description": "Latitude (Y-coordinate) in decimal degrees.",
+                    "example": 178.2,
+                },
+                "longitude": {
+                    "type": "number",
+                    "format": "float",
+                    "description": "Longitude (X-coordinate) in decimal degrees.",
+                    "example": -10.122,
+                },
+                "depth": {
+                    "type": "number",
+                    "format": "float",
+                    "description": "Target depth in metres",
+                    "example": 50.0,
+                    "default": 0.0,
+                },
+                "altitude": {
+                    "type": "number",
+                    "format": "float",
+                    "description": "Target altitude in metres",
+                    "example": 20.0,
+                },
+                "waypoint_latitude": {
+                    "type": "number",
+                    "format": "float",
+                    "description": "Latitude (Y-coordinate) in decimal degrees.",
+                    "example": 178.2,
+                },
+                "waypoint_longitude": {
+                    "type": "number",
+                    "format": "float",
+                    "description": "Longitude (X-coordinate) in decimal degrees.",
+                    "example": -10.122,
+                },
+                "waypoint_depth": {
+                    "type": "number",
+                    "format": "float",
+                    "description": "Target depth in metres",
+                    "example": 50.0,
+                    "default": 0.0,
+                },
+                "waypoint_altitude": {
+                    "type": "number",
+                    "format": "float",
+                    "description": "Target altitude in metres",
+                    "example": 20.0,
+                },
+            },
+            "required": [
+                "waypoint_latitude",
+                "waypoint_longitude",
+            ],
+        },
+    ],
+    "required": [
+        "message_type",
+        "platform_ID",
+        "status_source",
+        "platform_timestamp",
+    ],
+}
diff --git a/generate_schema_config.py b/generate_schema_config.py
index aa784fb..df97733 100644
--- a/generate_schema_config.py
+++ b/generate_schema_config.py
@@ -6,7 +6,8 @@ from formats.observation import observation_schema
 from formats.observation_encoded import observation_encoded_schema
 from formats.payload import payload_schema
 from formats.planning_configuration import planning_configuration_schema
-from formats.platform_status import platform_status_schema, waypoint_status_schema
+from formats.platform_status import platform_status_schema
+from formats.waypoint_status import waypoint_status_schema
 from formats.platform_status_encoded import platform_status_encoded_schema
 from formats.survey import survey_schema
 from formats.survey_encoded import survey_encoded_schema
-- 
GitLab