Package cds.moc

Class Moc2D

All Implemented Interfaces:
Cloneable, Comparable<Moc>, Iterable<MocCell>
Direct Known Subclasses:
STMoc

public abstract class Moc2D extends Moc
The Moc2D class implements the methods specific to two-dimensional MOCs (e.g. TIME.SPACE).
  • Field Details

    • range

      public Range2 range
    • protoDim1

      protected Moc1D protoDim1
    • protoDim2

      protected Moc1D protoDim2
    • MASK_T

      public static long MASK_T
      Binary utilities
    • UNMASK_T

      public static long UNMASK_T
  • Constructor Details

    • Moc2D

      protected Moc2D(Moc1D protoDim1, Moc1D protoDim2)
      Generic Moc 2D creator
  • Method Details

    • toDebug

      public String toDebug()
      Specified by:
      toDebug in class Moc
    • lowAscii

      protected String lowAscii(int n)
      Display the n first ranges at the max order
    • maxOrder1

      public int maxOrder1()
      Return the deepest possible order for the first dimension (ex: 61 for TMoc)
    • maxOrder2

      public int maxOrder2()
      Return the deepest possible order for the second dimension (ex: 29 for SMoc)
    • shiftOrder1

      public int shiftOrder1()
      Return the number of bit shifting between two consecutive orders for the first dimension (ex: 1 for TMoc)
    • shiftOrder2

      public int shiftOrder2()
      Return the number of bit shifting between two consecutive orders for the second dimension (ex: 2 for SMoc)
    • cDim1

      public char cDim1()
      Return the Moc signature character for the first dimension (ex: 't' for TMoc)
    • cDim2

      public char cDim2()
      Return the Moc signature character for the second dimension (ex: 's' for SMoc
    • seeRangeList

      public Range seeRangeList()
      Acces to the list of ranges (no copy)
      Specified by:
      seeRangeList in class Moc
    • setRangeList

      public void setRangeList(Range range)
      Set the list of ranges - Warning: no copy
      Specified by:
      setRangeList in class Moc
    • getMocOrder1

      public int getMocOrder1()
      Return the Moc order of the first dimension
    • getMocOrder2

      public int getMocOrder2()
      Return the Moc order of the second dimension
    • setMocOrder

      public void setMocOrder(int order1, int order2) throws Exception
      Set Moc orders of the first and the second dimension simultaneously (fastest than in two steps)
      Throws:
      Exception
    • setMocOrder1

      public void setMocOrder1(int order1) throws Exception
      Set Moc order of the first dimension
      Throws:
      Exception
    • setMocOrder2

      public void setMocOrder2(int order2) throws Exception
      Set Moc order of the second dimension
      Throws:
      Exception
    • getStart1

      public long getStart1(int order, long val)
      Returns the value of the beginning of the interval expressed at the maximum order (first dimension)
    • getEnd1

      public long getEnd1(int order, long val)
      Returns the value of the end of the interval (excluded) expressed at the maximum order (first dimension)
    • getStart2

      public long getStart2(int order, long val)
      Returns the value of the beginning of the interval expressed at the maximum order (second dimension)
    • getEnd2

      public long getEnd2(int order, long val)
      Returns the value of the end of the interval (excluded) expressed at the maximum order (second dimension)
    • add

      public void add(long val1, long val2, Range r)
    • add

      public void add(int order1, long val1, int order2, long val2) throws Exception
      Add one cell to the Moc2D.
      Parameters:
      order1 - Order of the cell (first dimension)
      val1 - Value of the cell (first dimension)
      order2 - Order of the cell (second dimension)
      val2 - Value of the cell (second dimension)
      Throws:
      Exception
    • add

      public void add(int order1, long firstVal1, long lastVal1, int order2, long firstVal2, long lastVal2) throws Exception
      Add a list of consecutive Moc cells.
      Parameters:
      order1 - Order of the cells (first dimension)
      firstVal1 - First value (first dimension)
      lastVal1 - Last value (included) (first dimension)
      order2 - Order of the cells (second dimension)
      firstVal2 - First value (second dimension)
      lastVal2 - Last value (included) (second dimension)
      Throws:
      Exception
    • equals

      public boolean equals(Object o)
      Return true in case of equality (only check data - no properties, nor MocOrder)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • clone1

      protected void clone1(Moc moc) throws CloneNotSupportedException
      Deep copy. The source is this, the target is the Moc in parameter
      Overrides:
      clone1 in class Moc
      Throws:
      CloneNotSupportedException
    • isEmpty

      public boolean isEmpty()
      Return true if the Moc is empty (no coverage)
      Specified by:
      isEmpty in class Moc
    • isFull

      public boolean isFull()
      Return true if the Moc is full (full coverage)
      Specified by:
      isFull in class Moc
    • getCoverage

      public double getCoverage()
      Return the coverage pourcentage of the Moc
      Specified by:
      getCoverage in class Moc
    • computeHierarchy

      protected void computeHierarchy()
      Recalculates the metrics associated with the MOC hierarchical view: the number of hierarchical cells, the deepest order used...
      Specified by:
      computeHierarchy in class Moc
    • getNbRanges

      public int getNbRanges()
      Return the number of ranges - first dimension
      Specified by:
      getNbRanges in class Moc
    • getMem

      public long getMem()
      Return approximatively the amount of memory used for storing this MOC in RAM (in bytes)
      Specified by:
      getMem in class Moc
    • clear

      public void clear()
      Clear the MOC - data only (not the properties, nor the mocOrder)
      Overrides:
      clear in class Moc
    • reduction

      public boolean reduction(long maxSize) throws Exception
      Degrades the resolution(s) of the MOC until the RAM size of the MOC is reduced under the specified maximum (expressed in bytes).
      Specified by:
      reduction in class Moc
      Throws:
      Exception
    • reduction

      public boolean reduction(long maxMB, String priority) throws Exception
      Degrades the resolution(s) of the MOC until the RAM size of the MOC is reduced under the specified maximum (expressed in bytes).
      Parameters:
      maxMB - size max in MB
      priority - Indicates the dimensions to be degraded as a priority in the form of a list of the dimension's signature characters ex: "t" for time only, "s" space only, "st"-both alternatively, space first (default), "ttts", ...
      Throws:
      Exception
    • isCompatible

      public boolean isCompatible(Moc moc)
      Return true if the moc is compatible for operation (same sys)
      Specified by:
      isCompatible in class Moc
    • operation

      protected Moc2D operation(Moc moc, int op) throws Exception
      Generic operations: 0-union, 1-intersection, 2-subtraction
      Specified by:
      operation in class Moc
      Throws:
      Exception
    • writeASCII

      public void writeASCII(OutputStream out) throws Exception
      Write MOC to an output stream in ASCII serialization
      Specified by:
      writeASCII in class Moc
      Throws:
      Exception
    • writeJSON

      public void writeJSON(OutputStream out) throws Exception
      Write MOC to an output stream in JSON serialization (non IVOA standard)
      Specified by:
      writeJSON in class Moc
      Throws:
      Exception
    • sizeOfCoding

      public int sizeOfCoding()
      Return the number of bytes used for coding each FITS value (=> always long)
      Specified by:
      sizeOfCoding in class Moc
    • getNbCoding

      public int getNbCoding()
      Return the number of values to write in FITS serialization
      Specified by:
      getNbCoding in class Moc
    • cellIterator

      public Iterator<MocCell> cellIterator(boolean flagRange)
      Provide an Iterator on the MOC cell List (range highest order architecture for Moc2D)
      Specified by:
      cellIterator in class Moc
      Parameters:
      flagRange - not use for Moc2D
      Returns:
      mocCell => dim,order,startVal,endVal,Moc1D
    • isCodedTime

      protected boolean isCodedTime(long a)
    • codeTime

      protected long codeTime(long a)
    • decodeTime

      protected long decodeTime(long a)
    • isCodedDim1

      protected abstract boolean isCodedDim1(long a)
    • codeDim1

      protected abstract long codeDim1(long a)
    • decodeDim1

      protected abstract long decodeDim1(long a)
    • writeSpecificDataRange

      public int writeSpecificDataRange(OutputStream out, int mode) throws Exception
      Write Moc2D data in Ranges
      Specified by:
      writeSpecificDataRange in class Moc
      Parameters:
      out - output stream
      mode - RAW or COMP_SINGLETON
      Returns:
      number of bytes written
      Throws:
      Exception
    • readSpecificDataRange

      public void readSpecificDataRange(int nval, byte[] t, int mode) throws Exception
      Create Moc2D from the list of fits values
      Specified by:
      readSpecificDataRange in class Moc
      Throws:
      Exception
    • flush

      public void flush()
      ASCII invalid input: '&' JSON parser
      Specified by:
      flush in class Moc
    • addToken

      protected void addToken(String token) throws Exception
      Description copied from class: Moc
      Internal usage: Add one token element according to the format "[s|t]order/npix[-npixn]". If the order is not mentioned, use the last used order (currentOrder) Note: Also support JSON non standard IVOA syntax
      Specified by:
      addToken in class Moc
      Parameters:
      token - one token (ex: s18/23-45)
      Throws:
      Exception