Package cds.healpix

Class HealpixNestedBMOC

java.lang.Object
cds.healpix.HealpixNestedBMOC
All Implemented Interfaces:
Iterable<HealpixNestedBMOC.CurrentValueAccessor>

public final class HealpixNestedBMOC extends Object implements Iterable<HealpixNestedBMOC.CurrentValueAccessor>
A BMOC is a MOC storing for each element a binary value telling if the cell is PARTIALY or FULLY covered by a region.
Internally, a long is made of bits:
BBBBxx...xxS00...00F if depth < depthMax
BBBBxx...xxxx...xxSF if depth = dephtMax
With:
  • B: the 4 bits coding the base hash [0- 11]
  • xx: the 2 bits of level x
  • S: the sentinel bit coding the depth
  • 00: if (depth != depthMax) those bits are unused bits
  • F; the flag bit (0: partial, 1: full)
WARNING: not tested yet at depth 29, may not work because of Java signed long (all 64 bits of a long are used: 62 + 1 sentinel + 1 flag)
Author:
F.-X. Pineau
  • Method Details

    • toDeeperDepth

      public HealpixNestedBMOC toDeeperDepth(int newDepth)
      Returns a new BMOC having a deeper depth.
      Parameters:
      newDepth - the depeht of the wanted new BMOC
      Returns:
      a new BMOC having a deeper depth.
    • toLowerDepth

      public HealpixNestedBMOC toLowerDepth(int newDepth)
    • size

      public int size()
      Returns the number of elements the moc contains, i.e. the number of cells at various depth.
      Returns:
      the number of elements the moc contains, i.e. the number of cells at various depth.
    • computeDeepSize

      public long computeDeepSize()
      Returns the number of cells at depth getDepthMax() the moc contains, i.e. the sum for each cell of the number of cells at depth getDepthMax().
      Returns:
      the number of cells at depth getDepthMax() the moc contains, i.e. the sum for each cell of the number of cells at depth getDepthMax().
    • createUnsafe

      public static HealpixNestedBMOC createUnsafe(int mocDepth, long[] mocCells)
      Create a MOC considering that the given array is already a MOC: i.e. it is sorted (ASC order) and do not contains duplicate or small cells included into larger one's. WARNING: the array is used internally, so it must not be modified by an external reference! use Arrays.copy() is you are not sure!
      Parameters:
      mocDepth - the depth of the MOC
      mocCells - the array representation of the MOC
      Returns:
      the MOC object storing internally the array
    • createUnsafe

      public static HealpixNestedBMOC createUnsafe(int mocDepth, long[] mocCells, int toIndex)
      Same as createUnsafe(int, long[]) except that not we do not use the full array.
      Parameters:
      mocDepth - the depth of the MOC
      mocCells - the array representation of the MOC
      toIndex - the index of the last element (exclusive) to be considered in the moc
      Returns:
      the MOC object storing internally the array
    • createCheck

      public static HealpixNestedBMOC createCheck(int mocDepth, long[] mocCells)
      Same a createUnsafe(int, long[]) except that the properties (array sorted, no duplicates, no cell included into an other one) is checked.
      Parameters:
      mocDepth - the depth of the MOC
      mocCells - the array representation of the MOC
      Returns:
      the MOC object storing internally the array
    • createCheck

      public static HealpixNestedBMOC createCheck(int mocDepth, long[] mocCells, int toIndex)
      Same as createCheck(int, long[]) except that not we do not use the full array.
      Parameters:
      mocDepth - the depth of the MOC
      mocCells - the array representation of the MOC
      toIndex - the index of the last element (exclusive) to be considered in the moc
      Returns:
      the MOC object storing internally the array
    • createPacking

      public static HealpixNestedBMOC createPacking(int mocDepth, long[] mocCells)
    • createPacking

      public static HealpixNestedBMOC createPacking(int mocDepth, long[] mocCells, int toIndex)
      We assume here that the given array is ordered, that no element overlaps another one, but that the MOC is not normalized, i.e. a large cell may be splitted in 4 sub-cell (each sub-cell possibly splitted in its 4 sub-cells recursively).
      Parameters:
      mocDepth - depth of the moc
      mocCells - ordered list of cells
      toIndex - index of the last cell to be read in the given array of cells
      Returns:
      a new moc from the input parameters, packing if necessary.
    • getDepthMax

      public int getDepthMax()
      Returns the BMOC deeper depth.
      Returns:
      the BMOC deeper depth.
    • status

      public HealpixNestedBMOC.Status status(int depth, long hash)
      Returns the status of the given hash at the given depth
      Parameters:
      depth - depth of the hash we want the status
      hash - hash for which we want the status
      Returns:
      the status of the given hash at the given depth
    • buildValue

      public static final long buildValue(int depth, long hash, boolean isFull, int depthMax)
      Creates a specific hash encoding the hash value at the given depth, the depth and the status flag.
      Parameters:
      depth - depth of the hash.
      hash - value of the hash.
      isFull - flag telling if the cell is fully covered or not.
      depthMax - maximum depth of the MOC the value will belong to.
      Returns:
      a BMOC encoded hash value with its depth and status flag.
    • iterator

      Specified by:
      iterator in interface Iterable<HealpixNestedBMOC.CurrentValueAccessor>
    • rangeIterator

      public Iterator<Range> rangeIterator()
      An Iterator over hash Ranges at order 29.
      Returns:
      an Iterator over hash Ranges at order 29.
    • flatHashIterator

      public FlatHashIterator flatHashIterator()
      Returns an iterator on all the cells in the BMOC at the maximum depth.
      Returns:
      an iterator on all the cells in the BMOC at the maximum depth.