/** * 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); }
public void run() throws ParseException { GeometryFactory fact = new GeometryFactory(); WKTReader wktRdr = new WKTReader(fact); String wktA = "POLYGON((40 100, 40 20, 120 20, 120 100, 40 100))"; String wktB = "LINESTRING(20 80, 80 60, 100 140)"; Geometry A = wktRdr.read(wktA); Geometry B = wktRdr.read(wktB); Geometry C = A.intersection(B); System.out.println("A = " + A); System.out.println("B = " + B); System.out.println("A intersection B = " + C); System.out.println("A relate C = " + A.relate(B)); }
/** * Default implementation. */ public boolean containsProperly(Geometry g) { // since raw relate is used, provide some optimizations // short-circuit test if (! baseGeom.getEnvelopeInternal().contains(g.getEnvelopeInternal())) return false; // otherwise, compute using relate mask return baseGeom.relate(g, "T**FF*FF*"); }
return relate(g).isCovers();
/** * 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>. * *@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()); }
/** * 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()); }
static public boolean relatePattern(Geometry arg0,Geometry arg1,String arg2) { Geometry _this = arg0; return _this.relate(arg1,arg2); }
/** * 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()); }
return relate(g).isEquals(getDimension(), g.getDimension());
static public boolean relatePattern(Geometry arg0,Geometry arg1,String arg2) { if (arg0 == null || arg1 == null || arg2 == null) return false; Geometry _this = arg0; return _this.relate(arg1,arg2); }
return relate(g).isContains();
return relate(g).isIntersects();
/** * @param a Geometry Geometry. * @param b Geometry instance * @return 9-character String representation of the 2 geometries IntersectionMatrix */ public static String relate(Geometry a,Geometry b) { if(a==null || b==null) { return null; } return a.relate(b).toString(); }
static public String relate(Geometry arg0,Geometry arg1) { if (arg0 == null || arg1 == null) return null; Geometry _this = arg0; return _this.relate(arg1).toString(); }
static public String relate(Geometry arg0,Geometry arg1) { Geometry _this = arg0; return _this.relate(arg1).toString(); }
public static Boolean relate(GeometryType geom1, GeometryType geom2, String intersectionPattern) throws FunctionExecutionException { Geometry g1 = getGeometry(geom1); Geometry g2 = getGeometry(geom2); return g1.relate(g2, intersectionPattern); }
public static Boolean relate(GeometryType geom1, GeometryType geom2, String intersectionPattern) throws FunctionExecutionException { Geometry g1 = getGeometry(geom1); Geometry g2 = getGeometry(geom2); return g1.relate(g2, intersectionPattern); }
public static Boolean relate(GeometryType geom1, GeometryType geom2, String intersectionPattern) throws FunctionExecutionException { Geometry g1 = getGeometry(geom1); Geometry g2 = getGeometry(geom2); return g1.relate(g2, intersectionPattern); }
/** * Default implementation. */ public boolean containsProperly(Geometry g) { // since raw relate is used, provide some optimizations // short-circuit test if (! baseGeom.getEnvelopeInternal().contains(g.getEnvelopeInternal())) return false; // otherwise, compute using relate mask return baseGeom.relate(g, "T**FF*FF*"); }
@Override public Item item(final QueryContext qc, final InputInfo ii) throws QueryException { final Geometry geo1 = checkGeo(0, qc); final Geometry geo2 = checkGeo(1, qc); final byte[] matrix = toToken(exprs[2], qc); try { return Bln.get(geo1.relate(geo2, Token.string(matrix))); } catch(final IllegalArgumentException ex) { Util.debug(ex); throw GEO_ARG.get(info, matrix); } } }