Class PointInPolygon

java.lang.Object
com.geodesk.geom.PointInPolygon

public class PointInPolygon extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    isInside(int[] coords, double cx, double cy)
     
    static int
    testFast(int[] coords, double cx, double cy)
    Fast but non-robust point-in-polygon test using the ray-crossing method.
    static int
    testFast(com.geodesk.feature.store.StoredWay.XYIterator iter, double cx, double cy)
    Fast but non-robust point-in-polygon test using the ray-crossing method.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • PointInPolygon

      public PointInPolygon()
  • Method Details

    • isInside

      public static boolean isInside(int[] coords, double cx, double cy)
    • testFast

      public static int testFast(int[] coords, double cx, double cy)
      Fast but non-robust point-in-polygon test using the ray-crossing method. Points located on a polygon edge (or very close to it) may or may not be considered "inside." Vertexes, however, are always identified correctly. This test can be applied to multiple line strings of the polygon in succession. In that case, the result of each test must be XOR'd with the previous results.
      Parameters:
      coords - pairs of x/y coordinates that form a polygon or part thereof
      cx - the X-coordinate to test
      cy - the Y-coordinate to test
      Returns:
      0 if even number of edges are crossed ("not inside") 1 if odd number of edges are crossed ("inside") -1 if the candidate point corresponds to a vertex
    • testFast

      public static int testFast(com.geodesk.feature.store.StoredWay.XYIterator iter, double cx, double cy)
      Fast but non-robust point-in-polygon test using the ray-crossing method. Points located on a polygon edge (or very close to it) may or may not be considered "inside." Vertexes, however, are always identified correctly. This test can be applied to multiple line strings of the polygon in succession. In that case, the result of each test must be XOR'd with the previous results.
      Parameters:
      iter - an XY iterator (consumed by this method)
      cx - the X-coordinate to test
      cy - the Y-coordinate to test
      Returns:
      0 if even number of edges are crossed ("not inside") 1 if odd number of edges are crossed ("inside")