@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.
- package/.editorconfig +19 -0
- package/CHANGELOG.md +96 -0
- package/LICENSE +21 -21
- package/README.md +91 -30
- package/THIRD_PARTY_NOTICES.md +37 -10
- package/assets/gdal/reference/raster-tools.md +538 -538
- package/assets/gdal/reference/vector-tools.md +149 -149
- package/assets/gdal-api/reference/raster-api.md +424 -424
- package/assets/gdal-api/reference/vector-api.md +724 -724
- package/assets/geometry-api-net/reference/geometry-types.md +243 -243
- package/assets/geopandas/reference/core-api.md +221 -221
- package/assets/geotools/reference/raster-rendering.md +108 -108
- package/assets/geotools/reference/vector-io.md +149 -149
- package/assets/jts/reference/geometry-operations.md +303 -303
- package/assets/mapsui/SKILL.md +283 -283
- package/assets/opengis-all/reference/data-stages.md +608 -608
- package/assets/opengis-all/reference/workflow-cheatsheets.md +324 -324
- package/assets/opengis-utils-for-java/reference/common-tasks.md +384 -384
- package/assets/opengis-utils-for-net/reference/code-patterns.md +124 -124
- package/assets/opengis-utils-for-net/reference/util-classes.md +291 -291
- package/assets/pyqgis/reference/processing-rendering.md +292 -292
- package/assets/pyqgis/reference/vector-raster-layers.md +318 -318
- package/assets/qgis-process/SKILL.md +414 -414
- package/assets/qgis-process/reference/algorithm-cheatsheet.md +194 -194
- package/assets/shapely/reference/operations-reference.md +199 -199
- package/cordis.patch.yml +6 -3
- package/lib/catalog.d.ts +50 -0
- package/lib/catalog.js +238 -0
- package/lib/index.d.ts +47 -6
- package/lib/index.js +32 -44
- package/lib/markdown-links.d.ts +11 -0
- package/lib/markdown-links.js +103 -0
- package/lib/skill-file.js +104 -17
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +11 -5
- package/upstream.json +64 -2
|
@@ -1,199 +1,199 @@
|
|
|
1
|
-
# Shapely Operations API Reference
|
|
2
|
-
|
|
3
|
-
Constructive operations, predicates, set operations, measurements, indexing and coordinate operations split from SKILL.md.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## Constructive Operations
|
|
8
|
-
|
|
9
|
-
All available as `shapely.<function>(geometry, ...)`.
|
|
10
|
-
|
|
11
|
-
| Function | Description |
|
|
12
|
-
|----------|-------------|
|
|
13
|
-
| `buffer(geom, distance, quad_segs=8, cap_style="round", join_style="round", mitre_limit=5.0, single_sided=False)` | Minkowski sum/difference with circle |
|
|
14
|
-
| `offset_curve(geom, distance, ...)` | Parallel curve at given distance |
|
|
15
|
-
| `centroid(geom)` | Geometric center |
|
|
16
|
-
| `point_on_surface(geom)` | Point guaranteed inside geometry |
|
|
17
|
-
| `boundary(geom)` | Topological boundary |
|
|
18
|
-
| `convex_hull(geom)` | Minimum convex enclosure |
|
|
19
|
-
| `concave_hull(geom, ratio)` | Concave enclosure (GEOS >= 3.11) |
|
|
20
|
-
| `envelope(geom)` | Axis-aligned bounding box |
|
|
21
|
-
| `oriented_envelope(geom)` | Minimum-area rotated rectangle |
|
|
22
|
-
| `minimum_bounding_circle(geom)` | Smallest enclosing circle |
|
|
23
|
-
| `simplify(geom, tolerance, preserve_topology=True)` | Douglas-Peucker simplification |
|
|
24
|
-
| `snap(geom, reference, tolerance)` | Snap vertices to reference |
|
|
25
|
-
| `segmentize(geom, max_segment_length)` | Densify by adding vertices |
|
|
26
|
-
| `reverse(geom)` | Reverse coordinate order |
|
|
27
|
-
| `normalize(geom)` | Canonical coordinate ordering |
|
|
28
|
-
| `make_valid(geom, method="linework")` | Repair invalid geometry |
|
|
29
|
-
| `build_area(geom)` | Polygonize from linework |
|
|
30
|
-
| `clip_by_rect(geom, xmin, ymin, xmax, ymax)` | Fast rectangle clip (may produce invalid output) |
|
|
31
|
-
| `delaunay_triangles(geom, tolerance=0.0, only_edges=False)` | Delaunay triangulation |
|
|
32
|
-
| `constrained_delaunay_triangles(geom)` | Constrained Delaunay (GEOS >= 3.11) |
|
|
33
|
-
| `voronoi_polygons(geom, tolerance=0.0, extend_to=None)` | Voronoi diagram |
|
|
34
|
-
| `polygonize(geometries)` | Create polygons from linework |
|
|
35
|
-
| `polygonize_full(geometries)` | Polygonize with dangles, cuts, invalids |
|
|
36
|
-
| `node(geom)` | Full noding of linear geometry |
|
|
37
|
-
| `remove_repeated_points(geom, tolerance=0.0)` | Remove duplicate vertices (GEOS >= 3.11) |
|
|
38
|
-
| `maximum_inscribed_circle(geom, tolerance=1.0)` | Largest inscribed circle |
|
|
39
|
-
| `minimum_width(geom)` | Minimum width line (2.2 新增) |
|
|
40
|
-
| `split(geom, splitter)` | Split a geometry by another (2.2 新增;GEOS >= 3.15,旧版回退 `shapely.ops.split`) |
|
|
41
|
-
| `orient_polygons(geom, sign=1.0)` | Enforce ring orientation |
|
|
42
|
-
|
|
43
|
-
## Spatial Predicates
|
|
44
|
-
|
|
45
|
-
All return `bool` (or bool array). Available as `shapely.<function>(a, b)` or `a.<method>(b)`.
|
|
46
|
-
|
|
47
|
-
| Function | Description |
|
|
48
|
-
|----------|-------------|
|
|
49
|
-
| `contains(a, b)` | B entirely inside A (boundary excluded) |
|
|
50
|
-
| `contains_properly(a, b)` | B inside A with no shared boundary |
|
|
51
|
-
| `contains_xy(geom, x, y)` | Fast point-in-geometry test |
|
|
52
|
-
| `covered_by(a, b)` | No point of A outside B |
|
|
53
|
-
| `covers(a, b)` | No point of B outside A |
|
|
54
|
-
| `crosses(a, b)` | A and B spatially cross |
|
|
55
|
-
| `disjoint(a, b)` | No shared space |
|
|
56
|
-
| `dwithin(a, b, distance)` | Within given distance |
|
|
57
|
-
| `equals(a, b)` | Topologically equal |
|
|
58
|
-
| `equals_exact(a, b, tolerance)` | Structurally equal within tolerance |
|
|
59
|
-
| `intersects(a, b)` | Share any space |
|
|
60
|
-
| `intersects_xy(geom, x, y)` | Fast point-intersects test |
|
|
61
|
-
| `overlaps(a, b)` | Partial overlap, same dimension |
|
|
62
|
-
| `touches(a, b)` | Only boundaries touch |
|
|
63
|
-
| `within(a, b)` | A entirely inside B |
|
|
64
|
-
| `relate(a, b)` | DE-9IM intersection matrix string |
|
|
65
|
-
| `relate_pattern(a, b, pattern)` | Test DE-9IM pattern match |
|
|
66
|
-
| `is_valid(geom)` | Well-formed geometry |
|
|
67
|
-
| `is_valid_reason(geom)` | Description if invalid |
|
|
68
|
-
| `is_empty(geom)` | Empty geometry test |
|
|
69
|
-
| `is_simple(geom)` | No self-intersections |
|
|
70
|
-
| `is_ring(geom)` | Closed and simple |
|
|
71
|
-
| `is_closed(geom)` | First == last point |
|
|
72
|
-
| `is_ccw(geom)` | Counter-clockwise ring orientation |
|
|
73
|
-
| `has_z(geom)` / `has_m(geom)` | Dimension checks |
|
|
74
|
-
|
|
75
|
-
## Set-Theoretic Operations
|
|
76
|
-
|
|
77
|
-
| Function | Description |
|
|
78
|
-
|----------|-------------|
|
|
79
|
-
| `intersection(a, b, grid_size=None)` | Shared geometry |
|
|
80
|
-
| `intersection_all(geometries)` | N-way intersection |
|
|
81
|
-
| `union(a, b, grid_size=None)` | Merge two geometries |
|
|
82
|
-
| `union_all(geometries)` | N-way union |
|
|
83
|
-
| `difference(a, b, grid_size=None)` | A minus B |
|
|
84
|
-
| `symmetric_difference(a, b, grid_size=None)` | XOR of A and B |
|
|
85
|
-
| `coverage_union(a, b)` | Optimized union for non-overlapping polygons |
|
|
86
|
-
| `coverage_union_all(geometries)` | N-way coverage union |
|
|
87
|
-
| `coverage_clean(geometries, gap_width=0.0, snapping_distance=-1, merge_strategy="longest_border")` | Cleanse a polygonal coverage (gaps/overlaps) (2.2 新增;GEOS >= 3.14) |
|
|
88
|
-
|
|
89
|
-
All binary operations support optional `grid_size` for precision snapping.
|
|
90
|
-
|
|
91
|
-
## Measurements
|
|
92
|
-
|
|
93
|
-
| Function | Description |
|
|
94
|
-
|----------|-------------|
|
|
95
|
-
| `area(geom)` | Area of polygon(s) |
|
|
96
|
-
| `length(geom)` | Length of line / polygon perimeter |
|
|
97
|
-
| `distance(a, b)` | Minimum Cartesian distance |
|
|
98
|
-
| `hausdorff_distance(a, b, densify=None)` | Hausdorff distance |
|
|
99
|
-
| `frechet_distance(a, b, densify=None)` | Frechet distance |
|
|
100
|
-
| `bounds(geom)` | (minx, miny, maxx, maxy) per geometry |
|
|
101
|
-
| `total_bounds(geometries)` | Combined bounds of all geometries |
|
|
102
|
-
| `minimum_clearance(geom)` | Smallest move to invalidate |
|
|
103
|
-
| `minimum_bounding_radius(geom)` | Radius of minimum bounding circle |
|
|
104
|
-
|
|
105
|
-
## STRtree Spatial Index
|
|
106
|
-
|
|
107
|
-
```python
|
|
108
|
-
from shapely import STRtree
|
|
109
|
-
|
|
110
|
-
tree = STRtree(geometries, node_capacity=10)
|
|
111
|
-
|
|
112
|
-
# Bounding-box query — returns indices
|
|
113
|
-
idx = tree.query(geometry) # shape (n,)
|
|
114
|
-
idx = tree.query(geom_array) # shape (2, n)
|
|
115
|
-
|
|
116
|
-
# With predicate filter
|
|
117
|
-
idx = tree.query(geom, predicate="intersects")
|
|
118
|
-
# predicates: intersects, within, contains, overlaps, crosses,
|
|
119
|
-
# touches, covers, covered_by, contains_properly, dwithin
|
|
120
|
-
|
|
121
|
-
# Distance-based query
|
|
122
|
-
idx = tree.query(geom, predicate="dwithin", distance=5.0)
|
|
123
|
-
|
|
124
|
-
# Nearest neighbor
|
|
125
|
-
idx = tree.nearest(geometry) # single nearest
|
|
126
|
-
|
|
127
|
-
# All nearest with options
|
|
128
|
-
result = tree.query_nearest(
|
|
129
|
-
geometry,
|
|
130
|
-
max_distance=10,
|
|
131
|
-
return_distance=True, # returns (indices, distances)
|
|
132
|
-
exclusive=False,
|
|
133
|
-
all_matches=True
|
|
134
|
-
)
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
## Geometry Accessors
|
|
138
|
-
|
|
139
|
-
```python
|
|
140
|
-
shapely.get_type_id(geom) # GeometryType enum int
|
|
141
|
-
shapely.get_dimensions(geom) # 0=point, 1=line, 2=polygon
|
|
142
|
-
shapely.get_coordinate_dimension(geom) # 2, 3, or 4
|
|
143
|
-
shapely.get_x(point) # x coordinate
|
|
144
|
-
shapely.get_y(point) # y coordinate
|
|
145
|
-
shapely.get_z(point) # z coordinate
|
|
146
|
-
shapely.get_num_points(linestring)
|
|
147
|
-
shapely.get_point(linestring, index) # extract nth point
|
|
148
|
-
shapely.get_exterior_ring(polygon)
|
|
149
|
-
shapely.get_interior_ring(polygon, index)
|
|
150
|
-
shapely.get_num_interior_rings(polygon)
|
|
151
|
-
shapely.get_geometry(collection, index)
|
|
152
|
-
shapely.get_num_geometries(collection)
|
|
153
|
-
shapely.get_parts(geom, return_index=False)
|
|
154
|
-
shapely.get_rings(polygon, return_index=False)
|
|
155
|
-
shapely.get_coordinates(geom, include_z=False, return_index=False)
|
|
156
|
-
shapely.set_coordinates(geom, new_coords) # modifies in-place!
|
|
157
|
-
shapely.count_coordinates(geom)
|
|
158
|
-
shapely.get_srid(geom) / shapely.set_srid(geom, srid)
|
|
159
|
-
shapely.get_precision(geom) / shapely.set_precision(geom, grid_size)
|
|
160
|
-
shapely.force_2d(geom) / shapely.force_3d(geom, z=0)
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
## Affine Transforms
|
|
164
|
-
|
|
165
|
-
```python
|
|
166
|
-
from shapely.affinity import affine_transform, rotate, scale, skew, translate
|
|
167
|
-
|
|
168
|
-
affine_transform(geom, [a, b, d, e, xoff, yoff]) # 2D 6-element matrix
|
|
169
|
-
affine_transform(geom, matrix_12) # 3D 12-element matrix
|
|
170
|
-
rotate(geom, angle, origin="center") # degrees CCW
|
|
171
|
-
scale(geom, xfact=1.0, yfact=1.0, zfact=1.0, origin="center")
|
|
172
|
-
skew(geom, xs=0, ys=0, origin="center") # degrees
|
|
173
|
-
translate(geom, xoff=0.0, yoff=0.0, zoff=0.0)
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
## Coordinate Transforms
|
|
177
|
-
|
|
178
|
-
```python
|
|
179
|
-
# Vectorized transform (fixed coordinate count)
|
|
180
|
-
shapely.transform(geom, lambda coords: coords * 2)
|
|
181
|
-
shapely.transform(geom, func, include_z=True)
|
|
182
|
-
|
|
183
|
-
# Per-ring transform (may change coordinate count)
|
|
184
|
-
shapely.transform_coordseq(geom, func)
|
|
185
|
-
|
|
186
|
-
# 注意:shapely.ops.transform 自 2.2 起弃用,改用以上两个函数
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
## Linear Referencing
|
|
190
|
-
|
|
191
|
-
```python
|
|
192
|
-
shapely.line_interpolate_point(line, distance, normalized=False)
|
|
193
|
-
shapely.line_locate_point(line, point, normalized=False)
|
|
194
|
-
shapely.line_merge(multilinestring, directed=False)
|
|
195
|
-
shapely.shared_paths(a, b)
|
|
196
|
-
shapely.shortest_line(a, b)
|
|
197
|
-
shapely.get_segments(geom) # 提取 LineString/LinearRing 的逐段线段(2.2 新增)
|
|
198
|
-
```
|
|
199
|
-
|
|
1
|
+
# Shapely Operations API Reference
|
|
2
|
+
|
|
3
|
+
Constructive operations, predicates, set operations, measurements, indexing and coordinate operations split from SKILL.md.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Constructive Operations
|
|
8
|
+
|
|
9
|
+
All available as `shapely.<function>(geometry, ...)`.
|
|
10
|
+
|
|
11
|
+
| Function | Description |
|
|
12
|
+
|----------|-------------|
|
|
13
|
+
| `buffer(geom, distance, quad_segs=8, cap_style="round", join_style="round", mitre_limit=5.0, single_sided=False)` | Minkowski sum/difference with circle |
|
|
14
|
+
| `offset_curve(geom, distance, ...)` | Parallel curve at given distance |
|
|
15
|
+
| `centroid(geom)` | Geometric center |
|
|
16
|
+
| `point_on_surface(geom)` | Point guaranteed inside geometry |
|
|
17
|
+
| `boundary(geom)` | Topological boundary |
|
|
18
|
+
| `convex_hull(geom)` | Minimum convex enclosure |
|
|
19
|
+
| `concave_hull(geom, ratio)` | Concave enclosure (GEOS >= 3.11) |
|
|
20
|
+
| `envelope(geom)` | Axis-aligned bounding box |
|
|
21
|
+
| `oriented_envelope(geom)` | Minimum-area rotated rectangle |
|
|
22
|
+
| `minimum_bounding_circle(geom)` | Smallest enclosing circle |
|
|
23
|
+
| `simplify(geom, tolerance, preserve_topology=True)` | Douglas-Peucker simplification |
|
|
24
|
+
| `snap(geom, reference, tolerance)` | Snap vertices to reference |
|
|
25
|
+
| `segmentize(geom, max_segment_length)` | Densify by adding vertices |
|
|
26
|
+
| `reverse(geom)` | Reverse coordinate order |
|
|
27
|
+
| `normalize(geom)` | Canonical coordinate ordering |
|
|
28
|
+
| `make_valid(geom, method="linework")` | Repair invalid geometry |
|
|
29
|
+
| `build_area(geom)` | Polygonize from linework |
|
|
30
|
+
| `clip_by_rect(geom, xmin, ymin, xmax, ymax)` | Fast rectangle clip (may produce invalid output) |
|
|
31
|
+
| `delaunay_triangles(geom, tolerance=0.0, only_edges=False)` | Delaunay triangulation |
|
|
32
|
+
| `constrained_delaunay_triangles(geom)` | Constrained Delaunay (GEOS >= 3.11) |
|
|
33
|
+
| `voronoi_polygons(geom, tolerance=0.0, extend_to=None)` | Voronoi diagram |
|
|
34
|
+
| `polygonize(geometries)` | Create polygons from linework |
|
|
35
|
+
| `polygonize_full(geometries)` | Polygonize with dangles, cuts, invalids |
|
|
36
|
+
| `node(geom)` | Full noding of linear geometry |
|
|
37
|
+
| `remove_repeated_points(geom, tolerance=0.0)` | Remove duplicate vertices (GEOS >= 3.11) |
|
|
38
|
+
| `maximum_inscribed_circle(geom, tolerance=1.0)` | Largest inscribed circle |
|
|
39
|
+
| `minimum_width(geom)` | Minimum width line (2.2 新增) |
|
|
40
|
+
| `split(geom, splitter)` | Split a geometry by another (2.2 新增;GEOS >= 3.15,旧版回退 `shapely.ops.split`) |
|
|
41
|
+
| `orient_polygons(geom, sign=1.0)` | Enforce ring orientation |
|
|
42
|
+
|
|
43
|
+
## Spatial Predicates
|
|
44
|
+
|
|
45
|
+
All return `bool` (or bool array). Available as `shapely.<function>(a, b)` or `a.<method>(b)`.
|
|
46
|
+
|
|
47
|
+
| Function | Description |
|
|
48
|
+
|----------|-------------|
|
|
49
|
+
| `contains(a, b)` | B entirely inside A (boundary excluded) |
|
|
50
|
+
| `contains_properly(a, b)` | B inside A with no shared boundary |
|
|
51
|
+
| `contains_xy(geom, x, y)` | Fast point-in-geometry test |
|
|
52
|
+
| `covered_by(a, b)` | No point of A outside B |
|
|
53
|
+
| `covers(a, b)` | No point of B outside A |
|
|
54
|
+
| `crosses(a, b)` | A and B spatially cross |
|
|
55
|
+
| `disjoint(a, b)` | No shared space |
|
|
56
|
+
| `dwithin(a, b, distance)` | Within given distance |
|
|
57
|
+
| `equals(a, b)` | Topologically equal |
|
|
58
|
+
| `equals_exact(a, b, tolerance)` | Structurally equal within tolerance |
|
|
59
|
+
| `intersects(a, b)` | Share any space |
|
|
60
|
+
| `intersects_xy(geom, x, y)` | Fast point-intersects test |
|
|
61
|
+
| `overlaps(a, b)` | Partial overlap, same dimension |
|
|
62
|
+
| `touches(a, b)` | Only boundaries touch |
|
|
63
|
+
| `within(a, b)` | A entirely inside B |
|
|
64
|
+
| `relate(a, b)` | DE-9IM intersection matrix string |
|
|
65
|
+
| `relate_pattern(a, b, pattern)` | Test DE-9IM pattern match |
|
|
66
|
+
| `is_valid(geom)` | Well-formed geometry |
|
|
67
|
+
| `is_valid_reason(geom)` | Description if invalid |
|
|
68
|
+
| `is_empty(geom)` | Empty geometry test |
|
|
69
|
+
| `is_simple(geom)` | No self-intersections |
|
|
70
|
+
| `is_ring(geom)` | Closed and simple |
|
|
71
|
+
| `is_closed(geom)` | First == last point |
|
|
72
|
+
| `is_ccw(geom)` | Counter-clockwise ring orientation |
|
|
73
|
+
| `has_z(geom)` / `has_m(geom)` | Dimension checks |
|
|
74
|
+
|
|
75
|
+
## Set-Theoretic Operations
|
|
76
|
+
|
|
77
|
+
| Function | Description |
|
|
78
|
+
|----------|-------------|
|
|
79
|
+
| `intersection(a, b, grid_size=None)` | Shared geometry |
|
|
80
|
+
| `intersection_all(geometries)` | N-way intersection |
|
|
81
|
+
| `union(a, b, grid_size=None)` | Merge two geometries |
|
|
82
|
+
| `union_all(geometries)` | N-way union |
|
|
83
|
+
| `difference(a, b, grid_size=None)` | A minus B |
|
|
84
|
+
| `symmetric_difference(a, b, grid_size=None)` | XOR of A and B |
|
|
85
|
+
| `coverage_union(a, b)` | Optimized union for non-overlapping polygons |
|
|
86
|
+
| `coverage_union_all(geometries)` | N-way coverage union |
|
|
87
|
+
| `coverage_clean(geometries, gap_width=0.0, snapping_distance=-1, merge_strategy="longest_border")` | Cleanse a polygonal coverage (gaps/overlaps) (2.2 新增;GEOS >= 3.14) |
|
|
88
|
+
|
|
89
|
+
All binary operations support optional `grid_size` for precision snapping.
|
|
90
|
+
|
|
91
|
+
## Measurements
|
|
92
|
+
|
|
93
|
+
| Function | Description |
|
|
94
|
+
|----------|-------------|
|
|
95
|
+
| `area(geom)` | Area of polygon(s) |
|
|
96
|
+
| `length(geom)` | Length of line / polygon perimeter |
|
|
97
|
+
| `distance(a, b)` | Minimum Cartesian distance |
|
|
98
|
+
| `hausdorff_distance(a, b, densify=None)` | Hausdorff distance |
|
|
99
|
+
| `frechet_distance(a, b, densify=None)` | Frechet distance |
|
|
100
|
+
| `bounds(geom)` | (minx, miny, maxx, maxy) per geometry |
|
|
101
|
+
| `total_bounds(geometries)` | Combined bounds of all geometries |
|
|
102
|
+
| `minimum_clearance(geom)` | Smallest move to invalidate |
|
|
103
|
+
| `minimum_bounding_radius(geom)` | Radius of minimum bounding circle |
|
|
104
|
+
|
|
105
|
+
## STRtree Spatial Index
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
from shapely import STRtree
|
|
109
|
+
|
|
110
|
+
tree = STRtree(geometries, node_capacity=10)
|
|
111
|
+
|
|
112
|
+
# Bounding-box query — returns indices
|
|
113
|
+
idx = tree.query(geometry) # shape (n,)
|
|
114
|
+
idx = tree.query(geom_array) # shape (2, n)
|
|
115
|
+
|
|
116
|
+
# With predicate filter
|
|
117
|
+
idx = tree.query(geom, predicate="intersects")
|
|
118
|
+
# predicates: intersects, within, contains, overlaps, crosses,
|
|
119
|
+
# touches, covers, covered_by, contains_properly, dwithin
|
|
120
|
+
|
|
121
|
+
# Distance-based query
|
|
122
|
+
idx = tree.query(geom, predicate="dwithin", distance=5.0)
|
|
123
|
+
|
|
124
|
+
# Nearest neighbor
|
|
125
|
+
idx = tree.nearest(geometry) # single nearest
|
|
126
|
+
|
|
127
|
+
# All nearest with options
|
|
128
|
+
result = tree.query_nearest(
|
|
129
|
+
geometry,
|
|
130
|
+
max_distance=10,
|
|
131
|
+
return_distance=True, # returns (indices, distances)
|
|
132
|
+
exclusive=False,
|
|
133
|
+
all_matches=True
|
|
134
|
+
)
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Geometry Accessors
|
|
138
|
+
|
|
139
|
+
```python
|
|
140
|
+
shapely.get_type_id(geom) # GeometryType enum int
|
|
141
|
+
shapely.get_dimensions(geom) # 0=point, 1=line, 2=polygon
|
|
142
|
+
shapely.get_coordinate_dimension(geom) # 2, 3, or 4
|
|
143
|
+
shapely.get_x(point) # x coordinate
|
|
144
|
+
shapely.get_y(point) # y coordinate
|
|
145
|
+
shapely.get_z(point) # z coordinate
|
|
146
|
+
shapely.get_num_points(linestring)
|
|
147
|
+
shapely.get_point(linestring, index) # extract nth point
|
|
148
|
+
shapely.get_exterior_ring(polygon)
|
|
149
|
+
shapely.get_interior_ring(polygon, index)
|
|
150
|
+
shapely.get_num_interior_rings(polygon)
|
|
151
|
+
shapely.get_geometry(collection, index)
|
|
152
|
+
shapely.get_num_geometries(collection)
|
|
153
|
+
shapely.get_parts(geom, return_index=False)
|
|
154
|
+
shapely.get_rings(polygon, return_index=False)
|
|
155
|
+
shapely.get_coordinates(geom, include_z=False, return_index=False)
|
|
156
|
+
shapely.set_coordinates(geom, new_coords) # modifies in-place!
|
|
157
|
+
shapely.count_coordinates(geom)
|
|
158
|
+
shapely.get_srid(geom) / shapely.set_srid(geom, srid)
|
|
159
|
+
shapely.get_precision(geom) / shapely.set_precision(geom, grid_size)
|
|
160
|
+
shapely.force_2d(geom) / shapely.force_3d(geom, z=0)
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## Affine Transforms
|
|
164
|
+
|
|
165
|
+
```python
|
|
166
|
+
from shapely.affinity import affine_transform, rotate, scale, skew, translate
|
|
167
|
+
|
|
168
|
+
affine_transform(geom, [a, b, d, e, xoff, yoff]) # 2D 6-element matrix
|
|
169
|
+
affine_transform(geom, matrix_12) # 3D 12-element matrix
|
|
170
|
+
rotate(geom, angle, origin="center") # degrees CCW
|
|
171
|
+
scale(geom, xfact=1.0, yfact=1.0, zfact=1.0, origin="center")
|
|
172
|
+
skew(geom, xs=0, ys=0, origin="center") # degrees
|
|
173
|
+
translate(geom, xoff=0.0, yoff=0.0, zoff=0.0)
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## Coordinate Transforms
|
|
177
|
+
|
|
178
|
+
```python
|
|
179
|
+
# Vectorized transform (fixed coordinate count)
|
|
180
|
+
shapely.transform(geom, lambda coords: coords * 2)
|
|
181
|
+
shapely.transform(geom, func, include_z=True)
|
|
182
|
+
|
|
183
|
+
# Per-ring transform (may change coordinate count)
|
|
184
|
+
shapely.transform_coordseq(geom, func)
|
|
185
|
+
|
|
186
|
+
# 注意:shapely.ops.transform 自 2.2 起弃用,改用以上两个函数
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## Linear Referencing
|
|
190
|
+
|
|
191
|
+
```python
|
|
192
|
+
shapely.line_interpolate_point(line, distance, normalized=False)
|
|
193
|
+
shapely.line_locate_point(line, point, normalized=False)
|
|
194
|
+
shapely.line_merge(multilinestring, directed=False)
|
|
195
|
+
shapely.shared_paths(a, b)
|
|
196
|
+
shapely.shortest_line(a, b)
|
|
197
|
+
shapely.get_segments(geom) # 提取 LineString/LinearRing 的逐段线段(2.2 新增)
|
|
198
|
+
```
|
|
199
|
+
|
package/cordis.patch.yml
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
# Bundle layer for @dsh-gis/dsh-opengis-skill.
|
|
2
2
|
#
|
|
3
3
|
# The row mounts the OpenGIS skill provider on the Host, so every preset that
|
|
4
|
-
# loads skills (the session catalog) sees the
|
|
5
|
-
# row
|
|
6
|
-
#
|
|
4
|
+
# loads skills (the session catalog) sees the bundled GIS skills. Disabling
|
|
5
|
+
# the row in the bundle configuration removes the provider, and disabling the
|
|
6
|
+
# bundle in Plugins removes the row; either way the session skill catalog
|
|
7
|
+
# follows the enabled bundle. The package and its assets are file-static, so
|
|
8
|
+
# a package update needs a reload or restart before the new version is
|
|
9
|
+
# visible.
|
|
7
10
|
- insert:
|
|
8
11
|
- id: opengis-skill
|
|
9
12
|
name: '@dsh-gis/dsh-opengis-skill'
|
package/lib/catalog.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/** One validated skill entry read from disk. */
|
|
2
|
+
export interface SkillEntry {
|
|
3
|
+
/** Validated kebab-case skill name. */
|
|
4
|
+
name: string;
|
|
5
|
+
/** Required routing description. */
|
|
6
|
+
description: string;
|
|
7
|
+
/** Absolute skill directory. */
|
|
8
|
+
directory: string;
|
|
9
|
+
/** Absolute path to SKILL.md. */
|
|
10
|
+
path: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** The instruction file name inside one skill directory. */
|
|
14
|
+
export declare const SKILL_FILE: "SKILL.md";
|
|
15
|
+
|
|
16
|
+
/** Read one skill directory, or undefined when it has no SKILL.md. */
|
|
17
|
+
export declare function readSkillEntry(directory: string, expectedName?: string): SkillEntry | undefined;
|
|
18
|
+
|
|
19
|
+
/** Read every skill directory under one asset root, sorted by name. */
|
|
20
|
+
export declare function readSkillCatalog(assetRoot: string): SkillEntry[];
|
|
21
|
+
|
|
22
|
+
/** Render one skill directory as a registry resource base. */
|
|
23
|
+
export declare function resourceBaseOf(directory: string): { kind: "directory"; path: string };
|
|
24
|
+
|
|
25
|
+
/** Render the generated README skill-count section. */
|
|
26
|
+
export declare function renderSkillCount(skills: readonly unknown[]): string;
|
|
27
|
+
|
|
28
|
+
/** Render the generated README skill table. */
|
|
29
|
+
export declare function renderSkillTable(skills: readonly { name: string; description: string }[]): string;
|
|
30
|
+
|
|
31
|
+
/** Read the generated README sections including their markers. */
|
|
32
|
+
export declare function readGeneratedSections(markdown: string): { count: string; table: string };
|
|
33
|
+
|
|
34
|
+
/** Regenerate both README sections in place. */
|
|
35
|
+
export declare function replaceGeneratedSections(
|
|
36
|
+
markdown: string,
|
|
37
|
+
skills: readonly { name: string; description: string }[]
|
|
38
|
+
): string;
|
|
39
|
+
|
|
40
|
+
/** List every regular file under one directory as sorted POSIX-style relative paths. */
|
|
41
|
+
export declare function listFiles(root: string): string[];
|
|
42
|
+
|
|
43
|
+
/** Hash one file with SHA-256 and return the lowercase hexadecimal digest. */
|
|
44
|
+
export declare function hashFile(path: string): string;
|
|
45
|
+
|
|
46
|
+
/** Hash every regular file under one directory. */
|
|
47
|
+
export declare function hashFiles(root: string): Record<string, string>;
|
|
48
|
+
|
|
49
|
+
/** Normalize one vendored file to the upstream git blob form (CRLF to LF, binary untouched). */
|
|
50
|
+
export declare function canonicalVendoredBytes(buffer: Buffer): Buffer;
|