class STAC::Client

Client for interacting with the root of a STAC API.

Constants

VERSION

Attributes

catalog[R]

STAC::Catalog instance of a STAC API landing page.

http_client[R]

Public Class Methods

from_url(url, params: {}, headers: {}, **http_options) click to toggle source

Returns a Client instance from STAC API landing page URL.

Raises STAC::TypeError when the fetched JSON from the given URL is not STAC Catalog.

# File lib/stac/client.rb, line 23
def from_url(url, params: {}, headers: {}, **http_options)
  http_client = HTTPClient.new(params: params, headers: headers, **http_options.merge(url: url))
  obj = STAC.from_url(url, http_client: http_client)
  unless obj.instance_of?(Catalog)
    raise TypeError, "could not resolve fetched JSON into STAC::Catalog: #{obj.class}"
  end

  new(obj, http_client: http_client)
end
new(catalog, http_client: HTTPClient.new) click to toggle source
# File lib/stac/client.rb, line 41
def initialize(catalog, http_client: HTTPClient.new)
  @catalog = catalog
  @http_client = http_client
end

Public Instance Methods

conformances() click to toggle source

Returns the value of “conformsTo” field.

# File lib/stac/client.rb, line 47
def conformances
  catalog.extra.fetch('conformsTo', [])
end
conforms_to?(conformance) click to toggle source

Returns wether the API conforms to the given standard.

The argument should be a constant of Conformance.

# File lib/stac/client.rb, line 54
def conforms_to?(conformance)
  conformances.any? { |c| conformance.match?(c) }
end