Skip to main content
Version: 7.3.0

transformTranslate

描述

🌐 Description

沿指定方向角将任何 GeoJSON 特性或几何体沿等角航线移动指定距离。

🌐 Moves any geojson Feature or Geometry of a specified distance along a Rhumb Line on the provided direction angle.

请注意,这会单独移动形状的各个点,因此可能会改变整体形状。其可见程度取决于距离和所使用的投影方式。

🌐 Note that this moves the points of your shape individually and can therefore change the overall shape. How noticable this is depends on the distance and the used projection.

参数

🌐 Parameters

名称类型描述
geojsonGeoJSON | GeometryCollection要翻译的对象
distancenumber运动的长度;负值表示运动方向相反
directionnumber运动的方向;从北方开始的角度,十进制度表示,顺时针为正
options?Object可选参数 (默认 {})
options.units?Units将用 distance 表示;支持所有有效的 Turf 单位 (默认 '公里')
options.zTranslation?number垂直运动的长度,相同的距离单位 (默认 0)
options.mutate?boolean允许修改 GeoJSON 输入(如果为真,性能将显著提高)(默认 false)

返回

🌐 Returns

GeoJSON | GeometryCollection 翻译后的 GeoJSON 对象

示例

🌐 Examples

var poly = turf.polygon([
[
[0, 29],
[3.5, 29],
[2.5, 32],
[0, 29],
],
]);
var translatedPoly = turf.transformTranslate(poly, 100, 35);

安装

🌐 Installation

$ npm install @turf/transform-translate

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

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