@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
74 lines (68 loc) • 4.77 kB
TypeScript
/**
* Performs a topological operation for slicing a 2D polygon into smaller polygons.
*
* @since 4.31
*/
import type Polygon from "../Polygon.js";
import type Transformation from "./support/Transformation.js";
import type { AreaUnit } from "../../core/units.js";
export interface Options {
/**
* 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()](https://developers.arcgis.com/javascript/latest/references/core/geometry/operators/support/Transformation/#setIdentity). To slice vertically, apply [Transformation.setSwapCoordinates()](https://developers.arcgis.com/javascript/latest/references/core/geometry/operators/support/Transformation/#setSwapCoordinates) that swaps x and y coordinate values, and for an arbitrary angle, use [Transformation.rotate()](https://developers.arcgis.com/javascript/latest/references/core/geometry/operators/support/Transformation/#rotate).
*/
transform?: Transformation;
}
export interface FindSlicesByAreaOptions extends Options {
/**
* The area unit of the remaining area.
* The default is the input geometry's spatial reference unit.
* An error will be thrown if this is set for Geographic Coordinate Systems.
*/
unit?: AreaUnit;
}
/**
* Finds positions of the sliced strips for a given polygon given the number of equal area parts to slice the polygon into.
*
* @param polygon - The input polygon.
* @param partCount - The number of parts to slice into.
* @param remainingArea - The size of the remaining piece of the uncut polygon. Pass zero, if you want to slice the whole polygon.
* Unless the `unit` option is set, the default is the spatial reference unit of `polygon`.
* @param options - Additional options.
* @returns Returns the y-coordinate set for the slice positions sorted in increasing y-order. The set can be used as input to the [sliceIntoStrips()](https://developers.arcgis.com/javascript/latest/references/core/geometry/operators/polygonSlicerOperator/#sliceIntoStrips) method.
* @example
* // Find the slice positions for a polygon
* const slicePositions = polygonSlicerOperator.findSlicesByArea(polygon, 3, 0);
*/
export function findSlicesByArea(polygon: Polygon, partCount: number, remainingArea: number, options?: FindSlicesByAreaOptions): number[];
/**
* 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).
*
* @param polygon - The input polygon to slice.
* @param partCount - The number of equal area parts to slice the polygon into.
* @param options - Additional options.
* @returns 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 parts
* const slicedPolygons = polygonSlicerOperator.recursiveSliceEqualArea(polygon, 3);
*/
export function recursiveSliceEqualArea(polygon: Polygon, partCount: number, options?: Options): Polygon[];
/**
* Slices the given polygon into strips.
*
* @param polygon - The input polygon to slice.
* @param ySlices - 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 `ySlices` are given in the coordinates after transform is applied to the polygon.
* @param options - Additional options.
* @returns 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 strips
* const slicedPolygons = polygonSlicerOperator.sliceIntoStrips(polygon, [100, 200, 300]);
*/
export function sliceIntoStrips(polygon: Polygon, ySlices: number[], options?: Options): Polygon[];
/**
* Indicates if the operator supports input geometries that contain curves.
* The value will always be `true`.
*/
export const supportsCurves: boolean;