import { findSlicesByArea, recursiveSliceEqualArea, sliceIntoStrips, supportsCurves } from "@arcgis/core/geometry/operators/polygonSlicerOperator.js";const { findSlicesByArea, recursiveSliceEqualArea, sliceIntoStrips, supportsCurves } = await $arcgis.import("@arcgis/core/geometry/operators/polygonSlicerOperator.js");- Since
- ArcGIS Maps SDK for JavaScript 4.31
Performs a topological operation for slicing a 2D polygon into smaller polygons.
Type definitions
Options
transform
- Type
- Transformation | undefined
The affine transformation to apply to the polygon before slicing. When applying the transformation, the slicing starts from the bottom and proceeds to the top. The default is the identity transformation. For horizontal slices, use Transformation.setIdentity(). To slice vertically, apply Transformation.setSwapCoordinates() that swaps x and y coordinate values, and for an arbitrary angle, use Transformation.rotate().
Functions
findSlicesByArea
Finds positions of the sliced strips for a given polygon given the number of equal area parts to slice the polygon into.
- Signature
-
findSlicesByArea (polygon: Polygon, partCount: number, remainingArea: number, options?: FindSlicesByAreaOptions): number[]
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| polygon | The input polygon. | | |
| partCount | The number of parts to slice into. | | |
| remainingArea | The size of the remaining piece of the uncut polygon. Pass zero, if you want to slice the whole polygon.
Unless the | | |
| options | Additional options. | |
- Returns
- number[]
Returns the y-coordinate set for the slice positions sorted in increasing y-order. The set can be used as input to the sliceIntoStrips() method.
Example
// Find the slice positions for a polygonconst slicePositions = polygonSlicerOperator.findSlicesByArea(polygon, 3, 0); recursiveSliceEqualArea
Slices the given polygon into equal area parts, not necessarily strips. The slicing is done recursively, each time slicing the polygon into two parts along the larger dimension (height or width).
- Signature
-
recursiveSliceEqualArea (polygon: Polygon, partCount: number, options?: Options): Polygon[]
Parameters
- Returns
- Polygon[]
Returns the array of polygons that are the result of the slicing. The number of output polygons will not necessarily match the number of requested slices. For example, if some of the slices became degenerate, they may not be output. The method uses topological operations that rely on the tolerance value in the input spatial reference. These operations may shift vertices in a way that affects result areas.
Example
// Slice a polygon into equal area partsconst slicedPolygons = polygonSlicerOperator.recursiveSliceEqualArea(polygon, 3); sliceIntoStrips
Slices the given polygon into strips.
- Signature
-
sliceIntoStrips (polygon: Polygon, ySlices: number[], options?: Options): Polygon[]
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| polygon | The input polygon to slice. | | |
| ySlices | number[] | The array of y coordinates, sorted in ascending order. The polygon will be transformed with the transform, and then it will be sliced horizontally at each y coordinate. That is, the | |
| options | Additional options. | |
- Returns
- Polygon[]
Returns the array of polygons that are the result of the slicing. The number of output polygons will not necessarily match the number of requested slices. For example, if some of the slices became degenerate, they may not be output. The method uses topological operations that rely on the tolerance value in the input spatial reference. These operations may shift vertices in a way that affects result areas.
Example
// Slice a polygon into stripsconst slicedPolygons = polygonSlicerOperator.sliceIntoStrips(polygon, [100, 200, 300]);Variables
supportsCurves
Indicates if the operator supports input geometries that contain curves.
The value will always be true.
- Type
- boolean