Class SimplePointInAreaLocator

java.lang.Object
org.locationtech.jts.algorithm.locate.SimplePointInAreaLocator
All Implemented Interfaces:
PointOnGeometryLocator

public class SimplePointInAreaLocator extends Object implements PointOnGeometryLocator
Computes the location of points relative to a Polygonal Geometry, using a simple O(n) algorithm. This algorithm is suitable for use in cases where only one or a few points will be tested against a given area.

The algorithm used is only guaranteed to return correct results for points which are not on the boundary of the Geometry.

Version:
1.7
  • Field Details

  • Constructor Details

    • SimplePointInAreaLocator

      public SimplePointInAreaLocator(Geometry geom)
  • Method Details

    • locate

      public static int locate(Coordinate p, Geometry geom)
      Determines the Location of a point in an areal Geometry. Computes
      invalid reference
      Location.BOUNDARY
      if the point lies exactly on a geometry line segment.
      Parameters:
      p - the point to test
      geom - the areal geometry to test
      Returns:
      the Location of the point in the geometry
    • locateInGeometry

      private static int locateInGeometry(Coordinate p, Geometry geom)
    • locatePointInPolygon

      public static int locatePointInPolygon(Coordinate p, Polygon poly)
      Determines the Location of a point in a Polygon. Computes
      invalid reference
      Location.BOUNDARY
      if the point lies exactly on the polygon boundary.
      Parameters:
      p - the point to test
      poly - the geometry to test
      Returns:
      the Location of the point in the polygon
    • containsPointInPolygon

      public static boolean containsPointInPolygon(Coordinate p, Polygon poly)
      Determines whether a point lies in a Polygon. If the point lies on the polygon boundary it is considered to be inside.
      Parameters:
      p - the point to test
      poly - the geometry to test
      Returns:
      true if the point lies in or on the polygon
    • locatePointInRing

      private static int locatePointInRing(Coordinate p, LinearRing ring)
      Determines whether a point lies in a LinearRing, using the ring envelope to short-circuit if possible.
      Parameters:
      p - the point to test
      ring - a linear ring
      Returns:
      true if the point lies inside the ring
    • locate

      public int locate(Coordinate p)
      Description copied from interface: PointOnGeometryLocator
      Determines the Location of a point in the Geometry.
      Specified by:
      locate in interface PointOnGeometryLocator
      Parameters:
      p - the point to test
      Returns:
      the location of the point in the geometry