class Geospatial::Index

This class represents a n-dimentional index. @param axes Point in n-space, e.g. [3, 7]. @param bits Number of bits to use for each axis, e.g. 8.

Attributes

axes[R]
bits[R]

Public Class Methods

from_integral(integral, width, bits) click to toggle source
# File lib/geospatial/index.rb, line 34
def self.from_integral(integral, width, bits)
        self.new(Interleave.unmap(integral, width), bits)
end
new(axes, bits) click to toggle source
# File lib/geospatial/index.rb, line 29
def initialize(axes, bits)
        @axes = axes
        @bits = bits
end

Public Instance Methods

&(mask) click to toggle source
# File lib/geospatial/index.rb, line 41
def & mask
        self.class.new(axes.collect{|axis| axis & mask}, @bits)
end
bit_length() click to toggle source
# File lib/geospatial/index.rb, line 57
def bit_length
        @axes.size * @bits
end
eql?(other) click to toggle source
# File lib/geospatial/index.rb, line 49
def eql?(other)
        self.class.eql?(other.class) and @axes.eql?(other.axes) and @bits.eql?(other.bits)
end
hash() click to toggle source
# File lib/geospatial/index.rb, line 45
def hash
        @axes.hash
end
inspect() click to toggle source
# File lib/geospatial/index.rb, line 61
def inspect
        i = self.to_i
        "\#<#{self.class}[#{@bits}] 0b#{i.to_s(2).rjust(bit_length, '0')} (#{i}) #{@axes.inspect}>"
end
to_i() click to toggle source
# File lib/geospatial/index.rb, line 53
def to_i
        Interleave.map(@axes, @bits)
end