Class: Geoblacklight::WmsLayer

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

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ WmsLayer

Returns a new instance of WmsLayer.



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

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

Instance Method Details

#feature_infoObject



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

def feature_info
  @response.check
end

#request_responseObject



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

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::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

#search_paramsObject



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

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

#urlObject



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

def url
  @params['URL']
end