/** * Returns whether the elements of this <code>IntersectionMatrix</code> * satisfies the required dimension symbols. * *@param requiredDimensionSymbols nine dimension symbols with which to * compare the elements of this <code>IntersectionMatrix</code>. Possible * values are <code>{T, F, * , 0, 1, 2}</code>. *@return <code>true</code> if this <code>IntersectionMatrix</code> * matches the required dimension symbols */ public boolean matches(String requiredDimensionSymbols) { if (requiredDimensionSymbols.length() != 9) { throw new IllegalArgumentException("Should be length 9: " + requiredDimensionSymbols); } for (int ai = 0; ai < 3; ai++) { for (int bi = 0; bi < 3; bi++) { if (!matches(matrix[ai][bi], requiredDimensionSymbols.charAt(3 * ai + bi))) { return false; } } } return true; }
/** * Tests if each of the actual dimension symbols in a matrix string satisfies the * corresponding required dimension symbol in a pattern string. * *@param actualDimensionSymbols nine dimension symbols to validate. * Possible values are <code>{T, F, * , 0, 1, 2}</code>. *@param requiredDimensionSymbols nine dimension symbols to validate * against. Possible values are <code>{T, F, * , 0, 1, 2}</code>. *@return true if each of the required dimension * symbols encompass the corresponding actual dimension symbol */ public static boolean matches(String actualDimensionSymbols, String requiredDimensionSymbols) { IntersectionMatrix m = new IntersectionMatrix(actualDimensionSymbols); return m.matches(requiredDimensionSymbols); }
/** * Tests whether the elements in the DE-9IM * {@link IntersectionMatrix} for the two <code>Geometry</code>s match the elements in <code>intersectionPattern</code>. * The pattern is a 9-character string, with symbols drawn from the following set: * <UL> * <LI> 0 (dimension 0) * <LI> 1 (dimension 1) * <LI> 2 (dimension 2) * <LI> T ( matches 0, 1 or 2) * <LI> F ( matches FALSE) * <LI> * ( matches any value) * </UL> * For more information on the DE-9IM, see the <i>OpenGIS Simple Features * Specification</i>. * *@param g the <code>Geometry</code> with which to compare * this <code>Geometry</code> *@param intersectionPattern the pattern against which to check the * intersection matrix for the two <code>Geometry</code>s *@return <code>true</code> if the DE-9IM intersection * matrix for the two <code>Geometry</code>s match <code>intersectionPattern</code> * @see IntersectionMatrix */ public boolean relate(Geometry g, String intersectionPattern) { return relate(g).matches(intersectionPattern); }
@Override public <P extends C2D> boolean relates(final Geometry<P> geometry, final Geometry<P> other, final String matrix) { if (geometry.isEmpty() || other.isEmpty()) return Boolean.FALSE; checkCompatibleCRS(geometry, other); final RelateOp relateOp = new RelateOp(JTS.to(geometry), JTS.to(other)); return relateOp.getIntersectionMatrix().matches(matrix); }
void runRelateTest(String wkt1, String wkt2, BoundaryNodeRule bnRule, String expectedIM) throws ParseException { Geometry g1 = rdr.read(wkt1); Geometry g2 = rdr.read(wkt2); IntersectionMatrix im = RelateOp.relate(g1, g2, bnRule); String imStr = im.toString(); //System.out.println(imStr); assertTrue(im.matches(expectedIM)); } }
void runRelateTest(String wkt1, String wkt2, String expectedIM) throws ParseException { Geometry g1 = rdr.read(wkt1); Geometry g2 = rdr.read(wkt2); IntersectionMatrix im = RelateOp.relate(g1, g2); String imStr = im.toString(); //System.out.println(imStr); assertTrue(im.matches(expectedIM)); } }
assertTrue(im.matches(expectedIM), msg);