Class: Geoblacklight::WmsLayer

Inherits:
Object
  • Object
show all
Defined in:
lib/geoblacklight/wms_layer.rb

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ WmsLayer


4
5
6
7
# File 'lib/geoblacklight/wms_layer.rb', line 4

def initialize(params)
  @params = params.merge(Settings.WMS_PARAMS)
  @response = Geoblacklight::FeatureInfoResponse.new(request_response)
end

Instance Method Details

#get_feature_infoObject


17
18
19
# File 'lib/geoblacklight/wms_layer.rb', line 17

def get_feature_info
  @response.check
end

#request_responseObject


21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/geoblacklight/wms_layer.rb', line 21

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

#search_paramsObject


13
14
15
# File 'lib/geoblacklight/wms_layer.rb', line 13

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

#urlObject


9
10
11
# File 'lib/geoblacklight/wms_layer.rb', line 9

def url
  @params['URL']
end