/** * Tests whether the point lies in or on * the ring, polygon * or multipolygon from which the processed segments were provided. * <p> * This method only determines the correct location * if <b>all</b> relevant segments must have been processed. * * @return true if the point lies in or on the supplied polygon */ public boolean isPointInPolygon() { return getLocation() != Location.EXTERIOR; } }
/** * Determines the {@link Location} of a point in a ring. * This method is an exemplar of how to use this class. * * @param p the point to test * @param ring an array of Coordinates forming a ring * @return the location of the point in the ring */ public static int locatePointInRing(Coordinate p, Coordinate[] ring) { RayCrossingCounter counter = new RayCrossingCounter(p); for (int i = 1; i < ring.length; i++) { Coordinate p1 = ring[i]; Coordinate p2 = ring[i-1]; counter.countSegment(p1, p2); if (counter.isOnSegment()) return counter.getLocation(); } return counter.getLocation(); }
/** * Determines the {@link Location} of a point in an areal {@link Geometry}. * * @param p the point to test * @return the location of the point in the geometry */ public int locate(Coordinate p) { RayCrossingCounter rcc = new RayCrossingCounter(p); SegmentVisitor visitor = new SegmentVisitor(rcc); index.query(p.y, p.y, visitor); /* // MD - slightly slower alternative List segs = index.query(p.y, p.y); countSegs(rcc, segs); */ return rcc.getLocation(); }
/** * Determines the {@link Location} of a point in a ring. * * @param p * the point to test * @param ring * a coordinate sequence forming a ring * @return the location of the point in the ring */ public static int locatePointInRing(Coordinate p, CoordinateSequence ring) { RayCrossingCounter counter = new RayCrossingCounter(p); Coordinate p1 = new Coordinate(); Coordinate p2 = new Coordinate(); for (int i = 1; i < ring.size(); i++) { ring.getCoordinate(i, p1); ring.getCoordinate(i - 1, p2); counter.countSegment(p1, p2); if (counter.isOnSegment()) return counter.getLocation(); } return counter.getLocation(); }
public int locate(Coordinate p) { RayCrossingCounter rcc = new RayCrossingCounter(p); RayCrossingSegmentFilter filter = new RayCrossingSegmentFilter(rcc); geom.apply(filter); return rcc.getLocation(); }
/** * Determines the {@link Location} of a point in an areal {@link Geometry}. * * @param p the point to test * @return the location of the point in the geometry */ public int locate(Coordinate p) { RayCrossingCounter rcc = new RayCrossingCounter(p); MCSegmentCounter mcSegCounter = new MCSegmentCounter(rcc); Envelope rayEnv = new Envelope(p.x, maxXExtent, p.y, p.y); List mcs = index.query(rayEnv); countSegs(rcc, rayEnv, mcs, mcSegCounter); return rcc.getLocation(); }