Class NaturalNeighborElements


  • public class NaturalNeighborElements
    extends Object
    Provides a simple container for the component elements computed during a natural neighbor interpolation. This class is intended to support research and experimentation. This class is not used as part of the internal operations in the NaturalNeighborInterpolator implementation.

    Interpreting the results If the query is successful, the result type element will be set to SUCCESS. In that case, the interpolated value can be computed as shown in the following example code. This logic is similar to what is used internally by the interpolator.

    
       NaturalNeighborInterpolator nni;  //  defined by application code
       NaturalNeighborElements result = nni.getNaturalNeighborElements(x, y);
       if(result.getResultType() == ResultType.SUCCESS){
          // the weight and neighbor arrays will be of the same length
          double []weight   = result.getSibsonCoordinates();
          Vertex []neighbor = result.getNaturalNeighbors();
          double zSum = 0;
          for(int i=0; i<weight.length; i++){
             zSum += weight[i]*neighbor[i].getZ();
          }
          // zSum is the interpolated value
        }
     
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  NaturalNeighborElements.ResultType
      Indicate the kind of results that are stored in this instance.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      double x
      The Cartesian x coordinate for the query that produced this instance.
      double y
      The Cartesian y coordinate for the query that produced this instance.
    • Constructor Summary

      Constructors 
      Constructor Description
      NaturalNeighborElements​(double x, double y, double[] lambda, Vertex[] neighbors, double areaOfEmbeddedPolygon)
      Constructs a result indicating a successful query.
    • Field Detail

      • x

        public double x
        The Cartesian x coordinate for the query that produced this instance.
      • y

        public double y
        The Cartesian y coordinate for the query that produced this instance.
    • Constructor Detail

      • NaturalNeighborElements

        public NaturalNeighborElements​(double x,
                                       double y,
                                       double[] lambda,
                                       Vertex[] neighbors,
                                       double areaOfEmbeddedPolygon)
        Constructs a result indicating a successful query. The specified coordinates were located in the interior of the Delaunay triangulation.
        Parameters:
        x - the Cartesian coordinate of the query
        y - the Cartesian coordinate of the query
        lambda - the Sibson coordinates (weights) for the natural neighbors
        neighbors - the natural neighbors
        areaOfEmbeddedPolygon - the area of the polygon that would be formed if a point with the specified coordinates were inserted into the structure.
    • Method Detail

      • getSibsonCoordinates

        public double[] getSibsonCoordinates()
        Gets the weights that were computed for the neighboring vertices during the interpolation operation that produced these results. For performance reasons, this method returns a direct reference to the member elements of this class, not a safe-copy of the array.

        If the query point point was not inside the polygon, this method will return an empty, zero-sized array. If the point is on the perimeter of the polygon, this method will also return an empty array.

        If the query point point was co-located or nearly co-located with a vertex in the underlying Delaunay triangulation, this method will return an array of size 1.

        Returns:
        a valid array, potentially of length zero if interpolation was unsuccessful.
      • getNaturalNeighbors

        public Vertex[] getNaturalNeighbors()
        Gets the set of natural neighbors that were identified for the interpolation that produced these results. For performance reasons, this method returns a direct reference to the member elements of this class, not a safe-copy of the array.

        If the query point point was not inside the polygon, this method will return an empty, zero-sized array. If the point is on the perimeter of the polygon, this method will also return an empty array.

        If the query point point was co-located or nearly co-located with a vertex in the underlying Delaunay triangulation, this method will return an array of size 1.

        Returns:
        a valid array, potentially of length zero if interpolation was unsuccessful.
      • getX

        public double getX()
        Gets the Cartesian x coordinate that was specified for the interpolation
        Returns:
        a floating-point value
      • getY

        public double getY()
        Gets the Cartesian y coordinate that was specified for the interpolation
        Returns:
        a floating-point value
      • getAreaOfEnvelope

        public double getAreaOfEnvelope()
        Gets the area of the containing envelope from which natural neighbor coordinates were derived. This value is the overall area of the polygon defined by the set of natural neighbors.
        Returns:
        a positive, finite floating-point value.
      • getAreaOfEmbeddedPolygon

        public double getAreaOfEmbeddedPolygon()
        Gets the area of the embedded polygon that was calculated when the natural neighbor elements were constructed.
        Returns:
        a valid floating-point number.
      • getElementCount

        public int getElementCount()
        Gets a count for the number of elements (neighbors, Sibson coordinates).
        Returns:
        a positive integer, zero if undefined.