@maplat/tin 0.14.1 → 0.14.2

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 (4) hide show
  1. package/LICENSE +1 -23
  2. package/README.ja.md +164 -154
  3. package/README.md +162 -152
  4. package/package.json +2 -2
package/LICENSE CHANGED
@@ -1,26 +1,4 @@
1
- Maplat Limited License
2
- Ver. 1.1 Mar. 9 2021
3
1
 
4
- 残念ながら、悪質なフリーライダーの発生により、Maplat関連のライブラリはオープンソースであることを一時放棄し、制限ライセンスで公開せざるを得なくなりました。
5
- 本ライセンスのVer.1.1を公開した2021年3月9日以降、問題が解決し再びApache 2.0ライセンスに戻せるようになるまでの間、MaplatTin Version 0.8.0以降のバージョンを制限ライセンスで公開します。
6
- 制限期間のライセンス条項は以下の通りです。
7
-
8
- 1. 次項以降に記されない一般の利用者については、通常のApache 2.0に等しい条件での利用を認める。ただし、本ライセンスとApache 2.0ライセンスが矛盾する場合は、本ライセンスが優先される。
9
- 2. しかし、下記に記す特定のユーザについては、ライブラリの利用、コードの閲覧や再利用、また利用に伴う特許の知的財産利用権など、本ライブラリの利用に関する一切の権限を認めない。
10
- * 株式会社コギト 日本、京都市中京区錦小路通烏丸西入ル占出山町311 アニマート錦5F
11
- 3. 本ライセンスの記載内容について日本語表記と英語表記が矛盾する場合、日本語表記での内容が優先される。
12
-
13
- Unfortunately, due to the occurrence of malicious free riders, we have been forced to temporarily abandon the Maplat-related libraries as open source and release them under a restricted license.
14
- After March 9, 2021, when we released Version 1.1 of this license, we will release MaplatTin Version 0.8.0 and later versions under a restricted license until the problem is resolved and we can revert to the Apache 2.0 license again.
15
- The license terms for the restricted period are as follows:
16
-
17
- 1. For general users not listed in the next sections, the terms of the license are the same as for regular Apache 2.0 license. However, if there is any conflict between this License and the Apache 2.0 License, this License shall prevail.
18
- 2. However, the specific users listed below are not granted any rights related to the use of the library, including but not limited to the use of the library, viewing and reuse of the code, and the right to use any patents associated with the use of the library.
19
- * COGITO Inc., 5F Animato Nishiki, 311 Uradeyamacho, Nakagyo-ku, Kyoto, Japan
20
- 3. In the event of any discrepancy between the Japanese and English versions of this license, the Japanese version shall prevail.
21
-
22
- =====
23
- Reference:
24
2
  Apache License
25
3
  Version 2.0, January 2004
26
4
  http://www.apache.org/licenses/
@@ -209,7 +187,7 @@ Reference:
209
187
  same "printed page" as the copyright notice for easier
210
188
  identification within third-party archives.
211
189
 
212
- Copyright 2019 Kohei Otsuka, Code for History
190
+ Copyright 2019-2026 Kohei Otsuka, Code for History / Nayuta, Inc.
213
191
 
214
192
  Licensed under the Apache License, Version 2.0 (the "License");
215
193
  you may not use this file except in compliance with the License.
package/README.ja.md CHANGED
@@ -1,220 +1,230 @@
1
- # Maplat Tin
1
+ <!-- SECTION 1: Header (logo, badges, title) -->
2
+ <h1 align="center">MaplatTin</h1>
2
3
 
3
- [![CI](https://github.com/code4history/MaplatTin/actions/workflows/ci.yml/badge.svg)](https://github.com/code4history/MaplatTin/actions/workflows/ci.yml)
4
+ <p align="center">
5
+ <a href="https://github.com/code4history/MaplatTin/actions/workflows/ci.yml"><img src="https://github.com/code4history/MaplatTin/actions/workflows/ci.yml/badge.svg" alt="CI" /></a>
6
+ <a href="https://www.npmjs.com/package/@maplat/tin"><img src="https://img.shields.io/npm/v/@maplat/tin" alt="npm version" /></a>
7
+ <a href="LICENSE"><img src="https://img.shields.io/npm/l/@maplat/tin" alt="License" /></a>
8
+ </p>
4
9
 
5
- 2つの平面座標系間で制御点に基づく同相変換を定義・実行するJavaScriptライブラリです。
6
- [Maplat](https://github.com/code4history/Maplat/)プロジェクトの一部として開発されています。
10
+ <!-- SECTION 2: Elevator Pitch -->
11
+ ## MaplatTin について
7
12
 
8
- English README is [here](./README.md).
13
+ MaplatTin は制御点に基づいて2つの平面座標系間の同相変換を定義・実行する
14
+ JavaScript ライブラリです。非線形かつ位相を保存する(同相な)双方向写像を
15
+ 保証し、これが [Maplat](https://github.com/code4history/Maplat) ビューアが
16
+ 古地図を正確な現代地図へ**元の画像を歪めずに**重ね合わせるための中核特性
17
+ です。
9
18
 
10
- ## 主な機能
19
+ MaplatTin は Apache License 2.0(バージョン 0.14.2 以降)のオープンソース
20
+ プロジェクトです。
11
21
 
12
- - **座標変換定義の生成:** 制御点とエッジ制約に基づいて座標変換定義を生成
13
- - **双方向座標変換:** 2つの平面間で双方向の座標変換が可能
14
- - **位相保存:** 変換時の同相性(トポロジー)を維持
15
- - **柔軟な設定:**
16
- - 通常/鳥瞰図モードの頂点処理
17
- - 厳密/自動/緩和モードのトポロジーチェック
18
- - Y軸の向きの制御
19
- - **エッジ制約:** より正確な変換のための制約付きエッジの指定が可能
20
- - **状態管理:** 変換定義の保存と復元をサポート
22
+ <!-- SECTION 3: Language switch link -->
23
+ **[英語版はこちら / Read this document in English](README.md)**
21
24
 
22
- ## 動作要件
25
+ <!-- SECTION 4: Key Features -->
26
+ ## 主な特徴
23
27
 
24
- - **Node.js**: 20.0.0 以上
25
- - **パッケージマネージャー**: pnpm 9.0.0 以上(推奨)または npm
28
+ - **座標変換定義の生成** — 制御点とエッジ制約に基づいて座標変換定義を生成
29
+ - **双方向座標変換** — 2つの平面間で双方向の座標変換が可能
30
+ - **位相保存** — 変換時の同相性(トポロジー)を維持
31
+ - **柔軟な設定** — 通常/鳥瞰図モードの頂点処理・厳密/自動/緩和モードの
32
+ トポロジーチェック・Y 軸の向きの制御
33
+ - **エッジ制約** — より正確な変換のための制約付きエッジの指定が可能
34
+ - **状態管理** — 変換定義の保存と復元をサポート
35
+ - オープンソース(Apache 2.0・バージョン 0.14.2 以降)— Maplat エコシステムの一部
26
36
 
27
- ## インストール方法
37
+ <!-- SECTION 5: Quick Start -->
38
+ ## クイックスタート
28
39
 
29
- ### pnpm(推奨)
40
+ > リリース依存情報(ADR-0012)。下記バージョン `0.14.2` は現在の
41
+ > リリースです。リリースごとに更新してください。
30
42
 
31
- ```sh
32
- pnpm add @maplat/tin
33
- ```
43
+ ### インストール
34
44
 
35
- ### npm
45
+ ```bash
46
+ # pnpm(推奨)
47
+ pnpm add @maplat/tin
36
48
 
37
- ```sh
49
+ # npm
38
50
  npm install @maplat/tin
39
51
  ```
40
52
 
53
+ ### 最小利用例
41
54
 
42
- ## 開発環境のセットアップ
43
-
44
- ### テスト
45
-
46
- プロジェクトには、TIN変換ロジックと内部EdgeBound制約エンジンの両方に対する包括的なユニットテストが含まれています。
47
-
48
- **すべてのテストを実行:**
49
- ```sh
50
- pnpm test
51
- ```
55
+ ```typescript
56
+ import Tin from '@maplat/tin';
52
57
 
53
- **特定のテストスイートを実行:**
54
- ```sh
55
- # EdgeBound制約エンジンのテスト
56
- pnpm test tests/edgebound
57
-
58
- # TIN変換のテスト
59
- pnpm test tests/tin
60
- ```
58
+ // 基本設定でインスタンスを作成
59
+ const tin = new Tin({
60
+ wh: [500, 500], // ソース座標系の幅と高さ
61
+ yaxisMode: Tin.YAXIS_FOLLOW,
62
+ });
61
63
 
62
- **テストカバレッジ:**
63
- - `tests/edgebound/` - 内部EdgeBound制約エンジンのテスト(455テスト)
64
- - `constrain.test.ts` - 制約操作の統合テスト
65
- - `constrain.unit.test.ts` - 制約メソッドのユニットテスト
66
- - `intersect.test.ts` - 線分交差検出テスト
67
- - `validators.ts` - 三角形分割の整合性検証用テストユーティリティ
68
- - `tests/tin.test.ts` - 実際の地図データを使用したTIN変換テスト
69
- - `tests/transform.test.ts` - 座標変換テスト
64
+ // 制御点の設定: [ソース座標, ターゲット座標] の配列
65
+ tin.setPoints([
66
+ [[100, 100], [200, 200]],
67
+ [[200, 200], [400, 400]],
68
+ [[150, 150], [320, 350]],
69
+ [[200, 100], [420, 220]],
70
+ ]);
70
71
 
71
- ### ビルド
72
+ // TIN ネットワークの初期化
73
+ tin.updateTin();
72
74
 
73
- ライブラリのビルド:
74
- ```sh
75
- pnpm run build
76
- ```
75
+ // 順方向の変換(ソース → ターゲット)
76
+ const transformed = tin.transform([160, 160], false);
77
77
 
78
- デモサイトのビルド:
79
- ```sh
80
- pnpm run build:demo
78
+ // 逆方向の変換(ターゲット → ソース)
79
+ const restored = tin.transform(transformed, true);
81
80
  ```
82
81
 
83
- ### ブラウザ
84
-
85
- ブラウザで使用する場合:
82
+ ### CDN(jsDelivr)
86
83
 
87
84
  ```html
88
- <!-- Maplat Tin (UMD) -->
89
- <script src="https://unpkg.com/@maplat/tin/dist/tin.umd.js"></script>
85
+ <!-- MaplatTin (UMD) -->
86
+ <script src="https://cdn.jsdelivr.net/npm/@maplat/tin@0.14.2/dist/maplat_tin.umd.js"></script>
90
87
  <script>
91
- // ライブラリを使用
92
- const tin = new tin.default({
93
- wh: [500, 500]
94
- });
88
+ const tin = new maplatTin.default({ wh: [500, 500] });
95
89
  </script>
96
90
  ```
97
91
 
98
- またはESモジュールとして使用する場合:
92
+ または ES モジュールとして使用する場合:
99
93
 
100
94
  ```html
101
- <!-- Maplat Tin (ESモジュール) -->
102
95
  <script type="module">
103
- import Tin from "https://unpkg.com/@maplat/tin/dist/index.js";
104
- // ライブラリを使用
105
- const tin = new Tin({
106
- wh: [500, 500]
107
- });
96
+ import Tin from 'https://cdn.jsdelivr.net/npm/@maplat/tin@0.14.2/dist/maplat_tin.js';
97
+ const tin = new Tin({ wh: [500, 500] });
108
98
  </script>
109
99
  ```
110
100
 
111
- ## 基本的な使用方法
101
+ ※最新の互換バージョンを使用してください。
112
102
 
113
- ```javascript
114
- // 基本設定でインスタンスを作成
115
- const tin = new Tin({
116
- wh: [500, 500], // ソース座標系の幅と高さ
117
- yaxisMode: Tin.YAXIS_FOLLOW // Y軸の向きの設定
118
- });
103
+ ### API リファレンス
119
104
 
120
- // 制御点の設定: [ソース座標, ターゲット座標] の配列
121
- tin.setPoints([
122
- [[100,100], [200, 200]], // 点1
123
- [[200,200], [400, 400]], // 点2
124
- [[150,150], [320, 350]], // 点3
125
- [[200,100], [420, 220]] // 点4
126
- ]);
105
+ - **API シグネチャ**(リリース依存): [`docs/api/`](docs/api/) を参照
106
+ - **概念解説**(リリース非依存):
107
+ [Wiki API-Reference](https://github.com/code4history/MaplatTin/wiki/API-Reference)
108
+ を参照
127
109
 
128
- // TINネットワークの初期化
129
- tin.updateTin();
110
+ ### 開発
130
111
 
131
- // トポロジーの状態確認
132
- if (tin.strict_status === Tin.STATUS_STRICT) {
133
- console.log('トポロジーOK: 往復変換が保証されます');
134
- } else if (tin.strict_status === Tin.STATUS_LOOSE) {
135
- console.log('トポロジー警告: 往復変換が保証されません');
136
- }
112
+ #### セットアップ
113
+ リポジトリをクローンし依存関係をインストールします。
137
114
 
138
- // 順方向の変換(ソース → ターゲット)
139
- const transformed = tin.transform([160, 160], false);
115
+ ```bash
116
+ git clone https://github.com/code4history/MaplatTin.git
117
+ cd MaplatTin
118
+ pnpm install
119
+ ```
140
120
 
141
- // 逆方向の変換(ターゲット → ソース)
142
- const restored = tin.transform(transformed, true);
121
+ #### 開発サーバー
122
+ ホットリロード付きの開発サーバーを起動します。
123
+
124
+ ```bash
125
+ pnpm dev
143
126
  ```
144
127
 
145
- ## 設定オプション
128
+ #### ビルド
146
129
 
147
- ### コンストラクタオプション
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` |
130
+ ```bash
131
+ pnpm build # ライブラリをビルド (dist/)
132
+ pnpm build:demo # デモサイトをビルド (dist-demo/)
133
+ ```
134
+
135
+ #### テスト
136
+
137
+ ```bash
138
+ pnpm test # ユニットテスト (Vitest) を実行
139
+ pnpm typecheck # 型チェック (TypeScript) を実行
140
+ pnpm lint # リンター/フォーマッター (ESLint/Prettier) を実行
141
+ ```
142
+
143
+ テストカバレッジ:
144
+
145
+ - `tests/edgebound/` — 内部 EdgeBound 制約エンジンのテスト(455 テスト)
146
+ - `tests/tin.test.ts` — 実際の地図データを使用した TIN 変換テスト
147
+ - `tests/transform.test.ts` — 座標変換テスト
157
148
 
158
- `bounds`または`wh`のいずれかを指定する必要があります。
149
+ <!-- SECTION 6: Prerequisites -->
150
+ ## 動作環境
159
151
 
160
- ### メソッド
152
+ > `package.json` の `engines` フィールドから自動抽出(ADR-0012: リリース依存)。
161
153
 
162
- | **メソッド** | **説明** |
163
- | ---------------------------- | ------------------------------------ |
164
- | `setPoints(points)` | **制御点の設定** |
165
- | `setEdges(edges)` | **制約付きエッジの設定** |
166
- | `updateTin()` | **TINネットワークの初期化/更新** |
167
- | `transform(coords, inverse)` | **座標変換の実行** |
168
- | `getCompiled()` | **シリアライズ可能な状態の取得** |
169
- | `setCompiled(state)` | **シリアライズされた状態からの復元** |
170
- | `getFormatVersion()` | **フォーマットバージョン番号の取得** |
154
+ - Node.js: `>=20.0.0`(GitHub Actions で検証済みの LTS)
155
+ - pnpm: `>=9.0.0`(必須・`package.json` で pnpm を強制)
171
156
 
172
- ### 定数
157
+ <!-- SECTION 7 Peer Dependencies: 省略(OpenLayers 依存なし) -->
173
158
 
174
- **Y軸モード:**
175
- - `Tin.YAXIS_FOLLOW` - Y軸が座標系に従う
176
- - `Tin.YAXIS_INVERT` - Y軸が反転する
159
+ <!-- SECTION 8: Ecosystem / Related Repositories -->
160
+ ## エコシステム
177
161
 
178
- **ステータス値:**
179
- - `Tin.STATUS_STRICT` - 厳密なトポロジー(往復変換が保証される)
180
- - `Tin.STATUS_LOOSE` - 緩和されたトポロジー(往復変換が保証されない)
162
+ MaplatTin は [Code for History](https://github.com/code4history) が運営する
163
+ Maplat エコシステムの一部です。全容は下記エコシステム図を参照してください。
181
164
 
182
- **フォーマットバージョン:**
183
- - `format_version` - 現在のTINフォーマットバージョン
165
+ 📖 **エコシステム図** — *(図は現在外部非公開の計画リポジトリに保持して
166
+ います。下記の姉妹リポジトリ表が公開版の代替です)*
184
167
 
185
- ### ユーティリティ関数
168
+ ### 姉妹リポジトリ
186
169
 
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)` | **頂点座標の計算** |
170
+ | リポジトリ | ライセンス | npm | 役割 |
171
+ |---|---|---|---|
172
+ | [Maplat](https://github.com/code4history/Maplat) | Apache 2.0 | `@maplat/ui` | メインビューア |
173
+ | [MaplatCore](https://github.com/code4history/MaplatCore) | Apache 2.0 | `@maplat/core` | コアライブラリ |
174
+ | [MaplatTin](https://github.com/code4history/MaplatTin) | Apache 2.0 | `@maplat/tin` | TIN 変換 |
175
+ | [MaplatTransform](https://github.com/code4history/MaplatTransform) | Apache 2.0 | `@maplat/transform` | 座標変換 |
176
+ | [MaplatEditor](https://github.com/code4history/MaplatEditor) | Apache 2.0 | — | データ作成ツール(デスクトップ) |
195
177
 
196
- ## ドキュメント
178
+ > MaplatEditor は上記ビューアライブラリが描画する地図・POI を作成する
179
+ > データ作成ツールです。Maplat エコシステムはエンドツーエンド:
180
+ > MaplatEditor で作成し、いずれかのビューアライブラリで公開、という流れになります。
197
181
 
198
- TIN内部構造の詳細情報:
199
- - [TIN 内部構造](docs/tin-internals.ja.md)
182
+ <!-- SECTION 9: Nayuta links -->
183
+ ## リンク
200
184
 
201
- ### エラーハンドリング
185
+ | 対象 | リンク | 用途 |
186
+ |---|---|---|
187
+ | プロジェクト情報・機能紹介・事例 | <https://www.maplat.jp/> | 製品サイト |
188
+ | 支援企業・案件問い合わせ | <https://www.nayuta-inc.co.jp/> | コーポレートサイト(那由多社) |
202
189
 
203
- このライブラリは以下の場合にエラーをスローします:
190
+ > ADR-0013: Apache ライセンスのリポジトリ(本リポジトリ)は両サイトへリンクします。
191
+ > MIT ライセンスの姉妹リポジトリ(Weiwudi / Quyuan / Chuci)へは那由多社リンクを置きません。
192
+ > 英語ページへ遷移する場合は `/en/` を付与してください(例: `https://www.maplat.jp/en/`)。
204
193
 
205
- - `"TOO LINEAR1"`,`"TOO LINEAR2"`: 制御点が直線状に並びすぎている
206
- - `"SOME POINTS OUTSIDE"`: 点が境界外にある
207
- - 逆変換が許可されていない状態での逆変換実行時
194
+ <!-- SECTION 10: License -->
195
+ ## License
208
196
 
209
- ## ライセンス
197
+ Apache License 2.0 — 詳細は [LICENSE](LICENSE) を参照。
198
+
199
+ ```
200
+ Copyright 2019-2026 Kohei Otsuka, Code for History / Nayuta, Inc.
201
+
202
+ Licensed under the Apache License, Version 2.0 (the "License");
203
+ you may not use this file except in compliance with the License.
204
+ You may obtain a copy of the License at
205
+
206
+ http://www.apache.org/licenses/LICENSE-2.0
207
+
208
+ Unless required by applicable law or agreed to in writing, software
209
+ distributed under the License is distributed on an "AS IS" BASIS,
210
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
211
+ See the License for the specific language governing permissions and
212
+ limitations under the License.
213
+ ```
210
214
 
211
- Maplat Limited License 1.1
215
+ > **特許注記**: Maplat の座標変換技術は日本国内で特許登録されています
216
+ > (Patent No. 6684776)。
212
217
 
213
- Copyright (c) 2024-2026 Code for History
218
+ > **過去のバージョン**: 0.14.2 より前のバージョンは Maplat Limited License
219
+ > 1.1 の下で配布されていました。Apache 2.0 へのライセンス復帰は 0.14.2
220
+ > 以降に適用されます。npmjs.com 上の過去版は元の制限付きライセンス条項の
221
+ > まま残ります。
214
222
 
215
- ## 開発者
223
+ <!-- SECTION 11: Contributors / Sponsors -->
224
+ ## Contributors
216
225
 
217
226
  - Kohei Otsuka
218
227
  - Code for History
219
228
 
220
- あなたの貢献をお待ちしています![イシューやプルリクエスト](https://github.com/code4history/MaplatTin/issues)は大歓迎です。
229
+ あなたの貢献をお待ちしています!
230
+ [イシューやプルリクエスト](https://github.com/code4history/MaplatTin/issues)は大歓迎です。
package/README.md CHANGED
@@ -1,221 +1,231 @@
1
- # Maplat Tin
1
+ <!-- SECTION 1: Header (logo, badges, title) -->
2
+ <h1 align="center">MaplatTin</h1>
2
3
 
3
- [![CI](https://github.com/code4history/MaplatTin/actions/workflows/ci.yml/badge.svg)](https://github.com/code4history/MaplatTin/actions/workflows/ci.yml)
4
+ <p align="center">
5
+ <a href="https://github.com/code4history/MaplatTin/actions/workflows/ci.yml"><img src="https://github.com/code4history/MaplatTin/actions/workflows/ci.yml/badge.svg" alt="CI" /></a>
6
+ <a href="https://www.npmjs.com/package/@maplat/tin"><img src="https://img.shields.io/npm/v/@maplat/tin" alt="npm version" /></a>
7
+ <a href="LICENSE"><img src="https://img.shields.io/npm/l/@maplat/tin" alt="License" /></a>
8
+ </p>
4
9
 
5
- A JavaScript library that defines and executes homeomorphic conversion between two plane coordinate systems based on control points.
6
- This is part of the [Maplat](https://github.com/code4history/Maplat/) project.
10
+ <!-- SECTION 2: Elevator Pitch -->
11
+ ## About MaplatTin
7
12
 
8
- 日本語のREADMEは[こちら](./README.ja.md)
13
+ MaplatTin is a JavaScript library that defines and executes homeomorphic
14
+ conversion between two plane coordinate systems based on control points. It
15
+ guarantees a nonlinear but topology-preserving (homeomorphic) bidirectional
16
+ mapping, which is the core property that lets the
17
+ [Maplat](https://github.com/code4history/Maplat) viewer overlay historical
18
+ maps on accurate modern maps **without distorting the original images**.
9
19
 
10
- ## Key Features
20
+ MaplatTin is open-source under the Apache License 2.0 (from version 0.14.2).
11
21
 
12
- - **Generate Transformation Definitions:** Create coordinate transformation definitions based on control points and edge constraints
13
- - **Bidirectional Coordinate Transformation:** Convert coordinates between two planes in both directions
14
- - **Topology Preservation:** Maintains homeomorphic properties during transformation
15
- - **Flexible Configuration:**
16
- - Vertex handling modes (normal/bird's-eye view)
17
- - Topology check modes (strict/auto/loose)
18
- - Y-axis direction control
19
- - **Edge Constraints:** Ability to specify constrained edges for more accurate transformation
20
- - **State Management:** Save and restore transformation definitions
22
+ <!-- SECTION 3: Language switch link -->
23
+ **[Read this document in Japanese / 日本語で読む](README.ja.md)**
21
24
 
22
- ## Requirements
25
+ <!-- SECTION 4: Key Features -->
26
+ ## Key Features
23
27
 
24
- - **Node.js**: 20.0.0 or higher
25
- - **Package Manager**: pnpm 9.0.0 or higher (recommended) or npm
28
+ - **Generate Transformation Definitions** — create coordinate transformation
29
+ definitions based on control points and edge constraints
30
+ - **Bidirectional Coordinate Transformation** — convert coordinates between
31
+ two planes in both directions
32
+ - **Topology Preservation** — maintains homeomorphic properties during
33
+ transformation
34
+ - **Flexible Configuration** — vertex handling modes (normal / bird's-eye
35
+ view), topology check modes (strict / auto / loose), Y-axis direction control
36
+ - **Edge Constraints** — specify constrained edges for more accurate transform
37
+ - **State Management** — save and restore transformation definitions
38
+ - Open-source (Apache 2.0 from version 0.14.2) — part of the Maplat ecosystem
26
39
 
27
- ## Installation
40
+ <!-- SECTION 5: Quick Start -->
41
+ ## Quick Start
28
42
 
29
- ### pnpm (Recommended)
43
+ > Release-dependent information (ADR-0012). The version `0.14.2` below is the
44
+ > current release; update it on each new release.
30
45
 
31
- ```sh
32
- pnpm add @maplat/tin
33
- ```
46
+ ### Install
34
47
 
35
- ### npm
48
+ ```bash
49
+ # pnpm (recommended)
50
+ pnpm add @maplat/tin
36
51
 
37
- ```sh
52
+ # npm
38
53
  npm install @maplat/tin
39
54
  ```
40
55
 
56
+ ### Minimal usage
41
57
 
42
- ## Development Setup
43
-
44
- ### Testing
45
-
46
- The project includes comprehensive unit tests for both the TIN transformation logic and the internal EdgeBound constraint engine.
58
+ ```typescript
59
+ import Tin from '@maplat/tin';
47
60
 
48
- **Run all tests:**
49
- ```sh
50
- pnpm test
51
- ```
52
-
53
- **Run specific test suite:**
54
- ```sh
55
- # EdgeBound constraint engine tests
56
- pnpm test tests/edgebound
57
-
58
- # TIN transformation tests
59
- pnpm test tests/tin
60
- ```
61
+ // Create a new instance with basic configuration
62
+ const tin = new Tin({
63
+ wh: [500, 500], // Width and height of the source plane
64
+ yaxisMode: Tin.YAXIS_FOLLOW,
65
+ });
61
66
 
62
- **Test coverage:**
63
- - `tests/edgebound/` - Internal EdgeBound constraint engine tests (455 tests)
64
- - `constrain.test.ts` - Integration tests for constraint operations
65
- - `constrain.unit.test.ts` - Unit tests for constraint methods
66
- - `intersect.test.ts` - Segment intersection detection tests
67
- - `validators.ts` - Test utilities for validating triangulation integrity
68
- - `tests/tin.test.ts` - TIN transformation tests with real map data
69
- - `tests/transform.test.ts` - Coordinate transformation tests
67
+ // Set control points: Array of [source, target] coordinates
68
+ tin.setPoints([
69
+ [[100, 100], [200, 200]],
70
+ [[200, 200], [400, 400]],
71
+ [[150, 150], [320, 350]],
72
+ [[200, 100], [420, 220]],
73
+ ]);
70
74
 
71
- ### Building
75
+ // Initialize the TIN network
76
+ tin.updateTin();
72
77
 
73
- Build the library:
74
- ```sh
75
- pnpm run build
76
- ```
78
+ // Forward transform: source to target
79
+ const transformed = tin.transform([160, 160], false);
77
80
 
78
- Build the demo site:
79
- ```sh
80
- pnpm run build:demo
81
+ // Backward transform: target to source
82
+ const restored = tin.transform(transformed, true);
81
83
  ```
82
84
 
83
- ### Browser
84
-
85
- When using in the browser:
85
+ ### CDN (jsDelivr)
86
86
 
87
87
  ```html
88
- <!-- Maplat Tin (UMD) -->
89
- <script src="https://unpkg.com/@maplat/tin/dist/tin.umd.js"></script>
88
+ <!-- MaplatTin (UMD) -->
89
+ <script src="https://cdn.jsdelivr.net/npm/@maplat/tin@0.14.2/dist/maplat_tin.umd.js"></script>
90
90
  <script>
91
- // Use the library
92
- const tin = new tin.default({
93
- wh: [500, 500]
94
- });
91
+ const tin = new maplatTin.default({ wh: [500, 500] });
95
92
  </script>
96
93
  ```
97
94
 
98
95
  Or using ES modules:
99
96
 
100
97
  ```html
101
- <!-- Maplat Tin (ESM) -->
102
98
  <script type="module">
103
- import Tin from "https://unpkg.com/@maplat/tin/dist/index.js";
104
- // Use the library
105
- const tin = new Tin({
106
- wh: [500, 500]
107
- });
99
+ import Tin from 'https://cdn.jsdelivr.net/npm/@maplat/tin@0.14.2/dist/maplat_tin.js';
100
+ const tin = new Tin({ wh: [500, 500] });
108
101
  </script>
109
102
  ```
110
103
 
111
- ## Basic Usage
104
+ *Note: Make sure to use the latest compatible versions.*
112
105
 
113
- ```javascript
114
- // Create a new instance with basic configuration
115
- const tin = new Tin({
116
- wh: [500, 500], // Width and height of the source plane
117
- yaxisMode: Tin.YAXIS_FOLLOW // Y-axis direction handling
118
- });
106
+ ### API reference
119
107
 
120
- // Set control points: Array of [source, target] coordinates
121
- tin.setPoints([
122
- [[100,100], [200, 200]], // Point 1
123
- [[200,200], [400, 400]], // Point 2
124
- [[150,150], [320, 350]], // Point 3
125
- [[200,100], [420, 220]] // Point 4
126
- ]);
108
+ - **API signatures** (release-dependent): see [`docs/api/`](docs/api/)
109
+ - **Conceptual guide** (release-independent): see the
110
+ [Wiki API-Reference](https://github.com/code4history/MaplatTin/wiki/API-Reference)
127
111
 
128
- // Initialize the TIN network
129
- tin.updateTin();
112
+ ### Development
130
113
 
131
- // Check topology status
132
- if (tin.strict_status === Tin.STATUS_STRICT) {
133
- console.log('Topology OK: Roundtrip transform is guaranteed');
134
- } else if (tin.strict_status === Tin.STATUS_LOOSE) {
135
- console.log('Topology warning: Roundtrip transform is not guaranteed');
136
- }
114
+ #### Setup
115
+ Clone the repository and install dependencies.
137
116
 
138
- // Forward transform: source to target
139
- const transformed = tin.transform([160, 160], false);
117
+ ```bash
118
+ git clone https://github.com/code4history/MaplatTin.git
119
+ cd MaplatTin
120
+ pnpm install
121
+ ```
140
122
 
141
- // Backward transform: target to source
142
- const restored = tin.transform(transformed, true);
123
+ #### Development Server
124
+ Start the development server with hot reload.
125
+
126
+ ```bash
127
+ pnpm dev
143
128
  ```
144
129
 
145
- ## Configuration
130
+ #### Build
146
131
 
147
- ### Constructor Options
132
+ ```bash
133
+ pnpm build # Build library (dist/)
134
+ pnpm build:demo # Build demo site (dist-demo/)
135
+ ```
148
136
 
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` |
137
+ #### Test
158
138
 
159
- Either `bounds` or `wh` must be specified.
139
+ ```bash
140
+ pnpm test # Run unit tests (Vitest)
141
+ pnpm typecheck # Run type checks (TypeScript)
142
+ pnpm lint # Run linter and formatter (ESLint/Prettier)
143
+ ```
160
144
 
161
- ### Methods
145
+ Test coverage:
162
146
 
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** |
147
+ - `tests/edgebound/` — internal EdgeBound constraint engine tests (455 tests)
148
+ - `tests/tin.test.ts` — TIN transformation tests with real map data
149
+ - `tests/transform.test.ts` — coordinate transformation tests
172
150
 
173
- ### Constants
151
+ <!-- SECTION 6: Prerequisites -->
152
+ ## Prerequisites
174
153
 
175
- **Y-axis Mode:**
176
- - `Tin.YAXIS_FOLLOW` - Y-axis follows the coordinate system
177
- - `Tin.YAXIS_INVERT` - Y-axis is inverted
154
+ > Derived from the `engines` field in `package.json` (ADR-0012: release-dependent).
178
155
 
179
- **Status Values:**
180
- - `Tin.STATUS_STRICT` - Strict topology (roundtrip transform guaranteed)
181
- - `Tin.STATUS_LOOSE` - Loose topology (roundtrip transform not guaranteed)
156
+ - Node.js: `>=20.0.0` (LTS tested via GitHub Actions)
157
+ - pnpm: `>=9.0.0` (required; `package.json` enforces pnpm)
182
158
 
183
- **Format Version:**
184
- - `format_version` - Current TIN format version
159
+ <!-- SECTION 7 Peer Dependencies: omitted (no OpenLayers dependency) -->
185
160
 
186
- ### Utility Functions
161
+ <!-- SECTION 8: Ecosystem / Related Repositories -->
162
+ ## Ecosystem
187
163
 
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** |
164
+ MaplatTin is part of the Maplat ecosystem by [Code for History](https://github.com/code4history).
165
+ See the full ecosystem map (8 repositories + product/corporate sites):
196
166
 
197
- ## Documentation
167
+ 📖 **Ecosystem Map** — *(the diagram is currently kept in a private planning
168
+ repository; the Sister repositories table below is the public substitute)*
198
169
 
199
- For detailed information about TIN internals:
200
- - [TIN Internals](docs/tin-internals.md)
170
+ ### Sister repositories
201
171
 
202
- ### Error Handling
172
+ | Repository | License | npm | Role |
173
+ |---|---|---|---|
174
+ | [Maplat](https://github.com/code4history/Maplat) | Apache 2.0 | `@maplat/ui` | Main viewer |
175
+ | [MaplatCore](https://github.com/code4history/MaplatCore) | Apache 2.0 | `@maplat/core` | Core library |
176
+ | [MaplatTin](https://github.com/code4history/MaplatTin) | Apache 2.0 | `@maplat/tin` | TIN conversion |
177
+ | [MaplatTransform](https://github.com/code4history/MaplatTransform) | Apache 2.0 | `@maplat/transform` | Coordinate transform |
178
+ | [MaplatEditor](https://github.com/code4history/MaplatEditor) | Apache 2.0 | — | Data authoring tool (desktop) |
203
179
 
204
- The library may throw errors in the following cases:
180
+ > MaplatEditor is the data authoring tool used to create the maps and POIs
181
+ > that the viewers above render. The Maplat ecosystem is end-to-end:
182
+ > author with MaplatEditor, serve with any of the viewer libraries.
205
183
 
206
- - `"TOO LINEAR1"`,`"TOO LINEAR2"`: Control points are too linear
207
- - `"SOME POINTS OUTSIDE"`: Points outside boundary
208
- - Custom error when attempting backward transformation in a disallowed state
184
+ <!-- SECTION 9: Nayuta links -->
185
+ ## Links
209
186
 
187
+ | Audience | Link | Purpose |
188
+ |---|---|---|
189
+ | Project info / features / cases | <https://www.maplat.jp/en/> | Product site |
190
+ | Sponsor / business inquiry | <https://www.nayuta-inc.co.jp/en/> | Corporate site (Nayuta, Inc.) |
191
+
192
+ > ADR-0013: Apache-licensed repositories (this one) link to both sites.
193
+ > MIT-licensed sister repos (Weiwudi / Quyuan / Chuci) carry no Nayuta link.
194
+
195
+ <!-- SECTION 10: License -->
210
196
  ## License
211
197
 
212
- Maplat Limited License 1.1
198
+ Apache License 2.0 — see [LICENSE](LICENSE).
199
+
200
+ ```
201
+ Copyright 2019-2026 Kohei Otsuka, Code for History / Nayuta, Inc.
202
+
203
+ Licensed under the Apache License, Version 2.0 (the "License");
204
+ you may not use this file except in compliance with the License.
205
+ You may obtain a copy of the License at
206
+
207
+ http://www.apache.org/licenses/LICENSE-2.0
208
+
209
+ Unless required by applicable law or agreed to in writing, software
210
+ distributed under the License is distributed on an "AS IS" BASIS,
211
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
212
+ See the License for the specific language governing permissions and
213
+ limitations under the License.
214
+ ```
215
+
216
+ > **Patent notice**: The Maplat coordinate-transform technology is patented
217
+ > in Japan (Patent No. 6684776).
213
218
 
214
- Copyright (c) 2024-2026 Code for History
219
+ > **Past versions**: Versions before 0.14.2 were distributed under the
220
+ > Maplat Limited License 1.1. The license restoration to Apache 2.0 takes
221
+ > effect from version 0.14.2 onward. Earlier versions available on npmjs.com
222
+ > remain under their original limited-license terms.
215
223
 
216
- ## Developers
224
+ <!-- SECTION 11: Contributors / Sponsors -->
225
+ ## Contributors
217
226
 
218
227
  - Kohei Otsuka
219
228
  - Code for History
220
229
 
221
- We welcome your contributions! Feel free to submit [issues and pull requests](https://github.com/code4history/MaplatTin/issues).
230
+ We welcome your contributions! Feel free to submit
231
+ [issues and pull requests](https://github.com/code4history/MaplatTin/issues).
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.14.1",
7
+ "version": "0.14.2",
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",
@@ -35,7 +35,7 @@
35
35
  "url": "git+https://github.com/code4history/MaplatTin.git"
36
36
  },
37
37
  "author": "Code for History",
38
- "license": "Maplat Limited License 1.1",
38
+ "license": "Apache-2.0",
39
39
  "bugs": {
40
40
  "url": "https://github.com/code4history/MaplatTin/issues"
41
41
  },