Use api.geonames.org for reverse searches

This commit is contained in:
Tom Hughes 2014-01-27 21:02:00 +00:00
parent b28b5509b8
commit ccebb796ab
2 changed files with 5 additions and 10 deletions

View file

@ -16,7 +16,7 @@ class GeocoderController < ApplicationController
if params[:lat] && params[:lon]
@sources.push "latlon"
@sources.push "osm_nominatim_reverse"
@sources.push "geonames_reverse"
@sources.push "geonames_reverse" if defined?(GEONAMES_USERNAME)
elsif params[:query].match(/^\d{5}(-\d{4})?$/)
@sources.push "us_postcode"
@sources.push "osm_nominatim"
@ -259,7 +259,7 @@ class GeocoderController < ApplicationController
@results = Array.new
# ask geonames.org
response = fetch_xml("http://ws.geonames.org/countrySubdivision?lat=#{lat}&lng=#{lon}")
response = fetch_xml("http://api.geonames.org/countrySubdivision?lat=#{lat}&lng=#{lon}&username=#{GEONAMES_USERNAME}")
# parse the response
response.elements.each("geonames/countrySubdivision") do |geoname|