描述
从几何体字符串类型和坐标创建 GeoJSON Geometry。 对于 GeometryCollection 类型,使用 helpers.geometryCollection。
参数
| 名称 | 类型 | 描述 |
|---|---|---|
| type | "Point" | "LineString" | "Polygon" | "MultiPoint" | "MultiLineString" | "MultiPolygon" | Geometry 类型 |
| coordinates | Array<any> | 坐标 |
| _options | Record<string, never> | (默认 {}) |
| options? | Object | 可选参数 (默认 {}) |
返回值
Geometry GeoJSON Geometry
示例
javascript
var type = "Point";
var coordinates = [110, 50];
var geometry = turf.geometry(type, coordinates);
// => geometry安装
javascript
$ npm install @turf/helpers
import { geometry } from "@turf/helpers";
const result = geometry(...);javascript
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.geometry(...);