Buffer 缓冲区分析
简介
缓冲区分析用于在指定目标(如点、线、面)周围,生成一定距离范围内的区域,用于表示影响范围或服务覆盖范围。在 Cesium 中,该功能常用于划定安全警戒区、分析设施周边影响范围,如地铁站500米生活圈、河流污染带等,为城市规划、应急响应、环境保护等提供空间决策支持。
演练场
引入
ts
import { Buffer } from "@m-tech/gis-core";
new Buffer(viewer, options);参数
| 参数 | 类型 | 必填 | 默认值 | 描述 |
|---|---|---|---|---|
viewer | Viewer | 是 | - | 容器 |
options | Object | 是 | {} | 缓冲区分析配置 |
options.type | BufferType | 是 | BufferType.POLYGON | 缓冲区类型 |
options.positions | Position[] | 是 | Position[] | 目标位置 |
options.distance | number | 否 | 10 | 缓冲区距离 |
options.color | Color | 否 | Color.RED | 缓冲区颜色 |
属性
| 属性名 | 类型 | 读/写 | 描述 |
|---|---|---|---|
buffered | Position[] | 读 | 缓冲区结果 |
delegate | Entity | 读 | 缓冲区实体 |
distance | number | 读写 | 缓冲区距离 |
type | BufferType | 读 | 缓冲区类型 |
方法
clear()
清除缓冲区。
示例
ts
import { Buffer, BufferType } from "@m-tech/gis-core";
// 点缓冲区
const bufferPoint = new Buffer(viewer, {
type: BufferType.POINT,
positions: [new Position(114.31, 30.57)],
distance: 100,
color: Color.BLUE.withAlpha(0.5),
});
// 线缓冲区
const bufferPolyline = new Buffer(viewer, {
type: BufferType.POLYLINE,
positions: [new Position(114.31, 30.57), new Position(114.32, 30.58)],
distance: 100,
color: Color.GREEN.withAlpha(0.5),
});
// 面缓冲区
const bufferPolygon = new Buffer(viewer, {
type: BufferType.POLYGON,
positions: [
new Position(114.31, 30.57),
new Position(114.32, 30.58),
new Position(114.33, 30.59),
],
distance: 100,
color: Color.RED.withAlpha(0.5),
});
// 清除缓冲区
bufferPoint.clear();
bufferPolyline.clear();
bufferPolygon.clear();