org.apache.lucene.spatial.util

## Class GeoRelationUtils

- java.lang.Object
- - org.apache.lucene.spatial.util.GeoRelationUtils

-     public class GeoRelationUtils
      extends Object

  Reusable geo-relation utility methods

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static boolean` | `pointInPolygon(double[] x, double[] y, double lat, double lon)` simple even-odd point in polygon computation 1.
    `static boolean` | `pointInRectPrecise(double lon, double lat, double minLon, double minLat, double maxLon, double maxLat)` Determine if a bbox (defined by minLon, minLat, maxLon, maxLat) contains the provided point (defined by lon, lat) NOTE: this is a basic method that does not handle dateline or pole crossing.
    `static boolean` | `rectContains(double aMinX, double aMinY, double aMaxX, double aMaxY, double bMinX, double bMinY, double bMaxX, double bMaxY)` Computes whether rectangle a contains rectangle b (touching allowed)
    `static boolean` | `rectCrosses(double aMinX, double aMinY, double aMaxX, double aMaxY, double bMinX, double bMinY, double bMaxX, double bMaxY)` Computes whether two rectangles cross
    `static boolean` | `rectCrossesCircle(double rMinX, double rMinY, double rMaxX, double rMaxY, double centerLon, double centerLat, double radiusMeters)` Determine if a bbox (defined by minLon, minLat, maxLon, maxLat) contains the provided point (defined by lon, lat) NOTE: this is basic method that does not handle dateline or pole crossing.
    `static boolean` | `rectCrossesCircle(double rMinX, double rMinY, double rMaxX, double rMaxY, double centerLon, double centerLat, double radiusMeters, boolean approx)` Computes whether a rectangle crosses a circle.
    `static boolean` | `rectCrossesOblateCircle(double centerLon, double centerLat, double radiusMeters, double rMinLon, double rMinLat, double rMaxLon, double rMaxLat)` Compute whether the rectangle (defined by min/max Lon/Lat) crosses a potentially oblate circle TODO benchmark for replacing existing rectCrossesCircle.
    `static boolean` | `rectCrossesPolyApprox(double rMinX, double rMinY, double rMaxX, double rMaxY, double[] shapeX, double[] shapeY, double sMinX, double sMinY, double sMaxX, double sMaxY)` Compute whether a rectangle crosses a shape.
    `static boolean` | `rectCrossesPolyPrecise(double rMinX, double rMinY, double rMaxX, double rMaxY, double[] shapeX, double[] shapeY, double sMinX, double sMinY, double sMaxX, double sMaxY)` Convenience method for accurately computing whether a rectangle crosses a poly
    `static boolean` | `rectDisjoint(double aMinX, double aMinY, double aMaxX, double aMaxY, double bMinX, double bMinY, double bMaxX, double bMaxY)` Computes whether two rectangles are disjoint
    `static boolean` | `rectIntersects(double aMinX, double aMinY, double aMaxX, double aMaxY, double bMinX, double bMinY, double bMaxX, double bMaxY)` Computes whether a rectangle intersects another rectangle (crosses, within, touching, etc)
    `static boolean` | `rectWithin(double aMinX, double aMinY, double aMaxX, double aMaxY, double bMinX, double bMinY, double bMaxX, double bMaxY)` Computes whether the first (a) rectangle is wholly within another (b) rectangle (shared boundaries allowed)
    `static boolean` | `rectWithinCircle(double rMinX, double rMinY, double rMaxX, double rMaxY, double centerLon, double centerLat, double radiusMeters)` Convenience method for computing whether a rectangle is within a circle using additional precision checks
    `static boolean` | `rectWithinCircle(double rMinX, double rMinY, double rMaxX, double rMaxY, double centerLon, double centerLat, double radiusMeters, boolean approx)` Computes whether a rectangle is within a circle.
    `static boolean` | `rectWithinPolyApprox(double rMinX, double rMinY, double rMaxX, double rMaxY, double[] shapeX, double[] shapeY, double sMinX, double sMinY, double sMaxX, double sMaxY)` Computes whether a rectangle is within a given polygon (shared boundaries allowed)
    `static boolean` | `rectWithinPolyPrecise(double rMinX, double rMinY, double rMaxX, double rMaxY, double[] shapeX, double[] shapeY, double sMinX, double sMinY, double sMaxX, double sMaxY)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### pointInRectPrecise

          public static boolean pointInRectPrecise(double lon,
                                   double lat,
                                   double minLon,
                                   double minLat,
                                   double maxLon,
                                   double maxLat)

      Determine if a bbox (defined by minLon, minLat, maxLon, maxLat) contains the provided point (defined by lon, lat) NOTE: this is a basic method that does not handle dateline or pole crossing. Unwrapping must be done before calling this method.

    - #### pointInPolygon

          public static boolean pointInPolygon(double[] x,
                               double[] y,
                               double lat,
                               double lon)

      simple even-odd point in polygon computation 1. Determine if point is contained in the longitudinal range 2. Determine whether point crosses the edge by computing the latitudinal delta between the end-point of a parallel vector (originating at the point) and the y-component of the edge sink NOTE: Requires polygon point (x,y) order either clockwise or counter-clockwise

    - #### rectDisjoint

          public static boolean rectDisjoint(double aMinX,
                             double aMinY,
                             double aMaxX,
                             double aMaxY,
                             double bMinX,
                             double bMinY,
                             double bMaxX,
                             double bMaxY)

      Computes whether two rectangles are disjoint

    - #### rectWithin

          public static boolean rectWithin(double aMinX,
                           double aMinY,
                           double aMaxX,
                           double aMaxY,
                           double bMinX,
                           double bMinY,
                           double bMaxX,
                           double bMaxY)

      Computes whether the first (a) rectangle is wholly within another (b) rectangle (shared boundaries allowed)

    - #### rectCrosses

          public static boolean rectCrosses(double aMinX,
                            double aMinY,
                            double aMaxX,
                            double aMaxY,
                            double bMinX,
                            double bMinY,
                            double bMaxX,
                            double bMaxY)

      Computes whether two rectangles cross

    - #### rectContains

          public static boolean rectContains(double aMinX,
                             double aMinY,
                             double aMaxX,
                             double aMaxY,
                             double bMinX,
                             double bMinY,
                             double bMaxX,
                             double bMaxY)

      Computes whether rectangle a contains rectangle b (touching allowed)

    - #### rectIntersects

          public static boolean rectIntersects(double aMinX,
                               double aMinY,
                               double aMaxX,
                               double aMaxY,
                               double bMinX,
                               double bMinY,
                               double bMaxX,
                               double bMaxY)

      Computes whether a rectangle intersects another rectangle (crosses, within, touching, etc)

    - #### rectCrossesPolyPrecise

          public static boolean rectCrossesPolyPrecise(double rMinX,
                                       double rMinY,
                                       double rMaxX,
                                       double rMaxY,
                                       double[] shapeX,
                                       double[] shapeY,
                                       double sMinX,
                                       double sMinY,
                                       double sMaxX,
                                       double sMaxY)

      Convenience method for accurately computing whether a rectangle crosses a poly

    - #### rectCrossesPolyApprox

          public static boolean rectCrossesPolyApprox(double rMinX,
                                      double rMinY,
                                      double rMaxX,
                                      double rMaxY,
                                      double[] shapeX,
                                      double[] shapeY,
                                      double sMinX,
                                      double sMinY,
                                      double sMaxX,
                                      double sMaxY)

      Compute whether a rectangle crosses a shape. (touching not allowed) Includes a flag for approximating the relation.

    - #### rectWithinPolyPrecise

          public static boolean rectWithinPolyPrecise(double rMinX,
                                      double rMinY,
                                      double rMaxX,
                                      double rMaxY,
                                      double[] shapeX,
                                      double[] shapeY,
                                      double sMinX,
                                      double sMinY,
                                      double sMaxX,
                                      double sMaxY)

    - #### rectWithinPolyApprox

          public static boolean rectWithinPolyApprox(double rMinX,
                                     double rMinY,
                                     double rMaxX,
                                     double rMaxY,
                                     double[] shapeX,
                                     double[] shapeY,
                                     double sMinX,
                                     double sMinY,
                                     double sMaxX,
                                     double sMaxY)

      Computes whether a rectangle is within a given polygon (shared boundaries allowed)

    - #### rectCrossesOblateCircle

          public static boolean rectCrossesOblateCircle(double centerLon,
                                        double centerLat,
                                        double radiusMeters,
                                        double rMinLon,
                                        double rMinLat,
                                        double rMaxLon,
                                        double rMaxLat)

      Compute whether the rectangle (defined by min/max Lon/Lat) crosses a potentially oblate circle TODO benchmark for replacing existing rectCrossesCircle.

    - #### rectWithinCircle

          public static boolean rectWithinCircle(double rMinX,
                                 double rMinY,
                                 double rMaxX,
                                 double rMaxY,
                                 double centerLon,
                                 double centerLat,
                                 double radiusMeters)

      Convenience method for computing whether a rectangle is within a circle using additional precision checks

    - #### rectWithinCircle

          public static boolean rectWithinCircle(double rMinX,
                                 double rMinY,
                                 double rMaxX,
                                 double rMaxY,
                                 double centerLon,
                                 double centerLat,
                                 double radiusMeters,
                                 boolean approx)

      Computes whether a rectangle is within a circle. Note: approx == true will be faster but less precise and may fail on large rectangles

    - #### rectCrossesCircle

          public static boolean rectCrossesCircle(double rMinX,
                                  double rMinY,
                                  double rMaxX,
                                  double rMaxY,
                                  double centerLon,
                                  double centerLat,
                                  double radiusMeters)

      Determine if a bbox (defined by minLon, minLat, maxLon, maxLat) contains the provided point (defined by lon, lat) NOTE: this is basic method that does not handle dateline or pole crossing. Unwrapping must be done before calling this method.

    - #### rectCrossesCircle

          public static boolean rectCrossesCircle(double rMinX,
                                  double rMinY,
                                  double rMaxX,
                                  double rMaxY,
                                  double centerLon,
                                  double centerLat,
                                  double radiusMeters,
                                  boolean approx)

      Computes whether a rectangle crosses a circle. Note: approx == true will be faster but less precise and may fail on large rectangles

Copyright © 2000-2017 Apache Software Foundation. All Rights Reserved.