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
| 名称 | 类型 | 描述 |
|---|---|---|
| geojson | GeoJSON | GeometryCollection | 要翻译的对象 |
| distance | number | 运动的长度;负值表示运动方向相反 |
| direction | number | 运动的方向;从北方开始的角度,十进制度表示,顺时针为正 |
| 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(...);