You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+162Lines changed: 162 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -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
+
constmt=newMapTransform();
83
+
mt.setMapData({
84
+
compiled: mainCompiledData, // Main TIN compiled data
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
+
constmt=newMapTransform();
113
+
mt.setMapData({ compiled: compiledData });
114
+
115
+
constcanvasSize= [800, 600]; // [width, height] in pixels
116
+
117
+
// Pixel viewport → EPSG:3857 five points
118
+
constviewpoint= {
119
+
center: [15000000, 4000000], // EPSG:3857 center of the pixel-space viewport
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.
0 commit comments