Sha256: c4ca255217af7cf63d786ffa2493d38fa48e7c68ae77fe7c4a717c3f71a1ae03

Contents?: true

Size: 901 Bytes

Versions: 4

Compression:

Stored size: 901 Bytes

Contents

# frozen_string_literal: true
module Geoblacklight
  class WmsLayer
    def initialize(params)
      @params = params.to_h.merge(Settings.WMS_PARAMS)
      @response = Geoblacklight::FeatureInfoResponse.new(request_response)
    end

    def url
      @params['URL']
    end

    def search_params
      @params.except('URL')
    end

    def feature_info
      @response.check
    end

    def request_response
      conn = Faraday.new(url: url)
      conn.get do |request|
        request.params = search_params
        request.options.timeout = Settings.TIMEOUT_WMS
        request.options.open_timeout = Settings.TIMEOUT_WMS
      end
    rescue Faraday::ConnectionFailed => error
      Geoblacklight.logger.error error.inspect
      { error: error.inspect }
    rescue Faraday::TimeoutError => error
      Geoblacklight.logger.error error.inspect
      { error: error.inspect }
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
geoblacklight-3.2.0 lib/geoblacklight/wms_layer.rb
geoblacklight-3.1.0 lib/geoblacklight/wms_layer.rb
geoblacklight-3.0.1 lib/geoblacklight/wms_layer.rb
geoblacklight-3.0.0 lib/geoblacklight/wms_layer.rb