Esempio n. 1
0
        responses:
            200:
                description:
                    PNG image of requested tile
            400:
                description:
                    Invalid query parameters
            404:
                description:
                    No dataset found for given key combination
    """
    tile_xyz = (tile_x, tile_y, tile_z)
    return _get_rgb_image(keys, tile_xyz=tile_xyz)


spec.definition('RGBOptions', schema=RGBOptionSchema)


class RGBPreviewQuerySchema(Schema):
    keys = fields.String(required=True,
                         description='Keys identifying dataset, in order')


@tile_api.route('/rgb/preview.png', methods=['GET'])
@tile_api.route('/rgb/<path:keys>/preview.png', methods=['GET'])
@convert_exceptions
def get_rgb_preview(keys: str = '') -> Any:
    """Return the requested RGB dataset preview as a PNG image.
    ---
    get:
        summary: /rgb (preview)
Esempio n. 2
0
          - in: query
            schema: DatasetOptionSchema
        responses:
            200:
                description: All available key combinations
                schema:
                    type: array
                    items: DatasetSchema
            400:
                description: Query parameters contain unrecognized keys
    """
    from terracotta.handlers.datasets import datasets
    option_schema = DatasetOptionSchema()
    options = option_schema.load(request.args)

    limit = options.pop('limit')
    page = options.pop('page')
    keys = options or None

    payload = {
        'limit': limit,
        'page': page,
        'datasets': datasets(keys, page=page, limit=limit)
    }

    schema = DatasetSchema()
    return jsonify(schema.load(payload))


spec.definition('Dataset', schema=DatasetSchema)
Esempio n. 3
0
    key = fields.String(description='Key name', required=True)
    description = fields.String(description='Key description')


class KeySchema(Schema):
    keys = fields.Nested(KeyItemSchema, many=True, required=True)


@metadata_api.route('/keys', methods=['GET'])
@convert_exceptions
def get_keys() -> str:
    """Get all key names
    ---
    get:
        summary: /keys
        description: List the names and descriptions (if available) of all known keys.
        responses:
            200:
                description: Array containing keys
                schema: KeySchema
    """
    from terracotta.handlers.keys import keys
    schema = KeySchema()
    payload = {'keys': keys()}
    return jsonify(schema.load(payload))


spec.definition('Keys', schema=KeySchema)
spec.definition('KeyItem', schema=KeyItemSchema)
Esempio n. 4
0
        responses:
            200:
                description:
                    PNG image of requested tile
            400:
                description:
                    Invalid query parameters
            404:
                description:
                    No dataset found for given key combination
    """
    tile_xyz = (tile_x, tile_y, tile_z)
    return _get_singleband_image(keys, tile_xyz)


spec.definition('SinglebandOptions', schema=SinglebandOptionSchema)


class SinglebandPreviewSchema(Schema):
    keys = fields.String(required=True, description='Keys identifying dataset, in order')


@tile_api.route('/singleband/<path:keys>/preview.png', methods=['GET'])
@convert_exceptions
def get_singleband_preview(keys: str) -> Any:
    """Return single-band PNG preview image of requested dataset
    ---
    get:
        summary: /singleband (preview)
        description: Return single-band PNG preview image of requested dataset
        parameters:
Esempio n. 5
0
@metadata_api.route('/metadata/<path:keys>', methods=['GET'])
@convert_exceptions
def get_metadata(keys: str) -> str:
    """Get metadata for given dataset
    ---
    get:
        summary: /metadata
        description: Retrieve metadata for given dataset (identified by keys).
        parameters:
          - name: keys
            in: path
            description: Keys of dataset to retrieve metadata for (e.g. 'value1/value2')
            type: path
            required: true
        responses:
            200:
                description: All metadata for given dataset
                schema: MetadataSchema
            404:
                description: No dataset found for given key combination
    """
    from terracotta.handlers.metadata import metadata
    parsed_keys = [key for key in keys.split('/') if key]
    payload = metadata(parsed_keys)
    schema = MetadataSchema()
    return jsonify(schema.load(payload))


spec.definition('Metadata', schema=MetadataSchema)
Esempio n. 6
0
    """Get a colormap mapping pixel values to colors
    ---
    get:
        summary: /colormap
        description:
            Get a colormap mapping pixel values to colors. Use this to construct a color bar for a
            dataset.
        parameters:
            - in: query
              schema: ColormapOptionSchema
        responses:
            200:
                description: Array containing data values and RGBA tuples
                schema: ColormapSchema
            400:
                description: Query parameters are invalid
    """
    from terracotta.handlers.colormap import colormap

    input_schema = ColormapOptionSchema()
    options = input_schema.load(request.args)

    payload = {'colormap': colormap(**options)}

    schema = ColormapSchema()
    return jsonify(schema.load(payload))


spec.definition('ColormapEntry', schema=ColormapEntrySchema)
spec.definition('Colormap', schema=ColormapSchema)