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.



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

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

Instance Method Details

#feature_infoObject



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

def feature_info
  @response.check
end

#request_responseObject



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

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, Faraday::TimeoutError => error
  Geoblacklight.logger.error error.inspect
  {error: error.inspect}
end

#search_paramsObject



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

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

#urlObject



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

def url
  @params["URL"]
end