Skip to content
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

Check for invalid polygonal geometry before fixing #656

Merged
merged 1 commit into from
Dec 24, 2020
Merged
Show file tree
Hide file tree
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 @@ -185,7 +185,8 @@ protected Geometry transformMultiPolygon(MultiPolygon geom, Geometry parent) {
* @return a valid area geometry
*/
private Geometry createValidArea(Geometry roughAreaGeom) {
if (! isValidated) return roughAreaGeom;
// if valid no need to process to make valid
if (! isValidated || roughAreaGeom.isValid()) return roughAreaGeom;
return roughAreaGeom.buffer(0.0);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ protected Geometry transformMultiPolygon(MultiPolygon geom, Geometry parent) {
*/
private Geometry createValidArea(Geometry rawAreaGeom)
{
if ( isEnsureValidTopology)
// if geometry is invalid then make it valid
if (isEnsureValidTopology && ! rawAreaGeom.isValid())
return rawAreaGeom.buffer(0.0);
return rawAreaGeom;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ protected Geometry transformMultiPolygon(MultiPolygon geom, Geometry parent)
*/
private Geometry createValidArea(Geometry rawAreaGeom)
{
if (isEnsureValidTopology)
// if geometry is invalid then make it valid
if (isEnsureValidTopology && ! rawAreaGeom.isValid())
return rawAreaGeom.buffer(0.0);
return rawAreaGeom;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void testPolygonWithTouchingHole() throws Exception {
DPSimplifierResult.getResult(
"POLYGON ((80 200, 240 200, 240 60, 80 60, 80 200), (120 120, 220 120, 180 199, 160 200, 140 199, 120 120))",
10.0))
.setExpectedResult("POLYGON ((80 200, 160 200, 240 200, 240 60, 80 60, 80 200), (160 200, 140 199, 120 120, 220 120, 180 199, 160 200)))")
.setExpectedResult("POLYGON ((80 200, 240 200, 240 60, 80 60, 80 200), (120 120, 220 120, 180 199, 160 200, 140 199, 120 120))")
.test();
}
public void testFlattishPolygon() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void testPolygonSpikeInShell() throws Exception {
VWSimplifierResult.getResult(
"POLYGON ((1721355.3 693015.146, 1721318.687 693046.251, 1721306.747 693063.038, 1721367.025 692978.29, 1721355.3 693015.146))",
10.0))
.setExpectedResult("POLYGON ((1721355.3 693015.146, 1721367.025 692978.29, 1721318.687 693046.251, 1721355.3 693015.146))")
.setExpectedResult("POLYGON ((1721355.3 693015.146, 1721318.687 693046.251, 1721367.025 692978.29, 1721355.3 693015.146))")
.test();
}
public void testPolygonSpikeInHole() throws Exception {
Expand Down