Module: CollectingEvent::GeoLocate

Extended by:
ActiveSupport::Concern
Included in:
CollectingEvent
Defined in:
app/models/collecting_event/geo_locate.rb

Overview

Hooks to Geolocate

Instance Method Summary collapse

Instance Method Details

#geolocate_attributesHash

rubocop:disable Style/StringHashKeys

Returns:

  • (Hash)

    parameters from collecting event that are of use to geolocate



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/models/collecting_event/geo_locate.rb', line 9

def geolocate_attributes
  parameters = {
    'country'   => country_name,
    'state'     => state_or_province_name,
    'county'    => county_or_equivalent_name,
    'locality'  => verbatim_locality,
    'Placename' => verbatim_locality,
  }

  focus = case lat_long_source
          when :georeference
            preferred_georeference.geographic_item
          when :geographic_area
            geographic_area.geographic_area_map_focus
          else
            nil
          end

  parameters.merge!(
    'Longitude' => focus.point.x,
    'Latitude'  => focus.point.y
  ) unless focus.nil?
  parameters
end

#geolocate_ui_paramsHash

Returns a complete set of params necessary to form a request string.

Returns:

  • (Hash)

    a complete set of params necessary to form a request string



37
38
39
# File 'app/models/collecting_event/geo_locate.rb', line 37

def geolocate_ui_params
  Georeference::GeoLocate::RequestUI.new(geolocate_attributes).request_params_hash
end

#geolocate_ui_params_stringString

Returns:

  • (String)


42
43
44
# File 'app/models/collecting_event/geo_locate.rb', line 42

def geolocate_ui_params_string
  Georeference::GeoLocate::RequestUI.new(geolocate_attributes).request_params_string
end

#lat_long_sourceObject



46
47
48
49
50
51
52
53
54
55
56
# File 'app/models/collecting_event/geo_locate.rb', line 46

def lat_long_source
  if preferred_georeference
    :georeference
  elsif verbatim_latitude && verbatim_longitude
    :verbatim
  elsif geographic_area && geographic_area.has_shape?
    :geographic_area
  else
    nil
  end
end