Sha256: a3e3fe6d33529805a0688533a91f769d8f3c69fa28e9079bdbd74dab13450bb1

Contents?: true

Size: 1003 Bytes

Versions: 1

Compression:

Stored size: 1003 Bytes

Contents

# frozen_string_literal: true

module GeoblacklightSidecarImages
  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

1 entries across 1 versions & 1 rubygems

Version Path
geoblacklight_sidecar_images-1.0.0 app/services/geoblacklight_sidecar_images/image_service/wms.rb