- 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"
+
+ if params[:latlon_digits]
+ # We've got two nondescript numbers for a query, which can mean both "lat, lon" or "lon, lat".
+ @results = []
+
+ if lat >= -90 && lat <= 90 && lon >= -180 && lon <= 180
+ @results.push(:lat => lat, :lon => lon,
+ :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"
+ else
+ render :action => "results"
+ end