@dsh-gis/dsh-opengis-skill 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/CHANGELOG.md +71 -0
  2. package/README.md +79 -43
  3. package/THIRD_PARTY_NOTICES.md +9 -0
  4. package/adaptations/brutile.md +8 -0
  5. package/adaptations/cesiumjs.md +8 -0
  6. package/adaptations/common.md +16 -0
  7. package/adaptations/deck-gl.md +8 -0
  8. package/adaptations/duckdb-spatial.md +8 -0
  9. package/adaptations/gdal-api.md +8 -0
  10. package/adaptations/gdal.md +8 -0
  11. package/adaptations/geolibre.md +8 -0
  12. package/adaptations/geometry-api-java.md +8 -0
  13. package/adaptations/geometry-api-net.md +8 -0
  14. package/adaptations/geonode.md +8 -0
  15. package/adaptations/geopandas.md +8 -0
  16. package/adaptations/geopipe-agent.md +8 -0
  17. package/adaptations/geoserver-cloud.md +8 -0
  18. package/adaptations/geoserver-rest-api.md +8 -0
  19. package/adaptations/geoserver.md +8 -0
  20. package/adaptations/geotools.md +8 -0
  21. package/adaptations/grass-gis.md +8 -0
  22. package/adaptations/jts.md +8 -0
  23. package/adaptations/kepler-gl.md +8 -0
  24. package/adaptations/leaflet.md +8 -0
  25. package/adaptations/mapbox-gl-js.md +8 -0
  26. package/adaptations/mapserver.md +8 -0
  27. package/adaptations/mapsui.md +8 -0
  28. package/adaptations/nettopologysuite.md +8 -0
  29. package/adaptations/opengis-all.md +8 -0
  30. package/adaptations/opengis-daf.md +8 -0
  31. package/adaptations/opengis-utils-for-java.md +8 -0
  32. package/adaptations/opengis-utils-for-net.md +8 -0
  33. package/adaptations/openlayers.md +8 -0
  34. package/adaptations/pdal.md +8 -0
  35. package/adaptations/postgis.md +8 -0
  36. package/adaptations/proj.md +8 -0
  37. package/adaptations/projnet4geoapi.md +8 -0
  38. package/adaptations/pyqgis.md +8 -0
  39. package/adaptations/qgis-process.md +8 -0
  40. package/adaptations/qgis-server.md +8 -0
  41. package/adaptations/shapely.md +8 -0
  42. package/adaptations/sharpmap.md +8 -0
  43. package/adaptations/spatialite.md +8 -0
  44. package/adaptations/whitebox-tools.md +8 -0
  45. package/assets/brutile/SKILL.md +289 -0
  46. package/assets/cesiumjs/SKILL.md +78 -29
  47. package/assets/deck-gl/SKILL.md +20 -20
  48. package/assets/duckdb-spatial/SKILL.md +370 -0
  49. package/assets/gdal/SKILL.md +50 -55
  50. package/assets/gdal-api/SKILL.md +12 -29
  51. package/assets/geolibre/SKILL.md +364 -0
  52. package/assets/geometry-api-java/SKILL.md +11 -19
  53. package/assets/geometry-api-net/SKILL.md +66 -29
  54. package/assets/geonode/SKILL.md +347 -0
  55. package/assets/geopandas/SKILL.md +22 -28
  56. package/assets/geopipe-agent/SKILL.md +25 -30
  57. package/assets/geoserver/SKILL.md +21 -24
  58. package/assets/geoserver-cloud/SKILL.md +23 -34
  59. package/assets/geoserver-rest-api/SKILL.md +18 -23
  60. package/assets/geotools/SKILL.md +13 -21
  61. package/assets/grass-gis/SKILL.md +19 -20
  62. package/assets/jts/SKILL.md +12 -17
  63. package/assets/kepler-gl/SKILL.md +313 -0
  64. package/assets/leaflet/SKILL.md +42 -17
  65. package/assets/mapbox-gl-js/SKILL.md +19 -18
  66. package/assets/mapserver/SKILL.md +18 -18
  67. package/assets/mapsui/SKILL.md +87 -58
  68. package/assets/nettopologysuite/SKILL.md +96 -27
  69. package/assets/opengis-all/SKILL.md +80 -292
  70. package/assets/opengis-all/reference/data-stages.md +262 -4
  71. package/assets/opengis-daf/SKILL.md +12 -14
  72. package/assets/opengis-utils-for-java/SKILL.md +52 -47
  73. package/assets/opengis-utils-for-java/reference/common-tasks.md +12 -12
  74. package/assets/opengis-utils-for-net/SKILL.md +106 -40
  75. package/assets/opengis-utils-for-net/reference/code-patterns.md +11 -11
  76. package/assets/opengis-utils-for-net/reference/util-classes.md +25 -26
  77. package/assets/openlayers/SKILL.md +71 -14
  78. package/assets/pdal/SKILL.md +21 -15
  79. package/assets/postgis/SKILL.md +66 -18
  80. package/assets/proj/SKILL.md +29 -42
  81. package/assets/projnet4geoapi/SKILL.md +299 -0
  82. package/assets/pyqgis/SKILL.md +28 -54
  83. package/assets/qgis-process/SKILL.md +67 -39
  84. package/assets/qgis-server/SKILL.md +21 -32
  85. package/assets/shapely/SKILL.md +133 -84
  86. package/assets/sharpmap/SKILL.md +96 -61
  87. package/assets/spatialite/SKILL.md +365 -0
  88. package/assets/whitebox-tools/SKILL.md +269 -0
  89. package/lib/adaptations.d.ts +47 -0
  90. package/lib/adaptations.js +268 -0
  91. package/lib/index.d.ts +1 -1
  92. package/lib/index.js +14 -2
  93. package/lib/skill-file.js +31 -7
  94. package/locale/en.json +1 -1
  95. package/locale/zh.json +1 -1
  96. package/package.json +12 -2
  97. package/upstream.json +56 -40
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: geoserver-cloud
3
- description: "Use when deploying GeoServer on Kubernetes as cloud-native microservices with auto-scaling, service discovery, and centralized configuration. GeoServer Cloud: break monolithic GeoServer into independently scalable WMS/WFS/WCS services."
3
+ description: "Use when deploying GeoServer Cloud 3.0.2 on Docker Compose or Kubernetes — gateway serving WMS/WFS/WCS/WPS/GWC microservices under /geoserver/cloud, PgConfig vs datadir backends, RabbitMQ config-bus sync, Helm chart geoservercloud 3.0.2, and diagnosing 502s via actuator/health and Consul registration."
4
4
  tags:
5
5
  - java
6
6
  - server
@@ -18,9 +18,9 @@ tags:
18
18
  >
19
19
  > **官方文档:** <https://geoserver.org/geoserver-cloud/>
20
20
  >
21
- > **Docker Hub:** <https://hub.docker.com/u/geoservercloud>(镜像标签与 GeoServer 主版本对应,如 `3.0.1.1`)
21
+ > **Docker Hub:** <https://hub.docker.com/u/geoservercloud>(镜像标签与 GeoServer 主版本对应,如 `3.0.2`)
22
22
  >
23
- > **最新版本:** 3.0.1.1(截至 2026-10,[GitHub Releases](https://github.com/geoserver/geoserver-cloud/releases))
23
+ > **最新版本:** 3.0.2(2026-10-20,[GitHub Releases](https://github.com/geoserver/geoserver-cloud/releases))
24
24
  >
25
25
  > **许可证:** GPL-2.0
26
26
 
@@ -43,7 +43,7 @@ GeoServer Cloud(GS Cloud):
43
43
  | 服务 | 镜像 | 用途 |
44
44
  |------|------|------|
45
45
  | `gateway` | `geoservercloud/geoserver-cloud-gateway` | 网关 |
46
- | `discovery` | `geoservercloud/geoserver-cloud-discovery` | 服务发现(3.x 的官方 compose 改用 `hashicorp/consul`) |
46
+ | `discovery` | —(3.x 不再发布该镜像) | 服务发现:官方 compose/K8s 改用 `hashicorp/consul`,`geoservercloud/geoserver-cloud-discovery:3.0.2` 在 Docker Hub 已 404 |
47
47
  | `config` | `geoservercloud/geoserver-cloud-config` | 配置中心 |
48
48
  | `web-ui` | `geoservercloud/geoserver-cloud-webui` | 管理界面 |
49
49
  | `rest` | `geoservercloud/geoserver-cloud-rest` | REST API |
@@ -98,7 +98,7 @@ PGCONFIG_SCHEMA: "pgconfig" # 启动时自动创建 schema
98
98
  ## Kubernetes(Helm)
99
99
 
100
100
  ```bash
101
- # Chart:camptocamp/helm-geoserver-cloud(chart 名 geoservercloud,最新 3.0.1)
101
+ # Chart:camptocamp/helm-geoserver-cloud(chart 名 geoservercloud,最新 3.0.2)
102
102
  helm repo add geoserver-cloud https://camptocamp.github.io/helm-geoserver-cloud
103
103
  helm repo update
104
104
  ```
@@ -110,7 +110,7 @@ helm repo update
110
110
  > dependencies:
111
111
  > - name: geoservercloud
112
112
  > repository: https://camptocamp.github.io/helm-geoserver-cloud
113
- > version: 3.0.1
113
+ > version: 3.0.2
114
114
  > ```
115
115
  >
116
116
  > ```yaml
@@ -182,7 +182,7 @@ management:
182
182
  ```bash
183
183
  docker run -e SPRING_PROFILES_ACTIVE=datadir \
184
184
  -v /mnt/gsdata:/opt/app/data_directory \
185
- geoservercloud/geoserver-cloud-wms:3.0.1.1
185
+ geoservercloud/geoserver-cloud-wms:3.0.2
186
186
  ```
187
187
 
188
188
  ---
@@ -198,17 +198,6 @@ docker run -e SPRING_PROFILES_ACTIVE=datadir \
198
198
 
199
199
  ---
200
200
 
201
- ## 常见问题
202
-
203
- | 问题 | 解决 |
204
- |------|------|
205
- | 配置不同步 | 检查 RabbitMQ 可达 + `GEOSERVER_BUS_ENABLED=true` |
206
- | Web UI 改了 wms 没生效 | 检查事件订阅 |
207
- | 启动顺序错乱 | `depends_on` + 健康检查;K8s 用 `initContainers` |
208
- | OOM | 调整 `-Xmx`,按服务独立资源 |
209
- | Gateway 502 / 服务不可达 | 检查目标服务健康状态与 Consul 注册(服务名解析:`wms`、`wfs` 等) |
210
- | 瓦片 404 / 缓存未命中 | 确认 gwc 服务已部署、`GEOSERVER_BASE_PATH` 与请求路径一致,必要时重新 seed |
211
-
212
201
  ---
213
202
 
214
203
  ## 典型工作流
@@ -247,25 +236,25 @@ kubectl -n gis get deploy | grep wms
247
236
  kubectl -n gis scale deploy <wms-deployment> --replicas=10
248
237
  ```
249
238
 
250
- ## AI 使用建议
251
-
252
- ### 推荐工作流
239
+ ## 常见问题
253
240
 
254
- 1. **确定架构**:根据业务需求选择配置后端(生产推荐 PgConfig)
255
- 2. **部署基础设施**:先部署 RabbitMQ + PostgreSQL(PgConfig 目录库),再启动微服务
256
- 3. **启动服务**:下载官方稳定版 docker-compose 文件或用 Helm Chart 部署
257
- 4. **验证服务**:通过 Gateway (`localhost:9090/geoserver/cloud`) 访问 Web UI
258
- 5. **配置监控**:启用 Prometheus + Grafana 监控各微服务状态
259
- 6. **弹性伸缩**:按负载独立扩缩 WMS/WFS 等服务的副本数
241
+ | 问题 | 解决 |
242
+ |------|------|
243
+ | 配置不同步 | 检查 RabbitMQ 可达 + `GEOSERVER_BUS_ENABLED=true` |
244
+ | Web UI 改了 wms 没生效 | 检查事件订阅 |
245
+ | 启动顺序错乱 | `depends_on` + 健康检查;K8s 用 `initContainers` |
246
+ | OOM | 调整 `-Xmx`,按服务独立资源 |
247
+ | Gateway 502 / 服务不可达 | 检查目标服务健康状态与 Consul 注册(服务名解析:`wms`、`wfs` 等) |
248
+ | 瓦片 404 / 缓存未命中 | 确认 gwc 服务已部署、`GEOSERVER_BASE_PATH` 与请求路径一致,必要时重新 seed |
260
249
 
261
- ### 关键注意事项
250
+ ## AI 使用建议
262
251
 
263
- - **启动顺序**:先启动 discovery/Consul → config → 数据库/RabbitMQ → 各业务服务
264
- - **配置同步**:确保 `GEOSERVER_BUS_ENABLED=true` 且 RabbitMQ 可达
265
- - **路径前缀**:默认 `GEOSERVER_BASE_PATH=/geoserver/cloud`,构造服务 URL 时不要漏掉
266
- - **PgConfig 一致性**:多副本共享同一个 PgConfig 数据库实现强一致
267
- - **JVM 独立调优**:每个微服务根据负载独立设置 `-Xmx`,避免 OOM
268
- - **不部署不需要的服务**:如不使用 WPS/WCS,直接从 docker-compose 中移除
252
+ - **执行环境**:命令在终端 / shell 中执行(Windows 无 `wget`,改 `curl.exe -LO`);先用 `docker version`、`helm version`、`kubectl version --client` 确认工具在 PATH。
253
+ - **先探测版本**:`curl.exe -s -u admin:geoserver http://localhost:9090/geoserver/cloud/rest/about/version.json` 读 GeoServer 版本;`curl.exe -s http://localhost:9090/actuator/health` 取 `{"status":"UP"}`(被 profile 关掉时改用 `kubectl -n gis get pods` 判活)。
254
+ - **验证产物**:部署后逐服务探活,再经网关 `.../rest/workspaces.json` 与一次 WMS `GetMap` 走通全链路;`docker compose ps` 显示 Up 不等于 OGC 服务可用。
255
+ - **排障顺序**:502 → 查 Consul 注册与目标服务健康(`kubectl -n gis logs deploy/<wms>`);配置不生效 → 查 RabbitMQ 与 `GEOSERVER_BUS_ENABLED`;瓦片 404 → 查 gwc 是否部署、`GEOSERVER_BASE_PATH` 前缀是否一致。
256
+ - **安全与权限**:`admin:geoserver`、`PGCONFIG_PASSWORD`、RabbitMQ 口令不要回显到报告;`docker compose down -v`、`helm uninstall`、删 PVC 或 PgConfig schema 会丢配置,先向用户确认并备份。
257
+ - **先本地复现**:能在 docker compose 复现的问题再上 K8s;镜像标签与 chart 版本保持同一版本号(3.0.2),避免网关与服务错配。
269
258
 
270
259
  ## 相关技能
271
260
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: geoserver-rest-api
3
- description: "Use when automating GeoServer management — programmatic workspace, datastore, and layer creation, style upload, service configuration via REST API. GeoServer REST API: manage GeoServer without GUI using curl, Python, or any HTTP client."
3
+ description: "Use when automating GeoServer 3.0.2 over REST — POST /rest/workspaces, datastores, featuretypes, PUT Shapefile ZIP to file.shp, GeoTIFF to coveragestores, upload SLD as application/vnd.ogc.sld+xml, ?recurse=true deletes. curl -u admin:geoserver, single-key JSON like {\"workspace\":{...}}, 401 on POST but 200 on GET, GWC cache masking style changes."
4
4
  tags:
5
5
  - rest
6
6
  - api
@@ -20,7 +20,7 @@ tags:
20
20
  >
21
21
  > **API 参考:** <https://docs.geoserver.org/stable/en/user/rest/api/index.html>
22
22
  >
23
- > **最新版本:** GeoServer 3.0.1(截至 2026-10,[官方下载](https://geoserver.org/release/stable/))
23
+ > **最新版本:** GeoServer 3.0.2(2026-10-17 发布,安全修复版;[官方下载](https://geoserver.org/release/stable/))
24
24
  >
25
25
  > **许可证:** GPL-2.0
26
26
 
@@ -47,14 +47,19 @@ REST API 的典型用途包括:
47
47
 
48
48
  所有写操作(POST / PUT / DELETE)均需认证。GeoServer 默认使用 HTTP Basic Auth:
49
49
 
50
+ 推荐用 `-u`,curl 自动生成 Basic 头;需要显式传头时用下面的等价写法(`YWRtaW46Z2Vvc2VydmVy` 是 `admin:geoserver` 的 base64):
51
+
50
52
  ```bash
51
- # curl 方式
52
- curl -u admin:geoserver ...
53
+ # 方式 1:curl -u(推荐)
54
+ curl -u admin:geoserver http://localhost:8080/geoserver/rest/about/version.json
53
55
 
54
- # HTTP Header 方式
55
- Authorization: Basic YWRtaW46Z2Vvc2VydmVy
56
+ # 方式 2:显式 Authorization 头
57
+ curl -H "Authorization: Basic YWRtaW46Z2Vvc2VydmVy" \
58
+ http://localhost:8080/geoserver/rest/about/version.json
56
59
  ```
57
60
 
61
+ > 凭据务必用环境变量传入(`curl -u "$GS_USER:$GS_PASS"`),不要写进脚本或提交到仓库。
62
+
58
63
  ---
59
64
 
60
65
  ## API 端点一览
@@ -356,23 +361,13 @@ await workspaceService.CreateWorkspaceAsync("myws");
356
361
 
357
362
  ## AI 使用建议
358
363
 
359
- ### 推荐工作流
360
-
361
- 1. **确认 GeoServer 运行**:先验证 `http://localhost:8080/geoserver/rest/about/version.json` 可访问
362
- 2. **创建工作空间**:POST `/rest/workspaces` → 创建命名空间
363
- 3. **添加数据存储**:根据数据类型 POST datastores(矢量)或 coveragestores(栅格)
364
- 4. **发布图层**:POST featuretypes(矢量)或 coverages(栅格)
365
- 5. **配置样式**:POST styles + PUT SLD 文件 → PUT layers 绑定样式
366
- 6. **验证发布**:GET `/rest/layers.json` 确认图层列表,访问 WMS GetMap 测试
367
-
368
- ### 关键注意事项
369
-
370
- - **JSON 包装结构**:GeoServer REST API 的 JSON 请求/响应使用单层包装(如 `{"workspace":{...}}`)
371
- - **recurse 参数**:删除 Workspace/Store 时务必添加 `?recurse=true` 级联删除
372
- - **Shapefile 上传**:必须打包为 ZIP(含 .shp/.shx/.dbf/.prj),用 PUT 方式上传
373
- - **URL 后缀**:可用 `.json` / `.xml` 后缀替代 `Accept` 头指定响应格式
374
- - **Content-Type**:样式上传使用 `application/vnd.ogc.sld+xml`,栅格上传使用 `image/tiff`
375
- - **认证**:所有 POST/PUT/DELETE 操作需要 HTTP Basic Auth(默认 admin:geoserver)
364
+ - **本技能的组织**:主文件给高频用法,完整参数表与高级示例在 `reference/endpoints.md`,需要时再展开;示例工程与生成的数据写到工作目录,不要改动技能目录本身。
365
+ - **执行环境**:示例在终端 / shell 中执行(显式 `curl.exe`,Windows 的 `curl` 是别名、参数不同);`\` 续行在 PowerShell 无效,压成单行;请求体先写成 `body.json`,用 `curl.exe --data "@body.json"` 传,避开各 shell 的引号差异。
366
+ - **先探测版本**:`curl.exe -s -u admin:geoserver http://localhost:8080/geoserver/rest/about/version.json`,确认是 3.0.2 并顺带看到组件版本;返回 401 是凭据/安全规则问题,不是版本问题。
367
+ - **验证产物**:写操作后立刻 GET 回读同一资源(`.../rest/workspaces/myws.json`、`.../rest/layers/myws:roads.json`),再发一次 WMS `GetMap` 取 `image/png` 确认非空图;不要只凭 201 或退出码报告成功。
368
+ - **幂等与坑**:同名资源重复 POST 会报已存在(重跑脚本前先 GET 判断或改 PUT);改了样式记得清 GWC 缓存,否则瓦片还是旧的。
369
+ - **安全与权限**:`admin:geoserver` 不要硬编码进脚本或回显到报告;`?recurse=true` 删除 workspace、`POST /rest/reset`、清缓存均不可逆,执行前向用户确认。
370
+ - **批量脚本**:循环建资源时检查 `$LASTEXITCODE`,一失败即停;半套配置留在服务端比报错更难排查。
376
371
 
377
372
  ## 相关技能
378
373
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: geotools
3
- description: "Use when building Java GIS applications — feature reading/writing, coordinate transformations, map styling, spatial filters, WMS/WFS clients. GeoTools: the Java GIS toolkit and OGC standards reference implementation."
3
+ description: "Use when building Java GIS apps on GeoTools 35.2 (JDK 17) — org.geotools:gt-main / gt-shapefile / gt-geopkg / gt-epsg-hsql from repo.osgeo.org (not Maven Central), CQL/ECQL filters, CRS.decode plus JTS.transform reprojection, StreamingRenderer PNG output, and disposing DataStore/SimpleFeatureIterator."
4
4
  tags:
5
5
  - java
6
6
  - gis
@@ -18,7 +18,7 @@ tags:
18
18
  >
19
19
  > **Maven GroupId:** `org.geotools`
20
20
  >
21
- > **最新版本:** 35.1(截至 2026-10,[OSGeo Maven 仓库](https://repo.osgeo.org/repository/release/))
21
+ > **最新版本:** 35.2(2026-10-16,[OSGeo Maven 仓库](https://repo.osgeo.org/repository/release/))
22
22
  >
23
23
  > **许可证:** LGPL 2.1
24
24
  >
@@ -36,7 +36,9 @@ GeoTools 是一个成熟、模块化的开源 Java GIS 工具库,由 OSGeo 基
36
36
  - **OGC Web 服务**:WMS / WFS / WCS 客户端
37
37
  - **几何运算**:基于 JTS Topology Suite 的全套几何计算
38
38
 
39
- **环境要求:** JDK 8(GeoTools ≤ 28);JDK 11(GeoTools 29–33);JDK 17(GeoTools 34+,当前 35.x)
39
+ **环境要求:** GeoTools 34+(当前 35.x)要求 **JDK 17**,35.x 官方构建文档另列出可选 JDK 21;更早分支的历史矩阵为 ≤28 用 JDK 8、29–33 用 JDK 11,具体以官方安装文档为准。
40
+
41
+ > 官方构建要求(实测 <https://docs.geotools.org/stable/userguide/build/install/index.html>):"Java Development Kit 17 (JDK 17)",可选 JDK 21;PR 同时用 JDK 17 与 21 测试。
40
42
 
41
43
  ---
42
44
 
@@ -60,7 +62,7 @@ GeoTools 发布在 OSGeo Maven 仓库,需在 `pom.xml` 中添加:
60
62
 
61
63
  ```xml
62
64
  <properties>
63
- <geotools.version>35.1</geotools.version><!-- 最新稳定版;版本列表见 https://geotools.org/ -->
65
+ <geotools.version>35.2</geotools.version><!-- 最新稳定版;版本列表见 https://geotools.org/ -->
64
66
  </properties>
65
67
 
66
68
  <dependencies>
@@ -388,23 +390,13 @@ store.dispose();
388
390
 
389
391
  ## AI 使用建议
390
392
 
391
- ### 推荐工作流
392
-
393
- 1. **配置 Maven 仓库**:在 `pom.xml` 中添加 OSGeo 仓库(`https://repo.osgeo.org/repository/release/`)
394
- 2. **引入必要模块**:`gt-main`(核心)、`gt-shapefile` / `gt-geopkg`(数据源)、`gt-epsg-hsql`(CRS)、`gt-cql`(查询)、`gt-render`(渲染)
395
- 3. **打开数据源**:使用 `FileDataStoreFinder.getDataStore()`(文件)或 `DataStoreFinder.getDataStore(params)`(数据库)
396
- 4. **执行查询**:使用 `CQL.toFilter()` 构建过滤器 → `featureSource.getFeatures(filter)`
397
- 5. **处理结果**:遍历 `SimpleFeatureIterator`,使用 JTS 几何方法进行空间运算
398
- 6. **释放资源**:`store.dispose()`、关闭 `SimpleFeatureIterator`
399
-
400
- ### 关键注意事项
401
-
402
- - **Maven 仓库必需**:GeoTools 不在 Maven Central,必须配置 OSGeo 仓库
403
- - **EPSG 数据库**:使用 CRS 功能需引入 `gt-epsg-hsql`,否则 `CRS.decode()` 抛出异常
404
- - **资源释放**:`DataStore`、`Reader`、`Writer`、`MapContent` 使用后必须调用 `dispose()`
405
- - **坐标轴顺序**:GeoTools 默认遵循 EPSG 规范(纬度在前),使用 `CRS.decode("EPSG:4326", true)` 强制经度在前
406
- - **线程安全**:`DataStore` 线程安全可共享;`SimpleFeatureIterator` 非线程安全
407
- - **JTS 包名**:GeoTools 20+ 使用 `org.locationtech.jts`(GeoTools ≤19 为旧版 `com.vividsolutions.jts`)
393
+ - **本技能的组织**:主文件给高频用法,完整参数表与高级示例在 `reference/raster-rendering.md`、`reference/vector-io.md`,需要时再展开;示例工程与生成的数据写到工作目录,不要改动技能目录本身。
394
+ - **执行环境**:命令在终端 / shell 中执行;先 `java -version` 与 `mvn -v` 确认 JDK 17,35.x 在 JDK 8/11 下编译即失败。
395
+ - **先探测版本**:`mvn dependency:tree -Dincludes=org.geotools` 确认解析到 35.2 且未被其他依赖压回旧版;`pom.xml` 里必须有指向 `repo.osgeo.org/repository/release/` 的 `<repository>`。
396
+ - **验证产物**:`mvn -q -DskipTests package` 后跑最小读图层程序(`FileDataStoreFinder` → `getFeatures()` → 打印 count 与 CRS)或 `mvn -q test`;`CRS.decode("EPSG:4326")` 抛异常说明缺 `gt-epsg-hsql`。
397
+ - **常见失败信号**:`getDataStore()` 返回 null 或报找不到工厂,是 SPI 模块没进 classpath;出现 `com.vividsolutions.jts` 是包名没升级(GeoTools 20+ 用 `org.locationtech.jts`)。
398
+ - **安全与权限**:测试别全量加载要素到内存(用 `Query` 限制属性与 bbox);连接串/密码不要回显,对生产库批量写入前先向用户确认。
399
+ - **按需读文件**:本 SKILL 较长,先按章节标题定位,再按行区间分段读取,避免整篇占满上下文。
408
400
 
409
401
  ## 相关技能
410
402
 
@@ -46,9 +46,9 @@ sudo apt update && sudo apt install grass
46
46
  # Conda / mamba / pixi(conda-forge 提供 Linux、macOS、Windows 64 位包)
47
47
  conda install -c conda-forge grass
48
48
 
49
- # Docker(官方镜像;下载页同时以 osgeo/grass-gis 名称与 releasebranch_8_5-* 标签发布)
50
- docker pull osgeo/grass
51
- docker run --rm osgeo/grass grass --version
49
+ # Docker(官方镜像名是 osgeo/grass-gis;标签形如 8.5.0-ubuntu / releasebranch_8_5-ubuntu)
50
+ docker pull osgeo/grass-gis:latest
51
+ docker run --rm osgeo/grass-gis grass --version
52
52
  ```
53
53
 
54
54
  Windows 可通过 OSGeo4W 安装器安装,之后在 "OSGeo4W Shell" 中使用 `grass` 命令。
@@ -310,16 +310,14 @@ grass $HOME/grassdata/ndvi_project/PERMANENT --exec sh -c '
310
310
  | Docker 中结果文件属主为 root | 运行时加 `--user=$(id -u):$(id -g)` 与 `--env HOME=/data/` |
311
311
  | `t.*` 报时空数据库错误 | 时空数据库按地图集独立且自动创建;确认在正确地图集内运行并检查 `t.connect -p` 状态 |
312
312
 
313
- ## 参考资源
313
+ ## AI 使用建议
314
314
 
315
- - **GRASS GIS 源码:** <https://github.com/OSGeo/grass>
316
- - **官方文档:** <https://grass.osgeo.org/>
317
- - **模块手册(grass-stable):** <https://grass.osgeo.org/grass-stable/manuals/>
318
- - **grass 启动器说明:** <https://grass.osgeo.org/grass-stable/manuals/grass.html>
319
- - **Python 脚本 API:** <https://grass.osgeo.org/grass-stable/manuals/libpython/>
320
- - **时空框架介绍:** <https://grass.osgeo.org/grass-stable/manuals/temporalintro.html>
321
- - **Docker 镜像说明:** <https://grass.osgeo.org/download/docker/>
322
- - **官方示例数据:** <https://grass.osgeo.org/sampledata/north_carolina/nc_basic_spm_grass7.zip>
315
+ - **执行环境**:命令在终端 / shell 中执行(Windows 用 PowerShell)。正文里 `grass ... --exec sh -c '...'` 的多行引用在 PowerShell 下不可靠,改为把模块序列写进 `.py` 脚本(首行 `#!/usr/bin/env python3`),再 `grass --tmp-project EPSG:3857 --exec python3 analysis.py`。
316
+ - **先探测版本**:`grass --version`(应为 8.5.0,LTR 8.4.2)、`grass --tmp-project EPSG:3857 --exec g.region -p`;8.4 之前没有 `grass.tools`,Python 脚本改用 `gs.run_command`。
317
+ - **验证产物**:`--tmp-project` 内的地图最后必须导出——`r.out.gdal input=slope output=/work/slope.tif format=GTiff`,随后 `gdalinfo -json slope.tif` 核对 CRS 与范围;会话内核对用 `g.region -p format=json`、`g.list type=raster`。
318
+ - **区域语义优先**:栅格模块只处理计算区域内的像元,结果范围不对先看 `g.region -p`;重复运行加 `--overwrite`,否则模块报地图已存在并非零退出。
319
+ - **错误识别**:GRASS 模块的失败以 `ERROR:` 开头并返回非零码(如 `Raster map <x> not found`),据此区分地图名、区域为空还是输出已存在问题,不要只读最后一行日志。
320
+ - **安全与权限**:`g.remove`、`--overwrite`、`t.connect` 会改/删地图集数据;`--tmp-project`/`--tmp-mapset` 结束即删除目录,结果必须先导出;启动 Docker 或改文件属主(`--user=$(id -u):$(id -g)`)前先确认写入路径。
323
321
 
324
322
  ## 相关技能
325
323
 
@@ -328,12 +326,13 @@ grass $HOME/grassdata/ndvi_project/PERMANENT --exec sh -c '
328
326
  - **geopandas** — Python 矢量数据分析:[../geopandas/SKILL.md](../geopandas/SKILL.md)
329
327
  - **pyqgis** — QGIS Python 绑定:[../pyqgis/SKILL.md](../pyqgis/SKILL.md)
330
328
 
331
- ## AI 使用建议
329
+ ## 参考资源
332
330
 
333
- 1. **优先单行无头命令**:`grass <project>/<mapset> --exec <module> ...` 或 `grass --tmp-project EPSG:<code> --exec ...`,便于在脚本与 CI 中复现。
334
- 2. **先探查再分析**:`g.list` 列出可用地图、`g.region -p` 查看区域、`t.list` 列出时空数据集,确认现状后再构造命令。
335
- 3. **结构化输出**:需要程序化解析时优先 `format=json`(如 `g.region -p format=json`)或用 `gs.parse_command`,避免解析文本表格。
336
- 4. **注意区域语义**:栅格模块只处理计算区域内的像元,写命令前先确认或设置 `g.region`。
337
- 5. **参数映射**:模块选项与标志位在 Python 中分别对应关键字参数与 `flags`(如 `gs.run_command("r.univar", map="elevation", flags="g")`)。
338
- 6. **错误识别**:GRASS 模块错误以 `ERROR:` 开头且返回非零状态码,据此判断失败原因(地图不存在、区域为空、输出已存在等)。
339
- 7. **覆盖与清理**:重复运行时统一使用 `--overwrite`,或先用 `g.remove` 清理中间地图。
331
+ - **GRASS GIS 源码:** <https://github.com/OSGeo/grass>
332
+ - **官方文档:** <https://grass.osgeo.org/>
333
+ - **模块手册(grass-stable):** <https://grass.osgeo.org/grass-stable/manuals/>
334
+ - **grass 启动器说明:** <https://grass.osgeo.org/grass-stable/manuals/grass.html>
335
+ - **Python 脚本 API:** <https://grass.osgeo.org/grass-stable/manuals/libpython/>
336
+ - **时空框架介绍:** <https://grass.osgeo.org/grass-stable/manuals/temporalintro.html>
337
+ - **Docker 镜像说明:** <https://grass.osgeo.org/download/docker/>
338
+ - **官方示例数据:** <https://grass.osgeo.org/sampledata/north_carolina/nc_basic_spm_grass7.zip>
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: jts
3
- description: "Use when performing precise 2D computational geometry in Java — spatial predicates (contains, intersects), overlay operations, buffering, triangulation. JTS (Java Topology Suite): the canonical geometry engine used as blueprint for GEOS, Shapely, and NetTopologySuite."
3
+ description: "Use when doing precise 2D computational geometry in Java with org.locationtech.jts:jts-core 1.20.0 — GeometryFactory construction, contains/intersects predicates, overlay via OverlayNGRobust, buffer, STRtree and PreparedGeometry speedups, WKT/WKB/GeoJSON I/O, and fixing TopologyException or unclosed rings."
4
4
 
5
5
  tags:
6
6
  - java
@@ -56,7 +56,7 @@ JTS Topology Suite(简称 JTS)是 LocationTech 项目组下的开源 Java
56
56
  </dependency>
57
57
  ```
58
58
 
59
- 如需 GeoJSON 等 I/O 支持:
59
+ 如需 GeoJSON 等 I/O 支持(注意 groupId 是 `org.locationtech.jts.io`,与 jts-core 的 `org.locationtech.jts` 不同):
60
60
 
61
61
  ```xml
62
62
  <dependency>
@@ -66,6 +66,8 @@ JTS Topology Suite(简称 JTS)是 LocationTech 项目组下的开源 Java
66
66
  </dependency>
67
67
  ```
68
68
 
69
+ `jts-io-common` 的 `GeoJsonWriter` 在运行期还依赖 `com.googlecode.json-simple:json-simple`(Maven/Gradle 会自动带入);手工拼 classpath 时漏掉它会在写出 GeoJSON 时抛 `NoClassDefFoundError: org/json/simple/JSONAware`。
70
+
69
71
  ### Gradle
70
72
 
71
73
  ```groovy
@@ -247,27 +249,20 @@ String geoJson = new GeoJsonWriter().write(buffered);
247
249
  | 批量空间查询慢 | 用 `STRtree` 建索引;重复关系判断用 `PreparedGeometry`;大量合并用 `UnaryUnionOp` |
248
250
  | 多线程复用 Reader/Writer 出错 | `GeometryFactory` 与 `Geometry` 线程安全;`WKTReader` / `WKTWriter` 等非线程安全,每线程独立创建 |
249
251
  | 叠加运算抛 TopologyException | 优先用 `OverlayNGRobust.overlay()`,比传统叠加引擎更鲁棒 |
252
+ | 写 GeoJSON 抛 `NoClassDefFoundError: org/json/simple/JSONAware` | 手工 classpath 缺 `json-simple`,用 Maven/Gradle 引入 `jts-io-common` 让其传递依赖生效 |
250
253
  | 旧代码升级后 import 报错 | JTS 1.15+ 包名由 `com.vividsolutions.jts` 迁移为 `org.locationtech.jts` |
251
254
 
252
255
  ---
253
256
 
254
257
  ## AI 使用建议
255
258
 
256
- ### 推荐工作流
257
-
258
- 1. **创建几何对象**:始终通过 `GeometryFactory` 工厂方法创建,不要直接 `new`
259
- 2. **格式解析**:从 WKT/WKB/GeoJSON 读入外部数据,使用对应的 Reader
260
- 3. **空间运算**:用 `PreparedGeometry` 加速批量 contains/intersects 判断
261
- 4. **批量查询**:用 `STRtree` 建空间索引后查询
262
- 5. **结果导出**:用 Writer 输出为 WKT/WKB/GeoJSON
263
-
264
- ### 关键注意事项
265
-
266
- - **坐标顺序**:JTS 使用 `(x, y)` 即 `(经度, 纬度)`,注意与部分 GIS 系统的 `(y, x)` 区分
267
- - **SRID 不参与计算**:JTS 所有计算在笛卡尔平面进行,不处理地球曲率
268
- - **OverlayNG 优先**:叠加运算优先使用 `OverlayNGRobust.overlay()`,比传统方法更鲁棒
269
- - **线程安全**:`GeometryFactory` 和 `Geometry` 线程安全;Reader/Writer 非线程安全
270
- - **有效性检查**:外部导入的几何用 `isValid()` 检查后用 `GeometryFixer.fix()` 修复
259
+ - **本技能的组织**:主文件给高频用法,完整参数表与高级示例在 `reference/geometry-operations.md`,需要时再展开;示例工程与生成的数据写到工作目录,不要改动技能目录本身。
260
+ - **执行环境**:命令在终端 / shell 中执行;JTS 只依赖 `jts-core`,Maven Central 直接可解析,不需要额外仓库,JDK 8+ 即可。
261
+ - **先探测版本**:`mvn dependency:tree -Dincludes=org.locationtech.jts` 确认解析到 1.20.0;同时确认 classpath 里没有遗留的 `com.vividsolutions.jts` 旧包。
262
+ - **验证产物**:`mvn -q test`,或最小 main 做 WKT 往返 + `geom.isValid()` + `buffer(0)` 断言;导出 GeoJSON 后用 `GeoJsonReader` 读回比对坐标数,别只看日志。
263
+ - **失败信号**:`TopologyException` 改用 `OverlayNGRobust.overlay()`;`isValid()` 为 false 先 `GeometryFixer.fix()`;结果为空多半是把坐标写成了 `(lat, lon)`。
264
+ - **注意事项**:SRID 在 JTS 里只是元数据、计算全在笛卡尔平面,跨投影需自己先转换;`WKTReader`/`WKTWriter` 非线程安全,不要多线程共享。
265
+ - **性能验证**:批量判断用 `PreparedGeometry` 前后各计时一次(`System.nanoTime()`),用数据证明优化有效,别凭感觉。
271
266
 
272
267
  ## 相关技能
273
268