View on GitHub Sample viewer app

Simplify a polygon with a self-intersecting geometry.

Image of geometry engine simplify

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 the ‘Simplify’ button to simplify the geometry. Click ‘Reset’ to reset to the original geometry.

How it works

  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
  • 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

Sample Code

module-info.java module-info.java GeometryEngineSimplifySample.java
/*
* Copyright 2022 Esri.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
module com.esri.samples.geometry_engine_simplify {
// require ArcGIS Maps SDK for Java module
requires com.esri.arcgisruntime;
// handle SLF4J http://www.slf4j.org/codes.html#StaticLoggerBinder
requires org.slf4j.nop;
// require JavaFX modules that the application uses
requires javafx.graphics;
requires javafx.controls;
exports com.esri.samples.geometry_engine_simplify;
}