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

Eric Theise notifications at github.com
Fri Mar 1 05:47:54 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

The first checks for apostrophes (') and single primes (′), the second checks for quotation marks (") and double primes (″). A typographer would correctly use the prime characters, and, indeed, this is what Wikipedia does, so a cut and paste for any country latlon on Wikipedia will fail without them. ```test_primes_and_double_primes``` beginning on line 211 looks for these. Believe it's in the commit message.

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


More information about the rails-dev mailing list