Sha256: 1bd9a0c82b862b2bb8daafb47a4ede1e308654bb33119e905750df35fea5d48e

Contents?: true

Size: 823 Bytes

Versions: 5

Compression:

Stored size: 823 Bytes

Contents

# frozen_string_literal: true

module GeoblacklightAdmin
  class ItemViewer
    def initialize(distributions)
      @distributions = distributions
      @keys = distributions.keys.collect { |k| reference_uri_2_key(k) }
    end

    def viewer_protocol
      viewer_preference.find { |vp| @keys.include?(vp) } || :map
    end

    def viewer_endpoint
      @distributions[viewer_protocol_2_endpoint]
    end

    def reference_uri_2_key(value)
      Geoblacklight::Constants::URI.key(value)
    end

    def viewer_protocol_2_endpoint
      Geoblacklight::Constants::URI[viewer_protocol]
    end

    def viewer_preference
      [:cog, :pmtiles, :oembed, :index_map, :tilejson, :xyz, :wmts, :tms, :wms, :iiif_manifest, :iiif, :tiled_map_layer, :dynamic_map_layer,
        :image_map_layer, :feature_layer]
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
geoblacklight_admin-0.7.0 app/services/geoblacklight_admin/item_viewer.rb
geoblacklight_admin-0.6.3 app/services/geoblacklight_admin/item_viewer.rb
geoblacklight_admin-0.6.2 app/services/geoblacklight_admin/item_viewer.rb
geoblacklight_admin-0.6.1 app/services/geoblacklight_admin/item_viewer.rb
geoblacklight_admin-0.6.0 app/services/geoblacklight_admin/item_viewer.rb