Class: Tasks::Gis::DrawableMapController

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

Instance Method Summary (collapse)

Methods included from TaskControllerConfiguration

#set_is_task_controller

Instance Method Details

- (Object) drawn_area_select



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/controllers/tasks/gis/drawable_map_controller.rb', line 4

def drawn_area_select
  message = ''
  value   = params['drawn_map_shape']
  finding = params['selection_object']
  if value.blank?
    case finding
      when 'collection_object'
        @collection_objects = CollectionObject.where('false')
      else
    end
  else
    feature   = RGeo::GeoJSON.decode(value, :json_parser => :json)
    # isolate the WKT
    geometry  = feature.geometry
    this_type = geometry.geometry_type.to_s.downcase
    geometry  = geometry.as_text
    radius    = feature['radius']
    case finding
      when 'collection_object'
        case this_type
          when 'point'
            @collection_objects = Georeference.joins(:geographic_item).where(GeographicItem.within_radius_of_wkt_sql(geometry, radius))
          when 'polygon'
            @collection_objects = Georeference.joins(:geographic_item).where(GeographicItem.contained_by_wkt_sql(geometry))
          else
        end
      else
    end
  end
  if @collection_objects.length == 0
    message = 'no objects contained in drawn shape'
  end
  render_gr_select_json(message)
end