Class: GeoHex::Polygon
- Inherits:
-
Struct
- Object
- Struct
- GeoHex::Polygon
- Defined in:
- lib/geo_hex/polygon.rb
Constant Summary collapse
- H_K =
Math.tan(Math::PI / 180.0 * 60)
Instance Attribute Summary collapse
-
#easting ⇒ Object
Returns the value of attribute easting.
-
#northing ⇒ Object
Returns the value of attribute northing.
-
#size ⇒ Object
Returns the value of attribute size.
Instance Method Summary collapse
-
#centroid ⇒ GeoHex::PP
(also: #c)
The Centroid of the Polygon.
-
#east ⇒ GeoHex::PP
(also: #e)
The East point of the Polygon.
-
#north ⇒ GeoHex::PP
(also: #n)
Point in the middle of the northern polygon boundary.
-
#north_east ⇒ GeoHex::PP
(also: #ne)
The Northeast point of the Polygon.
-
#north_west ⇒ GeoHex::PP
(also: #nw)
The Northwest point of the Polygon.
-
#points ⇒ Array<GeoHex::PP>
(also: #to_a)
All the points of the Polygon, ordered from Northeast round to Northwest.
-
#south ⇒ GeoHex::PP
(also: #s)
Point in the middle of the southern polygon boundary.
-
#south_east ⇒ GeoHex::PP
(also: #se)
The Southeast point of the Polygon.
-
#south_west ⇒ GeoHex::PP
(also: #sw)
The Southwest point of the Polygon.
-
#west ⇒ GeoHex::PP
(also: #w)
The West point of the Polygon.
Instance Attribute Details
#easting ⇒ Object
Returns the value of attribute easting
3 4 5 |
# File 'lib/geo_hex/polygon.rb', line 3 def easting @easting end |
#northing ⇒ Object
Returns the value of attribute northing
3 4 5 |
# File 'lib/geo_hex/polygon.rb', line 3 def northing @northing end |
#size ⇒ Object
Returns the value of attribute size
3 4 5 |
# File 'lib/geo_hex/polygon.rb', line 3 def size @size end |
Instance Method Details
#centroid ⇒ GeoHex::PP Also known as: c
Returns The Centroid of the Polygon.
7 8 9 |
# File 'lib/geo_hex/polygon.rb', line 7 def centroid @centroid ||= PP.new(easting, northing) end |
#east ⇒ GeoHex::PP Also known as: e
Returns The East point of the Polygon.
19 20 21 |
# File 'lib/geo_hex/polygon.rb', line 19 def east @east ||= PP.new(easting + 2 * size, northing) end |
#north ⇒ GeoHex::PP Also known as: n
Returns Point in the middle of the northern polygon boundary.
49 50 51 |
# File 'lib/geo_hex/polygon.rb', line 49 def north @north ||= PP.new(easting, north_bound) end |
#north_east ⇒ GeoHex::PP Also known as: ne
Returns The Northeast point of the Polygon.
13 14 15 |
# File 'lib/geo_hex/polygon.rb', line 13 def north_east @north_east ||= PP.new(east_bound, north_bound) end |
#north_west ⇒ GeoHex::PP Also known as: nw
Returns The Northwest point of the Polygon.
43 44 45 |
# File 'lib/geo_hex/polygon.rb', line 43 def north_west @north_west ||= PP.new(west_bound, north_bound) end |
#points ⇒ Array<GeoHex::PP> Also known as: to_a
Returns All the points of the Polygon, ordered from Northeast round to Northwest.
61 62 63 |
# File 'lib/geo_hex/polygon.rb', line 61 def points @points ||= [ne, e, se, sw, w, nw] end |
#south ⇒ GeoHex::PP Also known as: s
Returns Point in the middle of the southern polygon boundary.
55 56 57 |
# File 'lib/geo_hex/polygon.rb', line 55 def south @south ||= PP.new(easting, south_bound) end |
#south_east ⇒ GeoHex::PP Also known as: se
Returns The Southeast point of the Polygon.
25 26 27 |
# File 'lib/geo_hex/polygon.rb', line 25 def south_east @south_east ||= PP.new(east_bound, south_bound) end |
#south_west ⇒ GeoHex::PP Also known as: sw
Returns The Southwest point of the Polygon.
31 32 33 |
# File 'lib/geo_hex/polygon.rb', line 31 def south_west @south_west ||= PP.new(west_bound, south_bound) end |
#west ⇒ GeoHex::PP Also known as: w
Returns The West point of the Polygon.
37 38 39 |
# File 'lib/geo_hex/polygon.rb', line 37 def west @west ||= PP.new(easting - 2 * size, northing) end |