Skip to content

Patch/geometry engine simplify - add isSimple check #399

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

Merged
merged 3 commits into from
Aug 8, 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
36 changes: 19 additions & 17 deletions geometry/geometry-engine-simplify/README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
# Geometry Engine Simplify
# Geometry engine simplify

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

![](GeometryEngineSimplify.png)
![Geometry Engine Simplify Sample](GeometryEngineSimplify.png)

## Use case

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.

## How to use the sample

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

## How it works

To perform the simplify geometry operation on a `Polygon`:

1. Create a `GraphicsOverlay` and add it to the `MapView`.
2. Define the `PointCollection` of the `Geometry`.
3. Add the polygons to the GraphicsOverlay.
4. Determine the simplified geometry by using the `GeometryEngine.simplify(polygon.getGeometry())`.
1. Check if the polygon geometry needs to be simplified using `GeometryEngine.isSimple(Geometry)`.
2. Simplify the polygon's geometry using `GeometryEngine.simplify(Geometry)`.

## Relevant API

* Geometry
* Graphic
* GraphicsOverlay
* MapView
* Point
* PointCollection
* SimpleLineSymbol
* SimpleFillSymbol
* GeometryEngine

## Additional information

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.

## Tags

geometry, polygon, simplify, spatial operations, topology
21 changes: 6 additions & 15 deletions geometry/geometry-engine-simplify/README.metadata.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,21 @@
{
"category": "Geometry",
"description": "Simplify a polygon that has multiple parts.",
"description": "Simplify a polygon with a self-intersecting geometry.",
"ignore": false,
"images": [
"GeometryEngineSimplify.png"
],
"keywords": [
"Geometry",
"Graphic",
"GraphicsOverlay",
"MapView",
"Point",
"PointCollection",
"SimpleLineSymbol",
"SimpleFillSymbol"
"Polygon",
"Simplify",
"Spatial operations",
"Topology"
],
"redirect_from": "/java/latest/sample-code/geometry-engine-simplify.htm",
"relevant_apis": [
"Geometry",
"Graphic",
"GraphicsOverlay",
"MapView",
"Point",
"PointCollection",
"SimpleLineSymbol",
"SimpleFillSymbol"
"GeometryEngine"
],
"snippets": [
"src/main/java/com/esri/samples/geometry_engine_simplify/GeometryEngineSimplifySample.java"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,27 @@ public void start(Stage stage) {

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

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

resetButton.setDisable(false);
simplifyButton.setDisable(true);
// simplify the geometry
Geometry resultPolygon = GeometryEngine.simplify(polygon.getGeometry());

// update result as a red graphic
SimpleFillSymbol redSymbol = new SimpleFillSymbol(SimpleFillSymbol.Style.SOLID, 0xFFE91F1F, line);
resultGeomOverlay.getGraphics().add(new Graphic(resultPolygon, redSymbol));

resetButton.setDisable(false);
simplifyButton.setDisable(true);
}
});

// clear result layer
resetButton.setOnAction(e -> {
resultGeomOverlay.getGraphics().clear();
simplifyButton.setDisable(false);
resetButton.setDisable(true);
});

// add buttons to the control panel
Expand Down