observation.py 2.19 KB
Newer Older
1
"""
2 3
    schema: Observation Message sent by platforms when points of
    interest are found.
4
"""
5
from formats import abstract_schema
6

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

33 34 35
observation_schema = {
    "type": "object",
    "properties": {
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
        "payload": {
            "type": "object",
            "properties": {
                "platform_ID": {
                    "type": "integer",
                    "description": "ID of platform to sending observations",
                    "example": 2,
                },
                "points_of_interest": {
                    "type": "array",
                    "items": hits_schema,
                    "description": "Points from features of interest identified by"
                    + " platform if any found.",  # TODO: DEFINE FORMAT.
                },
                "region_surveyed": {
                    # "type": "null",
                    "nullable": True,
                    "description": "Region surveyed by given platform."
                    + " GEOJSON",  # TODO: DEFINE FORMAT.
                    "example": "",
                },
                "additional_data": {
                    "description": "Placeholder field for any additional data",
                    "example": {"sensor_payload": False},
                },
            },
62
        },
63
    },
64
    "required": ["platform_ID"],
65
}
66 67 68

full_observation_schema = abstract_schema
full_observation_schema["properties"]["payload"] = observation_schema