Class: AppsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/apps_controller.rb

Instance Method Summary collapse

Instance Method Details

#showObject



3
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'app/controllers/apps_controller.rb', line 3

def show
  @current_roles = current_roles.roles.collect(&:name)

  @topic_name = params['topic'] || DEFAULT_TOPIC[@zone].name
  @main_default_topic = DEFAULT_TOPIC[@zone].name
  @offlayers = params['offlayers'].blank? ? [] : params['offlayers'].split(',')

  @scale = params['scale'].nil? ? DEFAULT_SCALE : params['scale'].to_i
  @x = params['x'].nil? ? DEFAULT_X : params['x'].to_f
  @y = params['y'].nil? ? DEFAULT_Y : params['y'].to_f

  @seltopic = params['seltopic']
  @sellayer = params['sellayer']
  @selproperty = params['selproperty']
  @selvalues = params['selvalues'].nil? ? [] : params['selvalues'].split('$')

  @redlining = params['redlining'].blank? ? nil : params['redlining']
  @centermarker = params['centermarker']

  @markers = params['markers']

  if params['locate']
    rule = LOCATERULES[params['locate']]
    if rule.nil?
      logger.info "Locate rule not found: {params['locate']}"
    else
      model = rule.model.constantize
      features = if rule.layer.nil?
        #User defined model
        @seltopic = model.selection_topic
        @sellayer = model.selection_layer
        @selproperty = model.primary_key
        @selscalerange = model.selection_scalerange
        search_locs = model.search_locations(params['locations'])
        model.locate(search_locs)
      else
        #Generic SearchModel
        layer = Layer.find_by_name(rule.layer)
        @seltopic = @topic_name
        @sellayer = layer.name
        @selproperty = layer.feature_class.primary_key
        @selscalerange = model.selection_scalerange
        search_locs = params['locations'].split(',')
        model.layer_locate(layer, rule.search_field, search_locs)
      end
      if features.present?
        @x, @y, scale = model.map_center(features)
        @scale = params['scale'].nil? ? scale : params['scale'].to_i
        #Selection
        @selbbox = model.bbox(features)
        @selvalues = features.collect {|f| f.send(model.primary_key) }
      else
        logger.info "no features found."
      end
    end
  end

  @selection_valid = !(@seltopic.nil? || @sellayer.nil? || @selproperty.nil? || @selvalues.empty?)
  @app = params[:app]

  session[:map_ts] = Time.now # Used for checking access to non-public WMS

  render :action => @app, :layout => false
end