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 | 要翻译的对象 |
| 距离 | 数字 | 运动的长度;负值表示朝相反方向的运动 |
| 方向 | 数字 | 运动方向;从北方起的角度(十进制度),顺时针为正 |
| options? | 对象 | 可选参数 (默认 {}) |
| options.units? | 单位 | distance 将以哪种单位表示;支持所有有效的 Turf 单位 (默认 '公里') |
| options.zTranslation? | 数字 | 垂直运动的长度,相同的距离单位 (默认 0) |
| options.mutate? | 布尔值 | 允许修改 GeoJSON 输入(如果为 true,将显著提高性能)(默认 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(...);