transformRotate
描述
🌐 Description
将任何 geojson 特性或几何体绕其 centroid 点或指定的 pivot 点旋转指定角度。
🌐 Rotates any geojson Feature or Geometry of a specified angle, around its centroid or a given pivot point.
参数
🌐 Parameters
| 名称 | 类型 | 描述 |
|---|---|---|
| geojson | GeoJSON | 要旋转的对象 |
| angle | number | 旋转角度(十进制度),顺时针为正 |
| options? | Object | 可选参数 (默认 {}) |
| options.pivot? | Coord | 旋转将围绕的点 (默认 'centroid') |
| options.mutate? | boolean | 允许修改 GeoJSON 输入(如果为真,性能将显著提高)(默认 false) |
返回
🌐 Returns
GeoJSON 旋转后的 GeoJSON 要素
示例
🌐 Examples
const poly = turf.polygon([
[
[0, 29],
[3.5, 29],
[2.5, 32],
[0, 29],
],
]);
const options = { pivot: [0, 25] };
const rotatedPoly = turf.transformRotate(poly, 10, options);
安装
🌐 Installation
$ npm install @turf/transform-rotate
import { transformRotate } from "@turf/transform-rotate";
const result = transformRotate(...);
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.transformRotate(...);