transformScale
描述
🌐 Description
从给定点按缩放因子缩放 GeoJSON 对象,例如 factor=2 会使每个对象变大 200%。如果提供的是 FeatureCollection,原点将基于每个单独的要素计算,除非提供了精确的点。
🌐 Scale GeoJSON objects from a given point by a scaling factor e.g. factor=2 would make each object 200% larger. If a FeatureCollection is provided, the origin point will be calculated based on each individual feature unless an exact
参数
🌐 Parameters
| 名称 | 类型 | 描述 |
|---|---|---|
| geojson | GeoJSON | GeometryCollection | 要缩放的对 象 |
| 因子 | 数字 | 缩放因子,正值大于 0。介于 0 和 1 之间的数字将缩小 geojson,大于 1 的数字将放大 geojson,因子为 1 时不会改变 geojson。 |
| options? | 对象 | 可选参数 (默认 {}) |
| options.origin? | 角 | 坐标 | 缩放的起始点(字符串选项:sw/se/nw/ne/center/centroid) (默认 'centroid') |
| options.mutate? | 布尔 | 允许修改 GeoJSON 输入(如果为 true,性能将显著提高)(默认 false) |
返回
🌐 Returns
GeoJSON | GeometryCollection 缩放的 GeoJSON
示例
🌐 Examples
const poly = turf.polygon([
[
[0, 29],
[3.5, 29],
[2.5, 32],
[0, 29],
],
]);
const scaledPoly = turf.transformScale(poly, 3);
安装
🌐 Installation
$ npm install @turf/transform-scale
import { transformScale } from "@turf/transform-scale";
const result = transformScale(...);
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.transformScale(...);