DX::Grid
The DX::Grid
module provides methods for converting between lat/long coordinate pairs and amateur radio Maidenhead grid locators. It can also validate grid coordinators.
The supported grid formats are 4-character (e.g. FN22
) and 6-character (e.g. FN32ab
).
Installation
Add this line to your application's Gemfile:
gem 'dx-grid'
And then execute:
$ bundle
Or install it yourself as:
$ gem install dx-grid
Usage
require 'dx/grid'
Decoding a Grid to a Coordinate
DX::Grid.decode('FN22')
DX::Grid.decode('FN22ab')
Encoding a Coordinate to a Grid
DX::Grid.encode([42.481076, -75.037847])
DX::Grid.encode([42.481076, -75.037847], :length => 4)
DX::Grid.encode([42.481076, -75.037847], :length => 6)
Validating a Grid
DX::Grid.valid?('FN22')
DX::Grid.valid?('fn22')
DX::Grid.valid?('AA00aa')
DX::Grid.valid?('ab12xx')
DX::Grid.valid?('MO00OO')
DX::Grid.valid?('lo00ol')
DX::Grid.valid?('FN')
DX::Grid.valid?('st12')
DX::Grid.valid?('fn22yz')
DX::Grid.valid?('hello world')
DX::Grid.valid?(nil)
DX::Grid.valid?('')
DX::Grid.valid?(5)
DX::Grid.valid?(Math::PI)
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/schrockwell/dx-grid.
License
The gem is available as open source under the terms of the MIT License.