observation.py 3.26 KB
Newer Older
1
"""
2 3
    schema: Observation Message sent by platforms when points of
    interest are found.
4
"""
5 6
# from . import full_message_schema, api
# from flask_restx import fields
7

8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
hits_schema = {
    "type": "object",
    "properties": {
        "latitude": {
            "type": "number",
            "description": "Identified x-coordinate of point of interest",
            "example": 178.2,
        },
        "longitude": {
            "type": "number",
            "description": "Identified y-coordinate of point of interest",
            "example": -10.122,
        },
        "quality_of_point": {
            "type": "number",
            "description": "Quality/strength of points from features of"
            + " interest identified by platform. TODO: DEFINE FORMAT.",
            "example": 0.98,
        },
    },
    "required": [],
}

31 32 33 34
observation_schema = {
    "allOf": [{"$ref": "#/components/schemas/Message"}],
    "type": "object",
    "properties": {
35 36 37
        "platform_ID": {
            "type": "integer",
            "description": "ID of platform to sending observations",
38 39
            "example": "ecosub-3",
        },
40 41
        # "observation_type" ==> payloads tied to different types maybe?
        # properties of each observation?
42
        "points_of_interest": {
43 44
            "type": "array",
            "items": hits_schema,
45
            "description": "Points from features of interest identified by"
46
            + " platform if any found. DEFINE FORMAT.",
47 48 49
        },
        "region_surveyed": {
            "description": "Region surveyed by given platform. DEFINE FORMAT."
50
            + " GEOJSON",
51 52 53 54 55 56
            "example": "",
        },
        "additional_data": {
            "description": "Placeholder field for any additional data",
            "example": {"sensor_payload": False},
        },
57
    },
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
    "required": ["platform_serial"],
}

# observation_schema = api.model(
#     "Observation",
#     {
#         "message": fields.Nested(
#             full_message_schema,
#             required=True,
#             description="Message header",
#         ),
#         "platform_serial": fields.String(
#             required=True,
#             description="Serial of platform to sendign observations",
#             example="ecosub-3",
#         ),
#         # "observation_type" ==> payloads tied to different types maybe?
#         # properties of each observation?
#         "points_of_interest": fields.Float(
#             required=False,
#             description="Points from features of interest identified by"
#             + " platform if any found. DEFINE FORMAT.",
#             example="",
#         ),
#         "region_surveyed": fields.Float(
#             required=False,
#             description="Region surveyed by given platform. DEFINE FORMAT."
#             + " GEOJSON?",
#             example="",
#         ),
#         "quality_of_points": fields.Float(
#             required=False,
90 91
#             description="Quality/strength of points from features of"
#             + " interest identified by platform. DEFINE FORMAT.",
92 93 94 95 96 97 98 99 100
#             example=0.98,
#         ),
#         "additional_data": fields.Raw(
#             required=False,
#             description="Placeholder field for any additional data",
#             example={"sensor_payload": False},
#         ),
#     },
# )