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

Don't return null buffer polygon #243

Merged
merged 1 commit into from
Aug 15, 2019
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
10 changes: 9 additions & 1 deletion src/main/java/com/esri/core/geometry/Bufferer.java
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,9 @@ private Geometry bufferPolygon_() {
generateCircleTemplate_();
m_geometry = simplify.execute(m_geometry, null, false,
m_progress_tracker);
if(m_geometry.isEmpty()) {
return m_geometry;
}

if (m_distance < 0) {
Polygon poly = (Polygon) (m_geometry);
Expand All @@ -600,7 +603,12 @@ private Geometry bufferPolygon_() {
.getInstance().getOperator(Operator.Type.Union)).execute(
cursor, m_spatialReference, m_progress_tracker);
Geometry result = union_cursor.next();
return result;
if (result != null) {
return result;
} else {
//never return empty.
return new Polygon(m_geometry.getDescription());
}
}
}

Expand Down
25 changes: 25 additions & 0 deletions src/test/java/com/esri/core/geometry/TestBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import junit.framework.TestCase;
import org.junit.Test;

import com.esri.core.geometry.ogc.OGCGeometry;

public class TestBuffer extends TestCase {
@Override
protected void setUp() throws Exception {
Expand Down Expand Up @@ -389,4 +391,27 @@ public void testBufferPolygon() {
assertTrue(simplify.isSimpleAsFeature(result, sr, null));
}
}

@Test
public static void testTinyBufferOfPoint() {
{
Geometry result1 = OperatorBuffer.local().execute(new Point(0, 0), SpatialReference.create(4326), 1e-9, null);
assertTrue(result1 != null);
assertTrue(result1.isEmpty());
Geometry geom1 = OperatorImportFromWkt.local().execute(0, Geometry.Type.Unknown, "POLYGON ((177.0 64.0, 177.0000000001 64.0, 177.0000000001 64.0000000001, 177.0 64.0000000001, 177.0 64.0))", null);
Geometry result2 = OperatorBuffer.local().execute(geom1, SpatialReference.create(4326), 0.01, null);
assertTrue(result2 != null);
assertTrue(result2.isEmpty());

}

{
OGCGeometry p = OGCGeometry.fromText(
"POLYGON ((177.0 64.0, 177.0000000001 64.0, 177.0000000001 64.0000000001, 177.0 64.0000000001, 177.0 64.0))");
OGCGeometry buffered = p.buffer(0.01);
assertTrue(buffered != null);
}


}
}