supermap-wasi-geo
v1.1.0使用SuperMap WebAssembly 进行几何分析,支持缓冲区、凸包、相交、合并、擦除、裁剪等 20+ 种几何操作
Security Scan
OpenClaw
Benign
high confidencePurpose & Capability
名称、描述、SKILL.md 和代码文件(WASM glue + JS API + CLI)一致地实现了“使用 SuperMap WASM 做几何分析”的功能;未要求与该目的不符的环境变量或外部服务凭据。
Instruction Scope
SKILL.md 的运行/安装说明只涉及在本地安装/运行脚本、通过文件或 stdin 提供 GeoJSON、以及运行 CLI 或调用模块 API;说明未指示读取系统凭据、跨主机发送未授权数据或遍历任意文件系统。预扫描提示(base64-block)对应的是内嵌的 WASM 二进制,而非指令中要求的敏感操作。
Install Mechanism
没有 install spec(instruction-only),但包中包含一个 ~1.6MB 的 UGCWasmAll.js,其中以 data: URI/base64 形式内嵌了 WASM 二进制。这避免了运行时从外部 URL 下载,但也使二进制部分对人工审计更难(大体可理解为离线嵌入的 WASM 模块,功能上是合理的)。
Credentials
不要求任何环境变量、凭据或配置路径。代码在 node 环境中模拟浏览器 API(document/self/window/XMLHttpRequest)以初始化 WASM,但并未在代码中发现对外部凭据或第三方服务的访问请求。
Persistence & Privilege
skill 未声明 always: true,默认可由用户调用且允许模型自主调用(平台默认)。代码也不修改其他技能或系统级配置,也不持久化凭据。
Scan Findings in Context
[base64-block] expected: 检测到大段 base64 数据 URI —— 出现在 scripts/wasm/UGCWasmAll.js 作为内嵌 WASM 二进制是预期行为,用于离线包含 SuperMap WASM 模块。虽然这是合理的,但会使该二进制部分对人工审查更难。
Assessment
这是一个本地的 SuperMap WASM 几何分析实现,源代码和说明与其声明的功能一致;主要注意点:
- 内嵌 WASM(二进制以 base64 形式包含在 UGCWasmAll.js)是正常的,但该二进制较大且不易人工逐字审查——如果你对来源敏感,优先从 SuperMap 官方或你信任的分发渠道获取相同组件或索要校验和/源码构建说明。
- 包含的代码未请求凭据或联网凭证,但任何本地可执行代码都有风险:在对重要/敏感主机上运行前,建议先在隔离环境或沙箱中测试。
- 如果你需要更高保证,可要求包维护者提供:WASM 源或构建脚本、二进制的哈希校验或官方发行来源链接,或在受控环境下进行二进制行为监控(检测网络/文件系统活动)。
基于上述检查,这个 skill 在内部一致性上是良性的,但仍建议在敏感环境中采取常规防护(沙箱、校验来源、最小权限)。Like a lobster shell, security has layers — review code before you run it.
latest
SuperMap WASI Geometry Skill
基于 SuperMap WebAssembly 的高性能几何分析工具。支持 20+ 种几何分析操作,包括缓冲区分析、拓扑运算、距离计算等。
安装
# 进入项目目录
cd C:\supermap-wasi-geo
# 安装为全局命令(可选)
npm link
安装后可以直接使用 wasi-geo 命令,否则需要使用 node bin/supermap-wasi-geo.js。
支持的操作
单几何操作
| 操作 | 说明 | 参数 |
|---|---|---|
buffer | 缓冲区分析 | --input, --radius |
convex-hull | 凸包计算 | --input |
resample | 重采样分析 | --input, --tolerance |
smooth | 线要素光滑 | --input, --smoothness |
geodesic-distance | 测地线距离 | --input, [--major-axis], [--flatten] |
geodesic-area | 测地线面积 | --input, [--major-axis], [--flatten] |
parallel | 计算平行线 | --input, --distance |
双几何操作
| 操作 | 说明 | 参数 |
|---|---|---|
intersect | 相交分析 | --input1, --input2 |
union | 合并分析 | --input1, --input2 |
erase | 擦除分析 | --input1, --input2 |
xor | 异或分析 | --input1, --input2 |
clip | 裁剪分析 | --input1, --input2 |
has-intersection | 判断是否相交 | --input1, --input2, [--tolerance] |
has-touch | 判断边界是否接触 | --input1, --input2, [--tolerance] |
is-identical | 判断是否相等 | --input1, --input2, [--tolerance] |
distance | 计算两几何距离 | --input1, --input2 |
点线关系分析
| 操作 | 说明 | 参数 |
|---|---|---|
is-left | 点是否在线左侧 | --point, --line-start, --line-end |
is-right | 点是否在线右侧 | --point, --line-start, --line-end |
is-point-on-line | 点是否在线段上 | --point, --line-start, --line-end, [--extended] |
is-parallel | 两线是否平行 | --line1-start, --line1-end, --line2-start, --line2-end |
distance-to-line | 点到线段距离 | --point, --line-start, --line-end |
使用方式
Windows 命令行 (CMD)
# 基本用法:操作名 + 参数
node bin\supermap-wasi-geo.js buffer --input "{\"type\":\"Point\",\"coordinates\":[120,30]}" --radius 2
# 显示帮助
node bin\supermap-wasi-geo.js --help
# 显示特定操作帮助
node bin\supermap-wasi-geo.js buffer --help
Windows PowerShell
# 基本用法(使用单引号包裹)
node bin/supermap-wasi-geo.js buffer --input '{"type":"Point","coordinates":[120,30]}' --radius 2
# 管道输入
echo '{"type":"Point","coordinates":[120,30]}' | node bin/supermap-wasi-geo.js buffer --radius 2
通用参数
| 参数 | 说明 |
|---|---|
--input <json> | GeoJSON 字符串输入 |
--input-file <path> | 从文件读取 GeoJSON |
--output <path> | 输出到文件(默认 stdout) |
--pretty | 美化 JSON 输出 |
--help, -h | 显示帮助信息 |
--version, -v | 显示版本信息 |
示例
1. 缓冲区分析 (Windows CMD)
rem 点缓冲区
node bin\supermap-wasi-geo.js buffer --input "{\"type\":\"Point\",\"coordinates\":[120,30]}" --radius 2 --pretty
rem 线缓冲区
node bin\supermap-wasi-geo.js buffer --input "{\"type\":\"LineString\",\"coordinates\":[[0,0],[10,0]]}" --radius 0.5 --pretty
rem 多边形缓冲区
node bin\supermap-wasi-geo.js buffer --input "{\"type\":\"Polygon\",\"coordinates\":[[[0,0],[1,0],[1,1],[0,1],[0,0]]]}" --radius 0.1 --pretty
2. 距离计算 (Windows CMD)
rem 两点距离
node bin\supermap-wasi-geo.js distance --input1 "{\"type\":\"Point\",\"coordinates\":[0,0]}" --input2 "{\"type\":\"Point\",\"coordinates\":[3,4]}"
rem 输出: {"type":"Result","distance":5}
3. 相交判断 (Windows CMD)
node bin\supermap-wasi-geo.js has-intersection --input1 "{\"type\":\"Point\",\"coordinates\":[0,0]}" --input2 "{\"type\":\"Point\",\"coordinates\":[1,1]}"
rem 输出: {"type":"Result","hasIntersection":false}
4. 点线关系 (Windows CMD)
rem 判断点是否在线左侧
node bin\supermap-wasi-geo.js is-left --point "[0,1]" --line-start "[0,0]" --line-end "[1,0]"
rem 判断点是否在线段上
node bin\supermap-wasi-geo.js is-point-on-line --point "[0.5,0]" --line-start "[0,0]" --line-end "[1,0]"
rem 计算点到线段距离
node bin\supermap-wasi-geo.js distance-to-line --point "[0,1]" --line-start "[0,0]" --line-end "[1,0]"
5. 测地线计算 (Windows CMD)
rem 测地线距离(单位:米)
node bin\supermap-wasi-geo.js geodesic-distance --input "{\"type\":\"LineString\",\"coordinates\":[[0,0],[1,1]]}"
rem 测地线面积(单位:平方米)
node bin\supermap-wasi-geo.js geodesic-area --input "{\"type\":\"Polygon\",\"coordinates\":[[[0,0],[1,0],[1,1],[0,1],[0,0]]]}"
6. 文件输入输出
rem 从文件读取,输出到文件
node bin\supermap-wasi-geo.js buffer --input-file input.geojson --radius 2 --output buffer.geojson
rem 双几何操作
node bin\supermap-wasi-geo.js intersect --input1-file polygon1.geojson --input2-file polygon2.geojson --output intersect.geojson
7. PowerShell 示例
# 缓冲区分析
node bin/supermap-wasi-geo.js buffer --input '{"type":"Point","coordinates":[120,30]}' --radius 2 --pretty
# 距离计算
node bin/supermap-wasi-geo.js distance --input1 '{"type":"Point","coordinates":[0,0]}' --input2 '{"type":"Point","coordinates":[3,4]}'
# 管道操作
echo '{"type":"Point","coordinates":[0,0]}' | node bin/supermap-wasi-geo.js buffer --radius 1
支持的几何类型
- Point - 点
- LineString - 线
- Polygon - 多边形
- MultiPoint - 多点
- MultiLineString - 多线
- MultiPolygon - 多多边形
快速测试
cd e:\wasi_test
rem 显示帮助
node bin\supermap-wasi-geo.js --help
rem 测试缓冲区
node bin\supermap-wasi-geo.js buffer --input "{\"type\":\"Point\",\"coordinates\":[120,30]}" --radius 2 --pretty
rem 测试距离
node bin\supermap-wasi-geo.js distance --input1 "{\"type\":\"Point\",\"coordinates\":[0,0]}" --input2 "{\"type\":\"Point\",\"coordinates\":[3,4]}"
rem 测试点线关系
node bin\supermap-wasi-geo.js is-left --point "[0,1]" --line-start "[0,0]" --line-end "[1,0]"
Node.js 模块调用
也可以作为 Node.js 模块使用:
const GeometryAnalysis = require('./src/geometry-analysis.js');
async function main() {
// 缓冲区分析
const buffer = await GeometryAnalysis.buffer(
{ type: 'Point', coordinates: [120, 30] },
2
);
console.log('Buffer:', buffer);
// 距离计算
const dist = await GeometryAnalysis.distance(
{ type: 'Point', coordinates: [0, 0] },
{ type: 'Point', coordinates: [3, 4] }
);
console.log('Distance:', dist);
// 点线关系
const isLeft = await GeometryAnalysis.isLeft([0, 1], [0, 0], [1, 0]);
console.log('Is Left:', isLeft);
}
main();
注意事项
-
坐标单位:
- 缓冲区半径的单位与输入坐标系一致
- 经纬度坐标:单位为度
- 投影坐标:单位为米或其他投影单位
-
性能:首次调用需要初始化 WASM 模块,约需 1-2 秒
-
Windows 引号问题:
- CMD: 使用双引号
",内部双引号用\"转义 - PowerShell: 使用单引号
'包裹,内部使用双引号
- CMD: 使用双引号
-
路径分隔符:
- CMD: 使用反斜杠
\或正斜杠/ - PowerShell: 推荐使用正斜杠
/
- CMD: 使用反斜杠
错误处理
CLI 在出错时会返回非零退出码:
rem 测试错误情况
node bin\supermap-wasi-geo.js buffer --input "invalid" --radius 2
rem 检查退出码 (CMD)
echo %ERRORLEVEL%
API 参考
单几何操作
// 缓冲区分析
await GeometryAnalysis.buffer(input, radius);
// 凸包计算
await GeometryAnalysis.computeConvexHull(input);
// 重采样
await GeometryAnalysis.resample(input, tolerance);
// 光滑
await GeometryAnalysis.smooth(input, smoothness);
// 测地线距离
await GeometryAnalysis.computeGeodesicDistance(input, majorAxis?, flatten?);
// 测地线面积
await GeometryAnalysis.computeGeodesicArea(input, majorAxis?, flatten?);
// 平行线
await GeometryAnalysis.computeParallel(input, distance);
双几何操作
// 相交
await GeometryAnalysis.intersect(input1, input2);
// 合并
await GeometryAnalysis.union(input1, input2);
// 擦除
await GeometryAnalysis.erase(input1, input2);
// 异或
await GeometryAnalysis.xor(input1, input2);
// 裁剪
await GeometryAnalysis.clip(input1, input2);
// 判断相交
await GeometryAnalysis.hasIntersection(input1, input2, tolerance?);
// 判断接触
await GeometryAnalysis.hasTouch(input1, input2, tolerance?);
// 判断相等
await GeometryAnalysis.isIdentical(input1, input2, tolerance?);
// 计算距离
await GeometryAnalysis.distance(input1, input2);
点线关系
// 点是否在线左侧
await GeometryAnalysis.isLeft(point, lineStart, lineEnd);
// 点是否在线右侧
await GeometryAnalysis.isRight(point, lineStart, lineEnd);
// 点是否在线段上
await GeometryAnalysis.isPointOnLine(point, lineStart, lineEnd, extended?);
// 两线是否平行
await GeometryAnalysis.isParallel(line1Start, line1End, line2Start, line2End);
// 点到线段距离
await GeometryAnalysis.distanceToLineSegment(point, lineStart, lineEnd);
Comments
Loading comments...
