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. The result geometry contains segments less than or equal to maxSegementLength
, and it will not contain curves.
The piecewise approximation of curves will be within the specified deviation from the original curve,
and the angle between tangent segments does not exceed the specified value.
If maxAngleInDegrees
is not zero, vertices are added at points along the curve where the angle between tangent segments reaches this value.
These vertices are then connected by straight-line segments.
If maxSegmentLength
is zero, only curves are affected and other geometries remain unchanged.
The process always starts from the highest point on a segment, so equal segments will be densified in the same way.
When the maxSegmentLength
, maxDeviation
, and maxAngleInDegrees
parameters are all set to 0
,
curves are replaced with the line segments connecting the curve endpoints.
Suggestion: to limit the number of segments that are produced, if you have an area of interest such as a visible extent, clip the input geometries before densifying.
Property Overview
Name | Type | Summary | Object |
---|---|---|---|
Indicates if the operator supports input geometries that contain curves. | densifyOperator |
Property Details
-
supportsCurves
supportsCurves Booleanreadonly
-
Indicates if the operator supports input geometries that contain curves. This will produce densified output geometries.
- Default Value:true
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){GeometryUnion}
-
Performs the densify operation on the geometry.
ParametersSpecificationgeometry GeometryUnionThe geometry to be densified.
maxSegmentLength NumberThe maximum distance between vertices when the input geometry is densified. 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 densified 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 that a new vertex can deviate from the original geometry. The number must be greater than or equal to zero. Applicable only on curves. The default value of
0
disables densification by angle. The value will be capped at 90.maxDeviation NumberoptionalDefault Value: 0The maximum distance a newly placed vertex on a densified polyline can deviate from the original location on the curve. 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 GeometryUnion Returns the densified geometry that does not contain any curves. Examples// Returns a densified poyline. const densified = densifyOperator.execute(polyline, 100);
// Returns a polyline where all curve segments have been densified. if (polyline.curvePaths) { const densified = densifyOperator.execute(polyline, 0, { maxAngleInDegrees: 1 }); }
-
executeMany
executeMany(geometries, maxSegmentLength, options){GeometryUnion[]}
-
Performs the Densify operation on the geometry set.
ParametersSpecificationgeometries GeometryUnion[]The set of geometries to be densified. All the geometries must have the same spatial reference.
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.ReturnsType Description GeometryUnion[] Returns the densified geometries that do not contain any curves.