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)



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

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)



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

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)



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

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)



91
92
93
# File 'app/helpers/tasks/gis/locality_helper.rb', line 91

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

- (Object) locality_georeferences(collecting_events, geographic_area)



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

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)



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

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


79
80
81
82
# File 'app/helpers/tasks/gis/locality_helper.rb', line 79

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
# File 'app/helpers/tasks/gis/locality_helper.rb', line 37

def select_locality(letter)
  CollectingEvent.where(id: @collecting_events.map(&:id))
    .where("verbatim_locality like '#{letter}%'")
    .order(:verbatim_locality)
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



95
96
97
# File 'app/helpers/tasks/gis/locality_helper.rb', line 95

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