描述
从给定点按缩放因子缩放 GeoJSON 对象。例如 factor=2 会使每个对象变大 200%。 如果提供 FeatureCollection,则将根据每个单独要素计算原点,除非提供精确的原点。
参数
| Name | Type | Description |
|---|---|---|
| geojson | GeoJSON | GeometryCollection | 待缩放的对象 |
| factor | number | 缩放因子,正值大于 0。0 到 1 之间的数字将缩小 geojson,大于 1 的数字将放大它,因子 1 不会改变 geojson。 |
| options? | Object | 可选参数 (默认 {}) |
| options.origin? | Corners | Coord | 缩放发生的点(字符串选项:sw/se/nw/ne/center/centroid) (默认 'centroid') |
| options.mutate? | boolean | 允许 GeoJSON 输入被修改(如果为 true 则性能显著提升) (default false) |
返回值
GeoJSON | GeometryCollection 缩放后的 GeoJSON
示例
javascript
const poly = turf.polygon([
[
[0, 29],
[3.5, 29],
[2.5, 32],
[0, 29],
],
]);
const scaledPoly = turf.transformScale(poly, 3);安装
javascript
$ npm install @turf/transform-scale
import { transformScale } from "@turf/transform-scale";
const result = transformScale(...);javascript
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.transformScale(...);