▾
import { polygonSlicerFindSlicesByArea, findSlicesByArea, polygonSlicerRecursiveSliceEqualArea, recursiveSliceEqualArea, polygonSlicerSliceIntoStrips } from "@arcgis/core/geometry/operators/polygonSlicerOperator.js";const { polygonSlicerFindSlicesByArea, findSlicesByArea, polygonSlicerRecursiveSliceEqualArea, recursiveSliceEqualArea, polygonSlicerSliceIntoStrips } = 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
PolygonSlicerOptions
- Since
- ArcGIS Maps SDK for JavaScript 5.2
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().
PolygonSlicerFindSlicesByAreaOptions
- Since
- ArcGIS Maps SDK for JavaScript 5.2
- Supertypes
- PolygonSlicerOptions
Functions
polygonSlicerFindSlicesByArea
- Since
- ArcGIS Maps SDK for JavaScript 5.2
Finds positions of the sliced strips for a given polygon given the number of equal area parts to slice the polygon into.
- Signature
-
polygonSlicerFindSlicesByArea (polygon: Polygon, partCount: number, remainingArea: number, options?: PolygonSlicerFindSlicesByAreaOptions): 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 polygonSlicerSliceIntoStrips() method.
- Example
- // Find the slice positions for a polygonconst slicePositions = polygonSlicerFindSlicesByArea(polygon, 3, 0);
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?: PolygonSlicerFindSlicesByAreaOptions): 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 polygonSlicerSliceIntoStrips() method.
- Example
- // Find the slice positions for a polygonconst slicePositions = polygonSlicerFindSlicesByArea(polygon, 3, 0);
polygonSlicerRecursiveSliceEqualArea
- Since
- ArcGIS Maps SDK for JavaScript 5.2
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
-
polygonSlicerRecursiveSliceEqualArea (polygon: Polygon, partCount: number, options?: PolygonSlicerOptions): Polygon[]
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| polygon | The input polygon to slice. | | |
| partCount | The number of equal area parts to slice the polygon into. | | |
| 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 equal area partsconst slicedPolygons = polygonSlicerRecursiveSliceEqualArea(polygon, 3);
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?: PolygonSlicerOptions): Polygon[]
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| polygon | The input polygon to slice. | | |
| partCount | The number of equal area parts to slice the polygon into. | | |
| 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 equal area partsconst slicedPolygons = polygonSlicerRecursiveSliceEqualArea(polygon, 3);
polygonSlicerSliceIntoStrips
- Since
- ArcGIS Maps SDK for JavaScript 5.2
Slices the given polygon into strips.
- Signature
-
polygonSlicerSliceIntoStrips (polygon: Polygon, ySlices: number[], options?: PolygonSlicerOptions): 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 = polygonSlicerSliceIntoStrips(polygon, [100, 200, 300]);
sliceIntoStrips
Slices the given polygon into strips.
- Signature
-
sliceIntoStrips (polygon: Polygon, ySlices: number[], options?: PolygonSlicerOptions): 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 = polygonSlicerSliceIntoStrips(polygon, [100, 200, 300]);
Variables
polygonSlicerSupportsCurves
- Since
- ArcGIS Maps SDK for JavaScript 5.2
Indicates if the operator supports input geometries that contain curves.
The value will always be true.
- Type
- boolean
supportsCurves
Indicates if the operator supports input geometries that contain curves.
The value will always be true.
- Type
- ReturnType