Class: PlusCodes::CodeArea
- Inherits:
-
Object
- Object
- PlusCodes::CodeArea
- Defined in:
- lib/plus_codes/code_area.rb
Overview
- CodeArea
-
contains coordinates of a decoded Open Location Code(Plus+Codes).
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. Attributes:
latitude_lo: The latitude of the SW corner in degrees.
longitude_lo: The longitude of the SW corner in degrees.
latitude_hi: The latitude of the NE corner in degrees.
longitude_hi: The longitude of the NE corner in degrees.
latitude_center: The latitude of the center in degrees.
longitude_center: The longitude of the center in degrees.
code_length: The number of significant characters that were in the code.
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
Creates a [CodeArea].
- #to_s ⇒ Object
Constructor Details
#initialize(latitude_lo, longitude_lo, latitude_hi, longitude_hi, code_length) ⇒ CodeArea
Creates a [CodeArea].
28 29 30 31 32 33 34 35 36 |
# File 'lib/plus_codes/code_area.rb', line 28 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 @latitude_center = [@latitude_lo + (@latitude_hi - @latitude_lo) / 2, LATITUDE_MAX].min @longitude_center = [@longitude_lo + (@longitude_hi - @longitude_lo) / 2, LONGITUDE_MAX].min end |
Instance Attribute Details
#code_length ⇒ Object
Returns the value of attribute code_length.
17 18 19 |
# File 'lib/plus_codes/code_area.rb', line 17 def code_length @code_length end |
#latitude_center ⇒ Object
Returns the value of attribute latitude_center.
17 18 19 |
# File 'lib/plus_codes/code_area.rb', line 17 def latitude_center @latitude_center end |
#latitude_hi ⇒ Object
Returns the value of attribute latitude_hi.
17 18 19 |
# File 'lib/plus_codes/code_area.rb', line 17 def latitude_hi @latitude_hi end |
#latitude_lo ⇒ Object
Returns the value of attribute latitude_lo.
17 18 19 |
# File 'lib/plus_codes/code_area.rb', line 17 def latitude_lo @latitude_lo end |
#longitude_center ⇒ Object
Returns the value of attribute longitude_center.
17 18 19 |
# File 'lib/plus_codes/code_area.rb', line 17 def longitude_center @longitude_center end |
#longitude_hi ⇒ Object
Returns the value of attribute longitude_hi.
17 18 19 |
# File 'lib/plus_codes/code_area.rb', line 17 def longitude_hi @longitude_hi end |
#longitude_lo ⇒ Object
Returns the value of attribute longitude_lo.
17 18 19 |
# File 'lib/plus_codes/code_area.rb', line 17 def longitude_lo @longitude_lo end |
Instance Method Details
#to_s ⇒ Object
38 39 40 |
# File 'lib/plus_codes/code_area.rb', line 38 def to_s "lat_lo: #{@latitude_lo} long_lo: #{@longitude_lo} lat_hi: #{@latitude_hi} long_hi: #{@longitude_hi} code_len: #{@code_length}" end |