struct S2Cells::CellId

Included Modules

Defined in:

s2_cells/cell_id.cr

Constant 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

Class Method Summary

Instance Method Summary

Constructor Detail

def self.from_face_ij(face : Int32, i : Int128 | UInt64, j : Int128 | UInt64) : CellId #

[View source]
def self.from_face_ij_wrap(face : Int32, i : Int128, j : Int128) : CellId #

Conversion of from_face_ij_wrap method


[View source]
def self.from_face_pos_level(face : Int, pos : UInt64, level : Int) : CellId #

[View source]
def self.new(id : UInt64) #

[View source]

Class Method Detail

def self.from_face_ij_same(face : Int32, i : Int128, j : Int128, same_face : Bool) #

[View source]
def self.from_lat_lng(lat : Float64, lng : Float64) #

[View source]
def self.from_lat_lng(lat : Angle, lng : Angle) #

[View source]
def self.from_lat_lng(lat_lng : LatLng) #

[View source]
def self.from_point(p : Point) #

[View source]
def self.from_token(token : String) #

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


[View source]
def self.lookup_bits(i, j, orig_orientation, pos, orientation) #

[View source]
def self.lookup_cells(level, i, j, orig_orientation, pos, orientation) #

[View source]
def self.lsb_for_level(level : Int) #

[View source]
def self.max_angle_span #

[View source]
def self.max_diag #

[View source]
def self.max_edge #

[View source]
def self.min_width #

[View source]
def self.none #

[View source]
def self.range_begin(level : Int) #

[View source]
def self.range_end(level : Int) #

[View source]
def self.st_to_ij(s : Float64) : UInt64 #

[View source]
def self.st_to_uv(s : Float64) : Float64 #

[View source]
def self.uv_to_st(u : Float64) #

[View source]
def self.valid?(cell_id : CellId) #

[View source]
def self.walk(level : Int, &) #

[View source]

Instance Method Detail

def <=>(other : CellId) #
Description copied from module Comparable(S2Cells::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]

[View source]
def ==(other : CellId) #
Description copied from module Comparable(S2Cells::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.


[View source]
def child_begin(level : Int) #

[View source]
def child_begin #

[View source]
def child_end(level : Int) #

[View source]
def child_end #

[View source]
def children(level : Int32 | Nil = nil, &) #

[View source]
def children(level : Int32 | Nil = nil) : Array(CellId) #

[View source]
def 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


[View source]
def face : Int32 #

[View source]
def face? #

[View source]
def get_all_neighbors(nbr_level : Int32 = self.level) : Array(CellId) #

[View source]
def get_center_si_ti #

[View source]
def get_center_uv #

[View source]
def get_edge_neighbors : Array(CellId) #

[View source]
def get_size_ij(level = self.level) #

[View source]
def get_vertex_neighbors(level : Int32) : Array(CellId) #

[View source]
def hash : UInt64 #
Description copied from class Object

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.


[View source]
def id : UInt64 #

[View source]
def intersects(other : CellId) : Bool #

[View source]
def leaf? #

[View source]
def level : Int32 #

[View source]
def lsb #

[View source]
def next #

[View source]
def parent(level : Int) #

[View source]
def parent : CellId #

[View source]
def pos : UInt64 #

[View source]
def prev #

[View source]
def range_max #

[View source]
def range_min #

[View source]
def to_face_ij_orientation : Tuple(Int32, UInt64, UInt64, Int32) #

[View source]
def to_lat_lng : LatLng #

[View source]
def to_point : Point #

[View source]
def to_point_raw : Point #

[View source]
def to_s(io : IO) #
Description copied from struct Struct

Same as #inspect(io).


[View source]
def to_token : String #

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


[View source]
def valid? #

[View source]