[openstreetmap-website] fixes for trac #4730 (also #4748) (#216)
Tom Hughes
notifications at github.com
Thu Feb 28 22:25:09 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]
I don't think `\.?\d*` is right here (or on any of the others) as we shouldn't be matching the digits unless we saw the decimal point first, so surely the two should be grouped with the `?` covering both?
In addition the comment on this line is wrong - looks like it has been cut and pasted.
---
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/216/files#r3197375
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20130228/7a1fee66/attachment.html>
More information about the rails-dev
mailing list