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
名称 | 类型 | 描述 |
---|---|---|
geojson | GeoJSON | GeometryCollection | 要平移的对象 |
distance | number | 运动长度;negative values determine motion in opposite direction |
direction | number | 运动的长度;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? | number | length of the vertical motion, same unit of distance (default 0) |
options.mutate? | boolean | allows 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(...);