Skip to main content
Version: 7.2.0

transformTranslate

描述

¥Description

沿指定方向角的恒向线移动指定距离的任何 GeoJSON 要素或几何体。

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

参数

¥Parameters

名称类型描述
geojsonGeoJSON | GeometryCollection要平移的对象
distancenumber运动长度;负值表示反方向运动
directionnumber运动的长度;以十进制度数表示的与北的夹角,顺时针方向为正
options?对象可选参数(默认 {})
options.units?单位其中 distance 将以下列单位表示;英里、公里、度或弧度(默认值为 'kilometers')
options.zTranslation?number垂直运动的长度,与距离单位相同(默认值为 0)
options.mutate?boolean允许 GeoJSON 输入发生修改(如果为 true,则性能显著提升)(默认为 false)

返回

¥Returns

GeoJSON | GeometryCollection 转换后的 GeoJSON 对象

¥GeoJSON | GeometryCollection the translated GeoJSON object

示例

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