/** * Returns <code>true</code> if this <code>IntersectionMatrix</code> is * FT*******, F**T***** or F***T****. * *@param dimensionOfGeometryA the dimension of the first <code>Geometry</code> *@param dimensionOfGeometryB the dimension of the second <code>Geometry</code> *@return <code>true</code> if the two <code>Geometry</code> * s related by this <code>IntersectionMatrix</code> touch; Returns false * if both <code>Geometry</code>s are points. */ public boolean isTouches(int dimensionOfGeometryA, int dimensionOfGeometryB) { if (dimensionOfGeometryA > dimensionOfGeometryB) { //no need to get transpose because pattern matrix is symmetrical return isTouches(dimensionOfGeometryB, dimensionOfGeometryA); } if ((dimensionOfGeometryA == Dimension.A && dimensionOfGeometryB == Dimension.A) || (dimensionOfGeometryA == Dimension.L && dimensionOfGeometryB == Dimension.L) || (dimensionOfGeometryA == Dimension.L && dimensionOfGeometryB == Dimension.A) || (dimensionOfGeometryA == Dimension.P && dimensionOfGeometryB == Dimension.A) || (dimensionOfGeometryA == Dimension.P && dimensionOfGeometryB == Dimension.L)) { return matrix[Location.INTERIOR][Location.INTERIOR] == Dimension.FALSE && (isTrue(matrix[Location.INTERIOR][Location.BOUNDARY]) || isTrue(matrix[Location.BOUNDARY][Location.INTERIOR]) || isTrue(matrix[Location.BOUNDARY][Location.BOUNDARY])); } return false; }
/** * Tests whether this geometry touches the * argument geometry. * <p> * The <code>touches</code> predicate has the following equivalent definitions: * <ul> * <li>The geometries have at least one point in common, but their interiors do not intersect. * <li>The DE-9IM Intersection Matrix for the two geometries matches * at least one of the following patterns * <ul> * <li><code>[FT*******]</code> * <li><code>[F**T*****]</code> * <li><code>[F***T****]</code> * </ul> * </ul> * If both geometries have dimension 0, this predicate returns <code>false</code>. * * *@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 touch; * Returns <code>false</code> if both <code>Geometry</code>s are points */ public boolean touches(Geometry g) { // short-circuit test if (! getEnvelopeInternal().intersects(g.getEnvelopeInternal())) return false; return relate(g).isTouches(getDimension(), g.getDimension()); }
/** * Returns <code>true</code> if this <code>IntersectionMatrix</code> is * FT*******, F**T***** or F***T****. * *@param dimensionOfGeometryA the dimension of the first <code>Geometry</code> *@param dimensionOfGeometryB the dimension of the second <code>Geometry</code> *@return <code>true</code> if the two <code>Geometry</code> * s related by this <code>IntersectionMatrix</code> touch; Returns false * if both <code>Geometry</code>s are points. */ public boolean isTouches(int dimensionOfGeometryA, int dimensionOfGeometryB) { if (dimensionOfGeometryA > dimensionOfGeometryB) { //no need to get transpose because pattern matrix is symmetrical return isTouches(dimensionOfGeometryB, dimensionOfGeometryA); } if ((dimensionOfGeometryA == Dimension.A && dimensionOfGeometryB == Dimension.A) || (dimensionOfGeometryA == Dimension.L && dimensionOfGeometryB == Dimension.L) || (dimensionOfGeometryA == Dimension.L && dimensionOfGeometryB == Dimension.A) || (dimensionOfGeometryA == Dimension.P && dimensionOfGeometryB == Dimension.A) || (dimensionOfGeometryA == Dimension.P && dimensionOfGeometryB == Dimension.L)) { return matrix[Location.INTERIOR][Location.INTERIOR] == Dimension.FALSE && (isTrue(matrix[Location.INTERIOR][Location.BOUNDARY]) || isTrue(matrix[Location.BOUNDARY][Location.INTERIOR]) || isTrue(matrix[Location.BOUNDARY][Location.BOUNDARY])); } return false; }
return relate(g).isTouches(getDimension(), g.getDimension());