public static SpatialRelation intersectionMatrixToSpatialRelation(IntersectionMatrix matrix) { //As indicated in SpatialRelation javadocs, Spatial4j CONTAINS & WITHIN are // OGC's COVERS & COVEREDBY if (matrix.isCovers()) return SpatialRelation.CONTAINS; else if (matrix.isCoveredBy()) return SpatialRelation.WITHIN; else if (matrix.isDisjoint()) return SpatialRelation.DISJOINT; return SpatialRelation.INTERSECTS; }
/** * Returns <code>true</code> if <code>isDisjoint</code> returns false. * *@return <code>true</code> if the two <code>Geometry</code>s related by * this <code>IntersectionMatrix</code> intersect */ public boolean isIntersects() { return ! isDisjoint(); }
public void testIsDisjoint() { assertTrue((new IntersectionMatrix("FF*FF****")).isDisjoint()); assertTrue((new IntersectionMatrix("FF1FF2T*0")).isDisjoint()); assertTrue(! (new IntersectionMatrix("*F*FF****")).isDisjoint()); }
setPredicate(disjointAB, im.isDisjoint()); setPredicate(intersectsAB, im.isIntersects()); setPredicate(touchesAB, im.isTouches(dimA, dimB)); setPredicate(disjointBA, imBA.isDisjoint()); setPredicate(intersectsBA, imBA.isIntersects()); setPredicate(touchesBA, imBA.isTouches(dimB, dimA));
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() ); }