-
-
Notifications
You must be signed in to change notification settings - Fork 3
Tutorials.ja
Kohei Otsuka edited this page Jul 24, 2026
·
1 revision
Node.js およびブラウザから MaplatTin を利用するためのステップバイステップガイドです。
注: 最新のクイックスタート(インストールコマンド・CDN URL・バージョン番号)は README を参照してください。本ページはリリース非依存の チュートリアルを扱います。
import Tin from '@maplat/tin';
const tin = new Tin({
wh: [500, 500],
yaxisMode: Tin.YAXIS_FOLLOW,
});
tin.setPoints([
[[100, 100], [200, 200]],
[[200, 200], [400, 400]],
[[150, 150], [320, 350]],
[[200, 100], [420, 220]],
]);
tin.updateTin();
if (tin.strict_status === Tin.STATUS_STRICT) {
console.log('トポロジーOK: 往復変換が保証されます');
} else if (tin.strict_status === Tin.STATUS_LOOSE) {
console.log('トポロジー警告: 往復変換が保証されません');
}
// 順方向の変換
const ord = tin.transform([160, 160], false);
console.log(ord);
// 逆方向の変換
const rev = tin.transform(ord, true);
console.log(rev);メソッド名に関する注記: 旧 Wiki では
updateTinAsync()が Promise を 返すと記載されていました。現行 API はupdateTin()(内部計算完了後は同期)を 公開しています。正本のシグネチャはdocs/api/を 参照してください。
<script src="https://cdn.jsdelivr.net/npm/@maplat/tin@0.14.2/dist/maplat_tin.umd.js"></script>
<script>
const tin = new maplatTin.default({ wh: [500, 500] });
tin.setPoints([
[[100, 100], [200, 200]],
[[200, 200], [400, 400]],
[[150, 150], [320, 350]],
[[200, 100], [420, 220]],
]);
tin.updateTin();
console.log(tin.transform([160, 160], false));
</script><script type="module">
import Tin from 'https://cdn.jsdelivr.net/npm/@maplat/tin@0.14.2/dist/maplat_tin.js';
const tin = new Tin({ wh: [500, 500] });
// ...
</script>旧 Wiki が参照していたレガシースクリプト
maplat_tin.js(アンダースコア表記) は同じ UMD バンドルです。現在のパッケージ名は@maplat/tin(スコープ付き)で す。新規コードではスコープ付き名を使用してください。
多数の制御点から TIN ネットワークを解く処理は重いです。MaplatTin は オブジェクト直列化をサポートし、解決済み状態を再利用できます。
// updateTin() 後
const compiled = tin.getCompiled();
// 後で別プロセスで
const tin2 = new Tin();
tin2.setCompiled(compiled);
// updateTin() の呼出は不要 — 三角分割は既に読込済み。
console.log(tin2.transform([160, 160], false));try {
tin.updateTin();
} catch (e) {
if (e === 'TOO LINEAR1' || e === 'TOO LINEAR2') {
console.log('与えられた GCP 点が直線状に並びすぎており、TIN を構築できません。');
} else if (e === 'SOME POINTS OUTSIDE') {
console.log('一部の点が境界の外にあります。');
} else {
throw e;
}
}エラーケースの完全な一覧は
docs/api/ のエラーハンドリング節を参照してください。
英語版はこちら / Read this page in English
- Home
- Concepts.ja — TIN 理論と strict/loose モード
- API-Reference.ja — API の概念と利用パターン
- README — 最新のクイックスタート
-
docs/api/— API シグネチャ(正本)
- 🇬🇧 English (Home)
- 🇯🇵 日本語 (Home.ja)
English
日本語
- 📄 README / README.ja
- 📚 docs/api/ — API signatures
- 🗺️ Ecosystem Map(現在外部非公開)
- 🌐 Product site / 製品サイト
- 🏢 Nayuta, Inc. / コーポレートサイト