描述
将任何 geojson Feature 或 Geometry 沿指定方向角的 Rhumb Line 移动指定距离。
注意,这会单独移动您形状的点,因此可能改变整体形状。这取决于距离和使用的投影。
参数
| Name | Type | Description |
|---|---|---|
| geojson | GeoJSON | GeometryCollection | 待平移的对象 |
| distance | number | 移动长度;负值确定相反方向的移动 |
| direction | number | 移动方向;从北开始的十进制度数,顺时针为正 |
| options? | Object | 可选参数 (默认 {}) |
| options.units? | Units | distance 将以何种单位表示;支持所有有效的 Turf Units (默认 'kilometers') |
| options.zTranslation? | number | 垂直移动长度,与 distance 相同的单位 (默认 0) |
| options.mutate? | boolean | 允许 GeoJSON 输入被修改(如果为 true 则性能显著提升) (default false) |
返回值
GeoJSON | GeometryCollection 平移后的 GeoJSON 对象
示例
javascript
var poly = turf.polygon([
[
[0, 29],
[3.5, 29],
[2.5, 32],
[0, 29],
],
]);
var translatedPoly = turf.transformTranslate(poly, 100, 35);安装
javascript
$ npm install @turf/transform-translate
import { transformTranslate } from "@turf/transform-translate";
const result = transformTranslate(...);javascript
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.transformTranslate(...);