-
-
Notifications
You must be signed in to change notification settings - Fork 3
API Reference
Concepts and usage patterns for the Tin class exposed by MaplatTin. This
page focuses on release-independent explanatory material (ADR-0012). For
the complete and up-to-date API signature list, see
docs/api/ in the repository.
The Tin class is the main class of MaplatTin. Its lifecycle has three
phases:
-
Construction —
new Tin(options)creates an instance. Eitherboundsorwhmust be specified. -
Pre-computation —
setPoints(points)(and optionallysetEdges(edges)) feeds control data.updateTin()then computes the TIN. After this resolves,strict_statusindicates whether strict topology was achieved. -
Transform —
transform(xy, inverse)converts coordinates. The instance is reusable: callingsetPoints/setWh/setEdgesagain resets the TIN andupdateTin()must be called once more.
Why an explicit
updateTin()? Solving the triangulation is the expensive step. Separating configuration (setPoints) from computation (updateTin) lets callers batch edits and compute once.
Serialization shortcut:
setCompiled(data)skipsupdateTin()by loading a previously serialized TIN. See Tutorials § Saving and restoring.
The options object passed to the constructor has several categories:
| Category | Key properties | Purpose |
|---|---|---|
| Geometry |
bounds, wh
|
Boundary polygon OR width/height of source plane (one required) |
| Vertex handling | vertexMode |
"plain" (default) or "birdeye" (perspective correction) |
| Topology | strictMode |
"strict", "auto" (default), or "loose"
|
| Y-axis | yaxisMode |
"follow" or "invert" (default) |
| Metadata |
importance, priority
|
Map importance/priority hints (used by MaplatCore) |
The options control transform behavior. The control points and edges are added separately via
setPoints/setEdges(after construction), so the sameTininstance can be reused with different GCP sets.
<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>import Tin from '@maplat/tin';
const tin = new Tin({ wh: [500, 500] });
tin.setPoints([/* ... */]);
tin.updateTin();MaplatTin runs in pure Node.js (no OpenLayers needed), so it can be used in batch preprocessing pipelines (e.g. with MaplatTransform):
import Tin from '@maplat/tin';
import { readFileSync, writeFileSync } from 'node:fs';
const tin = new Tin({ wh: [2000, 1500] });
tin.setPoints(JSON.parse(readFileSync('gcps.json')));
tin.updateTin();
writeFileSync('compiled.json', JSON.stringify(tin.getCompiled()));The complete API signature list (constructor options, methods, constants,
utility functions, error cases) is maintained in
docs/api/ in the repository. This Wiki page
intentionally does not duplicate the signatures to avoid divergence from
the source of truth.
See:
-
docs/api/— authoritative API signatures - README §API reference — overview and links
- 🇬🇧 English (Home)
- 🇯🇵 日本語 (Home.ja)
English
日本語
- 📄 README / README.ja
- 📚 docs/api/ — API signatures
- 🗺️ Ecosystem Map(現在外部非公開)
- 🌐 Product site / 製品サイト
- 🏢 Nayuta, Inc. / コーポレートサイト