wkt-parse-and-geojson 1.0.0 → 1.0.1

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 (2) hide show
  1. package/README.md +17 -13
  2. package/package.json +12 -3
package/README.md CHANGED
@@ -74,19 +74,23 @@ npm run typecheck
74
74
 
75
75
  ### Node.js
76
76
 
77
+ ```bash
78
+ npm install wkt-parse-and-geojson
79
+ ```
80
+
77
81
  ```javascript
78
82
  // CommonJS
79
- const { parse, build, wktToFeature } = require('./dist/index.cjs.js');
83
+ const { parse, build, wktToFeature } = require('wkt-parse-and-geojson');
80
84
 
81
85
  // ES Module
82
- import { parse, build, wktToFeature } from './dist/index.esm.js';
86
+ import { parse, build, wktToFeature } from 'wkt-parse-and-geojson';
83
87
  ```
84
88
 
85
89
  ### 浏览器 (script 标签)
86
90
 
87
91
  ```html
88
92
  <!-- UMD 方式:通过 script 标签直接引入,全局变量 WKTGeoJSON -->
89
- <script src="./dist/index.umd.js"></script>
93
+ <script src="https://unpkg.com/wkt-parse-and-geojson/dist/index.umd.js"></script>
90
94
  <script>
91
95
  const geom = WKTGeoJSON.parse('POINT (116.39 39.91)');
92
96
  console.log(geom);
@@ -102,7 +106,7 @@ import { parse, build, wktToFeature } from './dist/index.esm.js';
102
106
 
103
107
  ```html
104
108
  <script type="module">
105
- import { parse, build } from '../dist/index.esm.js';
109
+ import { parse, build } from 'wkt-parse-and-geojson';
106
110
 
107
111
  const geom = parse('POINT (116.39 39.91)');
108
112
  console.log(geom);
@@ -246,7 +250,7 @@ build({ type: 'GeometryCollection', geometries: [] })
246
250
  将 WKT 字符串转换为 GeoJSON Geometry 对象(`parse` 的语义化别名)。
247
251
 
248
252
  ```javascript
249
- import { wktToGeoJSON } from './dist/index.esm.js';
253
+ import { wktToGeoJSON } from 'wkt-parse-and-geojson';
250
254
 
251
255
  const geom = wktToGeoJSON('POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))');
252
256
  // → { type: 'Polygon', coordinates: [[[0,0],[1,0],[1,1],[0,1],[0,0]]] }
@@ -266,7 +270,7 @@ const geom = wktToGeoJSON('POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))');
266
270
  **返回:** `Feature`
267
271
 
268
272
  ```javascript
269
- import { wktToFeature } from './dist/index.esm.js';
273
+ import { wktToFeature } from 'wkt-parse-and-geojson';
270
274
 
271
275
  // 带属性
272
276
  wktToFeature('POINT (116.39 39.91)', { name: '北京', pop: 21540000 })
@@ -298,7 +302,7 @@ wktToFeature('POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))')
298
302
  **返回:** `FeatureCollection`
299
303
 
300
304
  ```javascript
301
- import { wktToFeatureCollection } from './dist/index.esm.js';
305
+ import { wktToFeatureCollection } from 'wkt-parse-and-geojson';
302
306
 
303
307
  const fc = wktToFeatureCollection(
304
308
  ['POINT (116.39 39.91)', 'POINT (121.47 31.23)', 'POINT (113.26 23.13)'],
@@ -324,7 +328,7 @@ const fc2 = wktToFeatureCollection(['POINT (0 0)', 'LINESTRING (0 0, 1 1)']);
324
328
  将 GeoJSON Geometry 对象转换为 WKT 字符串(`build` 的语义化别名)。
325
329
 
326
330
  ```javascript
327
- import { geojsonToWkt } from './dist/index.esm.js';
331
+ import { geojsonToWkt } from 'wkt-parse-and-geojson';
328
332
 
329
333
  geojsonToWkt({ type: 'Point', coordinates: [116.39, 39.91] })
330
334
  // → 'POINT (116.39 39.91)'
@@ -339,7 +343,7 @@ geojsonToWkt({ type: 'Point', coordinates: [116.39, 39.91] })
339
343
  **抛出:** 若 `Feature.geometry` 为 `null`,则抛出 `Error`
340
344
 
341
345
  ```javascript
342
- import { featureToWkt } from './dist/index.esm.js';
346
+ import { featureToWkt } from 'wkt-parse-and-geojson';
343
347
 
344
348
  featureToWkt({
345
349
  type: 'Feature',
@@ -358,7 +362,7 @@ featureToWkt({
358
362
  **返回:** `Array<string | null>`
359
363
 
360
364
  ```javascript
361
- import { featureCollectionToWkt } from './dist/index.esm.js';
365
+ import { featureCollectionToWkt } from 'wkt-parse-and-geojson';
362
366
 
363
367
  featureCollectionToWkt({
364
368
  type: 'FeatureCollection',
@@ -578,7 +582,7 @@ parse('POINT (0 0) garbage')
578
582
  ### WKT → GeoJSON Feature → 回写 WKT
579
583
 
580
584
  ```javascript
581
- import { wktToFeature, featureToWkt } from './dist/index.esm.js';
585
+ import { wktToFeature, featureToWkt } from 'wkt-parse-and-geojson';
582
586
 
583
587
  const wkt = 'POLYGON ((116 39, 117 39, 117 40, 116 40, 116 39))';
584
588
 
@@ -597,7 +601,7 @@ console.log(outputWkt);
597
601
  ### 批量城市点构建 FeatureCollection
598
602
 
599
603
  ```javascript
600
- import { wktToFeatureCollection } from './dist/index.esm.js';
604
+ import { wktToFeatureCollection } from 'wkt-parse-and-geojson';
601
605
 
602
606
  const cities = [
603
607
  { wkt: 'POINT (116.39 39.91)', props: { name: '北京', code: 'BJ' } },
@@ -617,7 +621,7 @@ console.log(JSON.stringify(fc, null, 2));
617
621
  ### 使用工厂方法组合复杂几何
618
622
 
619
623
  ```javascript
620
- import { createPoint, createLineString, createPolygon, createGeometryCollection, build } from './dist/index.esm.js';
624
+ import { createPoint, createLineString, createPolygon, createGeometryCollection, build } from 'wkt-parse-and-geojson';
621
625
 
622
626
  const collection = createGeometryCollection([
623
627
  createPoint(0, 0),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wkt-parse-and-geojson",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "type": "module",
5
5
  "description": "Parse WKT and build GeoJSON, convert between WKT and GeoJSON",
6
6
  "main": "dist/index.cjs.js",
@@ -14,7 +14,13 @@
14
14
  "dev": "rollup -c -w",
15
15
  "typecheck": "tsc --noEmit"
16
16
  },
17
- "keywords": ["wkt", "geojson", "geometry", "parser", "gis"],
17
+ "keywords": [
18
+ "wkt",
19
+ "geojson",
20
+ "geometry",
21
+ "parser",
22
+ "gis"
23
+ ],
18
24
  "author": "",
19
25
  "license": "MIT",
20
26
  "devDependencies": {
@@ -22,5 +28,8 @@
22
28
  "rollup": "^4.40.0",
23
29
  "tslib": "^2.8.1",
24
30
  "typescript": "^5.8.3"
31
+ },
32
+ "dependencies": {
33
+ "wkt-parse-and-geojson": "^1.0.0"
25
34
  }
26
- }
35
+ }