Package cds.healpix
Class HealpixNestedBMOC
- java.lang.Object
-
- cds.healpix.HealpixNestedBMOC
-
- All Implemented Interfaces:
java.lang.Iterable<HealpixNestedBMOC.CurrentValueAccessor>
public final class HealpixNestedBMOC extends java.lang.Object implements java.lang.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)
- Author:
- F.-X. Pineau
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceHealpixNestedBMOC.CurrentValueAccessorProvides informations on the current element of the BMOC while iterating over it.static classHealpixNestedBMOC.StatusTells if an element of the MOC is covered or not by a region and, if covered, it tells is the element is partially or fully covered.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static longbuildValue(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.longcomputeDeepSize()Returns the number of cells at depthgetDepthMax()the moc contains, i.e.static HealpixNestedBMOCcreateCheck(int mocDepth, long[] mocCells)Same acreateUnsafe(int, long[])except that the properties (array sorted, no duplicates, no cell included into an other one) is checked.static HealpixNestedBMOCcreateCheck(int mocDepth, long[] mocCells, int toIndex)Same ascreateCheck(int, long[])except that not we do not use the full array.static HealpixNestedBMOCcreatePacking(int mocDepth, long[] mocCells)static HealpixNestedBMOCcreatePacking(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.static HealpixNestedBMOCcreateUnsafe(int mocDepth, long[] mocCells)Create a MOC considering that the given array is already a MOC: i.e.static HealpixNestedBMOCcreateUnsafe(int mocDepth, long[] mocCells, int toIndex)Same ascreateUnsafe(int, long[])except that not we do not use the full array.FlatHashIteratorflatHashIterator()Returns an iterator on all the cells in the BMOC at the maximum depth.intgetDepthMax()Returns the BMOC deeper depth.java.util.Iterator<HealpixNestedBMOC.CurrentValueAccessor>iterator()java.util.Iterator<Range>rangeIterator()An Iterator over hash Ranges at order 29.intsize()Returns the number of elements the moc contains, i.e.HealpixNestedBMOC.Statusstatut(int depth, long hash)Returns the status of the given hash at the given depthHealpixNestedBMOCtoDeeperDepth(int newDepth)Returns a new BMOC having a deeper depth.HealpixNestedBMOCtoLowerDepth(int newDepth)
-
-
-
Method Detail
-
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 depthgetDepthMax()the moc contains, i.e. the sum for each cell of the number of cells at depthgetDepthMax().- Returns:
- the number of cells at depth
getDepthMax()the moc contains, i.e. the sum for each cell of the number of cells at depthgetDepthMax().
-
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! useArrays.copy()is you are not sure!- Parameters:
mocDepth- the depth of the MOCmocCells- 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 ascreateUnsafe(int, long[])except that not we do not use the full array.- Parameters:
mocDepth- the depth of the MOCmocCells- the array representation of the MOCtoIndex- 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 acreateUnsafe(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 MOCmocCells- 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 ascreateCheck(int, long[])except that not we do not use the full array.- Parameters:
mocDepth- the depth of the MOCmocCells- the array representation of the MOCtoIndex- 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 mocmocCells- ordered list of cellstoIndex- 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.
-
statut
public HealpixNestedBMOC.Status statut(int depth, long hash)
Returns the status of the given hash at the given depth- Parameters:
depth- depth of the hash we want the statushash- 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
public java.util.Iterator<HealpixNestedBMOC.CurrentValueAccessor> iterator()
- Specified by:
iteratorin interfacejava.lang.Iterable<HealpixNestedBMOC.CurrentValueAccessor>
-
rangeIterator
public java.util.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.
-
-