Class S2.Metric

  • Enclosing class:
    S2

    public static class S2.Metric
    extends Object
    Defines an area or a length cell metric.
    • Constructor Summary

      Constructors 
      Constructor Description
      Metric​(int dim, double deriv)
      Defines a cell metric of the given dimension (1 == length, 2 == area).
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      double deriv()
      The "deriv" value of a metric is a derivative, and must be multiplied by a length or area in (s,t)-space to get a useful value.
      int getClosestLevel​(double value)
      Return the level at which the metric has approximately the given value.
      int getMaxLevel​(double value)
      Return the maximum level such that the metric is at least the given value, or zero if there is no such level.
      int getMinLevel​(double value)
      Return the minimum level such that the metric is at most the given value, or S2CellId::kMaxLevel if there is no such level.
      double getValue​(int level)
      Return the value of a metric for cells at the given level.
    • Constructor Detail

      • Metric

        public Metric​(int dim,
                      double deriv)
        Defines a cell metric of the given dimension (1 == length, 2 == area).
    • Method Detail

      • deriv

        public double deriv()
        The "deriv" value of a metric is a derivative, and must be multiplied by a length or area in (s,t)-space to get a useful value.
      • getValue

        public double getValue​(int level)
        Return the value of a metric for cells at the given level.
      • getClosestLevel

        public int getClosestLevel​(double value)
        Return the level at which the metric has approximately the given value. For example, S2::kAvgEdge.GetClosestLevel(0.1) returns the level at which the average cell edge length is approximately 0.1. The return value is always a valid level.
      • getMinLevel

        public int getMinLevel​(double value)
        Return the minimum level such that the metric is at most the given value, or S2CellId::kMaxLevel if there is no such level. For example, S2::kMaxDiag.GetMinLevel(0.1) returns the minimum level such that all cell diagonal lengths are 0.1 or smaller. The return value is always a valid level.
      • getMaxLevel

        public int getMaxLevel​(double value)
        Return the maximum level such that the metric is at least the given value, or zero if there is no such level. For example, S2.kMinWidth.GetMaxLevel(0.1) returns the maximum level such that all cells have a minimum width of 0.1 or larger. The return value is always a valid level.