本文整理匯總了Java中com.vividsolutions.jts.geom.Envelope.contains方法的典型用法代碼示例。如果您正苦於以下問題:Java Envelope.contains方法的具體用法?Java Envelope.contains怎麽用?Java Envelope.contains使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.vividsolutions.jts.geom.Envelope
的用法示例。
在下文中一共展示了Envelope.contains方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: checkEnvelope
import com.vividsolutions.jts.geom.Envelope; //導入方法依賴的package包/類
private void checkEnvelope() {
if (this.distance < 0.0) {
return;
}
double padding = this.distance * MAX_ENV_DIFF_FRAC;
if (padding == 0.0) {
padding = 0.001;
}
Envelope expectedEnv = new Envelope(this.input.getEnvelopeInternal());
expectedEnv.expandBy(this.distance);
Envelope bufEnv = new Envelope(this.result.getEnvelopeInternal());
bufEnv.expandBy(padding);
if (!bufEnv.contains(expectedEnv)) {
this.isValid = false;
this.errorMsg = "Buffer envelope is incorrect";
this.errorIndicator = this.input.getFactory().toGeometry(bufEnv);
}
this.report("Envelope");
}
示例2: clipGeometryCollection
import com.vividsolutions.jts.geom.Envelope; //導入方法依賴的package包/類
private static Geometry clipGeometryCollection(Geometry geom, Envelope clipEnv) {
Geometry clipPoly = geom.getFactory().toGeometry(clipEnv);
List clipped = new ArrayList();
for (int i = 0; i < geom.getNumGeometries(); i++) {
Geometry g = geom.getGeometryN(i);
Geometry result = null;
// don't clip unless necessary
if (clipEnv.contains(g.getEnvelopeInternal())) {
result = g;
} else if (clipEnv.intersects(g.getEnvelopeInternal())) {
result = clipPoly.intersection(g);
// keep vertex key info
result.setUserData(g.getUserData());
}
if (result != null && !result.isEmpty()) {
clipped.add(result);
}
}
return geom.getFactory().createGeometryCollection(GeometryFactory.toGeometryArray(clipped));
}
示例3: containsPoint
import com.vividsolutions.jts.geom.Envelope; //導入方法依賴的package包/類
/**
* This method will cause the ring to be computed.
* It will also check any holes, if they have been assigned.
*/
public boolean containsPoint(Coordinate p) {
LinearRing shell = this.getLinearRing();
Envelope env = shell.getEnvelopeInternal();
if (!env.contains(p)) {
return false;
}
if (!CGAlgorithms.isPointInRing(p, shell.getCoordinates())) {
return false;
}
for (Object hole1 : holes) {
EdgeRing hole = (EdgeRing) hole1;
if (hole.containsPoint(p)) {
return false;
}
}
return true;
}
示例4: visit
import com.vividsolutions.jts.geom.Envelope; //導入方法依賴的package包/類
@Override
protected void visit(Geometry geom) {
// if test geometry is not polygonal this check is not needed
if (!(geom instanceof Polygon)) {
return;
}
// skip if envelopes do not intersect
Envelope elementEnv = geom.getEnvelopeInternal();
if (!this.rectEnv.intersects(elementEnv)) {
return;
}
// test each corner of rectangle for inclusion
Coordinate rectPt = new Coordinate();
for (int i = 0; i < 4; i++) {
this.rectSeq.getCoordinate(i, rectPt);
if (!elementEnv.contains(rectPt)) {
continue;
}
// check rect point in poly (rect is known not to touch polygon at this
// point)
if (SimplePointInAreaLocator.containsPointInPolygon(rectPt,
(Polygon) geom)) {
this.containsPoint = true;
return;
}
}
}
示例5: findEdgeRingContaining
import com.vividsolutions.jts.geom.Envelope; //導入方法依賴的package包/類
/**
* Find the innermost enclosing shell EdgeRing containing the argument EdgeRing, if any.
* The innermost enclosing ring is the <i>smallest</i> enclosing ring.
* The algorithm used depends on the fact that:
* <br>
* ring A contains ring B iff envelope(ring A) contains envelope(ring B)
* <br>
* This routine is only safe to use if the chosen point of the hole
* is known to be properly contained in a shell
* (which is guaranteed to be the case if the hole does not touch its shell)
*
* @return containing EdgeRing, if there is one
* or null if no containing EdgeRing is found
*/
public static EdgeRing findEdgeRingContaining(EdgeRing testEr, List shellList) {
LinearRing testRing = testEr.getRing();
Envelope testEnv = testRing.getEnvelopeInternal();
Coordinate testPt = testRing.getCoordinateN(0);
EdgeRing minShell = null;
Envelope minShellEnv = null;
for (Object aShellList : shellList) {
EdgeRing tryShell = (EdgeRing) aShellList;
LinearRing tryShellRing = tryShell.getRing();
Envelope tryShellEnv = tryShellRing.getEnvelopeInternal();
// the hole envelope cannot equal the shell envelope
// (also guards against testing rings against themselves)
if (tryShellEnv.equals(testEnv)) {
continue;
}
// hole must be contained in shell
if (!tryShellEnv.contains(testEnv)) {
continue;
}
testPt = CoordinateArrays.ptNotInList(testRing.getCoordinates(), tryShellRing.getCoordinates());
boolean isContained = false;
if (CGAlgorithms.isPointInRing(testPt, tryShellRing.getCoordinates())) {
isContained = true;
}
// check if this new containing ring is smaller than the current minimum ring
if (isContained) {
if (minShell == null
|| minShellEnv.contains(tryShellEnv)) {
minShell = tryShell;
minShellEnv = minShell.getRing().getEnvelopeInternal();
}
}
}
return minShell;
}
示例6: findEdgeRingContaining
import com.vividsolutions.jts.geom.Envelope; //導入方法依賴的package包/類
/**
* Find the innermost enclosing shell EdgeRing containing the argument EdgeRing, if any.
* The innermost enclosing ring is the <i>smallest</i> enclosing ring.
* The algorithm used depends on the fact that:
* <br>
* ring A contains ring B iff envelope(ring A) contains envelope(ring B)
* <br>
* This routine is only safe to use if the chosen point of the hole
* is known to be properly contained in a shell
* (which is guaranteed to be the case if the hole does not touch its shell)
*
* @return containing EdgeRing, if there is one
* or null if no containing EdgeRing is found
*/
private EdgeRing findEdgeRingContaining(EdgeRing testEr, List shellList) {
LinearRing testRing = testEr.getLinearRing();
Envelope testEnv = testRing.getEnvelopeInternal();
Coordinate testPt = testRing.getCoordinateN(0);
EdgeRing minShell = null;
Envelope minEnv = null;
for (Object aShellList : shellList) {
EdgeRing tryShell = (EdgeRing) aShellList;
LinearRing tryRing = tryShell.getLinearRing();
Envelope tryEnv = tryRing.getEnvelopeInternal();
if (minShell != null) {
minEnv = minShell.getLinearRing().getEnvelopeInternal();
}
boolean isContained = false;
if (tryEnv.contains(testEnv)
&& CGAlgorithms.isPointInRing(testPt, tryRing.getCoordinates())) {
isContained = true;
}
// check if this new containing ring is smaller than the current minimum ring
if (isContained) {
if (minShell == null
|| minEnv.contains(tryEnv)) {
minShell = tryShell;
}
}
}
return minShell;
}
示例7: queryNode
import com.vividsolutions.jts.geom.Envelope; //導入方法依賴的package包/類
private void queryNode(KdNode currentNode, KdNode bottomNode,
Envelope queryEnv, boolean odd, List result) {
if (currentNode == bottomNode) {
return;
}
double min;
double max;
double discriminant;
if (odd) {
min = queryEnv.getMinX();
max = queryEnv.getMaxX();
discriminant = currentNode.getX();
} else {
min = queryEnv.getMinY();
max = queryEnv.getMaxY();
discriminant = currentNode.getY();
}
boolean searchLeft = min < discriminant;
boolean searchRight = discriminant <= max;
if (searchLeft) {
this.queryNode(currentNode.getLeft(), bottomNode, queryEnv, !odd, result);
}
if (queryEnv.contains(currentNode.getCoordinate())) {
result.add(currentNode);
}
if (searchRight) {
this.queryNode(currentNode.getRight(), bottomNode, queryEnv, !odd, result);
}
}
示例8: isInSegmentEnvelopes
import com.vividsolutions.jts.geom.Envelope; //導入方法依賴的package包/類
/**
* Test whether a point lies in the envelopes of both input segments.
* A correctly computed intersection point should return <code>true</code>
* for this test.
* Since this test is for debugging purposes only, no attempt is
* made to optimize the envelope test.
*
* @return <code>true</code> if the input point lies within both input segment envelopes
*/
private boolean isInSegmentEnvelopes(Coordinate intPt) {
Envelope env0 = new Envelope(this.inputLines[0][0], this.inputLines[0][1]);
Envelope env1 = new Envelope(this.inputLines[1][0], this.inputLines[1][1]);
return env0.contains(intPt) && env1.contains(intPt);
}