class STAC::ObjectResolver

Resolves a STAC object from a URL.

Attributes

resolvables[R]

Resolvable classes. Default is Catalog, Collection and Item.

http_client[R]

Public Class Methods

new(http_client:) click to toggle source
# File lib/stac/object_resolver.rb, line 21
def initialize(http_client:)
  @http_client = http_client
end

Public Instance Methods

resolve(url) click to toggle source

Reads a JSON from the given URL and returns a STAC object resolved from it.

Supports the following URL scheme:

  • http

  • https

  • file

Raises:

# File lib/stac/object_resolver.rb, line 35
def resolve(url)
  hash = read(url)
  klass = self.class.resolvables.find { |c| c.type == hash['type'] }
  raise TypeError, "unknown STAC object type: #{hash['type']}" unless klass

  object = klass.from_hash(hash)
  object.http_client = http_client
  object
end