From d1e33be0b7882deb3d22f86a2c825774048f1437 Mon Sep 17 00:00:00 2001 From: Dan Jones <danjon@noc.ac.uk> Date: Tue, 3 Sep 2024 13:17:51 +0100 Subject: [PATCH] refactor: use geojson or separate properties add waypoint --- formats/platform_status.py | 102 ++++++++++++++++++++++++++---------- project/soar/swagger.json | 104 +++++++++++++++++++++++++++---------- 2 files changed, 151 insertions(+), 55 deletions(-) diff --git a/formats/platform_status.py b/formats/platform_status.py index 81b452f..df4f047 100644 --- a/formats/platform_status.py +++ b/formats/platform_status.py @@ -72,31 +72,6 @@ platform_status_schema = { + " Engine's mission plan number sent) executed by platform", "example": 1, }, - "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, - }, "mission_track_ID": { "type": "integer", "description": "Track number - stage in mission (e.g. " @@ -196,13 +171,86 @@ platform_status_schema = { "example": 7.4, }, "sensor_config": sensor_schema, + "oneOf": [ + { + "type": "object", + "properties": { + "position": { + "$ref": "https://geojson.org/schema/Point.json", + }, + "waypoint": { + "$ref": "https://geojson.org/schema/Point.json", + }, + }, + "required": [ + "position", + ], + }, + { + "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": [ + "latitude", + "longitude", + ], + }, + ], }, "required": [ "message_type", "platform_ID", "status_source", "platform_timestamp", - "latitude", - "longitude", ], } diff --git a/project/soar/swagger.json b/project/soar/swagger.json index aaee112..9c39c8e 100644 --- a/project/soar/swagger.json +++ b/project/soar/swagger.json @@ -2011,12 +2011,6 @@ }, "platform_status": { "properties": { - "altitude": { - "description": "Target altitude in metres", - "example": 20.0, - "format": "float", - "type": "number" - }, "autonomy_engine_plan_ID": { "description": "Last mission plan ID (according to Autonomy Engine's mission plan number sent) executed by platform", "example": 1, @@ -2034,13 +2028,6 @@ "format": "float", "type": "number" }, - "depth": { - "default": 0.0, - "description": "Target depth in metres", - "example": 50.0, - "format": "float", - "type": "number" - }, "endurance": { "description": "Estimate of hours of operation remaining based on present output or performance", "example": 7.4, @@ -2070,12 +2057,6 @@ "example": false, "type": "boolean" }, - "latitude": { - "description": "Latitude (Y-coordinate) in decimal degrees.", - "example": 178.2, - "format": "float", - "type": "number" - }, "localisation_east_error": { "description": "Difference in EAST between deadreckoningand USBL update.", "example": 0.000129, @@ -2088,12 +2069,6 @@ "format": "float", "type": "number" }, - "longitude": { - "description": "Longitude (X-coordinate) in decimal degrees.", - "example": -10.122, - "format": "float", - "type": "number" - }, "message_type": { "description": "Type of message", "enum": [ @@ -2112,6 +2087,81 @@ "example": 4, "type": "integer" }, + "oneOf": [ + { + "properties": { + "position": { + "$ref": "https://geojson.org/schema/Point.json" + }, + "waypoint": { + "$ref": "https://geojson.org/schema/Point.json" + } + }, + "required": [ + "position" + ], + "type": "object" + }, + { + "properties": { + "altitude": { + "description": "Target altitude in metres", + "example": 20.0, + "format": "float", + "type": "number" + }, + "depth": { + "default": 0.0, + "description": "Target depth in metres", + "example": 50.0, + "format": "float", + "type": "number" + }, + "latitude": { + "description": "Latitude (Y-coordinate) in decimal degrees.", + "example": 178.2, + "format": "float", + "type": "number" + }, + "longitude": { + "description": "Longitude (X-coordinate) in decimal degrees.", + "example": -10.122, + "format": "float", + "type": "number" + }, + "waypoint_altitude": { + "description": "Target altitude in metres", + "example": 20.0, + "format": "float", + "type": "number" + }, + "waypoint_depth": { + "default": 0.0, + "description": "Target depth in metres", + "example": 50.0, + "format": "float", + "type": "number" + }, + "waypoint_latitude": { + "description": "Latitude (Y-coordinate) in decimal degrees.", + "example": 178.2, + "format": "float", + "type": "number" + }, + "waypoint_longitude": { + "description": "Longitude (X-coordinate) in decimal degrees.", + "example": -10.122, + "format": "float", + "type": "number" + } + }, + "required": [ + "latitude", + "longitude" + ], + "type": "object" + } + ], "platform_ID": { "description": "Unique identifier for this platform", "example": "reav-x-1", @@ -2208,9 +2258,7 @@ "message_type", "platform_ID", "status_source", - "platform_timestamp", - "latitude", - "longitude" + "platform_timestamp" ], "type": "object" }, -- GitLab