本文整理汇总了Java中com.vividsolutions.jts.algorithm.CGAlgorithms.isPointInRing方法的典型用法代码示例。如果您正苦于以下问题:Java CGAlgorithms.isPointInRing方法的具体用法?Java CGAlgorithms.isPointInRing怎么用?Java CGAlgorithms.isPointInRing使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.vividsolutions.jts.algorithm.CGAlgorithms
的用法示例。
在下文中一共展示了CGAlgorithms.isPointInRing方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkShellInsideHole
import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入方法依赖的package包/类
/**
* This routine checks to see if a shell is properly contained in a hole.
* It assumes that the edges of the shell and hole do not
* properly intersect.
*
* @return <code>null</code> if the shell is properly contained, or
* a Coordinate which is not inside the hole if it is not
*/
private Coordinate checkShellInsideHole(LinearRing shell, LinearRing hole, GeometryGraph graph) {
Coordinate[] shellPts = shell.getCoordinates();
Coordinate[] holePts = hole.getCoordinates();
// TODO: improve performance of this - by sorting pointlists for instance?
Coordinate shellPt = findPtNotNode(shellPts, hole, graph);
// if point is on shell but not hole, check that the shell is inside the hole
if (shellPt != null) {
boolean insideHole = CGAlgorithms.isPointInRing(shellPt, holePts);
if (!insideHole) {
return shellPt;
}
}
Coordinate holePt = findPtNotNode(holePts, shell, graph);
// if point is on hole but not shell, check that the hole is outside the shell
if (holePt != null) {
boolean insideShell = CGAlgorithms.isPointInRing(holePt, shellPts);
if (insideShell) {
return holePt;
}
return null;
}
Assert.shouldNeverReachHere("points in shell and hole appear to be equal");
return null;
}
示例2: containsPoint
import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入方法依赖的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;
}
示例3: findEdgeRingContaining
import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入方法依赖的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;
}
示例4: isNonNested
import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入方法依赖的package包/类
public boolean isNonNested() {
for (int i = 0; i < this.rings.size(); i++) {
LinearRing innerRing = (LinearRing) this.rings.get(i);
Coordinate[] innerRingPts = innerRing.getCoordinates();
for (Object ring : rings) {
LinearRing searchRing = (LinearRing) ring;
Coordinate[] searchRingPts = searchRing.getCoordinates();
if (innerRing == searchRing) {
continue;
}
if (!innerRing.getEnvelopeInternal().intersects(searchRing.getEnvelopeInternal())) {
continue;
}
Coordinate innerRingPt = IsValidOp.findPtNotNode(innerRingPts, searchRing, this.graph);
Assert.isTrue(innerRingPt != null, "Unable to find a ring point not a node of the search ring");
//Coordinate innerRingPt = innerRingPts[0];
boolean isInside = CGAlgorithms.isPointInRing(innerRingPt, searchRingPts);
if (isInside) {
this.nestedPt = innerRingPt;
return false;
}
}
}
return true;
}
示例5: isNonNested
import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入方法依赖的package包/类
public boolean isNonNested() {
this.buildQuadtree();
for (Object ring : rings) {
LinearRing innerRing = (LinearRing) ring;
Coordinate[] innerRingPts = innerRing.getCoordinates();
List results = this.quadtree.query(innerRing.getEnvelopeInternal());
//System.out.println(results.size());
for (Object result : results) {
LinearRing searchRing = (LinearRing) result;
Coordinate[] searchRingPts = searchRing.getCoordinates();
if (innerRing == searchRing) {
continue;
}
if (!innerRing.getEnvelopeInternal().intersects(searchRing.getEnvelopeInternal())) {
continue;
}
Coordinate innerRingPt = IsValidOp.findPtNotNode(innerRingPts, searchRing, this.graph);
Assert.isTrue(innerRingPt != null, "Unable to find a ring point not a node of the search ring");
//Coordinate innerRingPt = innerRingPts[0];
boolean isInside = CGAlgorithms.isPointInRing(innerRingPt, searchRingPts);
if (isInside) {
this.nestedPt = innerRingPt;
return false;
}
}
}
return true;
}
示例6: findEdgeRingContaining
import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入方法依赖的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: findEdgeRingContaining
import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入方法依赖的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 (Iterator it = shellList.iterator(); it.hasNext(); ) {
EdgeRing tryShell = (EdgeRing) it.next();
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;
}
示例8: isNonNested
import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入方法依赖的package包/类
public boolean isNonNested() {
for (int i = 0; i < rings.size(); i++) {
LinearRing innerRing = (LinearRing) rings.get(i);
Coordinate[] innerRingPts = innerRing.getCoordinates();
for (int j = 0; j < rings.size(); j++) {
LinearRing searchRing = (LinearRing) rings.get(j);
Coordinate[] searchRingPts = searchRing.getCoordinates();
if (innerRing == searchRing)
continue;
if (!innerRing.getEnvelopeInternal().intersects(searchRing.getEnvelopeInternal()))
continue;
Coordinate innerRingPt = IsValidOp.findPtNotNode(innerRingPts, searchRing, graph);
Assert.isTrue(innerRingPt != null, "Unable to find a ring point not a node of the search ring");
//Coordinate innerRingPt = innerRingPts[0];
boolean isInside = CGAlgorithms.isPointInRing(innerRingPt, searchRingPts);
if (isInside) {
nestedPt = innerRingPt;
return false;
}
}
}
return true;
}
示例9: isNonNested
import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入方法依赖的package包/类
public boolean isNonNested() {
buildQuadtree();
for (int i = 0; i < rings.size(); i++) {
LinearRing innerRing = (LinearRing) rings.get(i);
Coordinate[] innerRingPts = innerRing.getCoordinates();
List results = quadtree.query(innerRing.getEnvelopeInternal());
//System.out.println(results.size());
for (int j = 0; j < results.size(); j++) {
LinearRing searchRing = (LinearRing) results.get(j);
Coordinate[] searchRingPts = searchRing.getCoordinates();
if (innerRing == searchRing)
continue;
if (!innerRing.getEnvelopeInternal().intersects(searchRing.getEnvelopeInternal()))
continue;
Coordinate innerRingPt = IsValidOp.findPtNotNode(innerRingPts, searchRing, graph);
Assert.isTrue(innerRingPt != null, "Unable to find a ring point not a node of the search ring");
//Coordinate innerRingPt = innerRingPts[0];
boolean isInside = CGAlgorithms.isPointInRing(innerRingPt, searchRingPts);
if (isInside) {
nestedPt = innerRingPt;
return false;
}
}
}
return true;
}
示例10: findEdgeRingContaining
import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入方法依赖的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 (Iterator it = shellList.iterator(); it.hasNext(); ) {
EdgeRing tryShell = (EdgeRing) it.next();
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;
}
示例11: containsPoint
import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入方法依赖的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 = getLinearRing();
Envelope env = shell.getEnvelopeInternal();
if (!env.contains(p)) return false;
if (!CGAlgorithms.isPointInRing(p, shell.getCoordinates())) return false;
for (Iterator i = holes.iterator(); i.hasNext(); ) {
EdgeRing hole = (EdgeRing) i.next();
if (hole.containsPoint(p))
return false;
}
return true;
}
示例12: containsPoint
import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入方法依赖的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 = getLinearRing();
Envelope env = shell.getEnvelopeInternal();
if (! env.contains(p)) return false;
if (! CGAlgorithms.isPointInRing(p, shell.getCoordinates()) ) return false;
for (Iterator i = holes.iterator(); i.hasNext(); ) {
EdgeRing hole = (EdgeRing) i.next();
if (hole.containsPoint(p) )
return false;
}
return true;
}
示例13: isNonNested
import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入方法依赖的package包/类
public boolean isNonNested() {
this.buildIndex();
for (Object ring : rings) {
LinearRing innerRing = (LinearRing) ring;
Coordinate[] innerRingPts = innerRing.getCoordinates();
List results = this.index.query(innerRing.getEnvelopeInternal());
//System.out.println(results.size());
for (Object result : results) {
LinearRing searchRing = (LinearRing) result;
Coordinate[] searchRingPts = searchRing.getCoordinates();
if (innerRing == searchRing) {
continue;
}
if (!innerRing.getEnvelopeInternal().intersects(searchRing.getEnvelopeInternal())) {
continue;
}
Coordinate innerRingPt = IsValidOp.findPtNotNode(innerRingPts, searchRing, this.graph);
/**
* If no non-node pts can be found, this means
* that the searchRing touches ALL of the innerRing vertices.
* This indicates an invalid polygon, since either
* the two holes create a disconnected interior,
* or they touch in an infinite number of points
* (i.e. along a line segment).
* Both of these cases are caught by other tests,
* so it is safe to simply skip this situation here.
*/
if (innerRingPt == null) {
continue;
}
boolean isInside = CGAlgorithms.isPointInRing(innerRingPt, searchRingPts);
if (isInside) {
this.nestedPt = innerRingPt;
return false;
}
}
}
return true;
}
示例14: checkShellNotNested
import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入方法依赖的package包/类
/**
* Check if a shell is incorrectly nested within a polygon. This is the case
* if the shell is inside the polygon shell, but not inside a polygon hole.
* (If the shell is inside a polygon hole, the nesting is valid.)
* <p>
* The algorithm used relies on the fact that the rings must be properly contained.
* E.g. they cannot partially overlap (this has been previously checked by
* <code>checkRelateConsistency</code> )
*/
private void checkShellNotNested(LinearRing shell, Polygon p, GeometryGraph graph) {
Coordinate[] shellPts = shell.getCoordinates();
// test if shell is inside polygon shell
LinearRing polyShell = (LinearRing) p.getExteriorRing();
Coordinate[] polyPts = polyShell.getCoordinates();
Coordinate shellPt = findPtNotNode(shellPts, polyShell, graph);
// if no point could be found, we can assume that the shell is outside the polygon
if (shellPt == null) {
return;
}
boolean insidePolyShell = CGAlgorithms.isPointInRing(shellPt, polyPts);
if (!insidePolyShell) {
return;
}
// if no holes, this is an error!
if (p.getNumInteriorRing() <= 0) {
this.validErr = new TopologyValidationError(
TopologyValidationError.NESTED_SHELLS,
shellPt);
return;
}
/**
* Check if the shell is inside one of the holes.
* This is the case if one of the calls to checkShellInsideHole
* returns a null coordinate.
* Otherwise, the shell is not properly contained in a hole, which is an error.
*/
Coordinate badNestedPt = null;
for (int i = 0; i < p.getNumInteriorRing(); i++) {
LinearRing hole = (LinearRing) p.getInteriorRingN(i);
badNestedPt = this.checkShellInsideHole(shell, hole, graph);
if (badNestedPt == null) {
return;
}
}
this.validErr = new TopologyValidationError(
TopologyValidationError.NESTED_SHELLS,
badNestedPt);
}
示例15: contains
import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入方法依赖的package包/类
public boolean contains(Coordinate pt) {
Coordinate[] ring = this.getCoordinates();
return CGAlgorithms.isPointInRing(pt, ring);
}