Class: Georeference::GeoLocate::RequestUI

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

Overview

This class is used to create the string which will be sent to Tulane

Constant Summary

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'            => 'Tester'
}

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (RequestUI) initialize(request_params)

Returns a new instance of RequestUI



176
177
178
179
180
# File 'app/models/georeference/geo_locate.rb', line 176

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

Instance Attribute Details

- (Object) request_params (readonly)

Returns the value of attribute request_params



174
175
176
# File 'app/models/georeference/geo_locate.rb', line 174

def request_params
  @request_params
end

- (Object) request_params_hash (readonly)

Returns the value of attribute request_params_hash



174
175
176
# File 'app/models/georeference/geo_locate.rb', line 174

def request_params_hash
  @request_params_hash
end

- (Object) request_params_string (readonly)

Returns the value of attribute request_params_string



174
175
176
# File 'app/models/georeference/geo_locate.rb', line 174

def request_params_string
  @request_params_string
end

Instance Method Details

- (String) build_param_string

www.museum.tulane.edu/geolocate/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.



184
185
186
187
188
189
190
191
192
193
194
195
# File 'app/models/georeference/geo_locate.rb', line 184

def build_param_string
  # @request_param_string ||= @request_params.collect { |key, value| "#{key}=#{value}" }.join('&')
  ga                     = request_params_hash
  params_string          = 'http://' + URI_HOST +
    URI_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