Method: GeoTools::FormHelpers#latitude_field
- Defined in:
- lib/geo_tools/form_helpers.rb
#latitude_field(method, options = {}) ⇒ Object
Options:
:latitude
:degrees
:symbol
:minutes
:symbol
:decimal_minutes
:symbol
:maxlength
Assumes the latitude field is called ‘latitude’.
The ‘method’ argument is for consistency with other field helpers. We don’t use it when using the normal Rails form builder.
1/100th of a minute of latitude (or equitorial longitude) is approximately 20m.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/geo_tools/form_helpers.rb', line 21 def latitude_field(method, = {}) opts = { :degrees => { :symbol => '°' }, :minutes => { :symbol => '.' }, :decimal_minutes => { :symbol => '′', :maxlength => 2 }, } = .delete :latitude opts.merge! if output = [] # Degrees width = 2 output << text_field("latitude_degrees", .merge(:maxlength => width, :value => "%0#{width}d" % (@object.send("latitude_degrees") || 0))) output << opts[:degrees][:symbol] # Minutes width = 2 output << text_field("latitude_minutes", .merge(:maxlength => width, :value => "%0#{width}d" % (@object.send("latitude_minutes") || 0))) output << opts[:minutes][:symbol] # Decimal minutes width = opts[:decimal_minutes][:maxlength] output << text_field("latitude_decimal_minutes", .merge(:maxlength => width, :value => @object.send("latitude_decimal_minutes_as_string").ljust(width, '0'))) output << opts[:decimal_minutes][:symbol] # Hemisphere. # Hmm, we pass the options in the html_options position. output << select("latitude_hemisphere", %w( N S ), {}, ) output.join "\n" end |