checkShellsNotNested method

void checkShellsNotNested(
  1. MultiPolygon mp,
  2. GeometryGraph graph
)

Tests that no element polygon is wholly in the interior of another element polygon.

Preconditions:

  • shells do not partially overlap
  • shells do not touch along an edge
  • no duplicate rings exist
This routine relies on the fact that while polygon shells may touch at one or more vertices, they cannot touch at ALL vertices.

Implementation

void checkShellsNotNested(MultiPolygon mp, GeometryGraph graph) {
  for (int i = 0; i < mp.getNumGeometries(); i++) {
    Polygon p = mp.getGeometryN(i) as Polygon;
    LinearRing shell = p.getExteriorRing();
    for (int j = 0; j < mp.getNumGeometries(); j++) {
      if (i == j) continue;
      Polygon p2 = mp.getGeometryN(j) as Polygon;
      checkShellNotNested(shell, p2, graph);
      if (validErr != null) return;
    }
  }
}