Update to use api.geonames.org instead of ws.geonames.org
authorTom Hughes <tom@compton.nu>
Wed, 18 Apr 2012 17:44:37 +0000 (18:44 +0100)
committerTom Hughes <tom@compton.nu>
Wed, 18 Apr 2012 17:44:37 +0000 (18:44 +0100)
app/controllers/geocoder_controller.rb
config/example.application.yml

index c55c85833b8f6a1a233ce31ea042e0e00303ac1d..2b03790aacdbdb87ece90fc88833d22c296b060e 100644 (file)
@@ -26,7 +26,7 @@ class GeocoderController < ApplicationController
       @sources.push "osm_nominatim"
     else
       @sources.push "osm_nominatim"
-      @sources.push "geonames"
+      @sources.push "geonames" if defined?(GEONAMES_USERNAME)
     end
   end
 
@@ -272,7 +272,7 @@ class GeocoderController < ApplicationController
     @results = Array.new
 
     # ask geonames.org
-    response = fetch_xml("http://ws.geonames.org/search?q=#{escape_query(query)}&maxRows=20")
+    response = fetch_xml("http://api.geonames.org/search?q=#{escape_query(query)}&maxRows=20&username=#{GEONAMES_USERNAME}")
 
     # parse the response
     response.elements.each("geonames/geoname") do |geoname|
index 420278a1f87d9e8d5c6c89e5f7b990e89004364a..cf18ab5577cceed5fc7fe2395246cc0710c6757f 100644 (file)
@@ -38,6 +38,8 @@ defaults: &defaults
   max_messages_per_hour: 60
   # Domain for handling message replies
   #messages_domain: "messages.openstreetmap.org"
+  # Geonames authentication details
+  #geonames_username: ""
   # Quova authentication details
   #quova_username: ""
   #quova_password: ""