Skip to content

Commit dc340c2

Browse files
authored
Patch/geometry engine simplify - add isSimple check (#399)
* add isSimple check * update Readme.md * update comments, update metadata.json
1 parent f00d337 commit dc340c2

File tree

3 files changed

+38
-38
lines changed

3 files changed

+38
-38
lines changed
+19-17
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
1-
# Geometry Engine Simplify
1+
# Geometry engine simplify
22

3-
Simplify a polygon that has multiple parts.
3+
Simplify a polygon with a self-intersecting geometry.
44

5-
![](GeometryEngineSimplify.png)
5+
![Geometry Engine Simplify Sample](GeometryEngineSimplify.png)
6+
7+
## Use case
8+
9+
A user may draw a polygon which is self-intersecting or contains incorrect ring orientations. The geometry must be simplified before it can be saved to a geodatabase.
610

711
## How to use the sample
812

9-
Click on the simplify button to apply the simplify geometry operation between the intersecting polygons. Click reset to restart the sample.
13+
Click the 'Simplify' button to simplify the geometry. Click 'Reset' to reset to the original geometry.
1014

1115
## How it works
1216

13-
To perform the simplify geometry operation on a `Polygon`:
14-
15-
1. Create a `GraphicsOverlay` and add it to the `MapView`.
16-
2. Define the `PointCollection` of the `Geometry`.
17-
3. Add the polygons to the GraphicsOverlay.
18-
4. Determine the simplified geometry by using the `GeometryEngine.simplify(polygon.getGeometry())`.
17+
1. Check if the polygon geometry needs to be simplified using `GeometryEngine.isSimple(Geometry)`.
18+
2. Simplify the polygon's geometry using `GeometryEngine.simplify(Geometry)`.
1919

2020
## Relevant API
2121

2222
* Geometry
23-
* Graphic
24-
* GraphicsOverlay
25-
* MapView
26-
* Point
27-
* PointCollection
28-
* SimpleLineSymbol
29-
* SimpleFillSymbol
23+
* GeometryEngine
24+
25+
## Additional information
26+
27+
The concept of topological simplicity is different than geometry generalization, where points are removed from polygons or lines to create a more generalized result while preserving overall shape. See the 'Densify and Generalize' sample for comparison.
28+
29+
## Tags
30+
31+
geometry, polygon, simplify, spatial operations, topology

geometry/geometry-engine-simplify/README.metadata.json

+6-15
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,21 @@
11
{
22
"category": "Geometry",
3-
"description": "Simplify a polygon that has multiple parts.",
3+
"description": "Simplify a polygon with a self-intersecting geometry.",
44
"ignore": false,
55
"images": [
66
"GeometryEngineSimplify.png"
77
],
88
"keywords": [
99
"Geometry",
10-
"Graphic",
11-
"GraphicsOverlay",
12-
"MapView",
13-
"Point",
14-
"PointCollection",
15-
"SimpleLineSymbol",
16-
"SimpleFillSymbol"
10+
"Polygon",
11+
"Simplify",
12+
"Spatial operations",
13+
"Topology"
1714
],
1815
"redirect_from": "/java/latest/sample-code/geometry-engine-simplify.htm",
1916
"relevant_apis": [
2017
"Geometry",
21-
"Graphic",
22-
"GraphicsOverlay",
23-
"MapView",
24-
"Point",
25-
"PointCollection",
26-
"SimpleLineSymbol",
27-
"SimpleFillSymbol"
18+
"GeometryEngine"
2819
],
2920
"snippets": [
3021
"src/main/java/com/esri/samples/geometry_engine_simplify/GeometryEngineSimplifySample.java"

geometry/geometry-engine-simplify/src/main/java/com/esri/samples/geometry_engine_simplify/GeometryEngineSimplifySample.java

+13-6
Original file line numberDiff line numberDiff line change
@@ -92,20 +92,27 @@ public void start(Stage stage) {
9292

9393
// perform the simplify geometry operation
9494
simplifyButton.setOnAction(e -> {
95-
Geometry resultPolygon = GeometryEngine.simplify(polygon.getGeometry());
9695

97-
// update result as a red (0xFFE91F1F) geometry
98-
SimpleFillSymbol redSymbol = new SimpleFillSymbol(SimpleFillSymbol.Style.SOLID, 0xFFE91F1F, line);
99-
resultGeomOverlay.getGraphics().add(new Graphic(resultPolygon, redSymbol));
96+
// check if the geometry needs to be simplified
97+
if (!GeometryEngine.isSimple(polygon.getGeometry())) {
10098

101-
resetButton.setDisable(false);
102-
simplifyButton.setDisable(true);
99+
// simplify the geometry
100+
Geometry resultPolygon = GeometryEngine.simplify(polygon.getGeometry());
101+
102+
// update result as a red graphic
103+
SimpleFillSymbol redSymbol = new SimpleFillSymbol(SimpleFillSymbol.Style.SOLID, 0xFFE91F1F, line);
104+
resultGeomOverlay.getGraphics().add(new Graphic(resultPolygon, redSymbol));
105+
106+
resetButton.setDisable(false);
107+
simplifyButton.setDisable(true);
108+
}
103109
});
104110

105111
// clear result layer
106112
resetButton.setOnAction(e -> {
107113
resultGeomOverlay.getGraphics().clear();
108114
simplifyButton.setDisable(false);
115+
resetButton.setDisable(true);
109116
});
110117

111118
// add buttons to the control panel

0 commit comments

Comments
 (0)