Sha256: b4676884cd4897a174c860692bc48812e511c7033a5988c65738ce1ad01a247d

Contents?: true

Size: 995 Bytes

Versions: 2

Compression:

Stored size: 995 Bytes

Contents

# frozen_string_literal: true

module GeoblacklightAdmin
  class ImageService
    module Wms
      ##
      # Formats and returns a thumbnail url from a Web Map Service endpoint.
      # This utilizes the GeoServer specific 'reflect' service to generate
      # parameters like bbox that are difficult to tweak without more detailed
      # information about the layer.
      # @param [SolrDocument]
      # @param [Integer] thumbnail size
      # @return [String] wms thumbnail url
      def self.image_url(document, size)
        # Swap proxy url with princeton geoserver url.
        # Thumbnail requests send geoserver auth.
        endpoint = document.viewer_endpoint.gsub(Settings.PROXY_GEOSERVER_URL,
          Settings.INSTITUTION_GEOSERVER_URL)
        "#{endpoint}/reflect?" \
          "&FORMAT=image%2Fpng" \
          "&TRANSPARENT=TRUE" \
          "&LAYERS=#{document["gbl_wxsIdentifier_s"]}" \
          "&WIDTH=#{size}" \
          "&HEIGHT=#{size}"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
geoblacklight_admin-0.4.1 app/services/geoblacklight_admin/image_service/wms.rb
geoblacklight_admin-0.4.0 app/services/geoblacklight_admin/image_service/wms.rb