public void testIsCrosses() { assertTrue((new IntersectionMatrix("TFTFFFFFF")).isCrosses(P,L)); assertTrue(! (new IntersectionMatrix("TFTFFFFFF")).isCrosses(L,P)); assertTrue(! (new IntersectionMatrix("TFFFFFTFF")).isCrosses(P,L)); assertTrue((new IntersectionMatrix("TFFFFFTFF")).isCrosses(L,P)); assertTrue((new IntersectionMatrix("0FFFFFFFF")).isCrosses(L,L)); assertTrue(! (new IntersectionMatrix("1FFFFFFFF")).isCrosses(L,L)); }
/** * Tests whether this geometry crosses the * argument geometry. * <p> * The <code>crosses</code> predicate has the following equivalent definitions: * <ul> * <li>The geometries have some but not all interior points in common. * <li>The DE-9IM Intersection Matrix for the two geometries matches * one of the following patterns: * <ul> * <li><code>[T*T******]</code> (for P/L, P/A, and L/A situations) * <li><code>[T*****T**]</code> (for L/P, A/P, and A/L situations) * <li><code>[0********]</code> (for L/L situations) * </ul> * </ul> * For any other combination of dimensions this predicate returns <code>false</code>. * <p> * The SFS defined this predicate only for P/L, P/A, L/L, and L/A situations. * In order to make the relation symmetric, * JTS extends the definition to apply to L/P, A/P and A/L situations as well. * *@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 cross. */ public boolean crosses(Geometry g) { // short-circuit test if (! getEnvelopeInternal().intersects(g.getEnvelopeInternal())) return false; return relate(g).isCrosses(getDimension(), g.getDimension()); }
@Override public <P extends C2D> boolean crosses(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().isCrosses(geometry.getDimension(), other.getDimension()); }
setPredicate(intersectsAB, im.isIntersects()); setPredicate(touchesAB, im.isTouches(dimA, dimB)); setPredicate(crossesAB, im.isCrosses(dimA, dimB)); setPredicate(withinAB, im.isWithin()); setPredicate(containsAB, im.isContains()); setPredicate(intersectsBA, imBA.isIntersects()); setPredicate(touchesBA, imBA.isTouches(dimB, dimA)); setPredicate(crossesBA, imBA.isCrosses(dimB, dimA)); setPredicate(withinBA, imBA.isWithin()); setPredicate(containsBA, imBA.isContains());
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() ); }