public void testIsOverlaps() { assertTrue((new IntersectionMatrix("2*2***2**")).isOverlaps(P,P)); assertTrue((new IntersectionMatrix("2*2***2**")).isOverlaps(A,A)); assertTrue(! (new IntersectionMatrix("2*2***2**")).isOverlaps(P,A)); assertTrue(! (new IntersectionMatrix("2*2***2**")).isOverlaps(L,L)); assertTrue((new IntersectionMatrix("1*2***2**")).isOverlaps(L,L)); assertTrue(! (new IntersectionMatrix("0FFFFFFF2")).isOverlaps(P,P)); assertTrue(! (new IntersectionMatrix("1FFF0FFF2")).isOverlaps(L,L)); assertTrue(! (new IntersectionMatrix("2FFF1FFF2")).isOverlaps(A,A)); }
/** * Tests whether this geometry overlaps the * specified geometry. * <p> * The <code>overlaps</code> predicate has the following equivalent definitions: * <ul> * <li>The geometries have at least one point each not shared by the other * (or equivalently neither covers the other), * they have the same dimension, * and the intersection of the interiors of the two geometries has * the same dimension as the geometries themselves. * <li>The DE-9IM Intersection Matrix for the two geometries matches * <code>[T*T***T**]</code> (for two points or two surfaces) * or <code>[1*T***T**]</code> (for two curves) * </ul> * If the geometries are of different dimension this predicate returns <code>false</code>. * This predicate is symmetric. * *@param g the <code>Geometry</code> with which to compare this <code>Geometry</code> *@return <code>true</code> if the two <code>Geometry</code>s overlap. */ public boolean overlaps(Geometry g) { // short-circuit test if (! getEnvelopeInternal().intersects(g.getEnvelopeInternal())) return false; return relate(g).isOverlaps(getDimension(), g.getDimension()); }
@Override public <P extends C2D> boolean overlaps(final Geometry<P> geometry, final Geometry<P> other) { if (geometry.isEmpty() || other.isEmpty()) return Boolean.FALSE; checkCompatibleCRS(geometry, other); if (!envelopeIntersect(geometry, other)) return Boolean.FALSE; final RelateOp relateOp = new RelateOp(JTS.to(geometry), JTS.to(other)); return relateOp.getIntersectionMatrix().isOverlaps(geometry.getDimension(), other.getDimension()); }
setPredicate(withinAB, im.isWithin()); setPredicate(containsAB, im.isContains()); setPredicate(overlapsAB, im.isOverlaps(dimA, dimB)); setPredicate(coversAB, im.isCovers()); setPredicate(coveredByAB, im.isCoveredBy()); setPredicate(withinBA, imBA.isWithin()); setPredicate(containsBA, imBA.isContains()); setPredicate(overlapsBA, imBA.isOverlaps(dimB, dimA)); setPredicate(coversBA, imBA.isCovers()); setPredicate(coveredByBA, imBA.isCoveredBy());
public void doPredicates(Geometry a, Geometry b) throws Exception { assertTrue( a.contains(b) == a.relate(b).isContains() ); assertTrue( a.crosses(b) == a.relate(b).isCrosses(a.getDimension(), b.getDimension()) ); assertTrue( a.disjoint(b) == a.relate(b).isDisjoint() ); assertTrue( a.equals(b) == a.relate(b).isEquals(a.getDimension(), b.getDimension()) ); assertTrue( a.intersects(b) == a.relate(b).isIntersects() ); assertTrue( a.overlaps(b) == a.relate(b).isOverlaps(a.getDimension(), b.getDimension()) ); assertTrue( a.touches(b) == a.relate(b).isTouches(a.getDimension(), b.getDimension()) ); assertTrue( a.within(b) == a.relate(b).isWithin() ); }