@maplat/transform 0.5.0 → 0.5.1

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
@@ -15,6 +15,9 @@ English README is [here](./README.md).
15
15
  - **位相保存:** 変換時の同相性(トポロジー)を維持
16
16
  - **複数の座標系サポート:** 通常の直交座標系、Y軸反転座標系、鳥瞰図のような歪んだ座標系など、様々な座標系間の変換に対応
17
17
  - **状態管理:** 変換状態の保存と復元をサポート
18
+ - **サブマップ選択(処理2):** 同一画像上に複数のTIN領域(`sub_maps`)が存在する地図で、領域判定・優先度・重要度に基づいて適用するTINを自動選択し座標変換する
19
+ - **ビューポート変換(処理3):** ピクセル座標系上の表示ビューポート(中心位置・ズームレベル・回転角)を地図座標系(EPSG:3857)上のビューポートに相互変換する
20
+ - **地図間ビューポート同期(処理4):** ある絵地図の表示ビューポートを、共通の地図座標系(EPSG:3857)を中継して別の絵地図の表示ビューポートに直接変換する
18
21
 
19
22
  ## 動作要件
20
23
 
@@ -67,6 +70,90 @@ const restored = transform.transform(transformed, true);
67
70
 
68
71
  エラーが発生した場合は、変換定義データの修正が必要です。変換定義の修正は[@maplat/tin](https://github.com/code4history/MaplatTin/)を使用したエディタツールで行ってください。
69
72
 
73
+ ## MapTransform の使用方法
74
+
75
+ ### 処理2 — サブマップ選択つき座標変換
76
+
77
+ 1枚の地図画像上に複数のTIN定義(`sub_maps`)が重なって存在する場合、`MapTransform` を使うと適切なTINを自動選択して座標変換できます。
78
+
79
+ ```javascript
80
+ import { MapTransform } from '@maplat/transform';
81
+
82
+ const mt = new MapTransform();
83
+ mt.setMapData({
84
+ compiled: mainCompiledData, // メインTINのコンパイル済みデータ
85
+ sub_maps: [
86
+ { compiled: sub0Data, priority: 1, importance: 1 },
87
+ { compiled: sub1Data, priority: 2, importance: 2 },
88
+ ],
89
+ });
90
+
91
+ // 順方向: ピクセルXY → EPSG:3857([レイヤーインデックス, Merc座標] または false を返す)
92
+ const result = mt.xy2MercWithLayer([320, 240]);
93
+ if (result) {
94
+ const [layerIndex, merc] = result;
95
+ console.log('レイヤー:', layerIndex, 'Merc座標:', merc);
96
+ }
97
+
98
+ // 逆方向: EPSG:3857 → ピクセルXY(重要度順に最大2レイヤー返す)
99
+ const results = mt.merc2XyWithLayer([15000000, 4000000]);
100
+ results.forEach((r, i) => {
101
+ if (r) console.log(`結果${i}: レイヤー${r[0]}, XY座標`, r[1]);
102
+ });
103
+ ```
104
+
105
+ ### 処理3 — ビューポート変換
106
+
107
+ ピクセル地図の表示ビューポート(中心位置・ズームレベル・回転角)を、EPSG:3857空間上の5点(中心+東西南北)として相互変換します。
108
+
109
+ ```javascript
110
+ import { MapTransform } from '@maplat/transform';
111
+
112
+ const mt = new MapTransform();
113
+ mt.setMapData({ compiled: compiledData });
114
+
115
+ const canvasSize = [800, 600]; // キャンバスサイズ [幅, 高さ]
116
+
117
+ // ピクセルビューポート → EPSG:3857 5点
118
+ const viewpoint = {
119
+ center: [15000000, 4000000], // ピクセル空間の中心に対応するEPSG:3857相当座標
120
+ zoom: 14,
121
+ rotation: 0,
122
+ };
123
+ const mercs = mt.viewpoint2Mercs(viewpoint, canvasSize);
124
+ // mercs: [[中心], [北], [東], [南], [西]] (EPSG:3857)
125
+
126
+ // EPSG:3857 5点 → ピクセルビューポート
127
+ const vp = mt.mercs2Viewpoint(mercs, canvasSize);
128
+ console.log(vp.center, vp.zoom, vp.rotation);
129
+ ```
130
+
131
+ ### 処理4 — 地図間ビューポート同期
132
+
133
+ ある絵地図の表示ビューポートをEPSG:3857空間を中継して別の絵地図のビューポートへ直接変換します。
134
+
135
+ ```javascript
136
+ import { MapTransform } from '@maplat/transform';
137
+
138
+ const mtA = new MapTransform();
139
+ mtA.setMapData({ compiled: compiledDataA });
140
+
141
+ const mtB = new MapTransform();
142
+ mtB.setMapData({ compiled: compiledDataB });
143
+
144
+ const canvasSize = [800, 600];
145
+
146
+ // 地図Aのビューポート(ピクセル空間A)
147
+ const vpA = { center: [15000000, 4000000], zoom: 14, rotation: 0 };
148
+
149
+ // ピクセル空間A → EPSG:3857 5点(処理3の順変換)
150
+ const mercs = mtA.viewpoint2Mercs(vpA, canvasSize);
151
+
152
+ // EPSG:3857 5点 → 地図Bのビューポート(処理3の逆変換)
153
+ const vpB = mtB.mercs2Viewpoint(mercs, canvasSize);
154
+ console.log('地図Bのビューポート:', vpB);
155
+ ```
156
+
70
157
  ## API リファレンス
71
158
 
72
159
  ### Transform クラス
@@ -119,6 +206,78 @@ Maplatで生成されたコンパイル済み変換定義をインポートし
119
206
  - `Transform.YAXIS_FOLLOW`: Y軸方向に従う
120
207
  - `Transform.YAXIS_INVERT`: Y軸方向を反転
121
208
 
209
+ ### MapTransform クラス
210
+
211
+ サブマップ選択、ビューポート変換、地図間ビューポート同期(処理2〜4)を担うクラスです。
212
+
213
+ #### コンストラクタ
214
+
215
+ ```javascript
216
+ const mt = new MapTransform();
217
+ ```
218
+
219
+ #### メソッド
220
+
221
+ ##### `setMapData(mapData: MapData): void`
222
+
223
+ メインTINとオプションのサブマップTINをロードします。
224
+
225
+ - **パラメータ:**
226
+ - `mapData`: `{ compiled, maxZoom?, sub_maps? }` — メインのコンパイル済みTINデータ、オプションの明示的なmaxZoom、オプションのサブマップ定義配列
227
+
228
+ ##### `xy2Merc(xy: number[]): number[] | false`
229
+
230
+ メインTINを使ってピクセル座標をEPSG:3857に変換します。
231
+
232
+ - **パラメータ:** `xy` — ピクセル座標 `[x, y]`
233
+ - **戻り値:** EPSG:3857座標、または範囲外の場合は `false`
234
+
235
+ ##### `merc2Xy(merc: number[]): number[] | false`
236
+
237
+ メインTINを使ってEPSG:3857座標をピクセル座標に逆変換します。
238
+
239
+ - **パラメータ:** `merc` — EPSG:3857座標 `[x, y]`
240
+ - **戻り値:** ピクセル座標、または範囲外の場合は `false`
241
+
242
+ ##### `xy2MercWithLayer(xy: number[]): [number, number[]] | false`
243
+
244
+ 優先度と領域に基づいてサブマップから適切なTINを自動選択し、ピクセル座標をEPSG:3857に変換します(処理2)。
245
+
246
+ - **パラメータ:** `xy` — ピクセル座標 `[x, y]`
247
+ - **戻り値:** `[レイヤーインデックス, Merc座標]`、または範囲外の場合は `false`
248
+
249
+ ##### `merc2XyWithLayer(merc: number[]): ([number, number[]] | undefined)[]`
250
+
251
+ 該当する全TINレイヤーでEPSG:3857座標をピクセル座標に逆変換し、重要度順に最大2件を返します(処理2)。
252
+ > 3件以上返したい場合は、実装内の `.slice(0, 2)` / `.filter(i < 2)` の上限値を変更してください。
253
+
254
+ - **パラメータ:** `merc` — EPSG:3857座標 `[x, y]`
255
+ - **戻り値:** 最大2要素の配列。各要素は `[レイヤーインデックス, XY座標]` または `undefined`
256
+
257
+ ##### `viewpoint2Mercs(viewpoint: Viewpoint, size: [number, number]): number[][]`
258
+
259
+ ピクセル空間のビューポートをEPSG:3857の5点に変換します(処理3)。
260
+
261
+ - **パラメータ:**
262
+ - `viewpoint`: `{ center, zoom, rotation }` — ピクセル空間のビューポート(centerは `xy2SysCoord` 変換後のEPSG:3857相当値)
263
+ - `size`: キャンバスサイズ `[幅, 高さ]`
264
+ - **戻り値:** EPSG:3857の5点配列 `[中心, 北, 東, 南, 西]`
265
+ - **例外:** 中心点がTIN範囲外の場合にエラー
266
+
267
+ ##### `mercs2Viewpoint(mercs: number[][], size: [number, number]): Viewpoint`
268
+
269
+ EPSG:3857の5点からピクセル空間のビューポートに逆変換します(処理3の逆変換)。
270
+
271
+ - **パラメータ:**
272
+ - `mercs`: EPSG:3857の5点配列(`viewpoint2Mercs` の戻り値と同形式)
273
+ - `size`: キャンバスサイズ `[幅, 高さ]`
274
+ - **戻り値:** ピクセル空間の `Viewpoint` — `{ center, zoom, rotation }`
275
+ - **例外:** 中心点が逆変換できない場合にエラー
276
+
277
+ #### アクセサ
278
+
279
+ - `maxxy: number` — `2^maxZoom × 256`。ピクセル座標とEPSG:3857座標の変換スケール係数
280
+
122
281
  ### エクスポートされる型
123
282
 
124
283
  - `PointSet`, `BiDirectionKey`, `WeightBufferBD`, `VertexMode`, `StrictMode`, `StrictStatus`, `YaxisMode`
@@ -126,6 +285,9 @@ Maplatで生成されたコンパイル済み変換定義をインポートし
126
285
  - `Compiled`, `CompiledLegacy`
127
286
  - `Tins`, `Tri`, `PropertyTriKey`
128
287
  - `Edge`, `EdgeSet`, `EdgeSetLegacy`
288
+ - `Viewpoint` — `{ center: number[], zoom: number, rotation: number }`
289
+ - `MapData` — `{ compiled: Compiled, maxZoom?: number, sub_maps?: SubMapData[] }`
290
+ - `SubMapData` — `{ compiled: Compiled, priority: number, importance: number, bounds?: number[][] }`
129
291
 
130
292
  ### エクスポートされるユーティリティ関数
131
293
 
package/README.md CHANGED
@@ -15,6 +15,9 @@ This is part of the [Maplat](https://github.com/code4history/Maplat/) project.
15
15
  - **Topology Preservation:** Maintains homeomorphic properties during transformation
16
16
  - **Multiple Coordinate System Support:** Handles transformations between various coordinate systems including standard orthogonal coordinates, Y-axis inverted coordinates, and distorted coordinates like bird's-eye views
17
17
  - **State Management:** Save and restore transformation states
18
+ - **Sub-map Selection (Processing 2):** For maps with multiple overlapping TIN regions (`sub_maps`), automatically determines which TIN to apply based on region boundaries, priority, and importance
19
+ - **Viewport Transformation (Processing 3):** Converts a display viewport (center, zoom, rotation) in pixel coordinate space to a viewport in the map coordinate space (EPSG:3857)
20
+ - **Cross-map Viewport Sync (Processing 4):** Converts a display viewport from one pixel map directly to the corresponding viewport of another pixel map, via the shared map coordinate space
18
21
 
19
22
  ## Requirements
20
23
 
@@ -67,6 +70,90 @@ The library may throw errors in the following cases:
67
70
 
68
71
  If errors occur, the transformation definition data needs to be modified. Please use editor tools that incorporate [@maplat/tin](https://github.com/code4history/MaplatTin/) to modify transformation definitions.
69
72
 
73
+ ## MapTransform Usage
74
+
75
+ ### Processing 2 — Sub-map selection and coordinate transformation
76
+
77
+ When a single map image contains multiple overlapping TIN definitions (`sub_maps`), use `MapTransform` to automatically select the correct TIN and transform coordinates.
78
+
79
+ ```javascript
80
+ import { MapTransform } from '@maplat/transform';
81
+
82
+ const mt = new MapTransform();
83
+ mt.setMapData({
84
+ compiled: mainCompiledData, // Main TIN compiled data
85
+ sub_maps: [
86
+ { compiled: sub0Data, priority: 1, importance: 1 },
87
+ { compiled: sub1Data, priority: 2, importance: 2 },
88
+ ],
89
+ });
90
+
91
+ // Forward: pixel XY → EPSG:3857 (returns [layerIndex, mercCoord] or false)
92
+ const result = mt.xy2MercWithLayer([320, 240]);
93
+ if (result) {
94
+ const [layerIndex, merc] = result;
95
+ console.log('layer:', layerIndex, 'merc:', merc);
96
+ }
97
+
98
+ // Reverse: EPSG:3857 → pixel XY (returns up to 2 layers, each [layerIndex, xyCoord] or undefined)
99
+ const results = mt.merc2XyWithLayer([15000000, 4000000]);
100
+ results.forEach((r, i) => {
101
+ if (r) console.log(`result ${i}: layer ${r[0]}, xy`, r[1]);
102
+ });
103
+ ```
104
+
105
+ ### Processing 3 — Viewport transformation
106
+
107
+ Convert a pixel-map viewport (center position, zoom level, rotation angle) to and from a geographic viewport in EPSG:3857. The viewport is represented as five Mercator points (center + four cardinal offsets).
108
+
109
+ ```javascript
110
+ import { MapTransform } from '@maplat/transform';
111
+
112
+ const mt = new MapTransform();
113
+ mt.setMapData({ compiled: compiledData });
114
+
115
+ const canvasSize = [800, 600]; // [width, height] in pixels
116
+
117
+ // Pixel viewport → EPSG:3857 five points
118
+ const viewpoint = {
119
+ center: [15000000, 4000000], // EPSG:3857 center of the pixel-space viewport
120
+ zoom: 14,
121
+ rotation: 0,
122
+ };
123
+ const mercs = mt.viewpoint2Mercs(viewpoint, canvasSize);
124
+ // mercs: [[cx,cy], [north], [east], [south], [west]] (EPSG:3857)
125
+
126
+ // EPSG:3857 five points → pixel viewport
127
+ const vp = mt.mercs2Viewpoint(mercs, canvasSize);
128
+ console.log(vp.center, vp.zoom, vp.rotation);
129
+ ```
130
+
131
+ ### Processing 4 — Cross-map viewport synchronization
132
+
133
+ Convert the display viewport of one pixel map to the corresponding viewport of another pixel map, using the shared EPSG:3857 space as an intermediary.
134
+
135
+ ```javascript
136
+ import { MapTransform } from '@maplat/transform';
137
+
138
+ const mtA = new MapTransform();
139
+ mtA.setMapData({ compiled: compiledDataA });
140
+
141
+ const mtB = new MapTransform();
142
+ mtB.setMapData({ compiled: compiledDataB });
143
+
144
+ const canvasSize = [800, 600];
145
+
146
+ // Map A viewport (pixel space A)
147
+ const vpA = { center: [15000000, 4000000], zoom: 14, rotation: 0 };
148
+
149
+ // Pixel space A → EPSG:3857 five points (Processing 3 forward)
150
+ const mercs = mtA.viewpoint2Mercs(vpA, canvasSize);
151
+
152
+ // EPSG:3857 five points → Map B viewport (Processing 3 reverse)
153
+ const vpB = mtB.mercs2Viewpoint(mercs, canvasSize);
154
+ console.log('Map B viewport:', vpB);
155
+ ```
156
+
70
157
  ## API Reference
71
158
 
72
159
  ### Transform Class
@@ -119,6 +206,78 @@ Perform coordinate transformation.
119
206
  - `Transform.YAXIS_FOLLOW`: Follow Y-axis direction
120
207
  - `Transform.YAXIS_INVERT`: Invert Y-axis direction
121
208
 
209
+ ### MapTransform Class
210
+
211
+ The class for sub-map selection, viewport transformation, and cross-map viewport synchronization (Processings 2–4).
212
+
213
+ #### Constructor
214
+
215
+ ```javascript
216
+ const mt = new MapTransform();
217
+ ```
218
+
219
+ #### Methods
220
+
221
+ ##### `setMapData(mapData: MapData): void`
222
+
223
+ Load a main TIN and optional sub-map TINs.
224
+
225
+ - **Parameters:**
226
+ - `mapData`: `{ compiled, maxZoom?, sub_maps? }` — main compiled TIN data, optional explicit maxZoom, and optional array of sub-map definitions
227
+
228
+ ##### `xy2Merc(xy: number[]): number[] | false`
229
+
230
+ Transform a pixel coordinate to EPSG:3857 using the main TIN.
231
+
232
+ - **Parameters:** `xy` — pixel coordinate `[x, y]`
233
+ - **Returns:** EPSG:3857 coordinate, or `false` if out of bounds
234
+
235
+ ##### `merc2Xy(merc: number[]): number[] | false`
236
+
237
+ Transform an EPSG:3857 coordinate to pixel coordinate using the main TIN (reverse).
238
+
239
+ - **Parameters:** `merc` — EPSG:3857 coordinate `[x, y]`
240
+ - **Returns:** Pixel coordinate, or `false` if out of bounds
241
+
242
+ ##### `xy2MercWithLayer(xy: number[]): [number, number[]] | false`
243
+
244
+ Transform a pixel coordinate to EPSG:3857, automatically selecting the appropriate TIN from sub-maps based on priority and region (Processing 2).
245
+
246
+ - **Parameters:** `xy` — pixel coordinate `[x, y]`
247
+ - **Returns:** `[layerIndex, mercCoord]` or `false` if out of bounds
248
+
249
+ ##### `merc2XyWithLayer(merc: number[]): ([number, number[]] | undefined)[]`
250
+
251
+ Transform an EPSG:3857 coordinate to pixel coordinate across all applicable TIN layers, returning up to 2 results ordered by importance (Processing 2).
252
+ > To return more than 2 layers, increase the limit in the `.slice(0, 2)` / `.filter(i < 2)` lines inside the implementation.
253
+
254
+ - **Parameters:** `merc` — EPSG:3857 coordinate `[x, y]`
255
+ - **Returns:** Array of up to 2 elements; each is `[layerIndex, xyCoord]` or `undefined`
256
+
257
+ ##### `viewpoint2Mercs(viewpoint: Viewpoint, size: [number, number]): number[][]`
258
+
259
+ Convert a pixel-space viewport to five EPSG:3857 points (Processing 3).
260
+
261
+ - **Parameters:**
262
+ - `viewpoint`: `{ center, zoom, rotation }` — viewport in pixel space (center as EPSG:3857 equivalent via `xy2SysCoord`)
263
+ - `size`: Canvas size `[width, height]`
264
+ - **Returns:** Array of 5 EPSG:3857 points `[center, north, east, south, west]`
265
+ - **Throws:** Error if the center point is outside the TIN bounds
266
+
267
+ ##### `mercs2Viewpoint(mercs: number[][], size: [number, number]): Viewpoint`
268
+
269
+ Convert five EPSG:3857 points back to a pixel-space viewport (Processing 3 reverse).
270
+
271
+ - **Parameters:**
272
+ - `mercs`: Array of 5 EPSG:3857 points (as returned by `viewpoint2Mercs`)
273
+ - `size`: Canvas size `[width, height]`
274
+ - **Returns:** `Viewpoint` — `{ center, zoom, rotation }` in pixel space
275
+ - **Throws:** Error if the center point cannot be reverse-transformed
276
+
277
+ #### Accessors
278
+
279
+ - `maxxy: number` — `2^maxZoom × 256`; the pixel-to-EPSG:3857 scale factor
280
+
122
281
  ### Exported Types
123
282
 
124
283
  - `PointSet`, `BiDirectionKey`, `WeightBufferBD`, `VertexMode`, `StrictMode`, `StrictStatus`, `YaxisMode`
@@ -126,6 +285,9 @@ Perform coordinate transformation.
126
285
  - `Compiled`, `CompiledLegacy`
127
286
  - `Tins`, `Tri`, `PropertyTriKey`
128
287
  - `Edge`, `EdgeSet`, `EdgeSetLegacy`
288
+ - `Viewpoint` — `{ center: number[], zoom: number, rotation: number }`
289
+ - `MapData` — `{ compiled: Compiled, maxZoom?: number, sub_maps?: SubMapData[] }`
290
+ - `SubMapData` — `{ compiled: Compiled, priority: number, importance: number, bounds?: number[][] }`
129
291
 
130
292
  ### Exported Utility Functions
131
293
 
package/dist/index.d.ts CHANGED
@@ -102,6 +102,161 @@ export declare type KinksBD = {
102
102
  [key in BiDirectionKey]?: Kinks;
103
103
  };
104
104
 
105
+ /**
106
+ * Input data for MapTransform.setMapData().
107
+ */
108
+ export declare interface MapData {
109
+ /** Compiled TIN data for the main layer */
110
+ compiled: Compiled;
111
+ /** maxZoom value used to compute _maxxy = 2^maxZoom * 256 */
112
+ maxZoom?: number;
113
+ /** Sub-map layers */
114
+ sub_maps?: SubMapData[];
115
+ }
116
+
117
+ /**
118
+ * MapTransform — 処理2・3・4を担う座標変換クラス
119
+ *
120
+ * - 処理2: submaps 属性を持つ地図で、複数 TIN のうちどれを適用するか判定・選択し座標変換
121
+ * - 処理3: ビューポート ↔ メルカトル5点 変換
122
+ * - 処理4: ビューポート ↔ TIN 適用後メルカトル5点 変換
123
+ *
124
+ * OpenLayers への依存ゼロ。ブラウザ・Node.js 両対応。
125
+ */
126
+ export declare class MapTransform {
127
+ private mainTin;
128
+ private subTins;
129
+ private _maxxy;
130
+ /**
131
+ * 地図データ(コンパイル済み TIN + sub_maps)をロードする
132
+ *
133
+ * @param mapData - メイン TIN と sub_maps の情報
134
+ */
135
+ setMapData(mapData: MapData): void;
136
+ /**
137
+ * ピクセル座標 → メルカトル座標(最適レイヤー選択)
138
+ *
139
+ * @param xy - ピクセル座標 [x, y]
140
+ * @returns メルカトル座標、または範囲外の場合は false
141
+ */
142
+ xy2Merc(xy: number[]): number[] | false;
143
+ /**
144
+ * メルカトル座標 → ピクセル座標(最適レイヤー選択)
145
+ *
146
+ * @param merc - メルカトル座標 [x, y]
147
+ * @returns ピクセル座標、または範囲外の場合は false
148
+ */
149
+ merc2Xy(merc: number[]): number[] | false;
150
+ /**
151
+ * ピクセル座標 → メルカトル座標(レイヤーID付き)
152
+ * histmap_tin.ts xy2MercAsync_returnLayer() の同期版
153
+ *
154
+ * @param xy - ピクセル座標 [x, y]
155
+ * @returns [レイヤーインデックス, メルカトル座標] または false
156
+ */
157
+ xy2MercWithLayer(xy: number[]): [number, number[]] | false;
158
+ /**
159
+ * メルカトル座標 → ピクセル座標(複数レイヤー結果)
160
+ * histmap_tin.ts merc2XyAsync_returnLayer() の同期版
161
+ *
162
+ * 現在は MaplatCore の仕様に合わせ、最大2レイヤーまで返す。
163
+ * 3レイヤー以上返したい場合は、下記の .slice(0, 2) および .filter(i < 2) の
164
+ * 上限値を増やすか、引数で上限を指定できるようにすること。
165
+ *
166
+ * @param merc - メルカトル座標 [x, y]
167
+ * @returns 最大2要素の配列。各要素は [レイヤーインデックス, ピクセル座標] または undefined
168
+ */
169
+ merc2XyWithLayer(merc: number[]): ([number, number[]] | undefined)[];
170
+ /**
171
+ * メルカトル5点 → システム座標(複数レイヤー)
172
+ * histmap_tin.ts mercs2SysCoordsAsync_multiLayer() の同期版
173
+ *
174
+ * @param mercs - 5点のメルカトル座標配列(中心+上下左右)
175
+ * @returns 各レイヤーのシステム座標配列(または undefined)
176
+ */
177
+ mercs2SysCoords(mercs: number[][]): (number[][] | undefined)[];
178
+ /**
179
+ * ビューポート → TIN 適用後メルカトル5点
180
+ * histmap_tin.ts viewpoint2MercsAsync() の同期版
181
+ *
182
+ * @param viewpoint - ビューポート(center, zoom, rotation)
183
+ * @param size - 画面サイズ [width, height]
184
+ * @returns TIN 変換後のメルカトル5点
185
+ */
186
+ viewpoint2Mercs(viewpoint: Viewpoint, size: [number, number]): number[][];
187
+ /**
188
+ * TIN 適用後メルカトル5点 → ビューポート
189
+ * histmap_tin.ts mercs2ViewpointAsync() の同期版
190
+ *
191
+ * @param mercs - TIN 変換後のメルカトル5点
192
+ * @param size - 画面サイズ [width, height]
193
+ * @returns ビューポート(center, zoom, rotation)
194
+ */
195
+ mercs2Viewpoint(mercs: number[][], size: [number, number]): Viewpoint;
196
+ /** zoom2Radius の静的ラッパー */
197
+ static zoom2Radius(size: [number, number], zoom: number): number;
198
+ /** mercViewpoint2Mercs の静的ラッパー */
199
+ static mercViewpoint2Mercs(center: number[], zoom: number, rotation: number, size: [number, number]): number[][];
200
+ /** mercs2MercViewpoint の静的ラッパー */
201
+ static mercs2MercViewpoint(mercs: number[][], size: [number, number]): Viewpoint;
202
+ /** xy2SysCoord の静的ラッパー */
203
+ static xy2SysCoord(xy: number[], maxxy: number): number[];
204
+ /** sysCoord2Xy の静的ラッパー */
205
+ static sysCoord2Xy(sysCoord: number[], maxxy: number): number[];
206
+ private _assertMapData;
207
+ private _assertMaxxy;
208
+ /**
209
+ * レイヤーインデックスに対応する Transform インスタンスを返す(三角網描画などの用途)
210
+ *
211
+ * @param idx - 0 = メイン TIN、1以上 = sub_maps[idx-1]
212
+ * @returns 対応する Transform、または範囲外の場合は null
213
+ */
214
+ getLayerTransform(idx: number): Transform | null;
215
+ /** レイヤー数を返す(メイン + sub 数) */
216
+ get layerCount(): number;
217
+ /**
218
+ * viewpoint 変換に使用する最大ピクセル幅(2^maxZoom × 256)
219
+ * stateToViewpoint / viewpointToState で zoom ↔ scale 変換に使用する
220
+ * zoom = log2(scale × maxxy / 256) の関係
221
+ */
222
+ get maxxy(): number;
223
+ /** priority 降順でソートした [index, tin, isMain] の配列を返す */
224
+ private _getTinsSortedByPriority;
225
+ /** メイン TIN + 全 sub TIN を index 付きで返す */
226
+ private _getAllTinsWithIndex;
227
+ /**
228
+ * 指定レイヤーインデックスで TIN 変換を実行する
229
+ * index 0 → mainTin, index 1..n → subTins[index-1]
230
+ */
231
+ private _transformByIndex;
232
+ /** 内部用 xy2SysCoord(_maxxy を使用) */
233
+ private xy2SysCoordInternal;
234
+ }
235
+
236
+ export declare const MERC_CROSSMATRIX: number[][];
237
+
238
+ export declare const MERC_MAX = 20037508.342789244;
239
+
240
+ /**
241
+ * メルカトル5地点情報からメルカトル地図でのサイズ情報(中心座標、ズーム、回転)を得る
242
+ *
243
+ * @param mercs - 中心+上下左右の5点のメルカトル座標配列
244
+ * @param size - 画面サイズ [width, height]
245
+ * @returns Viewpoint オブジェクト(center, zoom, rotation)
246
+ */
247
+ export declare function mercs2MercViewpoint(mercs: number[][], size: [number, number]): Viewpoint;
248
+
249
+ /**
250
+ * 画面サイズと地図ズームから、メルカトル座標上での5座標を取得する
251
+ *
252
+ * @param center - 中心のメルカトル座標 [x, y]
253
+ * @param zoom - メルカトルズームレベル
254
+ * @param rotation - 回転角(ラジアン)
255
+ * @param size - 画面サイズ [width, height]
256
+ * @returns 中心+上下左右の5点のメルカトル座標配列
257
+ */
258
+ export declare function mercViewpoint2Mercs(center: number[], zoom: number, rotation: number, size: [number, number]): number[][];
259
+
105
260
  /**
106
261
  * エッジセットを正規化する
107
262
  * 古いバージョンのフォーマットを新しいフォーマットに変換する
@@ -128,6 +283,15 @@ declare type PropertyTri = {
128
283
 
129
284
  export declare type PropertyTriKey = "a" | "b" | "c";
130
285
 
286
+ /**
287
+ * 与えられた差分行列を回転する
288
+ *
289
+ * @param xys - 回転する座標の配列
290
+ * @param theta - 回転角(ラジアン)
291
+ * @returns 回転後の座標の配列
292
+ */
293
+ export declare function rotateMatrix(xys: number[][], theta: number): number[][];
294
+
131
295
  /**
132
296
  * 三角形の頂点の順序を修正する
133
297
  * 地図外郭の頂点を含む三角形について、頂点の順序を統一する
@@ -146,6 +310,29 @@ export declare type StrictMode = "strict" | "auto" | "loose";
146
310
  */
147
311
  export declare type StrictStatus = "strict" | "strict_error" | "loose";
148
312
 
313
+ /**
314
+ * Sub-map TIN data for MapTransform.setMapData().
315
+ */
316
+ export declare interface SubMapData {
317
+ /** Compiled TIN data */
318
+ compiled: Compiled;
319
+ /** Layer priority (higher = checked first) */
320
+ priority: number;
321
+ /** Layer importance (used when multiple layers overlap) */
322
+ importance: number;
323
+ /** Bounds vertices in pixel (XY) space. Falls back to compiled.bounds if omitted. */
324
+ bounds?: number[][];
325
+ }
326
+
327
+ /**
328
+ * システム座標(EPSG:3857相当)をピクセル座標に変換する
329
+ *
330
+ * @param sysCoord - システム座標 [x, y]
331
+ * @param maxxy - 最大座標値(2^maxZoom * 256)
332
+ * @returns ピクセル座標 [x, y]
333
+ */
334
+ export declare function sysCoord2Xy(sysCoord: number[], maxxy: number): number[];
335
+
149
336
  export declare type Tins = FeatureCollection<Polygon, PropertiesTri>;
150
337
 
151
338
  export declare type TinsBD = {
@@ -273,6 +460,18 @@ export declare type VerticesParamsBD = {
273
460
  [key in BiDirectionKey]?: VerticesParams;
274
461
  };
275
462
 
463
+ /**
464
+ * Viewport representation: center in mercator, zoom level, rotation in radians.
465
+ */
466
+ export declare interface Viewpoint {
467
+ /** Mercator coordinate [x, y] */
468
+ center: number[];
469
+ /** Mercator zoom level */
470
+ zoom: number;
471
+ /** Rotation angle in radians */
472
+ rotation: number;
473
+ }
474
+
276
475
  declare type WeightBuffer = {
277
476
  [index: string]: number;
278
477
  };
@@ -284,9 +483,27 @@ export declare type WeightBufferBD = {
284
483
  [key in BiDirectionKey]?: WeightBuffer;
285
484
  };
286
485
 
486
+ /**
487
+ * ピクセル座標をシステム座標(EPSG:3857相当)に変換する
488
+ *
489
+ * @param xy - ピクセル座標 [x, y]
490
+ * @param maxxy - 最大座標値(2^maxZoom * 256)
491
+ * @returns システム座標 [x, y]
492
+ */
493
+ export declare function xy2SysCoord(xy: number[], maxxy: number): number[];
494
+
287
495
  /**
288
496
  * Y-axis handling directive.
289
497
  */
290
498
  export declare type YaxisMode = "follow" | "invert";
291
499
 
500
+ /**
501
+ * size(画面サイズ)とズームから、地図面座標上での半径を得る
502
+ *
503
+ * @param size - 画面サイズ [width, height]
504
+ * @param zoom - メルカトルズームレベル
505
+ * @returns メルカトル座標上での半径
506
+ */
507
+ export declare function zoom2Radius(size: [number, number], zoom: number): number;
508
+
292
509
  export { }