Class: Georeference::GeoLocate::RequestUI

Inherits:
Object
  • Object
show all
Defined in:
app/models/georeference/geo_locate.rb

Overview

rubocop:disable Style/StringHashKeys This class is used to create the string which will be sent to Tulane

Constant Summary collapse

REQUEST_PARAMS =
{
  'country'       => nil, # name of a country 'USA', or Germany
  'state'         => nil, # 'IL', or 'illinois' (required in the United States)
  'county'        => nil, # supply as a parameter
  'locality'      => nil, # name of a place 'CHAMPAIGN' (or building, i.e. 'Eiffel Tower')
  'Latitude'      => nil, #
  'Longitude'     => nil, #
  'Placename'     => nil, #
  'Score'         => '0',
  'Uncertainty'   => '3',
  'H20'           => 'false',
  'HwyX'          => 'false',
  'Uncert'        => 'true',
  'Poly'          => 'true',
  'DisplacePoly'  => 'false',
  'RestrictAdmin' => 'false',
  'BG'            => 'false',
  'LanguageIndex' => '0',
  'gc'            => 'TaxonWorks'
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_params) ⇒ RequestUI

Returns a new instance of RequestUI.

Parameters:

  • request_params (ActionController::Parameters)


224
225
226
227
228
# File 'app/models/georeference/geo_locate.rb', line 224

def initialize(request_params)
  @request_params_hash = REQUEST_PARAMS.merge(request_params)
  build_param_string
  @succeeded = nil
end

Instance Attribute Details

#request_paramsObject (readonly)

rubocop:enable Style/StringHashKeys



221
222
223
# File 'app/models/georeference/geo_locate.rb', line 221

def request_params
  @request_params
end

#request_params_hashObject (readonly)

rubocop:enable Style/StringHashKeys



221
222
223
# File 'app/models/georeference/geo_locate.rb', line 221

def request_params_hash
  @request_params_hash
end

#request_params_stringObject (readonly)

rubocop:enable Style/StringHashKeys



221
222
223
# File 'app/models/georeference/geo_locate.rb', line 221

def request_params_string
  @request_params_string
end

Instance Method Details

#build_param_stringString

www.geo-locate.org/web/webgeoreflight.aspx?country=United States of America&state=Illinois&locality=Champaign&points=40.091622 |-88.241179|Champaign|low|7000&georef=run|false|false|true|true|false|false|false|0&gc=Tester”

Returns:

  • (String)

    a string to invoke as an api call to hunt for a particular place.



234
235
236
237
238
239
240
241
242
243
244
# File 'app/models/georeference/geo_locate.rb', line 234

def build_param_string
  # @request_param_string ||= @request_params.collect { |key, value| "#{key}=#{value}" }.join('&')
  ga                     = request_params_hash
  params_string          = 'http://' + EMBED_HOST + EMBED_PATH +
    "country=#{ga['country']}&state=#{ga['state']}&county=#{ga['county']}&locality=#{ga['locality']}&points=" \
    "#{ga['Latitude']}|#{ga['Longitude']}|#{ga['Placename']}|#{ga['Score']}|#{ga['Uncertainty']}" \
    "&georef=run|#{ga['H20']}|#{ga['HwyX']}|#{ga['Uncert']}|#{ga['Poly']}|#{ga['DisplacePoly']}|" \
    "#{ga['RestrictAdmin']}|#{ga['BG']}|#{ga['LanguageIndex']}" \
    "&gc=#{ga['gc']}"
  @request_params_string = params_string # URI.encode(params_string)
end