require(["esri/geometry/operators/densifyOperator"], (densifyOperator) => { /* code goes here */ });
import * as densifyOperator from "@arcgis/core/geometry/operators/densifyOperator.js";
esri/geometry/operators/densifyOperator
Densifies 2D geometries by length, deviation and/or angle in a 2D plane. In the result geometry, there are no segments longer than the given maxlength, and it will not contain curves. The piecewise approximation of curves is closer than the given deviation to the original curve, and the angle between tangent segments does not exceed given value.
When the maxAngleInDegrees
is not zero, vertices are introduced at points on the curve where the included angle between
tangents at those point is maxAngleInDegrees
. The new vertices are connected with line segments.
If maxSegmentLength
is zero, the operation only applies to curves and geometries that do not have curves will be passed through unchanged.
The operation always starts from the highest point on segment, thus guaranteeing that geometries that equal segments are densified exactly the same.
When all maxSegmentLength
, maxDeviation
, and maxAngleInDegrees
are set to 0
,
all curves are replaced with the line segments connecting the curve endpoints.
Suggestion: If you have an area of interest such as a visible extent, clip the input geometries before densifying to limit the amount of segments produced.
Method Overview
Name | Return Type | Summary | Object |
---|---|---|---|
Performs the densify operation on the geometry. | densifyOperator | ||
Performs the Densify operation on the geometry set. | densifyOperator |
Method Details
-
execute
execute(geometry, maxSegmentLength, options){Geometry}
-
Performs the densify operation on the geometry.
ParametersSpecificationgeometry GeometryThe geometry to be densified.
maxSegmentLength NumberThe maximum segment length allowed. The number must be greater than or equal to zero.
When the parameter is set to
0
, this operation only applies to curves and disables densification by length. Curves are densinfied to straight segments using the given length. And, curves are split into shorter subcurves such that the length of subcurves is shorter thanmaxSegmentLength
. After that the curves are replaced with straight segments. Unless theunit
option is set, the default is the spatial reference unit ofgeometry
.options ObjectoptionalAdditional options.
SpecificationmaxAngleInDegrees NumberoptionalDefault Value: 0The maximum angle allowed. The number must be greater than or equal to zero. Applicable only on curves. The default of passing
0
disables densification by angle. The value will be capped at pi/2.maxDeviation NumberoptionalDefault Value: 0The maximum deviation allowed. The number must be greater than or equal to zero. Applicable only on curves. The default of passing
0
disables densification by deviation. Unless theunit
option is set, the default is the geometry's spatial reference unit.unit LengthUnitoptionalThe length unit of
maxSegmentLength
andmaxDeviation
. An error will be thrown if this is set for Geographic Coordinate Systems.ReturnsType Description Geometry Returns the densified geometry that does not contain any curves. Example// Returns a densified geometry const densified = densifyOperator.execute(polyline, 100);
-
Performs the Densify operation on the geometry set.
ParametersSpecificationThe set of geometries to be densified.
maxSegmentLength NumberThe maximum segment length allowed. The number must be greater than or equal to zero.
When the parameter is set to
0
, this operation only applies to curves and disables densification by length. Curves are densinfied to straight segments using the given length. And, curves are split into shorter subcurves such that the length of subcurves is shorter thanmaxSegmentLength
. After that the curves are replaced with straight segments. Unless theunit
option is set, the default is the geometries spatial reference unit.options ObjectoptionalAdditional options.
SpecificationmaxAngleInDegrees NumberoptionalDefault Value: 0The maximum angle allowed. The number must be greater than or equal to zero. Applicable only on curves. The default of passing
0
disables densification by angle. The value will be capped at pi/2.maxDeviation NumberoptionalDefault Value: 0The maximum deviation allowed. The number must be greater than or equal to zero. Applicable only on curves. The default of passing
0
disables densification by deviation.unit LengthUnitoptionalThe length unit of
maxSegmentLength
andmaxDeviation
. An error will be thrown if this is set for Geographic Coordinate Systems.Returns