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

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 (37) hide show
  1. package/.editorconfig +19 -0
  2. package/CHANGELOG.md +96 -0
  3. package/LICENSE +21 -21
  4. package/README.md +91 -30
  5. package/THIRD_PARTY_NOTICES.md +37 -10
  6. package/assets/gdal/reference/raster-tools.md +538 -538
  7. package/assets/gdal/reference/vector-tools.md +149 -149
  8. package/assets/gdal-api/reference/raster-api.md +424 -424
  9. package/assets/gdal-api/reference/vector-api.md +724 -724
  10. package/assets/geometry-api-net/reference/geometry-types.md +243 -243
  11. package/assets/geopandas/reference/core-api.md +221 -221
  12. package/assets/geotools/reference/raster-rendering.md +108 -108
  13. package/assets/geotools/reference/vector-io.md +149 -149
  14. package/assets/jts/reference/geometry-operations.md +303 -303
  15. package/assets/mapsui/SKILL.md +283 -283
  16. package/assets/opengis-all/reference/data-stages.md +608 -608
  17. package/assets/opengis-all/reference/workflow-cheatsheets.md +324 -324
  18. package/assets/opengis-utils-for-java/reference/common-tasks.md +384 -384
  19. package/assets/opengis-utils-for-net/reference/code-patterns.md +124 -124
  20. package/assets/opengis-utils-for-net/reference/util-classes.md +291 -291
  21. package/assets/pyqgis/reference/processing-rendering.md +292 -292
  22. package/assets/pyqgis/reference/vector-raster-layers.md +318 -318
  23. package/assets/qgis-process/SKILL.md +414 -414
  24. package/assets/qgis-process/reference/algorithm-cheatsheet.md +194 -194
  25. package/assets/shapely/reference/operations-reference.md +199 -199
  26. package/cordis.patch.yml +6 -3
  27. package/lib/catalog.d.ts +50 -0
  28. package/lib/catalog.js +238 -0
  29. package/lib/index.d.ts +47 -6
  30. package/lib/index.js +32 -44
  31. package/lib/markdown-links.d.ts +11 -0
  32. package/lib/markdown-links.js +103 -0
  33. package/lib/skill-file.js +104 -17
  34. package/locale/en.json +1 -1
  35. package/locale/zh.json +1 -1
  36. package/package.json +11 -5
  37. package/upstream.json +64 -2
@@ -1,149 +1,149 @@
1
- # GeoTools Vector I/O Reference
2
-
3
- > 这是 [../SKILL.md](../SKILL.md) 的补充文件,收录矢量数据读写(Shapefile / GeoPackage / PostGIS)与 GeoJSON、WKT/WKB 格式示例。
4
-
5
- ---
6
-
7
- ## 矢量数据读取
8
-
9
- ### 读取 Shapefile
10
-
11
- ```java
12
- import org.geotools.data.*;
13
- import org.geotools.data.simple.*;
14
- import org.opengis.feature.simple.SimpleFeature;
15
-
16
- File file = new File("data/cities.shp");
17
- FileDataStore store = FileDataStoreFinder.getDataStore(file);
18
- SimpleFeatureSource source = store.getFeatureSource();
19
- SimpleFeatureCollection features = source.getFeatures();
20
-
21
- try (SimpleFeatureIterator iter = features.features()) {
22
- while (iter.hasNext()) {
23
- SimpleFeature f = iter.next();
24
- System.out.println(f.getID() + " " + f.getAttribute("NAME"));
25
- }
26
- }
27
- store.dispose();
28
- ```
29
-
30
- ### 读取 GeoPackage
31
-
32
- ```java
33
- Map<String, Object> params = new HashMap<>();
34
- params.put("dbtype", "geopkg");
35
- params.put("database", new File("data/world.gpkg").getAbsolutePath());
36
-
37
- DataStore store = DataStoreFinder.getDataStore(params);
38
- String[] typeNames = store.getTypeNames(); // 列出所有图层
39
- SimpleFeatureSource source = store.getFeatureSource(typeNames[0]);
40
- SimpleFeatureCollection features = source.getFeatures();
41
- // 遍历同 Shapefile
42
- store.dispose();
43
- ```
44
-
45
- ### 连接 PostGIS
46
-
47
- ```java
48
- Map<String, Object> params = new HashMap<>();
49
- params.put("dbtype", "postgis");
50
- params.put("host", "localhost");
51
- params.put("port", 5432);
52
- params.put("schema", "public");
53
- params.put("database", "gisdb");
54
- params.put("user", "postgres");
55
- params.put("passwd", "password");
56
-
57
- DataStore store = DataStoreFinder.getDataStore(params);
58
- SimpleFeatureSource source = store.getFeatureSource("buildings");
59
- SimpleFeatureCollection features = source.getFeatures();
60
- // 遍历处理...
61
- store.dispose();
62
- ```
63
-
64
- ---
65
-
66
- ## 矢量数据写入
67
-
68
- ### 创建 FeatureType 并写入 Shapefile
69
-
70
- ```java
71
- import org.geotools.feature.simple.*;
72
- import org.geotools.data.shapefile.*;
73
- import org.locationtech.jts.geom.Point;
74
- import org.geotools.referencing.crs.DefaultGeographicCRS;
75
-
76
- // 1. 定义 FeatureType
77
- SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder();
78
- typeBuilder.setName("POI");
79
- typeBuilder.setCRS(DefaultGeographicCRS.WGS84);
80
- typeBuilder.add("the_geom", Point.class);
81
- typeBuilder.add("name", String.class);
82
- typeBuilder.add("population", Integer.class);
83
- SimpleFeatureType featureType = typeBuilder.buildFeatureType();
84
-
85
- // 2. 构建要素
86
- GeometryFactory gf = JTSFactoryFinder.getGeometryFactory();
87
- SimpleFeatureBuilder fb = new SimpleFeatureBuilder(featureType);
88
- fb.add(gf.createPoint(new Coordinate(116.4, 39.9)));
89
- fb.add("北京");
90
- fb.add(21540000);
91
- SimpleFeature feature = fb.buildFeature(null);
92
-
93
- // 3. 写入 Shapefile
94
- ShapefileDataStoreFactory factory = new ShapefileDataStoreFactory();
95
- Map<String, Object> params = new HashMap<>();
96
- params.put("url", new File("output/poi.shp").toURI().toURL());
97
- ShapefileDataStore dataStore = (ShapefileDataStore) factory.createNewDataStore(params);
98
- dataStore.createSchema(featureType);
99
-
100
- SimpleFeatureStore featureStore =
101
- (SimpleFeatureStore) dataStore.getFeatureSource(dataStore.getTypeNames()[0]);
102
- featureStore.addFeatures(DataUtilities.collection(feature));
103
- dataStore.dispose();
104
- ```
105
-
106
- ---
107
-
108
- ## GeoJSON 读写
109
-
110
- ```java
111
- import org.geotools.geojson.feature.FeatureJSON;
112
- import org.geotools.geojson.geom.GeometryJSON;
113
-
114
- // 读取 GeoJSON 要素集
115
- FeatureJSON fjson = new FeatureJSON();
116
- SimpleFeatureCollection fc = fjson.readFeatureCollection(
117
- new FileInputStream("data/points.geojson")
118
- );
119
-
120
- // 写入 GeoJSON
121
- fjson.writeFeatureCollection(fc, new FileOutputStream("output/result.geojson"));
122
-
123
- // 单个几何体 GeoJSON
124
- GeometryJSON gjson = new GeometryJSON();
125
- Geometry geom = gjson.read(new StringReader("{\"type\":\"Point\",\"coordinates\":[116.4,39.9]}"));
126
- StringWriter sw = new StringWriter();
127
- gjson.write(geom, sw);
128
- ```
129
-
130
- ---
131
-
132
- ## WKT / WKB 格式转换
133
-
134
- ```java
135
- import org.locationtech.jts.io.*;
136
-
137
- // WKT
138
- WKTReader wktReader = new WKTReader();
139
- Geometry geom = wktReader.read("POLYGON((0 0,10 0,10 10,0 10,0 0))");
140
- String wkt = new WKTWriter().write(geom);
141
-
142
- // WKB
143
- WKBReader wkbReader = new WKBReader();
144
- Geometry geom2 = wkbReader.read(wkbBytes);
145
- byte[] wkb = new WKBWriter().write(geom);
146
- ```
147
-
148
- ---
149
-
1
+ # GeoTools Vector I/O Reference
2
+
3
+ > 这是 [../SKILL.md](../SKILL.md) 的补充文件,收录矢量数据读写(Shapefile / GeoPackage / PostGIS)与 GeoJSON、WKT/WKB 格式示例。
4
+
5
+ ---
6
+
7
+ ## 矢量数据读取
8
+
9
+ ### 读取 Shapefile
10
+
11
+ ```java
12
+ import org.geotools.data.*;
13
+ import org.geotools.data.simple.*;
14
+ import org.opengis.feature.simple.SimpleFeature;
15
+
16
+ File file = new File("data/cities.shp");
17
+ FileDataStore store = FileDataStoreFinder.getDataStore(file);
18
+ SimpleFeatureSource source = store.getFeatureSource();
19
+ SimpleFeatureCollection features = source.getFeatures();
20
+
21
+ try (SimpleFeatureIterator iter = features.features()) {
22
+ while (iter.hasNext()) {
23
+ SimpleFeature f = iter.next();
24
+ System.out.println(f.getID() + " " + f.getAttribute("NAME"));
25
+ }
26
+ }
27
+ store.dispose();
28
+ ```
29
+
30
+ ### 读取 GeoPackage
31
+
32
+ ```java
33
+ Map<String, Object> params = new HashMap<>();
34
+ params.put("dbtype", "geopkg");
35
+ params.put("database", new File("data/world.gpkg").getAbsolutePath());
36
+
37
+ DataStore store = DataStoreFinder.getDataStore(params);
38
+ String[] typeNames = store.getTypeNames(); // 列出所有图层
39
+ SimpleFeatureSource source = store.getFeatureSource(typeNames[0]);
40
+ SimpleFeatureCollection features = source.getFeatures();
41
+ // 遍历同 Shapefile
42
+ store.dispose();
43
+ ```
44
+
45
+ ### 连接 PostGIS
46
+
47
+ ```java
48
+ Map<String, Object> params = new HashMap<>();
49
+ params.put("dbtype", "postgis");
50
+ params.put("host", "localhost");
51
+ params.put("port", 5432);
52
+ params.put("schema", "public");
53
+ params.put("database", "gisdb");
54
+ params.put("user", "postgres");
55
+ params.put("passwd", "password");
56
+
57
+ DataStore store = DataStoreFinder.getDataStore(params);
58
+ SimpleFeatureSource source = store.getFeatureSource("buildings");
59
+ SimpleFeatureCollection features = source.getFeatures();
60
+ // 遍历处理...
61
+ store.dispose();
62
+ ```
63
+
64
+ ---
65
+
66
+ ## 矢量数据写入
67
+
68
+ ### 创建 FeatureType 并写入 Shapefile
69
+
70
+ ```java
71
+ import org.geotools.feature.simple.*;
72
+ import org.geotools.data.shapefile.*;
73
+ import org.locationtech.jts.geom.Point;
74
+ import org.geotools.referencing.crs.DefaultGeographicCRS;
75
+
76
+ // 1. 定义 FeatureType
77
+ SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder();
78
+ typeBuilder.setName("POI");
79
+ typeBuilder.setCRS(DefaultGeographicCRS.WGS84);
80
+ typeBuilder.add("the_geom", Point.class);
81
+ typeBuilder.add("name", String.class);
82
+ typeBuilder.add("population", Integer.class);
83
+ SimpleFeatureType featureType = typeBuilder.buildFeatureType();
84
+
85
+ // 2. 构建要素
86
+ GeometryFactory gf = JTSFactoryFinder.getGeometryFactory();
87
+ SimpleFeatureBuilder fb = new SimpleFeatureBuilder(featureType);
88
+ fb.add(gf.createPoint(new Coordinate(116.4, 39.9)));
89
+ fb.add("北京");
90
+ fb.add(21540000);
91
+ SimpleFeature feature = fb.buildFeature(null);
92
+
93
+ // 3. 写入 Shapefile
94
+ ShapefileDataStoreFactory factory = new ShapefileDataStoreFactory();
95
+ Map<String, Object> params = new HashMap<>();
96
+ params.put("url", new File("output/poi.shp").toURI().toURL());
97
+ ShapefileDataStore dataStore = (ShapefileDataStore) factory.createNewDataStore(params);
98
+ dataStore.createSchema(featureType);
99
+
100
+ SimpleFeatureStore featureStore =
101
+ (SimpleFeatureStore) dataStore.getFeatureSource(dataStore.getTypeNames()[0]);
102
+ featureStore.addFeatures(DataUtilities.collection(feature));
103
+ dataStore.dispose();
104
+ ```
105
+
106
+ ---
107
+
108
+ ## GeoJSON 读写
109
+
110
+ ```java
111
+ import org.geotools.geojson.feature.FeatureJSON;
112
+ import org.geotools.geojson.geom.GeometryJSON;
113
+
114
+ // 读取 GeoJSON 要素集
115
+ FeatureJSON fjson = new FeatureJSON();
116
+ SimpleFeatureCollection fc = fjson.readFeatureCollection(
117
+ new FileInputStream("data/points.geojson")
118
+ );
119
+
120
+ // 写入 GeoJSON
121
+ fjson.writeFeatureCollection(fc, new FileOutputStream("output/result.geojson"));
122
+
123
+ // 单个几何体 GeoJSON
124
+ GeometryJSON gjson = new GeometryJSON();
125
+ Geometry geom = gjson.read(new StringReader("{\"type\":\"Point\",\"coordinates\":[116.4,39.9]}"));
126
+ StringWriter sw = new StringWriter();
127
+ gjson.write(geom, sw);
128
+ ```
129
+
130
+ ---
131
+
132
+ ## WKT / WKB 格式转换
133
+
134
+ ```java
135
+ import org.locationtech.jts.io.*;
136
+
137
+ // WKT
138
+ WKTReader wktReader = new WKTReader();
139
+ Geometry geom = wktReader.read("POLYGON((0 0,10 0,10 10,0 10,0 0))");
140
+ String wkt = new WKTWriter().write(geom);
141
+
142
+ // WKB
143
+ WKBReader wkbReader = new WKBReader();
144
+ Geometry geom2 = wkbReader.read(wkbBytes);
145
+ byte[] wkb = new WKBWriter().write(geom);
146
+ ```
147
+
148
+ ---
149
+