@maplat/tin 0.11.1 → 0.11.3

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,176 +1,219 @@
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
- ### JSR (JavaScript Registry)
33
-
34
- ```sh
35
- # Deno向け
36
- deno add @maplat/tin
37
-
38
- # npm/Node.js向け
39
- npx jsr add @maplat/tin
40
- ```
41
-
42
- ### Deno
43
-
44
- ```typescript
45
- // JSR経由(推奨)
46
- import Tin from "jsr:@maplat/tin";
47
-
48
- // deno.jsonのimport mapを使用
49
- import Tin from "@maplat/tin";
50
-
51
- // またはnpmから直接
52
- import Tin from "npm:@maplat/tin@0.11.1";
53
-
54
- // ライブラリを使用
55
- const tin = new Tin({
56
- wh: [500, 500],
57
- yaxisMode: Tin.YAXIS_FOLLOW
58
- });
59
- ```
60
-
61
- ### ブラウザ
62
-
63
- ブラウザで使用する場合、ピア依存関係を含める必要があります:
64
-
65
- ```html
66
- <!-- 必要な依存関係 -->
67
- <script src="https://unpkg.com/delaunator@5.0.0/delaunator.min.js"></script>
68
- <script src="https://unpkg.com/@turf/helpers@7.2.0/dist/turf-helpers.min.js"></script>
69
- <script src="https://unpkg.com/@turf/boolean-point-in-polygon@7.2.0/dist/turf-boolean-point-in-polygon.min.js"></script>
70
- <script src="https://unpkg.com/@turf/centroid@7.2.0/dist/turf-centroid.min.js"></script>
71
- <script src="https://unpkg.com/@turf/convex@7.2.0/dist/turf-convex.min.js"></script>
72
- <script src="https://unpkg.com/@turf/line-intersect@7.2.0/dist/turf-line-intersect.min.js"></script>
73
-
74
- <!-- Maplat Tin (UMD) -->
75
- <script src="https://unpkg.com/@maplat/tin/dist/tin.umd.js"></script>
76
- <script>
77
- // ライブラリを使用
78
- const tin = new tin.default({
79
- wh: [500, 500]
80
- });
81
- </script>
82
- ```
83
-
84
- またはESモジュールとして使用する場合:
85
-
86
- ```html
87
- <!-- Maplat Tin (ESモジュール) -->
88
- <script type="module">
89
- import Tin from "https://unpkg.com/@maplat/tin/dist/index.js";
90
- // ライブラリを使用
91
- const tin = new Tin({
92
- wh: [500, 500]
93
- });
94
- </script>
95
- ```
96
-
97
- ## 基本的な使用方法
98
-
99
- ```javascript
100
- // 基本設定でインスタンスを作成
101
- const tin = new Tin({
102
- wh: [500, 500], // ソース座標系の幅と高さ
103
- yaxisMode: Tin.YAXIS_FOLLOW // Y軸の向きの設定
104
- });
105
-
106
- // 制御点の設定: [ソース座標, ターゲット座標] の配列
107
- tin.setPoints([
108
- [[100,100], [200, 200]], // 点1
109
- [[200,200], [400, 400]], // 点2
110
- [[150,150], [320, 350]], // 点3
111
- [[200,100], [420, 220]] // 点4
112
- ]);
113
-
114
- // TINネットワークの初期化
115
- tin.updateTin();
116
-
117
- // トポロジーの状態確認
118
- if (tin.strict_status === Tin.STATUS_STRICT) {
119
- console.log('トポロジーOK: 往復変換が保証されます');
120
- } else if (tin.strict_status === Tin.STATUS_LOOSE) {
121
- console.log('トポロジー警告: 往復変換が保証されません');
122
- }
123
-
124
- // 順方向の変換(ソース → ターゲット)
125
- const transformed = tin.transform([160, 160], false);
126
-
127
- // 逆方向の変換(ターゲット → ソース)
128
- const restored = tin.transform(transformed, true);
129
- ```
130
-
131
- ## 設定オプション
132
-
133
- ### コンストラクタオプション
134
- | **オプション** | **型** | **説明** | **デフォルト** |
135
- | ------------- | --------------------------- | ------------------------- | ------------- |
136
- | `bounds` | `Position[]` | **境界多角形の頂点** | `-` |
137
- | `wh` | `number[]` | **幅と高さ [w, h]** | `-` |
138
- | `vertexMode` | `"plain"|"birdeye"` | **頂点処理モード** | `"plain"` |
139
- | `strictMode` | `"strict"|"auto"|"loose"` | **トポロジーチェックモード** | `"auto"` |
140
- | `yaxisMode` | `"follow"|"invert"` | **Y軸の向き** | `"invert"` |
141
- | `importance` | `number` | **地図の重要度** | `0` |
142
- | `priority` | `number` | **地図の優先度** | `0` |
143
-
144
- `bounds`または`wh`のいずれかを指定する必要があります。
145
-
146
- ### メソッド
147
-
148
- | **メソッド** | **説明** |
149
- | ---------------------------- | --------------------------------- |
150
- | `setPoints(points)` | **制御点の設定** |
151
- | `setEdges(edges)` | **制約付きエッジの設定** |
152
- | `updateTin()` | **TINネットワークの初期化/更新** |
153
- | `transform(coords, inverse)` | **座標変換の実行** |
154
- | `getCompiled()` | **シリアライズ可能な状態の取得** |
155
- | `setCompiled(state)` | **シリアライズされた状態からの復元** |
156
-
157
- ### エラーハンドリング
158
-
159
- このライブラリは以下の場合にエラーをスローします:
160
-
161
- - `"TOO LINEAR1"`,`"TOO LINEAR2"`: 制御点が直線状に並びすぎている
162
- - `"SOME POINTS OUTSIDE"`: 点が境界外にある
163
- - 逆変換が許可されていない状態での逆変換実行時
164
-
165
- ## ライセンス
166
-
167
- Maplat Limited License 1.1
168
-
169
- Copyright (c) 2024 Code for History
170
-
171
- ## 開発者
172
-
173
- - Kohei Otsuka
174
- - Code for History
175
-
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
+ ### JSR (JavaScript Registry)
33
+
34
+ ```sh
35
+ # Deno向け
36
+ deno add @maplat/tin
37
+
38
+ # npm/Node.js向け
39
+ npx jsr add @maplat/tin
40
+ ```
41
+
42
+ ### Deno
43
+
44
+ ```typescript
45
+ // JSR経由(推奨)
46
+ import Tin from "jsr:@maplat/tin";
47
+
48
+ // deno.jsonのimport mapを使用
49
+ import Tin from "@maplat/tin";
50
+
51
+ // またはnpmから直接
52
+ import Tin from "npm:@maplat/tin@0.11.3";
53
+
54
+ // ライブラリを使用
55
+ const tin = new Tin({
56
+ wh: [500, 500],
57
+ yaxisMode: Tin.YAXIS_FOLLOW
58
+ });
59
+ ```
60
+
61
+ ## 開発環境のセットアップ
62
+
63
+ このプロジェクトは開発時にローカルの依存関係を使用することをサポートしています。ローカルパッケージの依存関係管理には`yalc`の使用を推奨します。
64
+
65
+ ### yalcを使用したローカル開発
66
+
67
+ 1. **yalcをグローバルにインストール:**
68
+ ```sh
69
+ npm install -g yalc
70
+ ```
71
+
72
+ 2. **ローカル依存関係を公開:**
73
+ ```sh
74
+ # MaplatTransformディレクトリで
75
+ cd ../MaplatTransform
76
+ yalc publish
77
+
78
+ # MaplatEdgeBoundディレクトリで
79
+ cd ../MaplatEdgeBound
80
+ yalc publish
81
+ ```
82
+
83
+ 3. **このプロジェクトでローカル依存関係をリンク:**
84
+ ```sh
85
+ # MaplatTinディレクトリで
86
+ yalc add @maplat/transform @maplat/edgebound
87
+ ```
88
+
89
+ 4. **変更時にローカル依存関係を更新:**
90
+ ```sh
91
+ # 依存関係のディレクトリで(例:MaplatTransform)
92
+ yalc publish --push
93
+ ```
94
+
95
+ 5. **ローカル依存関係を削除(npmパッケージを使用する場合):**
96
+ ```sh
97
+ # MaplatTinディレクトリで
98
+ yalc remove @maplat/transform @maplat/edgebound
99
+ npm install
100
+ ```
101
+
102
+ **注意:** `.yalc`ディレクトリと`yalc.lock`ファイルはgitに無視され、コミットされません。
103
+
104
+ ### ブラウザ
105
+
106
+ ブラウザで使用する場合、ピア依存関係を含める必要があります:
107
+
108
+ ```html
109
+ <!-- 必要な依存関係 -->
110
+ <script src="https://unpkg.com/delaunator@5.0.0/delaunator.min.js"></script>
111
+ <script src="https://unpkg.com/@turf/helpers@7.2.0/dist/turf-helpers.min.js"></script>
112
+ <script src="https://unpkg.com/@turf/boolean-point-in-polygon@7.2.0/dist/turf-boolean-point-in-polygon.min.js"></script>
113
+ <script src="https://unpkg.com/@turf/centroid@7.2.0/dist/turf-centroid.min.js"></script>
114
+ <script src="https://unpkg.com/@turf/convex@7.2.0/dist/turf-convex.min.js"></script>
115
+ <script src="https://unpkg.com/@turf/line-intersect@7.2.0/dist/turf-line-intersect.min.js"></script>
116
+
117
+ <!-- Maplat Tin (UMD) -->
118
+ <script src="https://unpkg.com/@maplat/tin/dist/tin.umd.js"></script>
119
+ <script>
120
+ // ライブラリを使用
121
+ const tin = new tin.default({
122
+ wh: [500, 500]
123
+ });
124
+ </script>
125
+ ```
126
+
127
+ またはESモジュールとして使用する場合:
128
+
129
+ ```html
130
+ <!-- Maplat Tin (ESモジュール) -->
131
+ <script type="module">
132
+ import Tin from "https://unpkg.com/@maplat/tin/dist/index.js";
133
+ // ライブラリを使用
134
+ const tin = new Tin({
135
+ wh: [500, 500]
136
+ });
137
+ </script>
138
+ ```
139
+
140
+ ## 基本的な使用方法
141
+
142
+ ```javascript
143
+ // 基本設定でインスタンスを作成
144
+ const tin = new Tin({
145
+ wh: [500, 500], // ソース座標系の幅と高さ
146
+ yaxisMode: Tin.YAXIS_FOLLOW // Y軸の向きの設定
147
+ });
148
+
149
+ // 制御点の設定: [ソース座標, ターゲット座標] の配列
150
+ tin.setPoints([
151
+ [[100,100], [200, 200]], // 点1
152
+ [[200,200], [400, 400]], // 点2
153
+ [[150,150], [320, 350]], // 点3
154
+ [[200,100], [420, 220]] // 点4
155
+ ]);
156
+
157
+ // TINネットワークの初期化
158
+ tin.updateTin();
159
+
160
+ // トポロジーの状態確認
161
+ if (tin.strict_status === Tin.STATUS_STRICT) {
162
+ console.log('トポロジーOK: 往復変換が保証されます');
163
+ } else if (tin.strict_status === Tin.STATUS_LOOSE) {
164
+ console.log('トポロジー警告: 往復変換が保証されません');
165
+ }
166
+
167
+ // 順方向の変換(ソース → ターゲット)
168
+ const transformed = tin.transform([160, 160], false);
169
+
170
+ // 逆方向の変換(ターゲット → ソース)
171
+ const restored = tin.transform(transformed, true);
172
+ ```
173
+
174
+ ## 設定オプション
175
+
176
+ ### コンストラクタオプション
177
+ | **オプション** | **型** | **説明** | **デフォルト** |
178
+ | ------------- | --------------------------- | ------------------------- | ------------- |
179
+ | `bounds` | `Position[]` | **境界多角形の頂点** | `-` |
180
+ | `wh` | `number[]` | **幅と高さ [w, h]** | `-` |
181
+ | `vertexMode` | `"plain"|"birdeye"` | **頂点処理モード** | `"plain"` |
182
+ | `strictMode` | `"strict"|"auto"|"loose"` | **トポロジーチェックモード** | `"auto"` |
183
+ | `yaxisMode` | `"follow"|"invert"` | **Y軸の向き** | `"invert"` |
184
+ | `importance` | `number` | **地図の重要度** | `0` |
185
+ | `priority` | `number` | **地図の優先度** | `0` |
186
+
187
+ `bounds`または`wh`のいずれかを指定する必要があります。
188
+
189
+ ### メソッド
190
+
191
+ | **メソッド** | **説明** |
192
+ | ---------------------------- | --------------------------------- |
193
+ | `setPoints(points)` | **制御点の設定** |
194
+ | `setEdges(edges)` | **制約付きエッジの設定** |
195
+ | `updateTin()` | **TINネットワークの初期化/更新** |
196
+ | `transform(coords, inverse)` | **座標変換の実行** |
197
+ | `getCompiled()` | **シリアライズ可能な状態の取得** |
198
+ | `setCompiled(state)` | **シリアライズされた状態からの復元** |
199
+
200
+ ### エラーハンドリング
201
+
202
+ このライブラリは以下の場合にエラーをスローします:
203
+
204
+ - `"TOO LINEAR1"`,`"TOO LINEAR2"`: 制御点が直線状に並びすぎている
205
+ - `"SOME POINTS OUTSIDE"`: 点が境界外にある
206
+ - 逆変換が許可されていない状態での逆変換実行時
207
+
208
+ ## ライセンス
209
+
210
+ Maplat Limited License 1.1
211
+
212
+ Copyright (c) 2024 Code for History
213
+
214
+ ## 開発者
215
+
216
+ - Kohei Otsuka
217
+ - Code for History
218
+
176
219
  あなたの貢献をお待ちしています![イシューやプルリクエスト](https://github.com/code4history/MaplatTin/issues)は大歓迎です。