- # 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
-
- def search_uk_postcode
- # get query parameters
- query = params[:query]
-
- # create result array
- @results = []
-
- # 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