Class: SearchController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- SearchController
- Defined in:
- app/controllers/search_controller.rb
Instance Method Summary collapse
Instance Method Details
#index ⇒ Object
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 |
# File 'app/controllers/search_controller.rb', line 3 def index @rule = SEARCHRULES[params[:rule]] if @rule.nil? then respond_to do |format| format.html # index.html.erb format.json { render :json => {:success => false, :quality => -9999, :msg => "ERROR: #{params[:rule]} model missing"} } end else # transform geometry fields to client SRID client_srid = params[:srid].blank? ? GeoModel.default_client_srid : params[:srid].to_i fields = transformed_geom_fields(@rule.fields, @rule.model.srid, client_srid) result = @rule.model.query(fields, params) @features = result[:features] @quality = result[:quality] @success = @quality >= 0 respond_to do |format| format.html # index.html.erb if @success then format.json { render :json => {:success => @success, :features => features_for_json_reader(@features), :quality => @quality} } else @msg = result[:msg] format.json { render :json => {:success => @success, :features => features_for_json_reader(@features), :quality => @quality, :msg => @msg} } end end end end |
#locate ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/controllers/search_controller.rb', line 32 def locate rule = LOCATERULES[params[:rule]] if rule.nil? render :json => {:success => false, :msg => "ERROR: #{params[:rule]} model missing"} else client_srid = params[:srid].blank? ? GeoModel.default_client_srid : params[:srid].to_i location = rule.locate(params['locations'], client_srid) unless location.nil? location[:success] = true render :json => location else render :json => {:success => false, :msg => "No features found"} end end end |
#soap ⇒ Object
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 |
# File 'app/controllers/search_controller.rb', line 52 def soap soap_action = nil soap_params = nil if params[:Envelope] && params[:Envelope][:Body] params[:Envelope][:Body].each do |key, value| soap_action = key soap_params = value end end if soap_action.nil? || soap_params.nil? # TODO: error response render :xml => "Invalid SOAP request" return end @rule = SEARCHRULES[params[:rule]] result = @rule.model.soap_query(@rule.fields, soap_params, soap_action) if result[:error] #TODO: error response render :xml => result[:error] else @feature = result[:feature] @hits = result[:hits] @quality = result[:quality] @features = result[:features] render result[:template] end end |
#soap_wsdl ⇒ Object
48 49 50 |
# File 'app/controllers/search_controller.rb', line 48 def soap_wsdl render "#{params[:rule]}_wsdl.xml" end |