Module: Tasks::Gis::LocalityHelper

Defined in:
app/helpers/tasks/gis/locality_helper.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) anchor_shade(letter)



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/helpers/tasks/gis/locality_helper.rb', line 11

def anchor_shade(letter)
  style = 'display:inline;'
  if select_locality_count(letter) == 0
    style += 'color:lightgrey;'
  end

  #"<p>
  #  <h3 style=\>#{letter}</h3>
  #  <a href=\"#top\">top</a>
  #</p>"

  "<p><h3 style=\"#{style}\">#{letter}</h3> <a href=\"#top\">top</a></p>"

  # TODO: change to class
  # content_tag(:p) do
  #   content_tag(:h3, letter, style: style ) do
  #     link_to('top', '#top')
  #   end
  # end
end

- (Object) ay_range



3
4
5
# File 'app/helpers/tasks/gis/locality_helper.rb', line 3

def ay_range
  ('A'..'Y')
end

- (Object) az_range



7
8
9
# File 'app/helpers/tasks/gis/locality_helper.rb', line 7

def az_range
  ay_range.to_a.push('Z')
end

- (Object) collecting_event_georeference_count(collecting_event)



59
60
61
62
63
64
65
66
# File 'app/helpers/tasks/gis/locality_helper.rb', line 59

def collecting_event_georeference_count(collecting_event)
  count = collecting_event.georeferences.count - 1
  if count > 0
    count.to_s
  else
    'none'
  end
end

- (Object) distance_between(collecting_event_1, collecting_event_2)



68
69
70
71
72
73
74
75
76
77
78
79
# File 'app/helpers/tasks/gis/locality_helper.rb', line 68

def distance_between(collecting_event_1, collecting_event_2)
  distance = collecting_event_1.distance_to(collecting_event_2.preferred_georeference.geographic_item_id).round
  # to the nearest meter
  case
    when distance >= 1000.0
      metric = '%1.3fkm'
      distance /= 1000.0
    else
      metric = '%im'
  end
  metric % distance
end

- (Object) distance_select_tag(digit, tag_string)



86
87
88
89
90
91
# File 'app/helpers/tasks/gis/locality_helper.rb', line 86

def distance_select_tag(digit, tag_string)
  tag = tag_string.gsub(',', '')

  label_tag(digit, tag_string)
  radio_button_tag(digit, tag.to_s)
end

- (Object) is_checked(digit, value)



93
94
95
# File 'app/helpers/tasks/gis/locality_helper.rb', line 93

def is_checked(digit, value)
  (params[digit] == value) ? true : false
end

- (Object) locality_georeferences(collecting_events, geographic_area)



44
45
46
47
48
49
50
51
52
53
# File 'app/helpers/tasks/gis/locality_helper.rb', line 44

def locality_georeferences(collecting_events, geographic_area)
  retval = []
  unless collecting_events.nil?
    retval = collecting_events.map(&:georeferences).flatten
  end
  if retval.empty?
    retval.push(geographic_area)
  end
  retval
end

- (Object) missing_verbatim_locality_count(collecting_events)



55
56
57
# File 'app/helpers/tasks/gis/locality_helper.rb', line 55

def missing_verbatim_locality_count(collecting_events)
  collecting_events.where(verbatim_locality: nil).count
end


81
82
83
84
# File 'app/helpers/tasks/gis/locality_helper.rb', line 81

def nearby_link(collecting_event)
  return nil if collecting_event.nil?
  link_to('nearby', collecting_event)
end

- (Object) select_locality(letter)

localities within @geographic_item which have a verbatim_locality starting with letter



37
38
39
40
41
42
# File 'app/helpers/tasks/gis/locality_helper.rb', line 37

def select_locality(letter)
  s = CollectingEvent.where(id: @collecting_events.ids)
        .where('verbatim_locality like ?', letter.to_s + '%')
        .order(:verbatim_locality)
  s
end

- (Object) select_locality_count(letter)



32
33
34
# File 'app/helpers/tasks/gis/locality_helper.rb', line 32

def select_locality_count(letter)
  select_locality(letter).count
end

- (Object) within_count



97
98
99
# File 'app/helpers/tasks/gis/locality_helper.rb', line 97

def within_count
  @collecting_events_count = CollectingEvent.contained_within(@geographic_item).count
end