60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
# File 'lib/geo_tools/form_helpers.rb', line 60
def longitude_field(method, options = {})
opts = {
:degrees => { :symbol => '°' },
:minutes => { :symbol => '.' },
:decimal_minutes => { :symbol => '′', :maxlength => 2 },
}
long_options = options.delete :longitude
opts.merge! long_options if long_options
output = []
width = 3
output << text_field("longitude_degrees",
options.merge(:maxlength => width,
:value => "%0#{width}d" % (@object.send("longitude_degrees") || 0)))
output << opts[:degrees][:symbol]
width = 2
output << text_field("longitude_minutes",
options.merge(:maxlength => width,
:value => "%0#{width}d" % (@object.send("longitude_minutes") || 0)))
output << opts[:minutes][:symbol]
width = opts[:decimal_minutes][:maxlength]
output << text_field("longitude_decimal_minutes",
options.merge(:maxlength => width,
:value => @object.send("longitude_decimal_minutes_as_string").ljust(width, '0')))
output << opts[:decimal_minutes][:symbol]
output << select("longitude_hemisphere", %w( E W ), {}, options)
output.join "\n"
end
|