Class: PlusCodes::CodeArea

Inherits:
Object
  • Object
show all
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.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(south_latitude, west_longitude, latitude_height, longitude_width) ⇒ CodeArea

Creates a [CodeArea].

Parameters:

  • south_latitude (Numeric)

    the latitude of the SW corner in degrees

  • west_longitude (Numeric)

    the longitude of the SW corner in degrees

  • latitude_height (Numeric)

    the height from the SW corner in degrees

  • longitude_width (Numeric)

    the width from the SW corner in degrees



20
21
22
23
24
25
26
27
# File 'lib/plus_codes/code_area.rb', line 20

def initialize(south_latitude, west_longitude, latitude_height, longitude_width)
  @south_latitude = south_latitude
  @west_longitude = west_longitude
  @latitude_height = latitude_height
  @longitude_width = longitude_width
  @latitude_center = south_latitude + latitude_height / 2.0
  @longitude_center = west_longitude + longitude_width / 2.0
end

Instance Attribute Details

#latitude_centerObject

Returns the value of attribute latitude_center.



10
11
12
# File 'lib/plus_codes/code_area.rb', line 10

def latitude_center
  @latitude_center
end

#latitude_heightObject

Returns the value of attribute latitude_height.



10
11
12
# File 'lib/plus_codes/code_area.rb', line 10

def latitude_height
  @latitude_height
end

#longitude_centerObject

Returns the value of attribute longitude_center.



10
11
12
# File 'lib/plus_codes/code_area.rb', line 10

def longitude_center
  @longitude_center
end

#longitude_widthObject

Returns the value of attribute longitude_width.



10
11
12
# File 'lib/plus_codes/code_area.rb', line 10

def longitude_width
  @longitude_width
end

#south_latitudeObject

Returns the value of attribute south_latitude.



10
11
12
# File 'lib/plus_codes/code_area.rb', line 10

def south_latitude
  @south_latitude
end

#west_longitudeObject

Returns the value of attribute west_longitude.



10
11
12
# File 'lib/plus_codes/code_area.rb', line 10

def west_longitude
  @west_longitude
end

Instance Method Details

#east_longitudeObject



33
34
35
# File 'lib/plus_codes/code_area.rb', line 33

def east_longitude
  @west_longitude + @longitude_width
end

#north_latitudeObject



29
30
31
# File 'lib/plus_codes/code_area.rb', line 29

def north_latitude
  @south_latitude + @latitude_height
end