{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://trinetrahq.com/schemas/sangam/1.0/detection.schema.json",
  "title": "SANGAM Detection",
  "description": "One measurement of one object by one sensor at one time. Carries either an absolute position with covariance (AIS-like transponder, fence zone, pre-georeferenced plots) or a sensor-relative polar measurement (radar plot, camera bearing with monoplotted range, acoustic bearing). Exactly one of position or polar is present.",
  "type": "object",
  "required": ["type", "schema_version", "id", "sensor_id", "sensor_type", "time"],
  "properties": {
    "type": {"const": "detection", "description": "Record type."},
    "schema_version": {"$ref": "common.schema.json#/$defs/schemaVersion"},
    "id": {"$ref": "common.schema.json#/$defs/id", "description": "Unique per sensor. A re-sent measurement keeps its id."},
    "sensor_id": {"$ref": "common.schema.json#/$defs/id", "description": "The reporting sensor, as named in its SensorStatus."},
    "sensor_type": {"$ref": "common.schema.json#/$defs/sensorType"},
    "time": {"$ref": "common.schema.json#/$defs/time", "description": "Moment of measurement (not of delivery), UTC."},
    "position": {"$ref": "common.schema.json#/$defs/positionWithCov"},
    "polar": {"$ref": "common.schema.json#/$defs/polar"},
    "velocity": {"$ref": "common.schema.json#/$defs/velocity"},
    "classification": {"$ref": "common.schema.json#/$defs/classification", "description": "The sensor's own classifier output, if any."},
    "attributes": {"$ref": "common.schema.json#/$defs/attributes"},
    "simulated": {"type": "boolean", "description": "True for synthetic records. Doctrine: simulated data is always labelled."}
  },
  "oneOf": [
    {"required": ["position"]},
    {"required": ["polar"]}
  ],
  "additionalProperties": false,
  "examples": [
    {
      "type": "detection",
      "schema_version": "1.0",
      "id": "RDR-1:000451:3",
      "sensor_id": "RDR-1",
      "sensor_type": "radar",
      "time": "2026-10-20T16:05:12.400Z",
      "polar": {
        "range_m": 812.5,
        "sigma_range_m": 7.5,
        "bearing_deg": 103.2,
        "sigma_bearing_deg": 0.6,
        "origin": {"lat": 22.58731, "lon": 88.93522, "height_m": 15}
      },
      "classification": {"label": "small_boat", "confidence": 0.62},
      "attributes": {"snr_db": 18.4},
      "simulated": true
    },
    {
      "type": "detection",
      "schema_version": "1.0",
      "id": "AIS-RX:SIM-TX-0002:58",
      "sensor_id": "AIS-RX",
      "sensor_type": "ais",
      "time": "2026-10-20T16:05:10.000Z",
      "position": {"lat": 22.59012, "lon": 88.93874, "cov_m2": [[64, 0], [0, 64]]},
      "velocity": {"east_ms": 0.1, "north_ms": -0.3},
      "classification": {"label": "small_boat", "confidence": 0.98},
      "attributes": {"transponder_id": "SIM-TX-0002"},
      "simulated": true
    }
  ]
}
