completed UK postcode search

This commit is contained in:
Nick Black 2007-04-24 07:55:19 +00:00
parent a926189c7f
commit bf2e2c7140
4 changed files with 14 additions and 17 deletions

View file

@ -4,15 +4,12 @@ class GeocoderController < ApplicationController
require 'net/http' require 'net/http'
require 'rexml/document' require 'rexml/document'
before_filter :authorize_web
before_filter :require_user
def search def search
res_hash = {} res_hash = {}
@postcode_arr = [] @postcode_arr = []
@res_ary = [] @res_ary = []
if params[:query][:postcode] != "" if params[:query][:postcode]
postcode = params[:query][:postcode] postcode = params[:query][:postcode]
if postcode.match(/(^\d{5}$)|(^\d{5}-\d{4}$)/) if postcode.match(/(^\d{5}$)|(^\d{5}-\d{4}$)/)
#its a zip code - do something #its a zip code - do something
@ -42,11 +39,11 @@ class GeocoderController < ApplicationController
end end
end end
end end
redirect_to :controller => 'geocoder', :action => 'results' redirect_to :controller => 'geocoder', :action => 'results', :params => @res_ary
end end
end end
def result def result
@res = :params[@res_ary]
end end
end end

View file

@ -7,16 +7,13 @@
<%= submit_tag 'Search' %> <%= submit_tag 'Search' %>
<%= end_form_tag %> <%= end_form_tag %>
<div id="postcode-helper"> <div id="postcode-helper">
eg SW15 6JH eg: SW15 6JH
</div> </div>
<div id="placename-helper"> <div id="placename-helper">
Essen eg:Essen
</div> </div>
</div> </div>
<% lon = params['lon'] || '-0.1' %> <% lon = params['lon'] || '-0.1' %>
<% lat = params['lat'] || '51.5' %> <% lat = params['lat'] || '51.5' %>
<% zoom = params['zoom'] || '4' %> <% zoom = params['zoom'] || '4' %>

View file

@ -75,8 +75,9 @@ ActionController::Routing::Routes.draw do |map|
# geocoder # geocoder
map.connect 'geocoder/search/', :controller => 'geocoder', :action => 'search' map.connect 'geocoder/search/', :controller => 'geocoder', :action => 'search'
map.connect 'geocoder/results/', :controller => 'geocoder', :action => 'results'
# fall through # fall through
map.connect ':controller/:id/:action' map.connect ':controller/:id/:action'
map.connect ':controller/:action' map.connect ':controller/:action'
end end

View file

@ -146,7 +146,7 @@ body {
#content { #content {
/* width: 700px; */ /* width: 700px; */
padding: 0; padding: 0;
/*padding-left: 1em;*/ /*padding-left: 1em;*/
margin: 0; margin: 0;
@ -292,17 +292,19 @@ hides rule from IE5-Mac \*/
} }
#placename-helper{ #placename-helper{
font-size: 10px; font-size: 9px;
position:relative; bottom:36px; left: 470px; position:relative; bottom:36px; left: 470px;
color: gray; color: gray;
} }
#postcode-helper{ #postcode-helper{
font-size: 10px; font-size: 9px;
position:relative; bottom:16px; left: 180px; position:relative; bottom:17px; left: 180px;
color: gray; color: gray;
} }
.gpxsummary { .gpxsummary {
font-size: 12px; font-size: 12px;
color: gray; color: gray;
@ -419,5 +421,5 @@ hides rule from IE5-Mac \*/
} }
input { input {
border: 1px solid black; border: 1px solid black;
} }