checkShellInsideHole method
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 null
if the shell is properly contained, or
a Coordinate which is not inside the hole if it is not
Implementation
Coordinate? checkShellInsideHole(
LinearRing shell, LinearRing hole, GeometryGraph graph) {
List<Coordinate> shellPts = shell.getCoordinates();
List<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) {
bool insideHole = PointLocation.isInRing(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) {
bool insideShell = PointLocation.isInRing(holePt, shellPts);
if (insideShell) {
return holePt;
}
return null;
}
assert(true, "points in shell and hole appear to be equal");
return null;
}