Module: MapLayers::GeoRSS

Defined in:
lib/map_layers/georss.rb

Overview

GeoRSS Server methods www.georss.org/1

Instance Method Summary collapse

Instance Method Details

#georssObject

Publish layer in GeoRSS format



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/map_layers/georss.rb', line 8

def georss
  rows = map_layers_config.model.find(:all, :limit => GEORSS_FEATURE_LIMIT)
  @features = rows.collect do |row|
    if map_layers_config.geometry
      Feature.from_geom(row.send(map_layers_config.text), row.send(map_layers_config.geometry), row.send(map_layers_config.id))
    else
      Feature.new(row.send(map_layers_config.text), row.send(map_layers_config.lon), row.send(map_layers_config.lat))
    end
  end
  @base_url = "http://#{request.env["HTTP_HOST"]}/"
  @item_url = "#{@base_url}#{map_layers_config.model_id.to_s.pluralize}"
  @title = map_layers_config.model_id.to_s.pluralize.humanize
  logger.info "MapLayers::GEORSS: returning #{@features.size} features"
  render :inline => GEORSS_XML_ERB, :content_type => "text/xml"
rescue Exception => e
  logger.error "MapLayers::GEORSS: returning no features - Caught exception '#{e}'"
  render :text => GEORSS_EMPTY_RESPONSE, :content_type => "text/xml"
end