- def search_us_postcode
- # get query parameters
- query = params[:query]
-
- # create result array
- @results = []
-
- # ask geocoder.us (they have a non-commercial use api)
- response = fetch_text("http://rpc.geocoder.us/service/csv?zip=#{escape_query(query)}")
-
- # parse the response
- unless response =~ /couldn't find this zip/
- data = response.split(/\s*,\s+/) # lat,long,town,state,zip
- @results.push(:lat => data[0], :lon => data[1],
- :zoom => POSTCODE_ZOOM,
- :prefix => "#{data[2]}, #{data[3]},",
- :name => data[4])
- end
-
- render :action => "results"
- rescue StandardError => ex
- @error = "Error contacting rpc.geocoder.us: #{ex}"
- render :action => "error"
- end
-
- def search_uk_postcode
- # get query parameters
- query = params[:query]
+ if lat >= -90 && lat <= 90 && lon >= -180 && lon <= 180
+ @results.push(:lat => lat, :lon => lon,
+ :zoom => params[:zoom],
+ :name => "#{lat}, #{lon}")
+ end