Skip to main content
Version: Next

transformTranslate

描述

¥Description

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运动长度;negative values determine motion in opposite direction
directionnumber运动的长度;angle from North in decimal degrees, positive clockwise
options?对象可选参数(默认
options.units?单位in which distance will be express;miles, kilometers, degrees, or radians (default 'kilometers')
options.zTranslation?numberlength of the vertical motion, same unit of distance (default 0)
options.mutate?booleanallows GeoJSON input to be mutated (significant performance increase if true) (default false)

返回

¥Returns

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