Sha256: 5c4a3336e16ebafedd80c1bb5d35409b48aa6bbec9e33a56e2bb2374fdd4ad9e

Contents?: true

Size: 871 Bytes

Versions: 2

Compression:

Stored size: 871 Bytes

Contents

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

2 entries across 2 versions & 1 rubygems

Version Path
geoblacklight-2.4.0 lib/geoblacklight/wms_layer.rb
geoblacklight-2.3.0 lib/geoblacklight/wms_layer.rb