Class Area

java.lang.Object
uk.ac.starlink.ttools.Area

public class Area extends Object
Coordinate value representing a two-dimensional shaped area. Instances of this class can be serialized to a plot tuple element. The shape is defined by a numeric code (Type enum) and a numeric array, so that it can be easily de/serialised.

Currently no distinction is made in this class between shapes on a 2-d plane and on the surface of a sphere; instances of this class may be interpreted in either context as required.

Since:
27 Mar 2020
Author:
Mark Taylor
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    Available shape types.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Area(Area.Type type, double[] dataArray)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Area
    Creates a multishape area from a list of other areas.
    static Area[]
    deserializeMultishape(double[] data)
    Converts a numeric representation of a MULTISHAPE into a list of Area instances.
    double[]
    Returns the numeric array that in conjunction with the type code defines the coverage of this shape.
    Returns the type of this shape.
    static double[]
    Converts a list of Area instances into its MULTISHAPE numeric array serialization.
    long[]
    toMocUniqs(int level)
    Returns an array of UNIQ values corresponding to this shape for a given maximum HEALPix level.
    void
    writePlaneCoords2(double[] buffer)
    Writes the characteristic (typically central) position of this area to a buffer that can be interpreted as the positional coordinates in the data space of a plane plot (x, y values).
    void
    writeSkyCoords3(double[] buffer)
    Writes the characteristic (typically central) position of this area to a buffer that can be interpreted as the positional coordinates in the data space of a sky plot (3-element unit vector).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Area

      public Area(Area.Type type, double[] dataArray)
      Constructor.
      Parameters:
      type - area shape type
      dataArray - numeric array defining the actual shape of the area
  • Method Details

    • getType

      public Area.Type getType()
      Returns the type of this shape.
      Returns:
      shape type
    • getDataArray

      public double[] getDataArray()
      Returns the numeric array that in conjunction with the type code defines the coverage of this shape.
      Returns:
      shape definition array
    • writePlaneCoords2

      public void writePlaneCoords2(double[] buffer)
      Writes the characteristic (typically central) position of this area to a buffer that can be interpreted as the positional coordinates in the data space of a plane plot (x, y values).
      Parameters:
      buffer - output array for characteristic position, length >=2
    • writeSkyCoords3

      public void writeSkyCoords3(double[] buffer)
      Writes the characteristic (typically central) position of this area to a buffer that can be interpreted as the positional coordinates in the data space of a sky plot (3-element unit vector). If the input values are out of range, the 3 components of the returned vector will all be NaN.
      Parameters:
      buffer - output array for characteristic position, length >=3
    • toMocUniqs

      public long[] toMocUniqs(int level)
      Returns an array of UNIQ values corresponding to this shape for a given maximum HEALPix level. Tiles may be returned at a higher level than requested, but the result should be at at least that resolution.
      Parameters:
      level - required HEALPix resolution level
      Returns:
      array of MOC tile uniq values
    • serializeMultishape

      public static double[] serializeMultishape(Area[] areas)
      Converts a list of Area instances into its MULTISHAPE numeric array serialization.
      Parameters:
      areas - array of area instances that form the multishape
      Returns:
      array serialization
      See Also:
    • deserializeMultishape

      public static Area[] deserializeMultishape(double[] data)
      Converts a numeric representation of a MULTISHAPE into a list of Area instances.
      Parameters:
      data - array serialization of a MULTISHAPE
      Returns:
      list of decoded Area instances
      See Also:
    • createMultishape

      public static Area createMultishape(Area[] areas)
      Creates a multishape area from a list of other areas.
      Parameters:
      areas - list of subordinate areas
      Returns:
      new area with Type.MULTISHAPE, or null if there the areas list is null or empty