- render :action => "results"
- end
- end
-
- 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.match(/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
+ if params[:latlon_digits]
+ # We've got two nondescript numbers for a query, which can mean both "lat, lon" or "lon, lat".
+ @results = []