@maplat/tin

中文文档
1.1.1发布于 2026/11/02Apache-2.0TypeScriptES Module构建来源已验证

JavaScript library which performs homeomorphic conversion mutually between the coordinate systems of two planes based on the control points.

原始使用文档
文档目录14 节
  1. About MaplatTin
  2. Key Features
  3. Quick Start
  4. Install
  5. Minimal usage
  6. CDN (jsDelivr)
  7. API reference
  8. Development
  9. Prerequisites
  10. Ecosystem
  11. Sister repositories
  12. Links
  13. License
  14. Contributors

MaplatTin

CI License

About MaplatTin

MaplatTin is a JavaScript library that defines and executes homeomorphic conversion between two plane coordinate systems based on control points. It guarantees a nonlinear but topology-preserving (homeomorphic) bidirectional mapping, which is the core property that lets the Maplat viewer overlay historical maps on accurate modern maps without distorting the original images.

MaplatTin is open-source under the Apache License 2.0 (from version 0.14.2).

Read this document in Japanese / 日本語で読む

Key Features

  • Generate Transformation Definitions — create coordinate transformation definitions based on control points and edge constraints
  • Bidirectional Coordinate Transformation — convert coordinates between two planes in both directions
  • Topology Preservation — maintains homeomorphic properties during transformation
  • Flexible Configuration — vertex handling modes (normal / bird's-eye view), topology check modes (strict / auto / loose), Y-axis direction control
  • Edge Constraints — specify constrained edges for more accurate transform
  • State Management — save and restore transformation definitions
  • Open-source (Apache 2.0 from version 0.14.2) — part of the Maplat ecosystem

Quick Start

Current release: 1.1.1. This block is the only place in this repository that carries a release version (ADR-0012); everything outside it is written against the 1.0 release. npm: @maplat/tin npm

Install

# pnpm (recommended)
pnpm add @maplat/tin

# npm
npm install @maplat/tin

Minimal usage

import Tin from '@maplat/tin';

// Create a new instance with basic configuration
const tin = new Tin({
  wh: [500, 500], // Width and height of the source plane
  yaxisMode: Tin.YAXIS_FOLLOW,
});

// Set control points: Array of [source, target] coordinates
tin.setPoints([
  [[100, 100], [200, 200]],
  [[200, 200], [400, 400]],
  [[150, 150], [320, 350]],
  [[200, 100], [420, 220]],
]);

// Initialize the TIN network
tin.updateTin();

// Forward transform: source to target
const transformed = tin.transform([160, 160], false);

// Backward transform: target to source
const restored = tin.transform(transformed, true);

CDN (jsDelivr)

<!-- MaplatTin (UMD) -->
<script src="https://cdn.jsdelivr.net/npm/@maplat/[email protected]/dist/maplat_tin.umd.js"></script>
<script>
  const tin = new maplatTin.default({ wh: [500, 500] });
</script>

Or using ES modules:

<script type="module">
  import Tin from 'https://cdn.jsdelivr.net/npm/@maplat/[email protected]/dist/maplat_tin.js';
  const tin = new Tin({ wh: [500, 500] });
</script>

Note: Make sure to use the latest compatible versions.

API reference

Development

Setup

Clone the repository and install dependencies.

git clone https://github.com/code4history/MaplatTin.git
cd MaplatTin
pnpm install

Development Server

Start the development server with hot reload.

pnpm dev

Build

pnpm build         # Build library (dist/)
pnpm build:demo    # Build demo site (dist-demo/)

Test

pnpm test          # Run unit tests (Vitest)
pnpm typecheck     # Run type checks (TypeScript)
pnpm lint          # Run linter and formatter (ESLint/Prettier)

Test coverage:

  • tests/edgebound/ — internal EdgeBound constraint engine tests (455 tests)
  • tests/tin.test.ts — TIN transformation tests with real map data
  • tests/transform.test.ts — coordinate transformation tests

Prerequisites

Derived from the engines field in package.json (ADR-0012: release-dependent).

  • Node.js: >=20.0.0 (LTS tested via GitHub Actions)
  • pnpm: >=9.0.0 (required; package.json enforces pnpm)

Ecosystem

MaplatTin is part of the Maplat ecosystem by Code for History. See the full ecosystem map (8 repositories + product/corporate sites):

📖 Ecosystem Map — (the diagram is currently kept in a private planning repository; the Sister repositories table below is the public substitute)

Sister repositories

RepositoryLicensenpmRole
MaplatApache 2.0@maplat/uiMain viewer
MaplatCoreApache 2.0@maplat/coreCore library
MaplatTinApache 2.0@maplat/tinTIN conversion
MaplatTransformApache 2.0@maplat/transformCoordinate transform
MaplatEditorApache 2.0—Data authoring tool (desktop)
ChuciMIT@c4h/chuciMultimedia swiper & viewer Web Components
QuyuanMIT@c4h/quyuanGeoJSON template engine + multimedia viewer Web Components
WeiwudiMIT@c4h/weiwudiService Worker for tile cache

MaplatEditor is the data authoring tool used to create the maps and POIs that the viewers above render. The Maplat ecosystem is end-to-end: author with MaplatEditor, serve with any of the viewer libraries.

AudienceLinkPurpose
Project info / features / caseshttps://www.maplat.jp/en/Product site
Sponsor / business inquiryhttps://www.nayuta-inc.co.jp/en/Corporate site (Nayuta, Inc.)

ADR-0013: Apache-licensed repositories (this one) link to both sites. MIT-licensed sister repos (Weiwudi / Quyuan / Chuci) carry no Nayuta link.

License

Apache License 2.0 — see LICENSE.

Copyright 2019-2026 Kohei Otsuka, Code for History / Nayuta, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Patent notice: The Maplat coordinate-transform technology is patented in Japan (Patent No. 6684776).

Past versions: Versions before 0.14.2 were distributed under the Maplat Limited License 1.1. The license restoration to Apache 2.0 takes effect from version 1.0.0-rc1 onward. Earlier versions available on npmjs.com remain under their original limited-license terms.

Contributors

  • Kohei Otsuka
  • Code for History

We welcome your contributions! Feel free to submit issues and pull requests.

版本与发布记录

@maplat/tin 共发布 37 个版本,首次发布于 2019/09/15;过去 12 个月发布了 12 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.1.1latest2026/11/021 天前
1.1.1-rc.1next2026/10/268 天前
1.1.02026/10/0529 天前
1.1.0-rc.12026/09/281 个月前
1.0.02026/08/252 个月前
1.0.0-rc1rc2026/08/072 个月前

关于 @maplat/tin 的常见问题

@maplat/tin 是什么?

JavaScript库,基于控制点在两个平面的坐标系之间相互执行同胚转换。

如何安装 @maplat/tin?

在项目目录运行 npm install @maplat/tin,或使用 pnpm add / yarn add / bun add。

@maplat/tin 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@maplat/tin 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@maplat/tin 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@maplat/tin 可以商用吗?

@maplat/tin 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@maplat/tin 还在维护吗?

最新版本 1.1.1 发布于 2026/11/02(1 天前);至今共发布 37 个版本,其中过去 12 个月发布了 12 个;首次发布于 2019/09/15。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。