class STAC::Client::ItemSearch
Represents a deferred query to a STAC search endpoint as described in the STAC API - Item Search spec
Attributes
client[R]
Public Class Methods
new(client:, url:, method: 'GET', params: {}, headers: {})
click to toggle source
# File lib/stac/client/item_search.rb, line 15 def initialize(client:, url:, method: 'GET', params: {}, headers: {}) @client = client @url = url @method = method @params = DEFAULT_PARAMS.merge(params.transform_keys(&:to_s)) @headers = headers end
Public Instance Methods
items()
click to toggle source
Returns search results as Enumerator::Lazy of Item with automatic pagination.
# File lib/stac/client/item_search.rb, line 29 def items pages.lazy.flat_map(&:features) end
matched()
click to toggle source
Returns the number matched for search.
# File lib/stac/client/item_search.rb, line 24 def matched pages.first.number_matched end
pages()
click to toggle source
Returns responses as Enumerator of ItemCollection
by following next links automatically.
# File lib/stac/client/item_search.rb, line 34 def pages @pages ||= Enumerator.new do |yielder| loop do response = request! item_collection = ItemCollection.from_hash(response) yielder << item_collection next_link = item_collection.find_link(rel: 'next') break unless next_link update_attrs!(next_link) end end end