Skip to content

don't return degenerate geometries in fast intersects operation #535

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public class FastPolygonOperations implements Serializable {
private final double envWidth;
private final double envHeight;

private final GeometryFactory gf = new GeometryFactory();

/**
* Constructor using a given geometry {@code geom} and geometry type {@code P}.
*
Expand All @@ -50,8 +52,6 @@ public <P extends Geometry & Polygonal> FastPolygonOperations(P geom) {
envWidth = env.getMaxX() - env.getMinX();
envHeight = env.getMaxY() - env.getMinY();

GeometryFactory gf = new GeometryFactory();

Geometry[] result = new Geometry[numBands * numBands];
traverseQuads(bandIterations, 0, 0, env, geom, gf, result);

Expand Down Expand Up @@ -184,10 +184,15 @@ public Geometry intersection(Geometry other) {
}

assert intersector != null;
Geometry result;
if (other instanceof GeometryCollection) {
return other.intersection(intersector);
result = other.intersection(intersector);
} else {
return intersector.intersection(other);
result = intersector.intersection(other);
}
if (result.getDimension() != other.getDimension()) {
return gf.createEmpty(other.getDimension());
}
return result;
}
}