Skip to main content
Version: 7.2.0

transformRotate

描述

¥Description

围绕其 centroid 或给定的 pivot 点,按指定角度旋转任何 geojson 要素或几何体。

¥Rotates any geojson Feature or Geometry of a specified angle, around its centroid or a given pivot point.

参数

¥Parameters

名称类型描述
geojsonGeoJSON要旋转的对象
anglenumber旋转角度(十进制度),顺时针旋转正数
options?对象可选参数(默认 {})
options.pivot?坐标系旋转将围绕其执行的点(默认 'centroid')
options.mutate?boolean允许 GeoJSON 输入发生修改(如果为 true,则性能显著提升)(默认为 false)

返回

¥Returns

GeoJSON 旋转后的 GeoJSON 要素

¥GeoJSON the rotated GeoJSON feature

示例

¥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(...);