Add parsing coordinates in lon, lat format
This commit is contained in:
parent
ad18d363b8
commit
d9d51fce9b
1 changed files with 15 additions and 9 deletions
|
@ -39,17 +39,23 @@ class GeocoderController < ApplicationController
|
||||||
def search_latlon
|
def search_latlon
|
||||||
lat = params[:lat].to_f
|
lat = params[:lat].to_f
|
||||||
lon = params[:lon].to_f
|
lon = params[:lon].to_f
|
||||||
if lat < -90 || lat > 90
|
@results = []
|
||||||
@error = "Latitude #{lat} out of range"
|
|
||||||
render :action => "error"
|
if lat >= -90 && lat <= 90 && lon >= -180 && lon <= 180
|
||||||
elsif lon < -180 || lon > 180
|
@results.push(:lat => lat, :lon => lon,
|
||||||
@error = "Longitude #{lon} out of range"
|
:zoom => params[:zoom],
|
||||||
|
:name => "#{lat}, #{lon}")
|
||||||
|
end
|
||||||
|
if lon >= -90 && lon <= 90 && lat >= -180 && lat <= 180
|
||||||
|
@results.push(:lat => lon, :lon => lat,
|
||||||
|
:zoom => params[:zoom],
|
||||||
|
:name => "#{lon}, #{lat}")
|
||||||
|
end
|
||||||
|
|
||||||
|
if @results.empty?
|
||||||
|
@error = "Latitude or longitude are out of range"
|
||||||
render :action => "error"
|
render :action => "error"
|
||||||
else
|
else
|
||||||
@results = [{ :lat => lat, :lon => lon,
|
|
||||||
:zoom => params[:zoom],
|
|
||||||
:name => "#{lat}, #{lon}" }]
|
|
||||||
|
|
||||||
render :action => "results"
|
render :action => "results"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue