struct

S2Cells::CellId

Inherits Comparable < Struct < Value < Object

Constants

FACE_BITS = 3
MAX_LEVEL = 30
MAX_SIZE = 1_u64 << MAX_LEVEL
MAX_SIZE_I = MAX_SIZE.to_i128
NUM_FACES = 6
POS_BITS = (2 * MAX_LEVEL) + 1
WRAP_OFFSET = NUM_FACES << POS_BITS

Constructors

from_face_ij(face : Int32, i : Int128 | UInt64, j : Int128 | UInt64) : CellId
Source
from_face_ij_wrap(face : Int32, i : Int128, j : Int128) : CellId

Conversion of from_face_ij_wrap method

Source
from_face_pos_level(face : Int, pos : UInt64, level : Int) : CellId
Source
new(id : UInt64)
Source

Class methods

from_face_ij_same(face : Int32, i : Int128, j : Int128, same_face : Bool)
Source
from_lat_lng(lat : Float64, lng : Float64)
Source
from_lat_lng(lat : Angle, lng : Angle)
Source
from_lat_lng(lat_lng : LatLng)
Source
from_point(p : Point)
Source
from_token(token : String)

returns a cell given a hex-encoded string of its uint64 ID

Source
lookup_bits(i, j, orig_orientation, pos, orientation)
Source
lookup_cells(level, i, j, orig_orientation, pos, orientation)
Source
lsb_for_level(level : Int)
Source
max_angle_span
Source
max_diag
Source
max_edge
Source
min_width
Source
none
Source
range_begin(level : Int)
Source
range_end(level : Int)
Source
st_to_ij(s : Float64) : UInt64
Source
st_to_uv(s : Float64) : Float64
Source
uv_to_st(u : Float64)
Source
valid?(cell_id : CellId)
Source
walk(level : Int, &)
Source

Instance methods

<=>(other : CellId)

The comparison operator. Returns 0 if the two objects are equal, a negative number if this object is considered less than other, a positive number if this object is considered greater than other, or nil if the two objects are not comparable.

Subclasses define this method to provide class-specific ordering.

The comparison operator is usually used to sort values:

# Sort in a descending way:
[3, 1, 2].sort { |x, y| y <=> x } # => [3, 2, 1]

# Sort in an ascending way:
[3, 1, 2].sort { |x, y| x <=> y } # => [1, 2, 3]
Source
==(other : CellId)

Compares this object to other based on the receiver’s <=> method, returning true if it returns 0.

Also returns true if this and other are the same object.

Source
child_begin(level : Int)
Source
child_begin
Source
child_end(level : Int)
Source
child_end
Source
children(level : Int32 | Nil = nil, &)
Source
children(level : Int32 | Nil = nil) : Array(CellId)
Source
contains(other : CellId) : Bool

def child(pos : Int) raise "Invalid cell id" unless valid? raise "Child position out of range" if leaf? new_lsb = lsb >> 2 self.class.new(@id &+ (2 * pos + 1 - 4) &* new_lsb) end

Source
face
Source
face?
Source
get_all_neighbors(nbr_level : Int32 = self.level) : Array(CellId)
Source
get_center_si_ti
Source
get_center_uv
Source
get_edge_neighbors
Source
get_size_ij(level = self.level)
Source
get_vertex_neighbors(level : Int32) : Array(CellId)
Source
hash

Generates an UInt64 hash value for this object.

This method must have the property that a == b implies a.hash == b.hash.

The hash value is used along with == by the Hash class to determine if two objects reference the same hash key.

Subclasses must not override this method. Instead, they must define hash(hasher), though usually the macro def_hash can be used to generate this method.

Source
intersects(other : CellId) : Bool
Source
leaf?
Source
level
Source
next
Source
parent(level : Int)
Source
parent
Source
prev
Source
range_max
Source
range_min
Source
to_face_ij_orientation
Source
to_lat_lng
Source
to_point
Source
to_point_raw
Source
to_s(io : IO)

Same as #inspect(io).

Source
to_token

ToToken returns a hex-encoded string of the uint64 cell id, with leading zeros included but trailing zeros stripped.

Source
valid?
Source