本文整理了Java中org.locationtech.jts.geom.Geometry.contains()
方法的一些代码示例,展示了Geometry.contains()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Geometry.contains()
方法的具体详情如下:
包路径:org.locationtech.jts.geom.Geometry
类名称:Geometry
方法名:contains
[英]Tests whether this geometry contains the argument geometry.
The contains
predicate has the following equivalent definitions:
[T*****FF*]
g.within(this) = true
contains
is the converse of #within )B.contains(A) = false
. (As a concrete example, take A to be a LineString which lies in the boundary of a Polygon B.) For a predicate with similar behaviour but avoiding this subtle limitation, see #covers.contains
谓词具有以下等效定义:[T*****FF*]
匹配g.within(this) = true
contains
是#in的反义词)B.contains(A) = false
。(作为一个具体的例子,假设a是一个位于多边形B边界的线字符串。)对于具有类似行为但避免这种微妙限制的谓词,请参见#covers。代码示例来源:origin: geotools/geotools
public static boolean contains(Geometry arg0, Geometry arg1) {
if (arg0 == null || arg1 == null) return false;
Geometry _this = arg0;
return _this.contains(arg1);
}
代码示例来源:origin: geotools/geotools
public boolean contains(Geometry g) {
return geometry.contains(g);
}
代码示例来源:origin: geotools/geotools
/**
* Tests if the interior of the <code>Shape</code> entirely contains the specified <code>
* Rectangle2D</code>. This method might conservatively return <code>false</code> when:
*
* <ul>
* <li>the <code>intersect</code> method returns <code>true</code> and
* <li>the calculations to determine whether or not the <code>Shape</code> entirely contains
* the <code>Rectangle2D</code> are prohibitively expensive.
* </ul>
*
* This means that this method might return <code>false</code> even though the <code>Shape
* </code> contains the <code>Rectangle2D</code>. The <code>Area</code> class can be used to
* perform more accurate computations of geometric intersection for any <code>Shape</code>
* object if a more precise answer is required.
*
* @param r The specified <code>Rectangle2D</code>
* @return <code>true</code> if the interior of the <code>Shape</code> entirely contains the
* <code>Rectangle2D</code>; <code>false</code> otherwise or, if the <code>Shape</code>
* contains the <code>Rectangle2D</code> and the <code>intersects</code> method returns
* <code>true</code> and the containment calculations would be too expensive to perform.
* @see #contains(double, double, double, double)
*/
public boolean contains(Rectangle2D r) {
Geometry rect = rectangleToGeometry(r);
return geometry.contains(rect);
}
代码示例来源:origin: geotools/geotools
/**
* Tests if the interior of the <code>Shape</code> entirely contains the specified <code>
* Rectangle2D</code>. This method might conservatively return <code>false</code> when:
*
* <ul>
* <li>the <code>intersect</code> method returns <code>true</code> and
* <li>the calculations to determine whether or not the <code>Shape</code> entirely contains
* the <code>Rectangle2D</code> are prohibitively expensive.
* </ul>
*
* This means that this method might return <code>false</code> even though the <code>Shape
* </code> contains the <code>Rectangle2D</code>. The <code>Area</code> class can be used to
* perform more accurate computations of geometric intersection for any <code>Shape</code>
* object if a more precise answer is required.
*
* @param r The specified <code>Rectangle2D</code>
* @return <code>true</code> if the interior of the <code>Shape</code> entirely contains the
* <code>Rectangle2D</code>; <code>false</code> otherwise or, if the <code>Shape</code>
* contains the <code>Rectangle2D</code> and the <code>intersects</code> method returns
* <code>true</code> and the containment calculations would be too expensive to perform.
* @see #contains(double, double, double, double)
*/
public boolean contains(Rectangle2D r) {
Geometry rect = rectangleToGeometry(r);
return geometry.contains(rect);
}
代码示例来源:origin: geotools/geotools
Geometry rect = createRectangle(x, y, w, h);
return geometry.contains(rect);
代码示例来源:origin: geotools/geotools
/**
* Tests if a specified {@link Point2D}is inside the boundary of the <code>Shape</code>.
*
* @param p a specified <code>Point2D</code>
* @return <code>true</code> if the specified <code>Point2D</code> is inside the boundary of the
* <code>Shape</code>; <code>false</code> otherwise.
*/
public boolean contains(Point2D p) {
Coordinate coord = new Coordinate(p.getX(), p.getY());
Geometry point = geometry.getFactory().createPoint(coord);
return geometry.contains(point);
}
代码示例来源:origin: geotools/geotools
Geometry rect = createRectangle(x, y, w, h);
return geometry.contains(rect);
代码示例来源:origin: geotools/geotools
/**
* Tests if a specified {@link Point2D} is inside the boundary of the <code>Shape</code>.
*
* @param p a specified <code>Point2D</code>
* @return <code>true</code> if the specified <code>Point2D</code> is inside the boundary of the
* <code>Shape</code>; <code>false</code> otherwise.
*/
public boolean contains(Point2D p) {
Coordinate coord = new Coordinate(p.getX(), p.getY());
Geometry point = geometry.getFactory().createPoint(coord);
return geometry.contains(point);
}
代码示例来源:origin: geotools/geotools
@Override
protected boolean basicEvaluate(Geometry left, Geometry right) {
Envelope envLeft = left.getEnvelopeInternal();
Envelope envRight = right.getEnvelopeInternal();
if (envLeft.contains(envRight)) return left.contains(right);
return false;
}
代码示例来源:origin: geotools/geotools
/**
* Tests if the specified coordinates are inside the boundary of the <code>Shape</code>.
*
* @param x the specified coordinates, x value
* @param y the specified coordinates, y value
* @return <code>true</code> if the specified coordinates are inside the <code>Shape</code>
* boundary; <code>false</code> otherwise.
*/
public boolean contains(double x, double y) {
Coordinate coord = new Coordinate(x, y);
Geometry point = geometry.getFactory().createPoint(coord);
return geometry.contains(point);
}
代码示例来源:origin: geotools/geotools
/**
* Tests if the specified coordinates are inside the boundary of the <code>Shape</code>.
*
* @param x the specified coordinates, x value
* @param y the specified coordinates, y value
* @return <code>true</code> if the specified coordinates are inside the <code>Shape</code>
* boundary; <code>false</code> otherwise.
*/
public boolean contains(double x, double y) {
Coordinate coord = new Coordinate(x, y);
Geometry point = geometry.getFactory().createPoint(coord);
return geometry.contains(point);
}
代码示例来源:origin: geotools/geotools
@DescribeProcess(
title = "Contains Test",
description =
"Tests if no points of the second geometry lie in the exterior of the first geometry and at least one point of the interior of second geometry lies in the interior of first geometry."
)
@DescribeResult(description = "True if the first input contains the second input")
public static boolean contains(
@DescribeParameter(name = "a", description = "First input geometry") Geometry a,
@DescribeParameter(
name = "b",
description =
"Second input geometry, tested to be contained in first geometry"
)
Geometry b) {
return a.contains(b);
}
代码示例来源:origin: geotools/geotools
private static Geometry pointInGeometry(Geometry g) {
Point p = g.getCentroid();
if (g instanceof Polygon) {
// if the geometry is heavily generalized centroid computation may fail and return NaN
if (Double.isNaN(p.getX()) || Double.isNaN(p.getY()))
return g.getFactory().createPoint(g.getCoordinate());
// otherwise let's check if the point is inside. Again, this check and
// "getInteriorPoint"
// will work only if the geometry is valid
if (g.isValid() && !g.contains(p)) {
try {
p = g.getInteriorPoint();
} catch (Exception e) {
// generalized geometries might make interior point go bye bye
return p;
}
} else {
return p;
}
}
return p;
}
代码示例来源:origin: geotools/geotools
/**
* TODO: should we use a spatial index? Would be warranted only if the input has a very
* large amount of sub-lines
*
* @param ls
* @return
*/
private LineString getOriginator(LineString ls) {
LineString original = null;
for (LineString ol : originalLines) {
if (ls.equals(ol) || ls.overlaps(ol) || ol.contains(ls)) {
original = ol;
break;
}
}
if (original == null) {
// sigh, there might be a small difference in the coordinate values,
// go for a more expensive, but tolerant search
for (LineString ol : originalLines) {
if (ol.buffer(PointDistance.EPS_METERS).contains(ls)) {
original = ol;
break;
}
}
}
return original;
}
}
代码示例来源:origin: geotools/geotools
@DescribeProcess(title = "Split Polygon", description = "Splits a polygon by a linestring")
@DescribeResult(description = "The collection of split polygons")
public static Geometry splitPolygon(
@DescribeParameter(name = "polygon", description = "Polygon to split") Geometry polygon,
@DescribeParameter(name = "line", description = "Linestring to split by")
LineString line) {
Geometry nodedLinework = polygon.getBoundary().union(line);
Geometry polys = polygonize(nodedLinework);
// Only keep polygons which are inside the input
List<Polygon> output = new ArrayList<Polygon>();
for (int i = 0; i < polys.getNumGeometries(); i++) {
Polygon candpoly = (Polygon) polys.getGeometryN(i);
// use interior point to test for inclusion in parent
if (polygon.contains(candpoly.getInteriorPoint())) {
output.add(candpoly);
}
}
return polygon.getFactory()
.createGeometryCollection(GeometryFactory.toGeometryArray(output));
}
代码示例来源:origin: geotools/geotools
if (envelope.contains(polyGeom.getEnvelopeInternal())) {
if (Polygon.class.isAssignableFrom(polyGeom.getClass())) {
if (!polyGeom.contains(lineGeom)) {
results.error(
poly, "Polygon does not contain the specified Line.");
代码示例来源:origin: geotools/geotools
if (!lineGeom.contains(p1)) {
代码示例来源:origin: geotools/geotools
if (Polygon.class.isAssignableFrom(polyGeom.getClass())) {
Geometry polyGeomBoundary = polyGeom.getBoundary();
if (!polyGeomBoundary.contains(lineGeom)) {
results.error(
poly, "Boundary does not contain the specified Line.");
代码示例来源:origin: geotools/geotools
if (!ls.getBoundary().contains(pt)) {
r = true;
代码示例来源:origin: geotools/geotools
if (g1.overlaps(g2) != expected || g1.contains(g2) != expected) {
results.error(
f1,
内容来源于网络,如有侵权,请联系作者删除!