Module: Tasks::CollectingEvents::Parse::Stepwise::LatLongHelper
- Defined in:
- app/helpers/tasks/collecting_events/parse/stepwise/lat_long_helper.rb
Instance Method Summary collapse
- #make_lat_long_matching_table(*pieces, collection) ⇒ Object
- #make_method_headers ⇒ Object
- #make_rows(label, filters) ⇒ Object
- #make_selected_method_boxes(filters = Utilities::Geo::REGEXP_COORD.keys) ⇒ Object
- #parse_label(label) ⇒ Object
- #parse_lat_long_skip(current_collecting_event_id, filters) ⇒ Object
- #scan_c_e ⇒ Object
- #show_ce_vl(collecting_event) ⇒ Object
- #test_lat ⇒ Object
- #test_long ⇒ Object
Instance Method Details
#make_lat_long_matching_table(*pieces, collection) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'app/helpers/tasks/collecting_events/parse/stepwise/lat_long_helper.rb', line 50 def make_lat_long_matching_table(*pieces, collection) columns = ['CEID', 'Match', 'Verbatim Lat', 'Verbatim Long', 'Decimal lat', 'Decimal long', 'Is georeferenced?', 'Select'] thead = content_tag(:thead) do content_tag(:tr) do columns.collect { |column| concat content_tag(:th, column) }.join.html_safe end end tbody = content_tag (:tbody) do collection.collect { |item| content_tag (:tr) do item_data = '' no_georef = false columns.collect.with_index { |column, dex| = {align: 'center'} case dex when 0 #'CEID' item_data = link_to(item.id, item) when 1 #'Match' item_data = pieces.join(' ') [:data] = {help: item.verbatim_label} when 2 #'Verbatim Lat' item_data = item.verbatim_latitude when 3 #'Verbatim Long' item_data = item.verbatim_longitude when 4 #'Decimal lat' item_data = item.latitude when 5 #'Decimal long' item_data = item.longitude when 6 #'Is georeferenced?' if item.georeferences.any? item_data = 'yes' no_georef = true else item_data = 'no' end when 7 #'Select' # check_box_tag(name, value = "1", checked = false, options = {}) public = {disabled: no_georef} [:class] = 'selectable_select' unless no_georef item_data = check_box_tag('selected[]', item.id, false, ) end concat content_tag(:td, item_data, ) }.to_s.html_safe end }.join().html_safe end content_tag(:table, thead.concat(tbody), {id: 'matching_table', border: '1', align: 'center'}).html_safe end |
#make_method_headers ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'app/helpers/tasks/collecting_events/parse/stepwise/lat_long_helper.rb', line 8 def make_method_headers list = Utilities::Geo::REGEXP_COORD selector_row = '' list.each_key { |kee| selector_row += content_tag(:th, kee.to_s.upcase, data: {help: Utilities::Geo::REGEXP_COORD[kee][:hlp]}) } selector_row.html_safe end |
#make_rows(label, filters) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/helpers/tasks/collecting_events/parse/stepwise/lat_long_helper.rb', line 30 def make_rows(label, filters) return nil if label.nil? tests = Utilities::Geo.hunt_wrapper(label, filters) tests.keys.collect.with_index do |kee, dex| trial = tests[kee] method = trial.delete(:method) next if trial.blank? content_tag(:tr, class: :extract_row) do content_tag(:td, method, align: 'center') + # content_tag(:td, kee == method ? '' : kee) + content_tag(:td, trial[:piece], class: :piece_value, align: 'center') + content_tag(:td, trial[:lat], class: :latitude_value, align: 'center') + content_tag(:td, trial[:long], class: :longitude_value, align: 'center') + content_tag(:td, ('select', dex, false, class: :select_lat_long), align: 'center') end end.join.html_safe end |
#make_selected_method_boxes(filters = Utilities::Geo::REGEXP_COORD.keys) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'app/helpers/tasks/collecting_events/parse/stepwise/lat_long_helper.rb', line 20 def make_selected_method_boxes(filters = Utilities::Geo::REGEXP_COORD.keys) list = Utilities::Geo::REGEXP_COORD box_row = '' list.each_key { |kee| checked = filters.include?(kee) box_row += content_tag(:td, check_box_tag('filters[]', kee.to_s, checked), align: 'center') } box_row.html_safe end |
#parse_label(label) ⇒ Object
3 4 5 6 |
# File 'app/helpers/tasks/collecting_events/parse/stepwise/lat_long_helper.rb', line 3 def parse_label(label) retval = Utilities::Geo.hunt_wrapper(label) retval end |
#parse_lat_long_skip(current_collecting_event_id, filters) ⇒ Object
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'app/helpers/tasks/collecting_events/parse/stepwise/lat_long_helper.rb', line 119 def parse_lat_long_skip(current_collecting_event_id, filters) # TODO: Now this has to be bound to next hit # filters = Utilities::Geo::REGEXP_COORD.keys next_id = Queries::CollectingEventLatLongExtractorQuery.new( collecting_event_id: current_collecting_event_id, filters: filters).all.with_project_id(sessions_current_project_id).first.try(:id) if next_id ('Skip to next record', {value: 'skip', id: 'skip'}) # link_to('Skip to next record', collecting_event_lat_long_task_path(collecting_event_id: next_id)) else content_tag(:span, 'no more matches') end + ('Re-evaluate', {value: 're_eval', id: 're_eval'}) end |
#scan_c_e ⇒ Object
135 136 137 138 139 140 141 142 143 144 |
# File 'app/helpers/tasks/collecting_events/parse/stepwise/lat_long_helper.rb', line 135 def scan_c_e pile = Queries::CollectingEventLatLongExtractorQuery.new( collecting_event_id: 0, filters: DEFAULT_SQL_REGEXS).all.with_project_id(sessions_current_project_id).order(:id) pile.each { |c_e| trials = Utilities::Geo.hunt_lat_long_full(c_e.verbatim_label) puts(c_e.id) } pile end |
#show_ce_vl(collecting_event) ⇒ Object
111 112 113 114 115 116 117 |
# File 'app/helpers/tasks/collecting_events/parse/stepwise/lat_long_helper.rb', line 111 def show_ce_vl(collecting_event) = 'No collecting event available.' unless collecting_event.nil? = collecting_event.verbatim_label end collecting_event_label_tag() end |
#test_lat ⇒ Object
103 104 105 |
# File 'app/helpers/tasks/collecting_events/parse/stepwise/lat_long_helper.rb', line 103 def test_lat @collecting_event.verbatim_latitude unless @collecting_event.nil? end |
#test_long ⇒ Object
107 108 109 |
# File 'app/helpers/tasks/collecting_events/parse/stepwise/lat_long_helper.rb', line 107 def test_long @collecting_event.verbatim_longitude unless @collecting_event.nil? end |