-
- render :action => "results"
- rescue Exception => ex
- @error = "Error contacting rpc.geocoder.us: #{ex.to_s}"
- render :action => "error"
- end
-
- def search_uk_postcode
- # get query parameters
- query = params[:query]
-
- # create result array
- @results = Array.new
-
- # ask npemap.org.uk to do a combined npemap + freethepostcode search
- response = fetch_text("http://www.npemap.org.uk/cgi/geocoder.fcgi?format=text&postcode=#{escape_query(query)}")
-
- # parse the response
- unless response.match(/Error/)
- dataline = response.split(/\n/)[1]
- data = dataline.split(/,/) # easting,northing,postcode,lat,long
- postcode = data[2].gsub(/'/, "")
- zoom = POSTCODE_ZOOM - postcode.count("#")
- @results.push({:lat => data[3], :lon => data[4], :zoom => zoom,
- :name => postcode})
- end
-
- render :action => "results"
- rescue Exception => ex
- @error = "Error contacting www.npemap.org.uk: #{ex.to_s}"
- render :action => "error"