{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://docs.devicechain.io/schema/device/location-payload.schema.json",
  "title": "DeviceChain Location payload",
  "description": "The payload of a device event whose eventType is Location. Every entry is one position fix. Every field of an entry is a JSON string, including the numeric ones: a bare number fails the whole message. Each value must parse as a finite number inside its range, or the message is refused. One event may carry at most 256 entries.",
  "type": "object",
  "properties": {
    "entries": {
      "type": "array",
      "minItems": 1,
      "items": { "$ref": "#/$defs/entry" },
      "description": "The fixes. A payload with no entries, or with coordinates placed directly under payload instead of in entries, is refused."
    }
  },
  "required": ["entries"],
  "$defs": {
    "entry": {
      "type": "object",
      "properties": {
        "latitude": {
          "type": "string",
          "description": "WGS84 (EPSG:4326) decimal degrees, from -90 to 90."
        },
        "longitude": {
          "type": "string",
          "description": "WGS84 (EPSG:4326) decimal degrees, from -180 to 180."
        },
        "elevation": {
          "type": "string",
          "description": "Metres above the WGS84 ellipsoid, not above mean sea level. Magnitude at most 99999999."
        },
        "accuracy": {
          "type": "string",
          "description": "Horizontal accuracy in metres, from 0 to 99999999."
        },
        "speed": {
          "type": "string",
          "description": "Metres per second, from 0 to 99999999."
        },
        "heading": {
          "type": "string",
          "description": "Degrees clockwise from true north, from 0 up to but not including 360. A value that would be stored as 360.0000 (359.99995 or more) is refused."
        },
        "occurredTime": {
          "type": "string",
          "format": "date-time",
          "description": "This fix's own instant, RFC 3339. Omitted, the fix takes the envelope's occurredTime. Refused under the same rules as the envelope's."
        }
      },
      "required": ["latitude", "longitude"]
    }
  },
  "examples": [
    {
      "entries": [
        {
          "latitude": "33.74900000",
          "longitude": "-84.38800000",
          "elevation": "320.5",
          "accuracy": "4.2",
          "speed": "0.0",
          "heading": "271.5"
        }
      ]
    }
  ]
}
