Skip to main content
Version: 7.3.0

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

名称类型描述
geojsonGeoJSON | GeometryCollection要缩放的对象
factornumber缩放时,正值大于0。介于0和1之间的数字会缩小GeoJSON,超过1的数字会放大GeoJSON,因子为1不会改变GeoJSON。
options?Object可选参数 (默认 {})
options.origin?Corners | Coord缩放将发生的点(字符串选项:sw/se/nw/ne/center/centroid) (默认 'centroid')
options.mutate?boolean允许修改 GeoJSON 输入(如果为真,将显著提高性能) (默认 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(...);