@maplat/tin 0.12.0 → 0.13.0

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.ja.md CHANGED
@@ -1,214 +1,214 @@
1
- # Maplat Tin
2
-
3
- 2つの平面座標系間で制御点に基づく同相変換を定義・実行するJavaScriptライブラリです。
4
- [Maplat](https://github.com/code4history/Maplat/)プロジェクトの一部として開発されています。
5
-
6
- English README is [here](./README.md).
7
-
8
- ## 主な機能
9
-
10
- - **座標変換定義の生成:** 制御点とエッジ制約に基づいて座標変換定義を生成
11
- - **双方向座標変換:** 2つの平面間で双方向の座標変換が可能
12
- - **位相保存:** 変換時の同相性(トポロジー)を維持
13
- - **柔軟な設定:**
14
- - 通常/鳥瞰図モードの頂点処理
15
- - 厳密/自動/緩和モードのトポロジーチェック
16
- - Y軸の向きの制御
17
- - **エッジ制約:** より正確な変換のための制約付きエッジの指定が可能
18
- - **状態管理:** 変換定義の保存と復元をサポート
19
-
20
- ## インストール方法
21
-
22
- ### npm
23
-
24
- ```sh
25
- # メインパッケージのインストール
26
- npm install @maplat/tin
27
-
28
- # 必要な依存パッケージのインストール
29
- npm install delaunator
30
- ```
31
-
32
-
33
- ## 開発環境のセットアップ
34
-
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
- ### テスト
73
-
74
- プロジェクトには、TIN変換ロジックと内部EdgeBound制約エンジンの両方に対する包括的なユニットテストが含まれています。
75
-
76
- **すべてのテストを実行:**
77
- ```sh
78
- pnpm test
79
- ```
80
-
81
- **特定のテストスイートを実行:**
82
- ```sh
83
- # EdgeBound制約エンジンのテスト
84
- pnpm test tests/edgebound
85
-
86
- # TIN変換のテスト
87
- pnpm test tests/tin
88
- ```
89
-
90
- **テストカバレッジ:**
91
- - `tests/edgebound/` - 内部EdgeBound制約エンジンのテスト(455テスト)
92
- - `constrain.test.ts` - 制約操作の統合テスト
93
- - `constrain.unit.test.ts` - 制約メソッドのユニットテスト
94
- - `intersect.test.ts` - 線分交差検出テスト
95
- - `validators.ts` - 三角形分割の整合性検証用テストユーティリティ
96
- - `tests/tin.test.ts` - 実際の地図データを使用したTIN変換テスト
97
- - `tests/transform.test.ts` - 座標変換テスト
98
-
99
- ### ブラウザ
100
-
101
- ブラウザで使用する場合、ピア依存関係を含める必要があります:
102
-
103
- ```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
- <!-- Maplat Tin (UMD) -->
113
- <script src="https://unpkg.com/@maplat/tin/dist/tin.umd.js"></script>
114
- <script>
115
- // ライブラリを使用
116
- const tin = new tin.default({
117
- wh: [500, 500]
118
- });
119
- </script>
120
- ```
121
-
122
- またはESモジュールとして使用する場合:
123
-
124
- ```html
125
- <!-- Maplat Tin (ESモジュール) -->
126
- <script type="module">
127
- import Tin from "https://unpkg.com/@maplat/tin/dist/index.js";
128
- // ライブラリを使用
129
- const tin = new Tin({
130
- wh: [500, 500]
131
- });
132
- </script>
133
- ```
134
-
135
- ## 基本的な使用方法
136
-
137
- ```javascript
138
- // 基本設定でインスタンスを作成
139
- const tin = new Tin({
140
- wh: [500, 500], // ソース座標系の幅と高さ
141
- yaxisMode: Tin.YAXIS_FOLLOW // Y軸の向きの設定
142
- });
143
-
144
- // 制御点の設定: [ソース座標, ターゲット座標] の配列
145
- tin.setPoints([
146
- [[100,100], [200, 200]], // 点1
147
- [[200,200], [400, 400]], // 点2
148
- [[150,150], [320, 350]], // 点3
149
- [[200,100], [420, 220]] // 点4
150
- ]);
151
-
152
- // TINネットワークの初期化
153
- tin.updateTin();
154
-
155
- // トポロジーの状態確認
156
- if (tin.strict_status === Tin.STATUS_STRICT) {
157
- console.log('トポロジーOK: 往復変換が保証されます');
158
- } else if (tin.strict_status === Tin.STATUS_LOOSE) {
159
- console.log('トポロジー警告: 往復変換が保証されません');
160
- }
161
-
162
- // 順方向の変換(ソース → ターゲット)
163
- const transformed = tin.transform([160, 160], false);
164
-
165
- // 逆方向の変換(ターゲット → ソース)
166
- const restored = tin.transform(transformed, true);
167
- ```
168
-
169
- ## 設定オプション
170
-
171
- ### コンストラクタオプション
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` |
181
-
182
- `bounds`または`wh`のいずれかを指定する必要があります。
183
-
184
- ### メソッド
185
-
186
- | **メソッド** | **説明** |
187
- | ---------------------------- | --------------------------------- |
188
- | `setPoints(points)` | **制御点の設定** |
189
- | `setEdges(edges)` | **制約付きエッジの設定** |
190
- | `updateTin()` | **TINネットワークの初期化/更新** |
191
- | `transform(coords, inverse)` | **座標変換の実行** |
192
- | `getCompiled()` | **シリアライズ可能な状態の取得** |
193
- | `setCompiled(state)` | **シリアライズされた状態からの復元** |
194
-
195
- ### エラーハンドリング
196
-
197
- このライブラリは以下の場合にエラーをスローします:
198
-
199
- - `"TOO LINEAR1"`,`"TOO LINEAR2"`: 制御点が直線状に並びすぎている
200
- - `"SOME POINTS OUTSIDE"`: 点が境界外にある
201
- - 逆変換が許可されていない状態での逆変換実行時
202
-
203
- ## ライセンス
204
-
205
- Maplat Limited License 1.1
206
-
207
- Copyright (c) 2024 Code for History
208
-
209
- ## 開発者
210
-
211
- - Kohei Otsuka
212
- - Code for History
213
-
214
- あなたの貢献をお待ちしています![イシューやプルリクエスト](https://github.com/code4history/MaplatTin/issues)は大歓迎です。
1
+ # Maplat Tin
2
+
3
+ 2つの平面座標系間で制御点に基づく同相変換を定義・実行するJavaScriptライブラリです。
4
+ [Maplat](https://github.com/code4history/Maplat/)プロジェクトの一部として開発されています。
5
+
6
+ English README is [here](./README.md).
7
+
8
+ ## 主な機能
9
+
10
+ - **座標変換定義の生成:** 制御点とエッジ制約に基づいて座標変換定義を生成
11
+ - **双方向座標変換:** 2つの平面間で双方向の座標変換が可能
12
+ - **位相保存:** 変換時の同相性(トポロジー)を維持
13
+ - **柔軟な設定:**
14
+ - 通常/鳥瞰図モードの頂点処理
15
+ - 厳密/自動/緩和モードのトポロジーチェック
16
+ - Y軸の向きの制御
17
+ - **エッジ制約:** より正確な変換のための制約付きエッジの指定が可能
18
+ - **状態管理:** 変換定義の保存と復元をサポート
19
+
20
+ ## インストール方法
21
+
22
+ ### npm
23
+
24
+ ```sh
25
+ # メインパッケージのインストール
26
+ npm install @maplat/tin
27
+
28
+ # 必要な依存パッケージのインストール
29
+ npm install delaunator
30
+ ```
31
+
32
+
33
+ ## 開発環境のセットアップ
34
+
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
+ ### テスト
73
+
74
+ プロジェクトには、TIN変換ロジックと内部EdgeBound制約エンジンの両方に対する包括的なユニットテストが含まれています。
75
+
76
+ **すべてのテストを実行:**
77
+ ```sh
78
+ pnpm test
79
+ ```
80
+
81
+ **特定のテストスイートを実行:**
82
+ ```sh
83
+ # EdgeBound制約エンジンのテスト
84
+ pnpm test tests/edgebound
85
+
86
+ # TIN変換のテスト
87
+ pnpm test tests/tin
88
+ ```
89
+
90
+ **テストカバレッジ:**
91
+ - `tests/edgebound/` - 内部EdgeBound制約エンジンのテスト(455テスト)
92
+ - `constrain.test.ts` - 制約操作の統合テスト
93
+ - `constrain.unit.test.ts` - 制約メソッドのユニットテスト
94
+ - `intersect.test.ts` - 線分交差検出テスト
95
+ - `validators.ts` - 三角形分割の整合性検証用テストユーティリティ
96
+ - `tests/tin.test.ts` - 実際の地図データを使用したTIN変換テスト
97
+ - `tests/transform.test.ts` - 座標変換テスト
98
+
99
+ ### ブラウザ
100
+
101
+ ブラウザで使用する場合、ピア依存関係を含める必要があります:
102
+
103
+ ```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
+ <!-- Maplat Tin (UMD) -->
113
+ <script src="https://unpkg.com/@maplat/tin/dist/tin.umd.js"></script>
114
+ <script>
115
+ // ライブラリを使用
116
+ const tin = new tin.default({
117
+ wh: [500, 500]
118
+ });
119
+ </script>
120
+ ```
121
+
122
+ またはESモジュールとして使用する場合:
123
+
124
+ ```html
125
+ <!-- Maplat Tin (ESモジュール) -->
126
+ <script type="module">
127
+ import Tin from "https://unpkg.com/@maplat/tin/dist/index.js";
128
+ // ライブラリを使用
129
+ const tin = new Tin({
130
+ wh: [500, 500]
131
+ });
132
+ </script>
133
+ ```
134
+
135
+ ## 基本的な使用方法
136
+
137
+ ```javascript
138
+ // 基本設定でインスタンスを作成
139
+ const tin = new Tin({
140
+ wh: [500, 500], // ソース座標系の幅と高さ
141
+ yaxisMode: Tin.YAXIS_FOLLOW // Y軸の向きの設定
142
+ });
143
+
144
+ // 制御点の設定: [ソース座標, ターゲット座標] の配列
145
+ tin.setPoints([
146
+ [[100,100], [200, 200]], // 点1
147
+ [[200,200], [400, 400]], // 点2
148
+ [[150,150], [320, 350]], // 点3
149
+ [[200,100], [420, 220]] // 点4
150
+ ]);
151
+
152
+ // TINネットワークの初期化
153
+ tin.updateTin();
154
+
155
+ // トポロジーの状態確認
156
+ if (tin.strict_status === Tin.STATUS_STRICT) {
157
+ console.log('トポロジーOK: 往復変換が保証されます');
158
+ } else if (tin.strict_status === Tin.STATUS_LOOSE) {
159
+ console.log('トポロジー警告: 往復変換が保証されません');
160
+ }
161
+
162
+ // 順方向の変換(ソース → ターゲット)
163
+ const transformed = tin.transform([160, 160], false);
164
+
165
+ // 逆方向の変換(ターゲット → ソース)
166
+ const restored = tin.transform(transformed, true);
167
+ ```
168
+
169
+ ## 設定オプション
170
+
171
+ ### コンストラクタオプション
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` |
181
+
182
+ `bounds`または`wh`のいずれかを指定する必要があります。
183
+
184
+ ### メソッド
185
+
186
+ | **メソッド** | **説明** |
187
+ | ---------------------------- | --------------------------------- |
188
+ | `setPoints(points)` | **制御点の設定** |
189
+ | `setEdges(edges)` | **制約付きエッジの設定** |
190
+ | `updateTin()` | **TINネットワークの初期化/更新** |
191
+ | `transform(coords, inverse)` | **座標変換の実行** |
192
+ | `getCompiled()` | **シリアライズ可能な状態の取得** |
193
+ | `setCompiled(state)` | **シリアライズされた状態からの復元** |
194
+
195
+ ### エラーハンドリング
196
+
197
+ このライブラリは以下の場合にエラーをスローします:
198
+
199
+ - `"TOO LINEAR1"`,`"TOO LINEAR2"`: 制御点が直線状に並びすぎている
200
+ - `"SOME POINTS OUTSIDE"`: 点が境界外にある
201
+ - 逆変換が許可されていない状態での逆変換実行時
202
+
203
+ ## ライセンス
204
+
205
+ Maplat Limited License 1.1
206
+
207
+ Copyright (c) 2024 Code for History
208
+
209
+ ## 開発者
210
+
211
+ - Kohei Otsuka
212
+ - Code for History
213
+
214
+ あなたの貢献をお待ちしています![イシューやプルリクエスト](https://github.com/code4history/MaplatTin/issues)は大歓迎です。