From e54697189f37be8a9fb2fe947bc26a5775d0bd70 Mon Sep 17 00:00:00 2001 From: Skud Date: Tue, 13 Aug 2013 12:31:19 +1000 Subject: [PATCH] look up nominatim directly --- app/controllers/places_controller.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/controllers/places_controller.rb b/app/controllers/places_controller.rb index cecae5d2f..cd468d8ad 100644 --- a/app/controllers/places_controller.rb +++ b/app/controllers/places_controller.rb @@ -24,12 +24,16 @@ class PlacesController < ApplicationController @units = :km end - location = Geocoder.search(Geocoder::Query.new(@place, :distance => @distance, :units => @units)) + json = open(URI.escape("http://nominatim.openstreetmap.org/search/#{@place}?format=json&limit=1")).read() + location = JSON.parse(json) + + if location && location[0] + puts location[0].to_yaml + @latitude = location[0]['lat'] + @longitude = location[0]['lon'] - if location && location[0] && location[0].coordinates - @latitude, @longitude = location[0].coordinates @sw_lat, @sw_lng, @ne_lat, @ne_lng = Geocoder::Calculations.bounding_box( - location[0].coordinates, + [@latitude, @longitude], @distance, options = { :units => @units } )