shaoxing-geo-tools 0.0.4 → 0.0.6
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/README.md +50 -9
- package/dist/Constant-BZ3rU2jA.js +8 -0
- package/dist/geoToolsWorker-CTS0SJgH.js +16 -0
- package/dist/index.js +172 -119
- package/dist/wasmApi-1NHF35d0.js +566 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
基于 Web Worker + WASM 的地理空间计算工具集,提供异步、高性能的 GeoJSON 空间运算能力。
|
|
4
4
|
|
|
5
|
-
**<span style="color:red">不要在worker中调用!</span>**
|
|
6
|
-
|
|
7
5
|
## 通用说明
|
|
8
6
|
|
|
9
7
|
- 所有函数均返回 `Promise`,通过 Worker 异步计算,不阻塞主线程
|
|
@@ -172,23 +170,66 @@
|
|
|
172
170
|
|
|
173
171
|
---
|
|
174
172
|
|
|
173
|
+
### 10. `getCityBoundary(toleranceMeters)`
|
|
174
|
+
|
|
175
|
+
**获取绍兴市边界**
|
|
176
|
+
|
|
177
|
+
从 WASM 中读取绍兴市行政边界 GeoJSON(`FeatureCollection`),可按米为单位设置简化容差来减少数据量。
|
|
178
|
+
|
|
179
|
+
| 参数 | 类型 | 默认值 | 说明 |
|
|
180
|
+
|------|------|--------|------|
|
|
181
|
+
| toleranceMeters | number \| null | `null` | 简化容差(米),不传或传 `null` 返回完整边界 |
|
|
182
|
+
|
|
183
|
+
**返回值:** 解析结果为 `{ valid, message, data }`,`data` 为 `FeatureCollection<Polygon>`。
|
|
184
|
+
|
|
185
|
+
**用途:** 在地图上绘制绍兴市行政边界轮廓,或用于空间分析中的边界参考。
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
### 11. `getDistrictBoundary(toleranceMeters)`
|
|
190
|
+
|
|
191
|
+
**获取绍兴市各区县边界**
|
|
192
|
+
|
|
193
|
+
从 WASM 中读取绍兴市各区县行政边界 GeoJSON(`FeatureCollection`),每个区县为一个 Feature,可按米为单位设置简化容差。
|
|
194
|
+
|
|
195
|
+
| 参数 | 类型 | 默认值 | 说明 |
|
|
196
|
+
|------|------|--------|------|
|
|
197
|
+
| toleranceMeters | number \| null | `null` | 简化容差(米),不传或传 `null` 返回完整边界 |
|
|
198
|
+
|
|
199
|
+
**返回值:** 解析结果为 `{ valid, message, data }`,`data` 为 `FeatureCollection<Polygon>`。
|
|
200
|
+
|
|
201
|
+
**用途:** 在地图上绘制各区县边界,或按区县维度进行空间统计与分析。
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
175
205
|
## 使用示例
|
|
176
206
|
```javascript
|
|
177
|
-
import
|
|
207
|
+
import geoTools from 'shaoxing-geo-tools'
|
|
178
208
|
|
|
179
|
-
|
|
209
|
+
// 设置默认地图视口和边距比例, 也可以不设置,在 batchGetSpaceExtra 和 batchGetLineExtra 传入[1920, 1080]以及0.5
|
|
210
|
+
// setDefault设置后,batchGetSpaceExtra 和 batchGetLineExtra 中缺省就按设置的走
|
|
180
211
|
|
|
181
|
-
|
|
182
|
-
setDefault(1920, 1080, 0.3)
|
|
212
|
+
geoTools.setDefault(1920, 1080, 0.3)
|
|
183
213
|
|
|
184
214
|
// 获取行政区划
|
|
185
|
-
const districts = await getDistricts(someGeoJson)
|
|
215
|
+
const districts = await geoTools.getDistricts(someGeoJson)
|
|
216
|
+
geoTools.getDistricts(someGeoJson).then(result => {})
|
|
186
217
|
|
|
187
218
|
// 批量简化
|
|
188
|
-
const simplified = await batchSimplify([complexGeoJson], 11)
|
|
219
|
+
const simplified = await geoTools.batchSimplify([complexGeoJson], 11)
|
|
220
|
+
geoTools.batchSimplify([complexGeoJson], 11).then(result => {})
|
|
189
221
|
|
|
190
222
|
// 获取空间信息
|
|
191
|
-
const extras = await batchGetSpaceExtra([polygonGeoJson])
|
|
223
|
+
const extras = await geoTools.batchGetSpaceExtra([polygonGeoJson])
|
|
224
|
+
geoTools.batchGetSpaceExtra([polygonGeoJson]).then(result => {})
|
|
225
|
+
|
|
226
|
+
// 获取绍兴市边界
|
|
227
|
+
const cityBoundary = await geoTools.getCityBoundary()
|
|
228
|
+
// 或传入简化容差
|
|
229
|
+
const simplifiedCityBoundary = await geoTools.getCityBoundary(50)
|
|
230
|
+
|
|
231
|
+
// 获取各区县边界
|
|
232
|
+
const districtBoundary = await geoTools.getDistrictBoundary()
|
|
192
233
|
```
|
|
193
234
|
|
|
194
235
|
## 架构说明
|