projects
/
rails.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
ad18d36
)
Add parsing coordinates in lon, lat format
author
Ilya Zverev
<zverik@textual.ru>
Mon, 27 Aug 2018 11:06:17 +0000
(14:06 +0300)
committer
Ilya Zverev
<zverik@textual.ru>
Mon, 27 Aug 2018 11:06:17 +0000
(14:06 +0300)
app/controllers/geocoder_controller.rb
patch
|
blob
|
history
diff --git
a/app/controllers/geocoder_controller.rb
b/app/controllers/geocoder_controller.rb
index 384f2c24c36a86272c47c6f713426edb971316a4..933e00a6ab4353c51075b36b967315722821b784 100644
(file)
--- a/
app/controllers/geocoder_controller.rb
+++ b/
app/controllers/geocoder_controller.rb
@@
-39,17
+39,23
@@
class GeocoderController < ApplicationController
def search_latlon
lat = params[:lat].to_f
lon = params[:lon].to_f
def search_latlon
lat = params[:lat].to_f
lon = params[:lon].to_f
- if lat < -90 || lat > 90
- @error = "Latitude #{lat} out of range"
- render :action => "error"
- elsif lon < -180 || lon > 180
- @error = "Longitude #{lon} out of range"
- render :action => "error"
- else
- @results = [{ :lat => lat, :lon => lon,
+ @results = []
+
+ if lat >= -90 && lat <= 90 && lon >= -180 && lon <= 180
+ @results.push(:lat => lat, :lon => lon,
:zoom => params[:zoom],
:zoom => params[:zoom],
- :name => "#{lat}, #{lon}" }]
+ :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"
+ else
render :action => "results"
end
end
render :action => "results"
end
end