[openstreetmap-website] fixes for trac #4730 (also #4748) (#216)

Tom Hughes notifications at github.com
Thu Feb 28 22:28:08 UTC 2013


> @@ -312,4 +314,26 @@ def count_results(results)
>    def escape_query(query)
>      return URI.escape(query, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]", false, 'N'))
>    end
> +
> +  def convert_latlon
> +    @query = params[:query]
> +
> +    if latlon = @query.match(/^([NS])\s*(\d{1,3}\.?\d*)\W*([EW])\s*(\d{1,3}\.?\d*)$/).try(:captures) # [NSEW] decimal degrees
> +      params[:query] = view_context.nsew_to_decdeg(latlon)
> +    elsif latlon = @query.match(/^(\d{1,3}\.?\d*)\s*([NS])\W*(\d{1,3}\.?\d*)\s*([EW])$/).try(:captures) # degrees, decimal minutes [NSEW]
> +      params[:query] = view_context.nsew_to_decdeg(latlon)
> +
> +    elsif latlon = @query.match(/^([NS])\s*(\d{1,3})°?\s*(\d{1,3}\.?\d*)?['′]?\W*([EW])\s*(\d{1,3})°?\s*(\d{1,3}\.?\d*)?['′]?$/).try(:captures) # [NSEW] degrees, decimal minutes

What's with `['']?` here? That is equivalent to `'?` which is a bit simpler...

---
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/216/files#r3197417
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20130228/38be76d6/attachment.html>


More information about the rails-dev mailing list