Skip to main content
Version: 7.2.0

bbox

描述

¥Description

计算任何 GeoJSON 对象(包括 FeatureCollection)的边界框。如果 geojson.bbox 可用且未设置 options.recompute,则使用 geojson.bbox。

¥Calculates the bounding box for any GeoJSON object, including FeatureCollection. Uses geojson.bbox if available and options.recompute is not set.

参数

¥Parameters

名称类型描述
geojsonGeoJSON任意 GeoJSON 对象
options?对象可选参数(默认 {})
options.recompute?boolean是否忽略 geojson 上现有的 bbox 属性

返回

¥Returns

BBox 边界框范围,顺序为 [minX, minY, maxX, maxY]

¥BBox bbox extent in [minX, minY, maxX, maxY] order

示例

¥Examples

var line = turf.lineString([
[-74, 40],
[-78, 42],
[-82, 35],
]);
var bbox = turf.bbox(line);
var bboxPolygon = turf.bboxPolygon(bbox);

安装

¥Installation

$ npm install @turf/bbox

import { bbox } from "@turf/bbox";
const result = bbox(...);
$ npm install @turf/turf

import * as turf from "@turf/turf";
const result = turf.bbox(...);