$schema: https://json-schema.org/draft/2020-12/schema
title: STAC Item
type: object
description: This object represents the metadata for an item in a SpatioTemporal Asset
  Catalog.
allOf:
- $ref: https://ogcincubator.github.io/bblocks-ogcapi-records/build/annotated/api/records/v1/schemas/recordGeoJSON/schema.yaml
- $ref: '#/definitions/core'
- $ref: https://ogcincubator.github.io/bblocks-stac/build/annotated/contrib/stac/components/assets/schema.yaml
- $ref: https://raw.githubusercontent.com/radiantearth/stac-spec/master/item-spec/json-schema/common.json
definitions:
  core:
    allOf:
    - $ref: https://opengeospatial.github.io/bblocks/annotated-schemas/geo/features/feature/schema.yaml
    - oneOf:
      - type: object
        required:
        - geometry
        - bbox
        properties:
          geometry:
            $ref: https://geojson.org/schema/Geometry.json
          bbox:
            type: array
            oneOf:
            - minItems: 4
              maxItems: 4
            - minItems: 6
              maxItems: 6
            items:
              type: number
      - type: object
        required:
        - geometry
        properties:
          geometry:
            type: 'null'
          bbox:
            not: {}
    - type: object
      required:
      - id
      - links
      - properties
      properties:
        stac_extensions:
          title: STAC extensions
          type: array
          uniqueItems: true
          items:
            title: Reference to a JSON Schema
            type: string
            format: iri
          x-jsonld-id: https://w3id.org/ogc/stac/core/hasExtension
        id:
          title: Provider ID
          description: Provider item ID
          type: string
          minLength: 1
          x-jsonld-id: '@id'
        links:
          $ref: '#/definitions/links'
        properties:
          allOf:
          - $ref: https://raw.githubusercontent.com/radiantearth/stac-spec/master/item-spec/json-schema/common.json
          - anyOf:
            - required:
              - datetime
              properties:
                datetime:
                  not:
                    type: 'null'
                  x-jsonld-id: http://purl.org/dc/terms/date
                  x-jsonld-type: xsd:dateTime
            - required:
              - datetime
              - start_datetime
              - end_datetime
      $comment: Rules enforcement for STAC Item
      allOf:
      - if:
          properties:
            links:
              contains:
                required:
                - rel
                properties:
                  rel:
                    const: collection
        then:
          required:
          - collection
          properties:
            collection:
              title: Collection ID
              description: The ID of the STAC Collection this Item references to.
              type: string
              minLength: 1
        else:
          properties:
            collection:
              not: {}
      - $comment: The if-then-else below checks whether the bands field is given in
          assets or not. If not, allows bands in properties (then), otherwise, disallows
          bands in properties (else).
        if:
          $comment: If there is no asset with bands...
          required:
          - assets
          properties:
            assets:
              type: object
              additionalProperties:
                properties:
                  bands: false
        then:
          $comment: '... then bands are not allowed in properties...'
          properties:
            properties:
              properties:
                bands:
                  not: true
        else:
          $comment: '... otherwise bands are allowed in properties.'
          properties:
            properties:
              $ref: https://raw.githubusercontent.com/radiantearth/stac-spec/master/item-spec/json-schema/bands.json
  links:
    title: Item links
    description: Links to item relations
    type: array
    items:
      allOf:
      - $ref: '#/definitions/link'
      - $ref: https://opengeospatial.github.io/bblocks/annotated-schemas/ogc-utils/json-link/schema.yaml
  link:
    allOf:
    - type: object
      required:
      - rel
      - href
      properties:
        href:
          title: Link reference
          type: string
          format: iri-reference
          minLength: 1
        rel:
          title: Link relation type
          type: string
          minLength: 1
        type:
          title: Link type
          type: string
          x-jsonld-id: '@type'
        title:
          title: Link title
          type: string
          x-jsonld-id: http://purl.org/dc/terms/title
        method:
          title: Link method
          type: string
          pattern: ^[A-Z]+$
          default: GET
        headers:
          title: Link headers
          type: object
          additionalProperties:
            oneOf:
            - type: string
            - type: array
              items:
                type: string
        body:
          title: Link body
          $comment: Any type is allowed.
      $comment: Link with relationship `self` must be absolute URI
      if:
        properties:
          rel:
            const: self
      then:
        properties:
          href:
            format: iri
    - $ref: https://raw.githubusercontent.com/radiantearth/stac-spec/master/item-spec/json-schema/common.json
x-jsonld-extra-terms:
  stac_version: https://w3id.org/ogc/stac/core/version
  type: '@type'
  title: http://purl.org/dc/terms/title
  description: http://purl.org/dc/terms/description
  keywords: http://purl.org/dc/terms/subject
  license: http://purl.org/dc/terms/license
  start_datetime:
    x-jsonld-id: https://w3id.org/ogc/stac/core/start_datetime
    x-jsonld-type: xsd:dateTime
  end_datetime:
    x-jsonld-id: https://w3id.org/ogc/stac/core/end_datetime
    x-jsonld-type: xsd:dateTime
  providers: https://w3id.org/ogc/stac/core/hasProvider
  media_type: http://purl.org/dc/terms/format
x-jsonld-prefixes:
  stac: https://w3id.org/ogc/stac/core/
  dct: http://purl.org/dc/terms/
  rdfs: http://www.w3.org/2000/01/rdf-schema#
