struct S2Cells::CellId
- S2Cells::CellId
- Struct
- Value
- Object
Included Modules
- Comparable(S2Cells::CellId)
Defined in:
s2_cells/cell_id.crConstant Summary
-
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
-
.from_face_ij_wrap(face : Int32, i : Int128, j : Int128) : CellId
Conversion of from_face_ij_wrap method
- .from_face_pos_level(face : Int, pos : UInt64, level : Int) : CellId
- .new(id : UInt64)
Class Method Summary
- .from_face_ij_same(face : Int32, i : Int128, j : Int128, same_face : Bool)
- .from_lat_lng(lat : Float64, lng : Float64)
- .from_lat_lng(lat : Angle, lng : Angle)
- .from_lat_lng(lat_lng : LatLng)
- .from_point(p : Point)
-
.from_token(token : String)
returns a cell given a hex-encoded string of its uint64 ID
- .lookup_bits(i, j, orig_orientation, pos, orientation)
- .lookup_cells(level, i, j, orig_orientation, pos, orientation)
- .lsb_for_level(level : Int)
- .max_angle_span
- .max_diag
- .max_edge
- .min_width
- .none
- .range_begin(level : Int)
- .range_end(level : Int)
- .st_to_ij(s : Float64) : UInt64
- .st_to_uv(s : Float64) : Float64
- .uv_to_st(u : Float64)
- .valid?(cell_id : CellId)
- .walk(level : Int, &)
Instance Method Summary
-
#<=>(other : CellId)
The comparison operator.
-
#==(other : CellId)
Compares this object to other based on the receiver’s
<=>
method, returningtrue
if it returns0
. - #child_begin(level : Int)
- #child_begin
- #child_end(level : Int)
- #child_end
- #children(level : Int32 | Nil = nil, &)
- #children(level : Int32 | Nil = nil) : Array(CellId)
-
#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
- #face : Int32
- #face?
- #get_all_neighbors(nbr_level : Int32 = self.level) : Array(CellId)
- #get_center_si_ti
- #get_center_uv
- #get_edge_neighbors : Array(CellId)
- #get_size_ij(level = self.level)
- #get_vertex_neighbors(level : Int32) : Array(CellId)
-
#hash : UInt64
Generates an
UInt64
hash value for this object. - #id : UInt64
- #intersects(other : CellId) : Bool
- #leaf?
- #level : Int32
- #lsb
- #next
- #parent(level : Int)
- #parent : CellId
- #pos : UInt64
- #prev
- #range_max
- #range_min
- #to_face_ij_orientation : Tuple(Int32, UInt64, UInt64, Int32)
- #to_lat_lng : LatLng
- #to_point : Point
- #to_point_raw : Point
-
#to_s(io : IO)
Same as
#inspect(io)
. -
#to_token : String
ToToken returns a hex-encoded string of the uint64 cell id, with leading zeros included but trailing zeros stripped.
- #valid?
Constructor Detail
Conversion of from_face_ij_wrap method
Class Method Detail
Instance Method Detail
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]
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.
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
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.
ToToken returns a hex-encoded string of the uint64 cell id, with leading zeros included but trailing zeros stripped.