transformScale
描述
¥Description
按指定比例缩放 GeoJSON 对象,例如,比例因子 = 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 | 要缩放的对象 |
factor | number | 缩放比例,大于 0 的正值。0 到 1 之间的数字会缩小 GeoJSON 数据,大于 1 的数字会扩大 GeoJSON 数据,因子 1 不会改变 GeoJSON 数据。 |
options? | 对象 | 可选参数(默认 {}) |
options.origin? | 角落 | 坐标系 | 缩放发生的起点(字符串选项:sw/se/nw/ne/center/centroid)(默认为 'centroid') |
options.mutate? | boolean | 允许 GeoJSON 输入发生修改(如果为 true,则性能显著提升)(默认为 false) |
返回
¥Returns
GeoJSON | GeometryCollection 缩放的 GeoJSON
¥GeoJSON | GeometryCollection scaled 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(...);