Class S2.Metric

  • Enclosing class:
    S2

    @GwtCompatible(emulated=true,
                   serializable=false)
    public static final class S2.Metric
    extends java.lang.Object
    Defines an area or a length cell metric.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private double deriv  
      private int dim  
    • 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • deriv

        private final double deriv
      • dim

        private final int dim
    • 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.