@dsh-gis/dsh-opengis-skill 0.1.3 → 0.3.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 (117) hide show
  1. package/CHANGELOG.md +95 -0
  2. package/README.md +68 -28
  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 +19 -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 +9 -0
  30. package/adaptations/opengis-daf.md +9 -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 +283 -0
  46. package/assets/cesiumjs/SKILL.md +81 -35
  47. package/assets/deck-gl/SKILL.md +26 -34
  48. package/assets/duckdb-spatial/SKILL.md +363 -0
  49. package/assets/gdal/SKILL.md +55 -33
  50. package/assets/gdal/reference/raster-tools.md +14 -0
  51. package/assets/gdal/reference/vector-tools.md +5 -0
  52. package/assets/gdal-api/SKILL.md +12 -18
  53. package/assets/gdal-api/reference/raster-api.md +7 -0
  54. package/assets/gdal-api/reference/vector-api.md +9 -0
  55. package/assets/geolibre/SKILL.md +357 -0
  56. package/assets/geometry-api-java/SKILL.md +10 -16
  57. package/assets/geometry-api-net/SKILL.md +70 -32
  58. package/assets/geometry-api-net/reference/geometry-types.md +5 -0
  59. package/assets/geonode/SKILL.md +340 -0
  60. package/assets/geopandas/SKILL.md +21 -24
  61. package/assets/geopandas/reference/core-api.md +4 -0
  62. package/assets/geopipe-agent/SKILL.md +29 -31
  63. package/assets/geopipe-agent/reference/steps-reference.md +12 -0
  64. package/assets/geopipe-agent/reference/workflows.md +8 -0
  65. package/assets/geoserver/SKILL.md +10 -15
  66. package/assets/geoserver-cloud/SKILL.md +25 -33
  67. package/assets/geoserver-rest-api/SKILL.md +17 -19
  68. package/assets/geoserver-rest-api/reference/endpoints.md +16 -0
  69. package/assets/geotools/SKILL.md +12 -17
  70. package/assets/geotools/reference/raster-rendering.md +5 -0
  71. package/assets/geotools/reference/vector-io.md +7 -0
  72. package/assets/grass-gis/SKILL.md +26 -33
  73. package/assets/jts/SKILL.md +12 -16
  74. package/assets/jts/reference/geometry-operations.md +13 -0
  75. package/assets/kepler-gl/SKILL.md +306 -0
  76. package/assets/leaflet/SKILL.md +58 -40
  77. package/assets/mapbox-gl-js/SKILL.md +26 -33
  78. package/assets/mapserver/SKILL.md +21 -29
  79. package/assets/mapsui/SKILL.md +109 -63
  80. package/assets/nettopologysuite/SKILL.md +96 -31
  81. package/assets/opengis-all/SKILL.md +91 -289
  82. package/assets/opengis-all/reference/data-stages.md +269 -4
  83. package/assets/opengis-all/reference/workflow-cheatsheets.md +7 -0
  84. package/assets/opengis-daf/SKILL.md +10 -17
  85. package/assets/opengis-utils-for-java/SKILL.md +58 -49
  86. package/assets/opengis-utils-for-java/reference/common-tasks.md +16 -12
  87. package/assets/opengis-utils-for-net/SKILL.md +109 -48
  88. package/assets/opengis-utils-for-net/reference/code-patterns.md +15 -11
  89. package/assets/opengis-utils-for-net/reference/util-classes.md +35 -26
  90. package/assets/openlayers/SKILL.md +81 -28
  91. package/assets/pdal/SKILL.md +25 -27
  92. package/assets/postgis/SKILL.md +80 -35
  93. package/assets/proj/SKILL.md +32 -41
  94. package/assets/projnet4geoapi/SKILL.md +293 -0
  95. package/assets/pyqgis/SKILL.md +33 -30
  96. package/assets/pyqgis/reference/processing-rendering.md +6 -0
  97. package/assets/pyqgis/reference/vector-raster-layers.md +6 -0
  98. package/assets/qgis-process/SKILL.md +75 -33
  99. package/assets/qgis-process/reference/algorithm-cheatsheet.md +6 -0
  100. package/assets/qgis-server/SKILL.md +25 -31
  101. package/assets/shapely/SKILL.md +136 -84
  102. package/assets/shapely/reference/operations-reference.md +12 -0
  103. package/assets/sharpmap/SKILL.md +97 -60
  104. package/assets/spatialite/SKILL.md +358 -0
  105. package/assets/whitebox-tools/SKILL.md +262 -0
  106. package/lib/adaptations.d.ts +53 -0
  107. package/lib/adaptations.js +343 -0
  108. package/lib/catalog.d.ts +7 -1
  109. package/lib/catalog.js +9 -1
  110. package/lib/index.d.ts +10 -1
  111. package/lib/index.js +34 -3
  112. package/lib/skill-file.d.ts +12 -0
  113. package/lib/skill-file.js +133 -18
  114. package/locale/en.json +1 -1
  115. package/locale/zh.json +1 -1
  116. package/package.json +12 -2
  117. package/upstream.json +73 -57
@@ -1,15 +1,10 @@
1
1
  ---
2
2
  name: opengis-utils-for-net
3
3
  description: "Use when needing common GIS utilities in .NET/C# — OguLayerUtil ReadLayer/WriteLayer/ConvertFormat, GeometryUtil 50+ ops, CrsUtil CGCS2000 transforms, Shapefile/GeoJSON/FileGDB/GeoPackage/KML/PostGIS I/O; also for Unable to load DLL gdal / DllNotFoundException, GBK shapefile mojibake, or ArgumentException from Geojson2Wkt on a whole FeatureCollection. OpenGIS.Utils 1.1.2."
4
- tags:
5
- - dotnet
6
- - csharp
7
- - gdal
8
- - ogr
9
- - geometry
10
- - vector
11
- - crs
12
- - cgcs2000
4
+ license: MIT
5
+ metadata:
6
+ category: gis
7
+ tags: "dotnet, csharp, gdal, ogr, geometry, vector, crs, cgcs2000"
13
8
  ---
14
9
 
15
10
  > **项目地址:** <https://github.com/znlgis/opengis-utils-for-net>
@@ -18,7 +13,7 @@ tags:
18
13
  >
19
14
  > **NuGet 包:** `OpenGIS.Utils`
20
15
  >
21
- > **最新版本:** 1.1.2(截至2026-10,NuGet)
16
+ > **最新版本:** 1.1.2(截至 2026-11,[NuGet `OpenGIS.Utils`](https://www.nuget.org/packages/OpenGIS.Utils);[GitHub Release v1.1.2](https://github.com/znlgis/opengis-utils-for-net/releases))
22
17
  >
23
18
  > **许可证:** LGPL-2.1-or-later
24
19
 
@@ -38,11 +33,31 @@ tags:
38
33
 
39
34
  ## 环境准备
40
35
 
36
+ ### 方式一:dotnet CLI
37
+
41
38
  ```bash
42
- dotnet add package OpenGIS.Utils
39
+ dotnet add package OpenGIS.Utils --version 1.1.2
43
40
  ```
44
41
 
45
- ## Build & Test
42
+ ### 方式二:手写 csproj 的 PackageReference
43
+
44
+ ```xml
45
+ <ItemGroup>
46
+ <PackageReference Include="OpenGIS.Utils" Version="1.1.2" />
47
+ </ItemGroup>
48
+ ```
49
+
50
+ ### 验证
51
+
52
+ ```bash
53
+ dotnet --version # 库为 netstandard2.0,.NET Core 2.0+ / .NET 5+ 均可引用
54
+ dotnet restore # 能解析 OpenGIS.Utils 1.1.2 即包可用
55
+ dotnet list package --include-transitive | findstr OpenGIS.Utils
56
+ ```
57
+
58
+ > GDAL 原生运行时由 `MaxRev.Gdal.Universal` 随包分发,无需手动 `GdalConfiguration.ConfigureGdal()`;`DllNotFoundException` 通常来自 RID 不匹配,见常见问题。
59
+
60
+ ## 构建与测试
46
61
 
47
62
  ```bash
48
63
  dotnet build OpenGIS.Utils.sln
@@ -51,7 +66,7 @@ dotnet test tests/OpenGIS.Utils.Tests/
51
66
 
52
67
  ---
53
68
 
54
- ## Project Structure
69
+ ## 项目结构
55
70
 
56
71
  ```text
57
72
  src/OpenGIS.Utils/
@@ -93,7 +108,7 @@ src/OpenGIS.Utils/
93
108
 
94
109
  ---
95
110
 
96
- ## Enums
111
+ ## 枚举
97
112
 
98
113
  ### GeometryType
99
114
 
@@ -131,7 +146,7 @@ TOO_FEW_POINTS, INVALID_COORDINATE, RING_NOT_CLOSED
131
146
 
132
147
  ---
133
148
 
134
- ## Core Model Classes
149
+ ## 核心模型类
135
150
 
136
151
  ### OguLayer
137
152
 
@@ -234,7 +249,7 @@ Methods: `ToWkt()` → `string`, `FromWkt(string wkt)` → `OguCoordinate` *(sta
234
249
 
235
250
  > OguLayerUtil、GeometryUtil、CrsUtil、ShpUtil、PostgisUtil、GtTxtUtil 等工具类与 GDAL 配置的完整 API 见 [reference/util-classes.md](reference/util-classes.md)
236
251
 
237
- ## Engine Architecture
252
+ ## 引擎架构
238
253
 
239
254
  ```csharp
240
255
  using OpenGIS.Utils.Engine;
@@ -278,7 +293,7 @@ public interface ILayerWriter
278
293
 
279
294
  ---
280
295
 
281
- ## General Utilities
296
+ ## 通用工具
282
297
 
283
298
  ### EncodingUtil
284
299
 
@@ -322,7 +337,7 @@ string NumUtil.FormatNumber(double value, int decimals)
322
337
 
323
338
  ---
324
339
 
325
- ## Exception Hierarchy
340
+ ## 异常层次
326
341
 
327
342
  ```text
328
343
  System.Exception
@@ -336,7 +351,7 @@ System.Exception
336
351
 
337
352
  ---
338
353
 
339
- ## Result Models
354
+ ## 结果模型
340
355
 
341
356
  ### TopologyValidationResult
342
357
 
@@ -367,27 +382,6 @@ Properties: `GdbPath` (`string?`), `LayerNames` (`List<string>`)
367
382
 
368
383
  > 常用代码模式完整示例见 [reference/code-patterns.md](reference/code-patterns.md)
369
384
 
370
- ## DeepSeek Harness 使用建议
371
-
372
- - **加载与引用**:用 `skill("opengis-utils-for-net")` 加载(用户也可输入 `/opengis-utils-for-net`);`reference/code-patterns.md`、`reference/util-classes.md` 按需 `read`,路径相对加载结果中的 Base directory;技能目录只读,验证工程建在会话工作区。
373
- - **执行环境**:先 `dotnet --version`;库目标 .NET Standard 2.0,可被 .NET Core 2.0+ / .NET 5+ / .NET Framework 4.6.1+ 引用,Windows 用 `pwsh`;用 `dotnet new console -o demo && cd demo` 起最小工程。
374
- - **依赖坐标**:`dotnet add package OpenGIS.Utils --version 1.1.2`(NuGet 最新 1.1.2),原生 GDAL 运行时随包分发(`MaxRev.Gdal.Universal`);用 `dotnet list package --include-transitive | Select-String OpenGIS.Utils` 核对解析出的版本,`NU1101`/`NU1102` 表示源或版本不可用,如实报告而不是改版本号重试。
375
- - **平台与原生库**:运行时与 RID 绑定,`DllNotFoundException` 或 `Unable to load DLL 'gdal'` 多因 `-r win-x64`/`linux-x64` 与运行环境不一致;`dotnet publish -r win-x64` 后跑发布目录,不要只跑 `bin/Debug` 里的半成品。
376
- - **验证产物**:最小程序 `OguLayerUtil.ReadLayer(DataFormatType.SHP, path)` 读入(完整重载见 `reference/code-patterns.md`)→ 打印 `layer.GetFeatureCount()` 与 `layer.Wkid`,再 `WriteLayer` 写出 GeoJSON 并重新读回,核对要素数与 CRS;`dotnet build` 成功只说明编译通过,GDAL 原生库是运行期才加载的。
377
- - **常见误操**:`Geojson2Wkt()` 只接受裸几何 / `Feature` / `FeatureCollection` 字符串,传整文件内容会抛 `ArgumentException`,整文件走 `OguLayerUtil.ReadLayer`;`OgrGeometry` 是 `IDisposable`,用完 `Dispose()`;`GEOTOOLS` 枚举仅为兼容,在 .NET 版实际重定向到 GDAL。
378
- - **构建与测试**:在仓库 checkout 内 `dotnet build OpenGIS.Utils.sln`、`dotnet test tests/OpenGIS.Utils.Tests/`,输出在 `bin/`、`obj/`(不要提交);只看某一条测试时加 `--filter FullyQualifiedName~关键字`。
379
- - **安全与权限**:写入 Shapefile/GeoPackage 会覆盖同名文件,执行前确认目标路径;PostGIS 连接串与 GDAL 配置里的密码不要回显;`dotnet restore`、安装 SDK 或改 `NuGet.config` 前先征得用户同意。
380
-
381
- ## 典型工作流
382
-
383
- 1. **读取数据**:使用 `OguLayerUtil.ReadLayer()` 统一入口读取各类矢量格式
384
- 2. **几何运算**:使用 `GeometryUtil.Wkt2Geometry()` 转换后操作,或直接用 `*Wkt` 后缀方法
385
- 3. **坐标转换**:使用 `CrsUtil.Transform()` 进行坐标系变换(CGCS2000 系列)
386
- 4. **写出结果**:使用 `OguLayerUtil.WriteLayer()` 写出为目标格式
387
- 5. **格式转换**:使用 `OguLayerUtil.ConvertFormat()` 一步完成
388
-
389
- ---
390
-
391
385
  ## 常见问题
392
386
 
393
387
  | 问题 | 解决 |
@@ -399,14 +393,7 @@ Properties: `GdbPath` (`string?`), `LayerNames` (`List<string>`)
399
393
  | `Geojson2Wkt`/`Geojson2Geometry` 抛 `ArgumentException` | 仅接受裸几何、`Feature` 或 `FeatureCollection` 字符串;空串或无法解析会抛错,整文件请走 `OguLayerUtil.ReadLayer` |
400
394
  | OGR 几何内存管理 | `OgrGeometry` 实现 `IDisposable`,用完及时 `Dispose()`;或用 `*Wkt` 便捷方法避免手动管理 |
401
395
 
402
- ## 相关技能
403
-
404
- - **nettopologysuite** — .NET 几何计算核心:[../nettopologysuite/SKILL.md](../nettopologysuite/SKILL.md)
405
- - **geometry-api-net** — Esri Geometry API for .NET:[../geometry-api-net/SKILL.md](../geometry-api-net/SKILL.md)
406
- - **gdal** — 命令行数据处理:[../gdal/SKILL.md](../gdal/SKILL.md)
407
- - **gdal-api** — GDAL 编程 API:[../gdal-api/SKILL.md](../gdal-api/SKILL.md)
408
-
409
- ## Important Notes
396
+ ## AI 编码约定
410
397
 
411
398
  1. **GDAL auto-initializes** — No manual `GdalConfiguration.ConfigureGdal()` call needed.
412
399
  2. **GeoJSON string parsing is supported** — `Geojson2Wkt()` / `Geojson2Geometry()` parse bare geometry, `Feature`, or `FeatureCollection` strings (first feature's geometry wins) via the GDAL GeoJSON driver and throw `ArgumentException` for unparseable input. For whole files use `GdalReader` or `OguLayerUtil.ReadLayer(DataFormatType.GEOJSON, path)`.
@@ -416,6 +403,80 @@ Properties: `GdbPath` (`string?`), `LayerNames` (`List<string>`)
416
403
  6. **Encoding support** — `EncodingUtil` detects UTF-8, UTF-16 LE/BE, GBK, GB2312. Register CodePages with `Encoding.RegisterProvider(CodePagesEncodingProvider.Instance)` if needed.
417
404
  7. **WKT convenience methods** — Most `GeometryUtil` methods have `*Wkt` variants that accept/return WKT strings directly, avoiding the need to manage `OgrGeometry` objects.
418
405
 
406
+ ---
407
+
408
+ ## 典型工作流
409
+
410
+ 以「Shapefile → 属性筛选 → 缓冲区 → 投影 → GeoPackage」为例:输入 `data/parcels.shp`(EPSG:4326),输出 `data/parcels_4528.gpkg`。
411
+
412
+ 1. **读取数据**:`OguLayerUtil.ReadLayer(DataFormatType.SHP, path)` 统一入口读取各类矢量格式
413
+ 2. **几何运算**:`GeometryUtil.Wkt2Geometry()` 转换后操作,或直接用 `*Wkt` 后缀方法
414
+ 3. **坐标转换**:`CrsUtil.Transform()` 只接受 WKT 或 `OgrGeometry`,整层变换需逐要素处理后改 `layer.Wkid`
415
+ 4. **写出结果**:`OguLayerUtil.WriteLayer()` 写出为目标格式
416
+ 5. **格式转换**:`OguLayerUtil.ConvertFormat()` 一步完成
417
+ 6. **回读验证**:重新读取产物,核对要素数与 `Wkid`
418
+
419
+ ```csharp
420
+ using OpenGIS.Utils.DataSource;
421
+ using OpenGIS.Utils.Engine.Enums;
422
+ using OpenGIS.Utils.Engine.Model.Layer;
423
+ using OpenGIS.Utils.Geometry;
424
+
425
+ // 1. 读:完整重载见 reference/code-patterns.md
426
+ OguLayer layer = OguLayerUtil.ReadLayer(DataFormatType.SHP, "data/parcels.shp");
427
+ Console.WriteLine($"{layer.Wkid} / {layer.GetFeatureCount()}");
428
+
429
+ // 2. 筛选 + 缓冲:几何以 WKT 字符串存放,OgrGeometry 需要 Dispose
430
+ var large = layer.Filter(f =>
431
+ {
432
+ using var g = GeometryUtil.Wkt2Geometry(f.Wkt!);
433
+ return GeometryUtil.Area(g) > 10000;
434
+ });
435
+
436
+ foreach (var f in large)
437
+ {
438
+ using var g = GeometryUtil.Wkt2Geometry(f.Wkt!);
439
+ using var buffered = GeometryUtil.Buffer(g, 50);
440
+ f.Wkt = GeometryUtil.Geometry2Wkt(buffered);
441
+ }
442
+
443
+ // 3. 投影到 CGCS2000 3 度带(EPSG:4528)。
444
+ // CrsUtil 只有 WKT / OgrGeometry 两个重载,没有整层变换,必须逐要素处理并改 Wkid
445
+ int sourceWkid = layer.Wkid ?? 4326;
446
+ foreach (var f in layer.Features)
447
+ f.Wkt = CrsUtil.Transform(f.Wkt!, sourceWkid, 4528);
448
+ layer.Wkid = 4528;
449
+
450
+ // 4. 写出 GeoPackage
451
+ OguLayerUtil.WriteLayer(DataFormatType.GEOPACKAGE, layer, "data/parcels_4528.gpkg");
452
+
453
+ // 6. 回读验证
454
+ OguLayer check = OguLayerUtil.ReadLayer(DataFormatType.GEOPACKAGE, "data/parcels_4528.gpkg");
455
+ Console.WriteLine($"{check.Wkid} / {check.GetFeatureCount()}");
456
+ ```
457
+
458
+ **验收**:打印的 WKID 应为 4528、要素数与筛选结果一致;再用 `ogrinfo -so data/parcels_4528.gpkg` 复核。`dotnet build` 成功不代表能跑——GDAL 原生库是运行期才加载的。
459
+
460
+ ---
461
+
462
+ ## AI 使用建议
463
+
464
+ - **本技能的组织**:主文件给高频用法,完整参数表与高级示例在 `reference/code-patterns.md`、`reference/util-classes.md`,需要时再展开;示例工程与生成的数据写到工作目录,不要改动技能目录本身。
465
+ - **执行环境**:先 `dotnet --version`;库目标 .NET Standard 2.0,可被 .NET Core 2.0+ / .NET 5+ / .NET Framework 4.6.1+ 引用,Windows 用 PowerShell;用 `dotnet new console -o demo && cd demo` 起最小工程。
466
+ - **依赖坐标**:`dotnet add package OpenGIS.Utils --version 1.1.2`(NuGet 最新 1.1.2),原生 GDAL 运行时随包分发(`MaxRev.Gdal.Universal`);用 `dotnet list package --include-transitive | Select-String OpenGIS.Utils` 核对解析出的版本,`NU1101`/`NU1102` 表示源或版本不可用,如实报告而不是改版本号重试。
467
+ - **平台与原生库**:运行时与 RID 绑定,`DllNotFoundException` 或 `Unable to load DLL 'gdal'` 多因 `-r win-x64`/`linux-x64` 与运行环境不一致;`dotnet publish -r win-x64` 后跑发布目录,不要只跑 `bin/Debug` 里的半成品。
468
+ - **验证产物**:最小程序 `OguLayerUtil.ReadLayer(DataFormatType.SHP, path)` 读入(完整重载见 `reference/code-patterns.md`)→ 打印 `layer.GetFeatureCount()` 与 `layer.Wkid`,再 `WriteLayer` 写出 GeoJSON 并重新读回,核对要素数与 CRS;`dotnet build` 成功只说明编译通过,GDAL 原生库是运行期才加载的。
469
+ - **常见误操**:`Geojson2Wkt()` 只接受裸几何 / `Feature` / `FeatureCollection` 字符串,传整文件内容会抛 `ArgumentException`,整文件走 `OguLayerUtil.ReadLayer`;`OgrGeometry` 是 `IDisposable`,用完 `Dispose()`;`GEOTOOLS` 枚举仅为兼容,在 .NET 版实际重定向到 GDAL。
470
+ - **构建与测试**:在仓库 checkout 内 `dotnet build OpenGIS.Utils.sln`、`dotnet test tests/OpenGIS.Utils.Tests/`,输出在 `bin/`、`obj/`(不要提交);只看某一条测试时加 `--filter FullyQualifiedName~关键字`。
471
+ - **安全与权限**:写入 Shapefile/GeoPackage 会覆盖同名文件,执行前确认目标路径;PostGIS 连接串与 GDAL 配置里的密码不要回显;`dotnet restore`、安装 SDK 或改 `NuGet.config` 前先征得用户同意。
472
+
473
+ ## 相关技能
474
+
475
+ - **nettopologysuite** — .NET 几何计算核心:[../nettopologysuite/SKILL.md](../nettopologysuite/SKILL.md)
476
+ - **geometry-api-net** — Esri Geometry API for .NET:[../geometry-api-net/SKILL.md](../geometry-api-net/SKILL.md)
477
+ - **gdal** — 命令行数据处理:[../gdal/SKILL.md](../gdal/SKILL.md)
478
+ - **gdal-api** — GDAL 编程 API:[../gdal-api/SKILL.md](../gdal-api/SKILL.md)
479
+
419
480
  ## 参考资源
420
481
 
421
482
  - **GitHub 仓库:** <https://github.com/znlgis/opengis-utils-for-net>
@@ -1,12 +1,16 @@
1
- # OpenGIS Utils for .NET Common Code Patterns
1
+ # OpenGIS Utils for .NET 常用代码模式
2
2
 
3
- Common code patterns and examples split from SKILL.md.
3
+ ## Contents
4
+
5
+ - 常用代码模式
6
+
7
+ 从 SKILL.md 拆出的常用代码模式与示例,.NET 版本按 OpenGIS.Utils 1.1.2 编写。
4
8
 
5
9
  ---
6
10
 
7
- ## Common Code Patterns
11
+ ## 常用代码模式
8
12
 
9
- ### Create a Layer from Scratch
13
+ ### 从零构造图层
10
14
 
11
15
  ```csharp
12
16
  using OpenGIS.Utils.Engine.Model.Layer;
@@ -32,7 +36,7 @@ layer.AddFeature(feature);
32
36
  layer.Validate();
33
37
  ```
34
38
 
35
- ### Read → Process → Write
39
+ ### 读取 → 处理 → 写出
36
40
 
37
41
  ```csharp
38
42
  using OpenGIS.Utils.DataSource;
@@ -60,7 +64,7 @@ foreach (var feature in layer.Features)
60
64
  OguLayerUtil.WriteLayer(DataFormatType.GEOJSON, layer, "output.geojson");
61
65
  ```
62
66
 
63
- ### Coordinate Transformation
67
+ ### 坐标变换
64
68
 
65
69
  ```csharp
66
70
  using OpenGIS.Utils.Engine.Util;
@@ -73,7 +77,7 @@ int wkid = CrsUtil.GetProjectedWkid(zone); // Projected WKID
73
77
  string projected = CrsUtil.Transform(wktWgs84, 4326, wkid);
74
78
  ```
75
79
 
76
- ### Geometry Analysis
80
+ ### 几何分析
77
81
 
78
82
  ```csharp
79
83
  using OpenGIS.Utils.Geometry;
@@ -87,20 +91,20 @@ string center = GeometryUtil.CentroidWkt(polygon); // "POINT (5 5)"
87
91
  string buffer = GeometryUtil.BufferWkt(point, 1.0); // Buffered polygon WKT
88
92
  ```
89
93
 
90
- ### Format Conversion (One Line)
94
+ ### 格式转换(一行代码)
91
95
 
92
96
  ```csharp
93
97
  OguLayerUtil.ConvertFormat("input.shp", DataFormatType.SHP, "output.gpkg", DataFormatType.GEOPACKAGE);
94
98
  ```
95
99
 
96
- ### JSON Serialization
100
+ ### JSON 序列化
97
101
 
98
102
  ```csharp
99
103
  string json = layer.ToJson();
100
104
  OguLayer? restored = OguLayer.FromJson(json);
101
105
  ```
102
106
 
103
- ### Shapefile with Encoding
107
+ ### 带编码的 Shapefile
104
108
 
105
109
  ```csharp
106
110
  using OpenGIS.Utils.Engine.Util;
@@ -110,7 +114,7 @@ var layer = ShpUtil.ReadShapefile("data.shp", Encoding.GetEncoding("GBK"));
110
114
  ShpUtil.WriteShapefile(layer, "output.shp", Encoding.UTF8);
111
115
  ```
112
116
 
113
- ### Natural Sorting
117
+ ### 自然排序
114
118
 
115
119
  ```csharp
116
120
  using OpenGIS.Utils.Utils;
@@ -1,17 +1,27 @@
1
- # OpenGIS Utils for .NET Utility Classes Reference
1
+ # OpenGIS Utils for .NET 工具类参考
2
2
 
3
- OguLayerUtil, GeometryUtil, CrsUtil, ShpUtil, PostgisUtil, GtTxtUtil and GDAL configuration split from SKILL.md.
3
+ ## Contents
4
+
5
+ - 数据读写 — OguLayerUtil(推荐入口)
6
+ - 几何运算 — GeometryUtil
7
+ - 坐标参考系 — CrsUtil
8
+ - Shapefile 工具 — ShpUtil
9
+ - PostGIS 工具 — PostgisUtil
10
+ - 国土调查 TXT 格式 — GtTxtUtil
11
+ - GDAL 配置
12
+
13
+ 从 SKILL.md 拆出的 OguLayerUtil、GeometryUtil、CrsUtil、ShpUtil、PostgisUtil、GtTxtUtil 与 GDAL 配置参考,按 OpenGIS.Utils 1.1.2 编写。
4
14
 
5
15
  ---
6
16
 
7
- ## Data I/O — OguLayerUtil (Recommended Entry Point)
17
+ ## 数据读写 — OguLayerUtil(推荐入口)
8
18
 
9
19
  ```csharp
10
20
  using OpenGIS.Utils.DataSource;
11
21
  using OpenGIS.Utils.Engine.Enums;
12
22
  ```
13
23
 
14
- ### Read
24
+ ### 读取
15
25
 
16
26
  ```csharp
17
27
  OguLayer layer = OguLayerUtil.ReadLayer(
@@ -28,7 +38,7 @@ OguLayer layer = OguLayerUtil.ReadLayer(
28
38
  OguLayer layer = await OguLayerUtil.ReadLayerAsync(DataFormatType.GEOJSON, "data.geojson");
29
39
  ```
30
40
 
31
- ### Write
41
+ ### 写出
32
42
 
33
43
  ```csharp
34
44
  OguLayerUtil.WriteLayer(
@@ -44,7 +54,7 @@ OguLayerUtil.WriteLayer(
44
54
  await OguLayerUtil.WriteLayerAsync(DataFormatType.SHP, layer, "output.shp");
45
55
  ```
46
56
 
47
- ### Format Conversion
57
+ ### 格式转换
48
58
 
49
59
  ```csharp
50
60
  OguLayerUtil.ConvertFormat(
@@ -59,13 +69,13 @@ await OguLayerUtil.ConvertFormatAsync(
59
69
  );
60
70
  ```
61
71
 
62
- ### Utilities
72
+ ### 工具
63
73
 
64
74
  ```csharp
65
75
  IList<string> names = OguLayerUtil.GetLayerNames(DataFormatType.FILEGDB, "data.gdb");
66
76
  ```
67
77
 
68
- ### Supported Format ↔ Driver
78
+ ### 支持的格式 ↔ 驱动
69
79
 
70
80
  | DataFormatType | Driver Name | Extension |
71
81
  |---|---|---|
@@ -80,7 +90,7 @@ IList<string> names = OguLayerUtil.GetLayerNames(DataFormatType.FILEGDB, "data.g
80
90
 
81
91
  ---
82
92
 
83
- ## Geometry Operations — GeometryUtil
93
+ ## 几何运算 — GeometryUtil
84
94
 
85
95
  ```csharp
86
96
  using OpenGIS.Utils.Geometry;
@@ -88,7 +98,7 @@ using OpenGIS.Utils.Geometry;
88
98
 
89
99
  All methods are `public static`.
90
100
 
91
- ### Format Conversion
101
+ ### 几何格式转换
92
102
 
93
103
  ```csharp
94
104
  OgrGeometry geom = GeometryUtil.Wkt2Geometry(string wkt);
@@ -99,7 +109,7 @@ string geojson = GeometryUtil.Geometry2Geojson(OgrGeometry geom);
99
109
 
100
110
  > **Note:** `Geojson2Wkt(string)` and `Geojson2Geometry(string)` parse GeoJSON strings (bare geometry, `Feature`, or `FeatureCollection` — the first feature's geometry is used) through the GDAL GeoJSON driver. Unparseable input, or input without a geometry, raises `ArgumentException`. For whole files use `GdalReader` or `OguLayerUtil.ReadLayer(DataFormatType.GEOJSON, path)`.
101
111
 
102
- ### Spatial Relationships (OgrGeometry)
112
+ ### 空间关系(OgrGeometry)
103
113
 
104
114
  ```csharp
105
115
  bool GeometryUtil.Intersects(OgrGeometry a, OgrGeometry b)
@@ -111,14 +121,14 @@ bool GeometryUtil.Overlaps(OgrGeometry a, OgrGeometry b)
111
121
  bool GeometryUtil.Disjoint(OgrGeometry a, OgrGeometry b)
112
122
  ```
113
123
 
114
- ### Spatial Relationships (WKT convenience)
124
+ ### 空间关系(WKT 便捷方法)
115
125
 
116
126
  ```csharp
117
127
  bool GeometryUtil.IntersectsWkt(string wktA, string wktB)
118
128
  bool GeometryUtil.ContainsWkt(string wktA, string wktB)
119
129
  ```
120
130
 
121
- ### Spatial Analysis (OgrGeometry)
131
+ ### 空间分析(OgrGeometry)
122
132
 
123
133
  ```csharp
124
134
  OgrGeometry GeometryUtil.Buffer(OgrGeometry geom, double distance)
@@ -129,7 +139,7 @@ OgrGeometry GeometryUtil.Difference(OgrGeometry a, OgrGeometry b)
129
139
  OgrGeometry GeometryUtil.SymDifference(OgrGeometry a, OgrGeometry b)
130
140
  ```
131
141
 
132
- ### Spatial Analysis (WKT convenience)
142
+ ### 空间分析(WKT 便捷方法)
133
143
 
134
144
  ```csharp
135
145
  string GeometryUtil.BufferWkt(string wkt, double distance)
@@ -137,7 +147,7 @@ string GeometryUtil.IntersectionWkt(string wktA, string wktB)
137
147
  string GeometryUtil.UnionWkt(IEnumerable<string> wktList)
138
148
  ```
139
149
 
140
- ### Geometry Properties
150
+ ### 几何属性
141
151
 
142
152
  ```csharp
143
153
  double GeometryUtil.Area(OgrGeometry geom)
@@ -150,7 +160,7 @@ GeometryType GeometryUtil.GetGeometryType(OgrGeometry geom)
150
160
  bool GeometryUtil.IsEmpty(OgrGeometry geom)
151
161
  ```
152
162
 
153
- ### Geometry Properties (WKT convenience)
163
+ ### 几何属性(WKT 便捷方法)
154
164
 
155
165
  ```csharp
156
166
  double GeometryUtil.AreaWkt(string wkt)
@@ -158,7 +168,7 @@ double GeometryUtil.LengthWkt(string wkt)
158
168
  string GeometryUtil.CentroidWkt(string wkt)
159
169
  ```
160
170
 
161
- ### Geometry Operations
171
+ ### 几何操作
162
172
 
163
173
  ```csharp
164
174
  OgrGeometry GeometryUtil.Boundary(OgrGeometry geom)
@@ -169,14 +179,14 @@ OgrGeometry GeometryUtil.Densify(OgrGeometry geom, double distanceTolerance)
169
179
  string GeometryUtil.SimplifyWkt(string wkt, double tolerance)
170
180
  ```
171
181
 
172
- ### Topology Validation
182
+ ### 拓扑校验
173
183
 
174
184
  ```csharp
175
185
  TopologyValidationResult GeometryUtil.IsValid(OgrGeometry geom)
176
186
  SimpleGeometryResult GeometryUtil.IsSimple(OgrGeometry geom)
177
187
  ```
178
188
 
179
- ### Equality & Distance
189
+ ### 相等与距离
180
190
 
181
191
  ```csharp
182
192
  bool GeometryUtil.EqualsExact(OgrGeometry a, OgrGeometry b)
@@ -188,7 +198,7 @@ bool GeometryUtil.IsWithinDistance(OgrGeometry a, OgrGeometry b, double maxDis
188
198
 
189
199
  ---
190
200
 
191
- ## Coordinate Reference Systems — CrsUtil
201
+ ## 坐标参考系 — CrsUtil
192
202
 
193
203
  ```csharp
194
204
  using OpenGIS.Utils.Engine.Util;
@@ -216,7 +226,7 @@ bool CrsUtil.IsProjectedCRS(int wkid) // Is projected CRS?
216
226
 
217
227
  ---
218
228
 
219
- ## Shapefile Utilities — ShpUtil
229
+ ## Shapefile 工具 — ShpUtil
220
230
 
221
231
  ```csharp
222
232
  using OpenGIS.Utils.Engine.Util;
@@ -233,7 +243,7 @@ void ShpUtil.RepairShapefile(string shpPath)
233
243
 
234
244
  ---
235
245
 
236
- ## PostGIS Utilities — PostgisUtil
246
+ ## PostGIS 工具 — PostgisUtil
237
247
 
238
248
  ```csharp
239
249
  using OpenGIS.Utils.Engine.Util;
@@ -248,7 +258,7 @@ void PostgisUtil.CreateSpatialIndex(string connectionString, string tableNam
248
258
 
249
259
  ---
250
260
 
251
- ## National Land Survey TXT Format — GtTxtUtil
261
+ ## 国土调查 TXT 格式 — GtTxtUtil
252
262
 
253
263
  ```csharp
254
264
  using OpenGIS.Utils.DataSource;
@@ -263,7 +273,7 @@ string GtTxtUtil.FormatTxtLine(OguCoordinate coordinate, int zoneNumber)
263
273
 
264
274
  ---
265
275
 
266
- ## GDAL Configuration
276
+ ## GDAL 配置
267
277
 
268
278
  ```csharp
269
279
  using OpenGIS.Utils.Configuration;
@@ -277,7 +287,7 @@ IList<string> GdalConfiguration.GetSupportedDrivers()
277
287
  bool GdalConfiguration.IsDriverAvailable(string driverName)
278
288
  ```
279
289
 
280
- ### LibrarySettings (Global Defaults)
290
+ ### LibrarySettings(全局默认值)
281
291
 
282
292
  | Property | Type | Default | Description |
283
293
  |---|---|---|---|
@@ -288,4 +298,3 @@ bool GdalConfiguration.IsDriverAvailable(string driverName)
288
298
  | `UseGdalExceptions` | `bool` | `true` | GDAL exception mode |
289
299
 
290
300
  ---
291
-