Class: Georeference::GeoLocate::RequestUI

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

Overview

def self.default_options_string

'&points=|||low|&georef=run|false|false|true|true|false|false|false|0&gc=Tester'

end

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



155
156
157
158
159
# File 'app/models/georeference/geo_locate.rb', line 155

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



153
154
155
# File 'app/models/georeference/geo_locate.rb', line 153

def request_params
  @request_params
end

- (Object) request_params_hash (readonly)

Returns the value of attribute request_params_hash



153
154
155
# File 'app/models/georeference/geo_locate.rb', line 153

def request_params_hash
  @request_params_hash
end

- (Object) request_params_string (readonly)

Returns the value of attribute request_params_string



153
154
155
# File 'app/models/georeference/geo_locate.rb', line 153

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.



163
164
165
166
167
168
169
170
171
172
173
# File 'app/models/georeference/geo_locate.rb', line 163

def build_param_string
  # @request_param_string ||= @request_params.collect { |key, value| "#{key}=#{value}" }.join('&')
  ga                     = request_params_hash
  @request_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']}"
end