Class: OpenLocationCode::CodeArea
- Inherits:
-
Object
- Object
- OpenLocationCode::CodeArea
- Defined in:
- lib/open_location_code/code_area.rb
Overview
Coordinates of a decoded Open Location Code.
The coordinates include the latitude and longitude of the lower left and
upper right corners and the center of the bounding box for the area the
code represents.
Instance Attribute Summary collapse
-
#code_length ⇒ Object
Returns the value of attribute code_length.
-
#latitude_center ⇒ Object
Returns the value of attribute latitude_center.
-
#latitude_hi ⇒ Object
Returns the value of attribute latitude_hi.
-
#latitude_lo ⇒ Object
Returns the value of attribute latitude_lo.
-
#longitude_center ⇒ Object
Returns the value of attribute longitude_center.
-
#longitude_hi ⇒ Object
Returns the value of attribute longitude_hi.
-
#longitude_lo ⇒ Object
Returns the value of attribute longitude_lo.
Instance Method Summary collapse
-
#initialize(latitude_lo, longitude_lo, latitude_hi, longitude_hi, code_length) ⇒ CodeArea
constructor
A new instance of CodeArea.
-
#set_center ⇒ Object
Calculate center latitude and longitude.
Constructor Details
#initialize(latitude_lo, longitude_lo, latitude_hi, longitude_hi, code_length) ⇒ CodeArea
Returns a new instance of CodeArea.
13 14 15 16 17 18 19 20 21 |
# File 'lib/open_location_code/code_area.rb', line 13 def initialize(latitude_lo, longitude_lo, latitude_hi, longitude_hi, code_length) @latitude_lo = latitude_lo @longitude_lo = longitude_lo @latitude_hi = latitude_hi @longitude_hi = longitude_hi @code_length = code_length set_center end |
Instance Attribute Details
#code_length ⇒ Object
Returns the value of attribute code_length.
11 12 13 |
# File 'lib/open_location_code/code_area.rb', line 11 def code_length @code_length end |
#latitude_center ⇒ Object
Returns the value of attribute latitude_center.
11 12 13 |
# File 'lib/open_location_code/code_area.rb', line 11 def latitude_center @latitude_center end |
#latitude_hi ⇒ Object
Returns the value of attribute latitude_hi.
10 11 12 |
# File 'lib/open_location_code/code_area.rb', line 10 def latitude_hi @latitude_hi end |
#latitude_lo ⇒ Object
Returns the value of attribute latitude_lo.
10 11 12 |
# File 'lib/open_location_code/code_area.rb', line 10 def latitude_lo @latitude_lo end |
#longitude_center ⇒ Object
Returns the value of attribute longitude_center.
11 12 13 |
# File 'lib/open_location_code/code_area.rb', line 11 def longitude_center @longitude_center end |
#longitude_hi ⇒ Object
Returns the value of attribute longitude_hi.
10 11 12 |
# File 'lib/open_location_code/code_area.rb', line 10 def longitude_hi @longitude_hi end |
#longitude_lo ⇒ Object
Returns the value of attribute longitude_lo.
10 11 12 |
# File 'lib/open_location_code/code_area.rb', line 10 def longitude_lo @longitude_lo end |
Instance Method Details
#set_center ⇒ Object
Calculate center latitude and longitude
26 27 28 29 |
# File 'lib/open_location_code/code_area.rb', line 26 def set_center @latitude_center = [ latitude_lo + (latitude_hi - latitude_lo) / 2.0, LATITUDE_MAX].min @longitude_center = [ longitude_lo + (longitude_hi - longitude_lo)/ 2.0, LONGITUDE_MAX].min end |