Skip to content

Commit

Permalink
CoveragePolygon code cleanup, renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-jts committed May 22, 2024
1 parent ac8cfa6 commit a025ba5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,29 @@ public CoveragePolygon(Polygon poly) {
polyEnv = polygon.getEnvelopeInternal();
}

public boolean intersects(Envelope env) {
public boolean intersectsEnv(Envelope env) {
//-- test intersection explicitly to avoid expensive null check
//return polyEnv.intersects(env);
return ! (env.getMinX() > polyEnv.getMaxX()
|| env.getMaxX() < polyEnv.getMinX()
|| env.getMinY() > polyEnv.getMaxY()
|| env.getMaxY() < polyEnv.getMinY());
}

public boolean contains(Coordinate p) {
private boolean intersectsEnv(Coordinate p) {
//-- test intersection explicitly to avoid expensive null check
if (! intersects(p))
return false;
PointOnGeometryLocator pia = getLocator();
return Location.INTERIOR == pia.locate(p);
}

private boolean intersects(Coordinate p) {
return ! (p.x > polyEnv.getMaxX() ||
p.x < polyEnv.getMinX() ||
p.y > polyEnv.getMaxY() ||
p.y < polyEnv.getMinY());
}

public boolean contains(Coordinate p) {
if (! intersectsEnv(p))
return false;
PointOnGeometryLocator pia = getLocator();
return Location.INTERIOR == pia.locate(p);
}

private PointOnGeometryLocator getLocator() {
if (locator == null) {
locator = new IndexedPointInAreaLocator(polygon);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ private void markInvalidInteriorSection(CoverageRing ring, int iStart, int iEnd,
Envelope sectionEnv = ring.getEnvelope(iStart, iEnd);
//TODO: is it worth indexing polygons?
for (CoveragePolygon adjPoly : adjPolygons) {
if (adjPoly.intersects(sectionEnv)) {
if (adjPoly.intersectsEnv(sectionEnv)) {
//-- test vertices in section
for (int i = iStart; i < iEnd; i++) {
markInvalidInteriorSegment(ring, i, adjPoly);
Expand Down

0 comments on commit a025ba5

Please sign in to comment.