Skip to content

描述 ​

将任何 geojson Feature 或 Geometry 围绕其 centroid 或给定的 pivot 点旋转指定角度。

参数 ​

NameTypeDescription
geojsonGeoJSON待旋转的对象
anglenumber旋转角度(十进制度),顺时针为正
options?Object可选参数 (默认 {})
options.pivot?Coord旋转所围绕的点 (默认 'centroid')
options.mutate?boolean允许 GeoJSON 输入被修改(如果为 true 则性能显著提升) (默认 false)

返回值 ​

GeoJSON 旋转后的 GeoJSON 要素

示例 ​

javascript
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);

安装 ​

javascript
$ npm install @turf/transform-rotate

import { transformRotate } from "@turf/transform-rotate";
const result = transformRotate(...);
javascript
$ npm install @turf/turf

import * as turf from "@turf/turf";
const result = turf.transformRotate(...);