Class: S2Cells::S2LatLon
- Inherits:
-
Object
- Object
- S2Cells::S2LatLon
- Defined in:
- lib/s2_cells/s2_lat_lon.rb
Instance Method Summary collapse
-
#initialize(lat_degrees, lon_degrees) ⇒ S2LatLon
constructor
A new instance of S2LatLon.
- #to_point ⇒ Object
- #to_s2_id(level) ⇒ Object
Constructor Details
#initialize(lat_degrees, lon_degrees) ⇒ S2LatLon
Returns a new instance of S2LatLon.
5 6 7 8 |
# File 'lib/s2_cells/s2_lat_lon.rb', line 5 def initialize(lat_degrees, lon_degrees) @lat = lat_degrees * Math::PI / 180 @lon = lon_degrees * Math::PI / 180 end |
Instance Method Details
#to_point ⇒ Object
10 11 12 13 14 15 |
# File 'lib/s2_cells/s2_lat_lon.rb', line 10 def to_point phi = @lat theta = @lon cosphi = Math.cos(phi) S2Point.new(Math.cos(theta) * cosphi, Math.sin(theta) * cosphi, Math.sin(phi)) end |
#to_s2_id(level) ⇒ Object
17 18 19 20 21 |
# File 'lib/s2_cells/s2_lat_lon.rb', line 17 def to_s2_id(level) S2CellId.from_point(to_point) .parent(level) .signed_id end |