@maplat/tin 0.13.0 → 0.13.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 (3) hide show
  1. package/README.ja.md +72 -66
  2. package/README.md +74 -68
  3. package/package.json +5 -5
package/README.ja.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Maplat Tin
2
2
 
3
+ [![CI](https://github.com/code4history/MaplatTin/actions/workflows/ci.yml/badge.svg)](https://github.com/code4history/MaplatTin/actions/workflows/ci.yml)
4
+
3
5
  2つの平面座標系間で制御点に基づく同相変換を定義・実行するJavaScriptライブラリです。
4
6
  [Maplat](https://github.com/code4history/Maplat/)プロジェクトの一部として開発されています。
5
7
 
@@ -17,58 +19,28 @@ English README is [here](./README.md).
17
19
  - **エッジ制約:** より正確な変換のための制約付きエッジの指定が可能
18
20
  - **状態管理:** 変換定義の保存と復元をサポート
19
21
 
22
+ ## 動作要件
23
+
24
+ - **Node.js**: 20.0.0 以上
25
+ - **パッケージマネージャー**: pnpm 9.0.0 以上(推奨)または npm
26
+
20
27
  ## インストール方法
21
28
 
29
+ ### pnpm(推奨)
30
+
31
+ ```sh
32
+ pnpm add @maplat/tin
33
+ ```
34
+
22
35
  ### npm
23
36
 
24
37
  ```sh
25
- # メインパッケージのインストール
26
38
  npm install @maplat/tin
27
-
28
- # 必要な依存パッケージのインストール
29
- npm install delaunator
30
39
  ```
31
40
 
32
41
 
33
42
  ## 開発環境のセットアップ
34
43
 
35
- このプロジェクトは開発時にローカルの依存関係を使用することをサポートしています。ローカルパッケージの依存関係管理には`yalc`の使用を推奨します。
36
-
37
- ### yalcを使用したローカル開発
38
-
39
- 1. **yalcをグローバルにインストール:**
40
- ```sh
41
- npm install -g yalc
42
- ```
43
-
44
- 2. **ローカル依存関係を公開:**
45
- ```sh
46
- # MaplatTransformディレクトリで
47
- cd ../MaplatTransform
48
- yalc publish
49
- ```
50
-
51
- 3. **このプロジェクトでローカル依存関係をリンク:**
52
- ```sh
53
- # MaplatTinディレクトリで
54
- yalc add @maplat/transform
55
- ```
56
-
57
- 4. **変更時にローカル依存関係を更新:**
58
- ```sh
59
- # 依存関係のディレクトリで(例:MaplatTransform)
60
- yalc publish --push
61
- ```
62
-
63
- 5. **ローカル依存関係を削除(npmパッケージを使用する場合):**
64
- ```sh
65
- # MaplatTinディレクトリで
66
- yalc remove @maplat/transform
67
- npm install
68
- ```
69
-
70
- **注意:** `.yalc`ディレクトリと`yalc.lock`ファイルはgitに無視され、コミットされません。
71
-
72
44
  ### テスト
73
45
 
74
46
  プロジェクトには、TIN変換ロジックと内部EdgeBound制約エンジンの両方に対する包括的なユニットテストが含まれています。
@@ -96,19 +68,23 @@ pnpm test tests/tin
96
68
  - `tests/tin.test.ts` - 実際の地図データを使用したTIN変換テスト
97
69
  - `tests/transform.test.ts` - 座標変換テスト
98
70
 
71
+ ### ビルド
72
+
73
+ ライブラリのビルド:
74
+ ```sh
75
+ pnpm run build
76
+ ```
77
+
78
+ デモサイトのビルド:
79
+ ```sh
80
+ pnpm run build:demo
81
+ ```
82
+
99
83
  ### ブラウザ
100
84
 
101
- ブラウザで使用する場合、ピア依存関係を含める必要があります:
85
+ ブラウザで使用する場合:
102
86
 
103
87
  ```html
104
- <!-- 必要な依存関係 -->
105
- <script src="https://unpkg.com/delaunator@5.0.0/delaunator.min.js"></script>
106
- <script src="https://unpkg.com/@turf/helpers@7.2.0/dist/turf-helpers.min.js"></script>
107
- <script src="https://unpkg.com/@turf/boolean-point-in-polygon@7.2.0/dist/turf-boolean-point-in-polygon.min.js"></script>
108
- <script src="https://unpkg.com/@turf/centroid@7.2.0/dist/turf-centroid.min.js"></script>
109
- <script src="https://unpkg.com/@turf/convex@7.2.0/dist/turf-convex.min.js"></script>
110
- <script src="https://unpkg.com/@turf/line-intersect@7.2.0/dist/turf-line-intersect.min.js"></script>
111
-
112
88
  <!-- Maplat Tin (UMD) -->
113
89
  <script src="https://unpkg.com/@maplat/tin/dist/tin.umd.js"></script>
114
90
  <script>
@@ -169,28 +145,58 @@ const restored = tin.transform(transformed, true);
169
145
  ## 設定オプション
170
146
 
171
147
  ### コンストラクタオプション
172
- | **オプション** | **型** | **説明** | **デフォルト** |
173
- | ------------- | --------------------------- | ------------------------- | ------------- |
174
- | `bounds` | `Position[]` | **境界多角形の頂点** | `-` |
175
- | `wh` | `number[]` | **幅と高さ [w, h]** | `-` |
176
- | `vertexMode` | `"plain"|"birdeye"` | **頂点処理モード** | `"plain"` |
177
- | `strictMode` | `"strict"|"auto"|"loose"` | **トポロジーチェックモード** | `"auto"` |
178
- | `yaxisMode` | `"follow"|"invert"` | **Y軸の向き** | `"invert"` |
179
- | `importance` | `number` | **地図の重要度** | `0` |
180
- | `priority` | `number` | **地図の優先度** | `0` |
148
+ | **オプション** | **型** | **説明** | **デフォルト** |
149
+ | -------------- | --------------------------- | ---------------------------- | -------------- |
150
+ | `bounds` | `Position[]` | **境界多角形の頂点** | `-` |
151
+ | `wh` | `number[]` | **幅と高さ [w, h]** | `-` |
152
+ | `vertexMode` | `"plain"|"birdeye"` | **頂点処理モード** | `"plain"` |
153
+ | `strictMode` | `"strict"|"auto"|"loose"` | **トポロジーチェックモード** | `"auto"` |
154
+ | `yaxisMode` | `"follow"|"invert"` | **Y軸の向き** | `"invert"` |
155
+ | `importance` | `number` | **地図の重要度** | `0` |
156
+ | `priority` | `number` | **地図の優先度** | `0` |
181
157
 
182
158
  `bounds`または`wh`のいずれかを指定する必要があります。
183
159
 
184
160
  ### メソッド
185
161
 
186
- | **メソッド** | **説明** |
187
- | ---------------------------- | --------------------------------- |
188
- | `setPoints(points)` | **制御点の設定** |
189
- | `setEdges(edges)` | **制約付きエッジの設定** |
190
- | `updateTin()` | **TINネットワークの初期化/更新** |
191
- | `transform(coords, inverse)` | **座標変換の実行** |
162
+ | **メソッド** | **説明** |
163
+ | ---------------------------- | ------------------------------------ |
164
+ | `setPoints(points)` | **制御点の設定** |
165
+ | `setEdges(edges)` | **制約付きエッジの設定** |
166
+ | `updateTin()` | **TINネットワークの初期化/更新** |
167
+ | `transform(coords, inverse)` | **座標変換の実行** |
192
168
  | `getCompiled()` | **シリアライズ可能な状態の取得** |
193
169
  | `setCompiled(state)` | **シリアライズされた状態からの復元** |
170
+ | `getFormatVersion()` | **フォーマットバージョン番号の取得** |
171
+
172
+ ### 定数
173
+
174
+ **Y軸モード:**
175
+ - `Tin.YAXIS_FOLLOW` - Y軸が座標系に従う
176
+ - `Tin.YAXIS_INVERT` - Y軸が反転する
177
+
178
+ **ステータス値:**
179
+ - `Tin.STATUS_STRICT` - 厳密なトポロジー(往復変換が保証される)
180
+ - `Tin.STATUS_LOOSE` - 緩和されたトポロジー(往復変換が保証されない)
181
+
182
+ **フォーマットバージョン:**
183
+ - `format_version` - 現在のTINフォーマットバージョン
184
+
185
+ ### ユーティリティ関数
186
+
187
+ | **関数** | **説明** |
188
+ | --------------------------------------------------------------------- | ---------------------------------- |
189
+ | `constrainedTin(points, edges, z)` | **制約付きドロネー三角分割の生成** |
190
+ | `findIntersections(features)` | **フィーチャ内の交点を検出** |
191
+ | `insertSearchIndex(tins, centroid, strict)` | **TINの検索インデックスを挿入** |
192
+ | `counterPoint(point)` | **対向点の計算** |
193
+ | `createPoint(xy, mercator, forw)` | **ポイントフィーチャの作成** |
194
+ | `vertexCalc(points, edgeNodes, centroid, originPoly, xy, vertexMode)` | **頂点座標の計算** |
195
+
196
+ ## ドキュメント
197
+
198
+ TIN内部構造の詳細情報:
199
+ - [TIN 内部構造](docs/tin-internals.ja.md)
194
200
 
195
201
  ### エラーハンドリング
196
202
 
@@ -204,7 +210,7 @@ const restored = tin.transform(transformed, true);
204
210
 
205
211
  Maplat Limited License 1.1
206
212
 
207
- Copyright (c) 2024 Code for History
213
+ Copyright (c) 2024-2026 Code for History
208
214
 
209
215
  ## 開発者
210
216
 
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Maplat Tin
2
2
 
3
+ [![CI](https://github.com/code4history/MaplatTin/actions/workflows/ci.yml/badge.svg)](https://github.com/code4history/MaplatTin/actions/workflows/ci.yml)
4
+
3
5
  A JavaScript library that defines and executes homeomorphic conversion between two plane coordinate systems based on control points.
4
6
  This is part of the [Maplat](https://github.com/code4history/Maplat/) project.
5
7
 
@@ -17,58 +19,28 @@ This is part of the [Maplat](https://github.com/code4history/Maplat/) project.
17
19
  - **Edge Constraints:** Ability to specify constrained edges for more accurate transformation
18
20
  - **State Management:** Save and restore transformation definitions
19
21
 
22
+ ## Requirements
23
+
24
+ - **Node.js**: 20.0.0 or higher
25
+ - **Package Manager**: pnpm 9.0.0 or higher (recommended) or npm
26
+
20
27
  ## Installation
21
28
 
29
+ ### pnpm (Recommended)
30
+
31
+ ```sh
32
+ pnpm add @maplat/tin
33
+ ```
34
+
22
35
  ### npm
23
36
 
24
37
  ```sh
25
- # Install the main package
26
38
  npm install @maplat/tin
27
-
28
- # Install required dependency
29
- npm install delaunator
30
39
  ```
31
40
 
32
41
 
33
42
  ## Development Setup
34
43
 
35
- This project supports using local dependencies for development. We recommend using `yalc` for managing local package dependencies.
36
-
37
- ### Using yalc for Local Development
38
-
39
- 1. **Install yalc globally:**
40
- ```sh
41
- npm install -g yalc
42
- ```
43
-
44
- 2. **Publish local dependencies:**
45
- ```sh
46
- # In the MaplatTransform directory
47
- cd ../MaplatTransform
48
- yalc publish
49
- ```
50
-
51
- 3. **Link local dependencies in this project:**
52
- ```sh
53
- # In the MaplatTin directory
54
- yalc add @maplat/transform
55
- ```
56
-
57
- 4. **Update local dependencies when changed:**
58
- ```sh
59
- # In the dependency directory (e.g., MaplatTransform)
60
- yalc publish --push
61
- ```
62
-
63
- 5. **Remove local dependencies (to use npm packages):**
64
- ```sh
65
- # In the MaplatTin directory
66
- yalc remove @maplat/transform
67
- npm install
68
- ```
69
-
70
- **Note:** The `.yalc` directory and `yalc.lock` file are ignored by git and will not be committed.
71
-
72
44
  ### Testing
73
45
 
74
46
  The project includes comprehensive unit tests for both the TIN transformation logic and the internal EdgeBound constraint engine.
@@ -96,19 +68,23 @@ pnpm test tests/tin
96
68
  - `tests/tin.test.ts` - TIN transformation tests with real map data
97
69
  - `tests/transform.test.ts` - Coordinate transformation tests
98
70
 
71
+ ### Building
72
+
73
+ Build the library:
74
+ ```sh
75
+ pnpm run build
76
+ ```
77
+
78
+ Build the demo site:
79
+ ```sh
80
+ pnpm run build:demo
81
+ ```
82
+
99
83
  ### Browser
100
84
 
101
- When using in the browser, you need to include the peer dependencies:
85
+ When using in the browser:
102
86
 
103
87
  ```html
104
- <!-- Required dependencies -->
105
- <script src="https://unpkg.com/delaunator@5.0.0/delaunator.min.js"></script>
106
- <script src="https://unpkg.com/@turf/helpers@7.2.0/dist/turf-helpers.min.js"></script>
107
- <script src="https://unpkg.com/@turf/boolean-point-in-polygon@7.2.0/dist/turf-boolean-point-in-polygon.min.js"></script>
108
- <script src="https://unpkg.com/@turf/centroid@7.2.0/dist/turf-centroid.min.js"></script>
109
- <script src="https://unpkg.com/@turf/convex@7.2.0/dist/turf-convex.min.js"></script>
110
- <script src="https://unpkg.com/@turf/line-intersect@7.2.0/dist/turf-line-intersect.min.js"></script>
111
-
112
88
  <!-- Maplat Tin (UMD) -->
113
89
  <script src="https://unpkg.com/@maplat/tin/dist/tin.umd.js"></script>
114
90
  <script>
@@ -170,28 +146,58 @@ const restored = tin.transform(transformed, true);
170
146
 
171
147
  ### Constructor Options
172
148
 
173
- | **Option** | **Type** | **Description** | **Default** |
174
- | ------------- | --------------------------- | ------------------------- | ------------- |
175
- | `bounds` | `Position[]` | **Boundary polygon vertices** | `-` |
176
- | `wh` | `number[]` | **Width and height [w, h]** | `-` |
177
- | `vertexMode` | `"plain"|"birdeye"` | **Vertex handling mode** | `"plain"` |
178
- | `strictMode` | `"strict"|"auto"|"loose"` | **Topology check mode** | `"auto"` |
179
- | `yaxisMode` | `"follow"|"invert"` | **Y-axis direction** | `"invert"` |
180
- | `importance` | `number` | **Map importance** | `0` |
181
- | `priority` | `number` | **Map priority** | `0` |
149
+ | **Option** | **Type** | **Description** | **Default** |
150
+ | ------------ | --------------------------- | ----------------------------- | ----------- |
151
+ | `bounds` | `Position[]` | **Boundary polygon vertices** | `-` |
152
+ | `wh` | `number[]` | **Width and height [w, h]** | `-` |
153
+ | `vertexMode` | `"plain"|"birdeye"` | **Vertex handling mode** | `"plain"` |
154
+ | `strictMode` | `"strict"|"auto"|"loose"` | **Topology check mode** | `"auto"` |
155
+ | `yaxisMode` | `"follow"|"invert"` | **Y-axis direction** | `"invert"` |
156
+ | `importance` | `number` | **Map importance** | `0` |
157
+ | `priority` | `number` | **Map priority** | `0` |
182
158
 
183
159
  Either `bounds` or `wh` must be specified.
184
160
 
185
161
  ### Methods
186
162
 
187
- | **Method** | **Description** |
188
- | ---------------------------- | --------------------------------- |
189
- | `setPoints(points)` | **Set control points** |
190
- | `setEdges(edges)` | **Set constrained edges** |
191
- | `updateTin()` | **Initialize/update TIN network** |
192
- | `transform(coords, inverse)` | **Execute coordinate transformation** |
193
- | `getCompiled()` | **Get serializable state** |
194
- | `setCompiled(state)` | **Restore from serialized state** |
163
+ | **Method** | **Description** |
164
+ | ---------------------------- | ------------------------------------- |
165
+ | `setPoints(points)` | **Set control points** |
166
+ | `setEdges(edges)` | **Set constrained edges** |
167
+ | `updateTin()` | **Initialize/update TIN network** |
168
+ | `transform(coords, inverse)` | **Execute coordinate transformation** |
169
+ | `getCompiled()` | **Get serializable state** |
170
+ | `setCompiled(state)` | **Restore from serialized state** |
171
+ | `getFormatVersion()` | **Get format version number** |
172
+
173
+ ### Constants
174
+
175
+ **Y-axis Mode:**
176
+ - `Tin.YAXIS_FOLLOW` - Y-axis follows the coordinate system
177
+ - `Tin.YAXIS_INVERT` - Y-axis is inverted
178
+
179
+ **Status Values:**
180
+ - `Tin.STATUS_STRICT` - Strict topology (roundtrip transform guaranteed)
181
+ - `Tin.STATUS_LOOSE` - Loose topology (roundtrip transform not guaranteed)
182
+
183
+ **Format Version:**
184
+ - `format_version` - Current TIN format version
185
+
186
+ ### Utility Functions
187
+
188
+ | **Function** | **Description** |
189
+ | --------------------------------------------------------------------- | ----------------------------------------------- |
190
+ | `constrainedTin(points, edges, z)` | **Generate constrained Delaunay triangulation** |
191
+ | `findIntersections(features)` | **Find intersection points in features** |
192
+ | `insertSearchIndex(tins, centroid, strict)` | **Insert search index for TIN** |
193
+ | `counterPoint(point)` | **Calculate counter point** |
194
+ | `createPoint(xy, mercator, forw)` | **Create point feature** |
195
+ | `vertexCalc(points, edgeNodes, centroid, originPoly, xy, vertexMode)` | **Calculate vertex coordinates** |
196
+
197
+ ## Documentation
198
+
199
+ For detailed information about TIN internals:
200
+ - [TIN Internals](docs/tin-internals.md)
195
201
 
196
202
  ### Error Handling
197
203
 
@@ -205,7 +211,7 @@ The library may throw errors in the following cases:
205
211
 
206
212
  Maplat Limited License 1.1
207
213
 
208
- Copyright (c) 2024 Code for History
214
+ Copyright (c) 2024-2026 Code for History
209
215
 
210
216
  ## Developers
211
217
 
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.13.0",
7
+ "version": "0.13.1",
8
8
  "description": "JavaScript library which performs homeomorphic conversion mutually between the coordinate systems of two planes based on the control points.",
9
9
  "type": "module",
10
10
  "module": "./dist/maplat_tin.js",
@@ -49,7 +49,7 @@
49
49
  "deno"
50
50
  ],
51
51
  "dependencies": {
52
- "@maplat/transform": "0.4.0",
52
+ "@maplat/transform": "0.4.1",
53
53
  "@turf/turf": "^7.3.1",
54
54
  "delaunator": "^5.0.1",
55
55
  "robust-predicates": "^3.0.2"
@@ -61,8 +61,8 @@
61
61
  "@types/estree": "^1.0.8",
62
62
  "@types/geojson": "^7946.0.16",
63
63
  "@types/node": "^24.10.4",
64
- "@typescript-eslint/eslint-plugin": "^8.50.1",
65
- "@typescript-eslint/parser": "^8.50.1",
64
+ "@typescript-eslint/eslint-plugin": "^8.51.0",
65
+ "@typescript-eslint/parser": "^8.51.0",
66
66
  "@vitest/coverage-v8": "^3.2.4",
67
67
  "cross-env": "^10.1.0",
68
68
  "dotenv": "^17.2.3",
@@ -75,7 +75,7 @@
75
75
  "prettier": "^3.7.4",
76
76
  "robust-segment-intersect": "^1.0.1",
77
77
  "typescript": "^5.9.3",
78
- "typescript-eslint": "^8.50.1",
78
+ "typescript-eslint": "^8.51.0",
79
79
  "vite": "^6.4.1",
80
80
  "vite-plugin-dts": "^4.5.4",
81
81
  "vitest": "^3.2.4"