Class: Tasks::Gis::LocalityController

Inherits:
ApplicationController
  • Object
show all
Includes:
TaskControllerConfiguration
Defined in:
app/controllers/tasks/gis/locality_controller.rb

Instance Method Summary (collapse)

Methods included from TaskControllerConfiguration

#set_is_task_controller

Instance Method Details

- (Object) gather_list_data(geographic_area) (protected)



45
46
47
48
49
50
51
# File 'app/controllers/tasks/gis/locality_controller.rb', line 45

def gather_list_data(geographic_area)
  if @geographic_area.has_shape?
    @geographic_item = @geographic_area.default_geographic_item
  else
    @geographic_item = nil
  end
end

- (Object) list

use the params to locate the area, use that to find a geographic



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/controllers/tasks/gis/locality_controller.rb', line 28

def list
  case params[:commit]
  when 'Show'
    geographic_area_id = params[:geographic_area_ids]
    shape_in = params['drawn_area_shape']
    finding = params['selection_object']

    @collecting_events = GeographicItem.gather_selected_data(geographic_area_id, shape_in, finding)
      .order(:verbatim_locality)
    @drawing_modes = 'active: polygon, circle'
  else
    # some other case, TBDL
  end
end

- (Object) nearby



4
5
6
7
8
9
10
11
12
13
14
# File 'app/controllers/tasks/gis/locality_controller.rb', line 4

def nearby
  if params[:id]
    @collecting_event  = CollectingEvent.where(project_id: sessions_current_project_id).find(params[:id])
    @nearby_distance   = Utilities::Geo.nearby_from_params(params)
    @collecting_events = @collecting_event.collecting_events_within_radius_of(@nearby_distance).where(project_id: sessions_current_project_id).limit(100).order(:verbatim_locality)
  else
    @collecting_event  = CollectingEvent.new()
    @collecting_events = []
    @nearby_distance   = 5000
  end
end

- (Scope) new_list

Returns Preload an empty set of collecting events

Returns:

  • (Scope)

    Preload an empty set of collecting events



22
23
24
25
# File 'app/controllers/tasks/gis/locality_controller.rb', line 22

def new_list
  @collecting_events = CollectingEvent.where('false')
  @drawing_modes     = 'active: polygon, circle'
end

- (Object) within



16
17
18
19
# File 'app/controllers/tasks/gis/locality_controller.rb', line 16

def within
  @geographic_item   = GeographicItem.find(params[:id])
  @collecting_events = CollectingEvent.where(project_id: sessions_current_project_id).contained_within(@geographic_item)
end