Class: Poke::API::Geometry::S2CellId
- Inherits:
-
Object
- Object
- Poke::API::Geometry::S2CellId
- Includes:
- S2Base
- Defined in:
- lib/poke-api/geometry/s2_cell_id.rb
Constant Summary
Constants included from S2Base
Poke::API::Geometry::S2Base::INVERT_MASK, Poke::API::Geometry::S2Base::LINEAR_PROJECTION, Poke::API::Geometry::S2Base::LOOKUP_BITS, Poke::API::Geometry::S2Base::LOOKUP_IJ, Poke::API::Geometry::S2Base::LOOKUP_POS, Poke::API::Geometry::S2Base::MAX_LEVEL, Poke::API::Geometry::S2Base::MAX_SIZE, Poke::API::Geometry::S2Base::NUM_FACES, Poke::API::Geometry::S2Base::POS_BITS, Poke::API::Geometry::S2Base::POS_TO_IJ, Poke::API::Geometry::S2Base::POS_TO_OR, Poke::API::Geometry::S2Base::QUADRATIC_PROJECTION, Poke::API::Geometry::S2Base::SWAP_MASK, Poke::API::Geometry::S2Base::TAN_PROJECTION
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id) ⇒ S2CellId
constructor
A new instance of S2CellId.
- #level ⇒ Object
- #next ⇒ Object
- #parent(level) ⇒ Object
- #prev ⇒ Object
Methods included from S2Base
Constructor Details
#initialize(id) ⇒ S2CellId
Returns a new instance of S2CellId.
8 9 10 |
# File 'lib/poke-api/geometry/s2_cell_id.rb', line 8 def initialize(id) @id = id end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/poke-api/geometry/s2_cell_id.rb', line 6 def id @id end |
Class Method Details
Instance Method Details
#level ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/poke-api/geometry/s2_cell_id.rb', line 28 def level return MAX_LEVEL if leaf? x = (@id & 0xffffffff) level = -1 if x != 0 level += 16 else x = ((@id >> 32) & 0xffffffff) end x &= -x level += 8 unless (x & 0x00005555).zero? level += 4 unless (x & 0x00550055).zero? level += 2 unless (x & 0x05050505).zero? level += 1 unless (x & 0x11111111).zero? level end |
#next ⇒ Object
24 25 26 |
# File 'lib/poke-api/geometry/s2_cell_id.rb', line 24 def next S2CellId.new(@id + (lsb << 1)) end |
#parent(level) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/poke-api/geometry/s2_cell_id.rb', line 12 def parent(level) new_lsb = lsb_for_level(level) s2 = S2CellId.new((@id & -new_lsb) | new_lsb) raise Errors::InvalidLevel, level unless valid?(s2.id) s2 end |