public boolean contains(Coordinate pt) { Coordinate[] ring = getCoordinates(); return PointLocation.isInRing(pt, ring); }
/** * Tests whether a point lies inside or on a ring. The ring may be oriented in * either direction. A point lying exactly on the ring boundary is considered * to be inside the ring. * <p> * This method does <i>not</i> first check the point against the envelope of * the ring. * * @param p * point to check for ring inclusion * @param ring * an array of coordinates representing the ring (which must have * first point identical to last point) * @return true if p is inside ring * * @see locatePointInRing */ public static boolean isInRing(Coordinate p, Coordinate[] ring) { return PointLocation.locateInRing(p, ring) != Location.EXTERIOR; }
void checkOnLine(double x, double y, String wktLine, boolean expected) { LineString line = (LineString) read(wktLine); assertTrue(expected == PointLocation.isOnLine(new Coordinate(x,y), line.getCoordinates())); assertTrue(expected == PointLocation.isOnLine(new Coordinate(x,y), line.getCoordinateSequence())); }
void checkOnLine(double x, double y, String wktLine, boolean expected) { LineString line = (LineString) read(wktLine); assertTrue(expected == PointLocation.isOnLine(new Coordinate(x,y), line.getCoordinates())); assertTrue(expected == PointLocation.isOnLine(new Coordinate(x,y), line.getCoordinateSequence())); }
public static boolean isPointInRing(Geometry g1, Geometry g2) { Geometry ring = g1; Geometry pt = g2; if (g1.getNumPoints() == 1) { ring = g2; pt = g1; } Coordinate[] ptsRing = OrientationFunctions.getRing(ring); if (ptsRing == null) return false; return PointLocation.isInRing(pt.getCoordinate(), ptsRing); }
private int locateOnLineString(Coordinate p, LineString l) { // bounding-box check if (! l.getEnvelopeInternal().intersects(p)) return Location.EXTERIOR; CoordinateSequence seq = l.getCoordinateSequence(); if (! l.isClosed()) { if (p.equals(seq.getCoordinate(0)) || p.equals(seq.getCoordinate(seq.size() - 1)) ) { return Location.BOUNDARY; } } if (PointLocation.isOnLine(p, seq)) { return Location.INTERIOR; } return Location.EXTERIOR; }
private int locateInPolygonRing(Coordinate p, LinearRing ring) { // bounding-box check if (! ring.getEnvelopeInternal().intersects(p)) return Location.EXTERIOR; return PointLocation.locateInRing(p, ring.getCoordinates()); }
/** * This method will cause the ring to be computed. * It will also check any holes, if they have been assigned. */ public boolean containsPoint(Coordinate p) { LinearRing shell = getLinearRing(); Envelope env = shell.getEnvelopeInternal(); if (! env.contains(p)) return false; if (! PointLocation.isInRing(p, shell.getCoordinates()) ) return false; for (Iterator i = holes.iterator(); i.hasNext(); ) { EdgeRing hole = (EdgeRing) i.next(); if (hole.containsPoint(p) ) return false; } return true; }
public void testA() { Coordinate p1 = new Coordinate(-123456789, -40); Coordinate p2 = new Coordinate(381039468754763d, 123456789); Coordinate q = new Coordinate(0, 0); LineString l = new GeometryFactory().createLineString(new Coordinate[] {p1, p2}); Point p = new GeometryFactory().createPoint(q); assertEquals(false, l.intersects(p)); assertEquals(false, PointLocation.isOnLine(q, new Coordinate[] {p1, p2})); assertEquals(-1, Orientation.index(p1, p2, q)); }
/** * Determines whether a point lies in a LinearRing, * using the ring envelope to short-circuit if possible. * * @param p the point to test * @param ring a linear ring * @return true if the point lies inside the ring */ private static int locatePointInRing(Coordinate p, LinearRing ring) { // short-circuit if point is not in ring envelope if (! ring.getEnvelopeInternal().intersects(p)) return Location.EXTERIOR; return PointLocation.locateInRing(p, ring.getCoordinates()); }
if (! PointLocation.isInRing(inputPts[i], polyPts)) { reducedSet.add(inputPts[i]);
protected void runPtInRing(int expectedLoc, Coordinate pt, String wkt) throws Exception { Geometry geom = reader.read(wkt); assertEquals(expectedLoc, PointLocation.locateInRing(pt, geom.getCoordinates())); }
|| PointLocation.isInRing(testHolePt, coordList) || pointInList(testHolePt, coordList)) isContained = true;
/** * Tests whether the point pt is contained in the triangle defined by 3 * {@link Vertex}es. * * @param tri * an array containing at least 3 Vertexes * @param pt * the point to test * @return true if the point is contained in the triangle */ public static boolean contains(Vertex[] tri, Coordinate pt) { Coordinate[] ring = new Coordinate[] { tri[0].getCoordinate(), tri[1].getCoordinate(), tri[2].getCoordinate(), tri[0].getCoordinate() }; return PointLocation.isInRing(pt, ring); }
continue; boolean isInside = PointLocation.isInRing(innerRingPt, searchRingPts); if (isInside) { nestedPt = innerRingPt;
protected void runPtInRing(int expectedLoc, Coordinate pt, String wkt) throws Exception { // isPointInRing is not defined for pts on boundary if (expectedLoc == Location.BOUNDARY) return; Geometry geom = reader.read(wkt); boolean expected = expectedLoc == Location.INTERIOR; assertEquals(expected, PointLocation.isInRing(pt, geom.getCoordinates())); }
/** * Tests whether the point pt is contained in the triangle defined by 3 * {@link QuadEdge}es. * * @param tri * an array containing at least 3 QuadEdges * @param pt * the point to test * @return true if the point is contained in the triangle */ public static boolean contains(QuadEdge[] tri, Coordinate pt) { Coordinate[] ring = new Coordinate[] { tri[0].orig().getCoordinate(), tri[1].orig().getCoordinate(), tri[2].orig().getCoordinate(), tri[0].orig().getCoordinate() }; return PointLocation.isInRing(pt, ring); }
public boolean isNonNested() { for (int i = 0; i < rings.size(); i++) { LinearRing innerRing = (LinearRing) rings.get(i); Coordinate[] innerRingPts = innerRing.getCoordinates(); for (int j = 0; j < rings.size(); j++) { LinearRing searchRing = (LinearRing) rings.get(j); Coordinate[] searchRingPts = searchRing.getCoordinates(); if (innerRing == searchRing) continue; if (! innerRing.getEnvelopeInternal().intersects(searchRing.getEnvelopeInternal())) continue; Coordinate innerRingPt = IsValidOp.findPtNotNode(innerRingPts, searchRing, graph); Assert.isTrue(innerRingPt != null, "Unable to find a ring point not a node of the search ring"); //Coordinate innerRingPt = innerRingPts[0]; boolean isInside = PointLocation.isInRing(innerRingPt, searchRingPts); if (isInside) { nestedPt = innerRingPt; return false; } } } return true; }
if (PointLocation.isInRing(testPt, tryShellRing.getCoordinates()) ) isContained = true;