{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://critwire.com/learn/labs/c1-feed.schema.json",
  "title": "Encounter weights from open GBIF records",
  "description": "Where people recorded a species, per equal-area cell. Records, not a range: a missing cell means no record, not no animal.",
  "type": "object",
  "required": ["version", "species", "cell", "meaning", "license", "license_url", "attribution", "source", "credit", "cells"],
  "additionalProperties": false,
  "properties": {
    "version": { "const": 1 },
    "species": {
      "type": "object",
      "required": ["scientific_name", "common_name"],
      "additionalProperties": false,
      "properties": { "scientific_name": { "type": "string" }, "common_name": { "type": "string" } }
    },
    "cell": { "type": "string", "description": "The cells' shape, size and projection" },
    "meaning": { "type": "string", "description": "What a weight is, in words a player-facing screen can quote" },
    "license": { "type": "string", "description": "The feed's license" },
    "license_url": { "type": "string", "pattern": "^https://", "description": "The license's deed" },
    "attribution": { "type": "string", "description": "Who made the feed, as they ask to be credited" },
    "source": { "type": "string", "description": "GBIF's citation of the download, with its DOI" },
    "credit": {
      "type": "array",
      "description": "Every dataset with CC BY 4.0 records in the feed, with its DOI (null if it has none)",
      "items": {
        "type": "object",
        "required": ["title", "publisher", "doi"],
        "additionalProperties": false,
        "properties": { "title": { "type": "string" }, "publisher": { "type": "string" }, "doi": { "type": ["string", "null"] } }
      }
    },
    "cells": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": ["id", "lon", "lat", "records", "weight", "recording_hot_spot"],
        "additionalProperties": false,
        "properties": {
          "id": { "type": "integer" },
          "lon": { "type": "number", "minimum": -180, "maximum": 180 },
          "lat": { "type": "number", "minimum": -90, "maximum": 90 },
          "records": { "type": "integer", "minimum": 1 },
          "weight": { "type": "number", "minimum": 0, "maximum": 1 },
          "recording_hot_spot": { "type": "boolean" }
        }
      }
    }
  }
}
