@maplat/tin 0.11.2 → 0.11.3
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/LICENSE +224 -224
- package/README.ja.md +218 -218
- package/README.md +219 -219
- package/dist/index.html +41 -41
- package/package.json +5 -4
- package/src/constrained-tin.ts +84 -84
- package/src/index.ts +41 -41
- package/src/kinks.ts +1039 -1039
- package/src/searchutils.ts +68 -68
- package/src/tin.ts +1027 -1027
- package/src/types/cdt2d.d.ts +4 -4
- package/src/types/constrainautor.d.ts +6 -6
- package/src/types/kinks.d.ts +49 -49
- package/src/types/tin.d.ts +54 -54
- package/src/vertexutils.ts +88 -88
package/README.md
CHANGED
|
@@ -1,220 +1,220 @@
|
|
|
1
|
-
# Maplat Tin
|
|
2
|
-
|
|
3
|
-
A JavaScript library that defines and executes homeomorphic conversion between two plane coordinate systems based on control points.
|
|
4
|
-
This is part of the [Maplat](https://github.com/code4history/Maplat/) project.
|
|
5
|
-
|
|
6
|
-
日本語のREADMEは[こちら](./README.ja.md)
|
|
7
|
-
|
|
8
|
-
## Key Features
|
|
9
|
-
|
|
10
|
-
- **Generate Transformation Definitions:** Create coordinate transformation definitions based on control points and edge constraints
|
|
11
|
-
- **Bidirectional Coordinate Transformation:** Convert coordinates between two planes in both directions
|
|
12
|
-
- **Topology Preservation:** Maintains homeomorphic properties during transformation
|
|
13
|
-
- **Flexible Configuration:**
|
|
14
|
-
- Vertex handling modes (normal/bird's-eye view)
|
|
15
|
-
- Topology check modes (strict/auto/loose)
|
|
16
|
-
- Y-axis direction control
|
|
17
|
-
- **Edge Constraints:** Ability to specify constrained edges for more accurate transformation
|
|
18
|
-
- **State Management:** Save and restore transformation definitions
|
|
19
|
-
|
|
20
|
-
## Installation
|
|
21
|
-
|
|
22
|
-
### npm
|
|
23
|
-
|
|
24
|
-
```sh
|
|
25
|
-
# Install the main package
|
|
26
|
-
npm install @maplat/tin
|
|
27
|
-
|
|
28
|
-
# Install required dependency
|
|
29
|
-
npm install delaunator
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
### JSR (JavaScript Registry)
|
|
33
|
-
|
|
34
|
-
```sh
|
|
35
|
-
# For Deno
|
|
36
|
-
deno add @maplat/tin
|
|
37
|
-
|
|
38
|
-
# For npm/Node.js
|
|
39
|
-
npx jsr add @maplat/tin
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
### Deno
|
|
43
|
-
|
|
44
|
-
```typescript
|
|
45
|
-
// Using JSR (recommended)
|
|
46
|
-
import Tin from "jsr:@maplat/tin";
|
|
47
|
-
|
|
48
|
-
// Using deno.json import map
|
|
49
|
-
import Tin from "@maplat/tin";
|
|
50
|
-
|
|
51
|
-
// Or directly from npm
|
|
52
|
-
import Tin from "npm:@maplat/tin@0.11.
|
|
53
|
-
|
|
54
|
-
// Use the library
|
|
55
|
-
const tin = new Tin({
|
|
56
|
-
wh: [500, 500],
|
|
57
|
-
yaxisMode: Tin.YAXIS_FOLLOW
|
|
58
|
-
});
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
## Development Setup
|
|
62
|
-
|
|
63
|
-
This project supports using local dependencies for development. We recommend using `yalc` for managing local package dependencies.
|
|
64
|
-
|
|
65
|
-
### Using yalc for Local Development
|
|
66
|
-
|
|
67
|
-
1. **Install yalc globally:**
|
|
68
|
-
```sh
|
|
69
|
-
npm install -g yalc
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
2. **Publish local dependencies:**
|
|
73
|
-
```sh
|
|
74
|
-
# In the MaplatTransform directory
|
|
75
|
-
cd ../MaplatTransform
|
|
76
|
-
yalc publish
|
|
77
|
-
|
|
78
|
-
# In the MaplatEdgeBound directory
|
|
79
|
-
cd ../MaplatEdgeBound
|
|
80
|
-
yalc publish
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
3. **Link local dependencies in this project:**
|
|
84
|
-
```sh
|
|
85
|
-
# In the MaplatTin directory
|
|
86
|
-
yalc add @maplat/transform @maplat/edgebound
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
4. **Update local dependencies when changed:**
|
|
90
|
-
```sh
|
|
91
|
-
# In the dependency directory (e.g., MaplatTransform)
|
|
92
|
-
yalc publish --push
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
5. **Remove local dependencies (to use npm packages):**
|
|
96
|
-
```sh
|
|
97
|
-
# In the MaplatTin directory
|
|
98
|
-
yalc remove @maplat/transform @maplat/edgebound
|
|
99
|
-
npm install
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
**Note:** The `.yalc` directory and `yalc.lock` file are ignored by git and will not be committed.
|
|
103
|
-
|
|
104
|
-
### Browser
|
|
105
|
-
|
|
106
|
-
When using in the browser, you need to include the peer dependencies:
|
|
107
|
-
|
|
108
|
-
```html
|
|
109
|
-
<!-- Required dependencies -->
|
|
110
|
-
<script src="https://unpkg.com/delaunator@5.0.0/delaunator.min.js"></script>
|
|
111
|
-
<script src="https://unpkg.com/@turf/helpers@7.2.0/dist/turf-helpers.min.js"></script>
|
|
112
|
-
<script src="https://unpkg.com/@turf/boolean-point-in-polygon@7.2.0/dist/turf-boolean-point-in-polygon.min.js"></script>
|
|
113
|
-
<script src="https://unpkg.com/@turf/centroid@7.2.0/dist/turf-centroid.min.js"></script>
|
|
114
|
-
<script src="https://unpkg.com/@turf/convex@7.2.0/dist/turf-convex.min.js"></script>
|
|
115
|
-
<script src="https://unpkg.com/@turf/line-intersect@7.2.0/dist/turf-line-intersect.min.js"></script>
|
|
116
|
-
|
|
117
|
-
<!-- Maplat Tin (UMD) -->
|
|
118
|
-
<script src="https://unpkg.com/@maplat/tin/dist/tin.umd.js"></script>
|
|
119
|
-
<script>
|
|
120
|
-
// Use the library
|
|
121
|
-
const tin = new tin.default({
|
|
122
|
-
wh: [500, 500]
|
|
123
|
-
});
|
|
124
|
-
</script>
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
Or using ES modules:
|
|
128
|
-
|
|
129
|
-
```html
|
|
130
|
-
<!-- Maplat Tin (ESM) -->
|
|
131
|
-
<script type="module">
|
|
132
|
-
import Tin from "https://unpkg.com/@maplat/tin/dist/index.js";
|
|
133
|
-
// Use the library
|
|
134
|
-
const tin = new Tin({
|
|
135
|
-
wh: [500, 500]
|
|
136
|
-
});
|
|
137
|
-
</script>
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
## Basic Usage
|
|
141
|
-
|
|
142
|
-
```javascript
|
|
143
|
-
// Create a new instance with basic configuration
|
|
144
|
-
const tin = new Tin({
|
|
145
|
-
wh: [500, 500], // Width and height of the source plane
|
|
146
|
-
yaxisMode: Tin.YAXIS_FOLLOW // Y-axis direction handling
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
// Set control points: Array of [source, target] coordinates
|
|
150
|
-
tin.setPoints([
|
|
151
|
-
[[100,100], [200, 200]], // Point 1
|
|
152
|
-
[[200,200], [400, 400]], // Point 2
|
|
153
|
-
[[150,150], [320, 350]], // Point 3
|
|
154
|
-
[[200,100], [420, 220]] // Point 4
|
|
155
|
-
]);
|
|
156
|
-
|
|
157
|
-
// Initialize the TIN network
|
|
158
|
-
tin.updateTin();
|
|
159
|
-
|
|
160
|
-
// Check topology status
|
|
161
|
-
if (tin.strict_status === Tin.STATUS_STRICT) {
|
|
162
|
-
console.log('Topology OK: Roundtrip transform is guaranteed');
|
|
163
|
-
} else if (tin.strict_status === Tin.STATUS_LOOSE) {
|
|
164
|
-
console.log('Topology warning: Roundtrip transform is not guaranteed');
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
// Forward transform: source to target
|
|
168
|
-
const transformed = tin.transform([160, 160], false);
|
|
169
|
-
|
|
170
|
-
// Backward transform: target to source
|
|
171
|
-
const restored = tin.transform(transformed, true);
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
## Configuration
|
|
175
|
-
|
|
176
|
-
### Constructor Options
|
|
177
|
-
|
|
178
|
-
| **Option** | **Type** | **Description** | **Default** |
|
|
179
|
-
| ------------- | --------------------------- | ------------------------- | ------------- |
|
|
180
|
-
| `bounds` | `Position[]` | **Boundary polygon vertices** | `-` |
|
|
181
|
-
| `wh` | `number[]` | **Width and height [w, h]** | `-` |
|
|
182
|
-
| `vertexMode` | `"plain"|"birdeye"` | **Vertex handling mode** | `"plain"` |
|
|
183
|
-
| `strictMode` | `"strict"|"auto"|"loose"` | **Topology check mode** | `"auto"` |
|
|
184
|
-
| `yaxisMode` | `"follow"|"invert"` | **Y-axis direction** | `"invert"` |
|
|
185
|
-
| `importance` | `number` | **Map importance** | `0` |
|
|
186
|
-
| `priority` | `number` | **Map priority** | `0` |
|
|
187
|
-
|
|
188
|
-
Either `bounds` or `wh` must be specified.
|
|
189
|
-
|
|
190
|
-
### Methods
|
|
191
|
-
|
|
192
|
-
| **Method** | **Description** |
|
|
193
|
-
| ---------------------------- | --------------------------------- |
|
|
194
|
-
| `setPoints(points)` | **Set control points** |
|
|
195
|
-
| `setEdges(edges)` | **Set constrained edges** |
|
|
196
|
-
| `updateTin()` | **Initialize/update TIN network** |
|
|
197
|
-
| `transform(coords, inverse)` | **Execute coordinate transformation** |
|
|
198
|
-
| `getCompiled()` | **Get serializable state** |
|
|
199
|
-
| `setCompiled(state)` | **Restore from serialized state** |
|
|
200
|
-
|
|
201
|
-
### Error Handling
|
|
202
|
-
|
|
203
|
-
The library may throw errors in the following cases:
|
|
204
|
-
|
|
205
|
-
- `"TOO LINEAR1"`,`"TOO LINEAR2"`: Control points are too linear
|
|
206
|
-
- `"SOME POINTS OUTSIDE"`: Points outside boundary
|
|
207
|
-
- Custom error when attempting backward transformation in a disallowed state
|
|
208
|
-
|
|
209
|
-
## License
|
|
210
|
-
|
|
211
|
-
Maplat Limited License 1.1
|
|
212
|
-
|
|
213
|
-
Copyright (c) 2024 Code for History
|
|
214
|
-
|
|
215
|
-
## Developers
|
|
216
|
-
|
|
217
|
-
- Kohei Otsuka
|
|
218
|
-
- Code for History
|
|
219
|
-
|
|
1
|
+
# Maplat Tin
|
|
2
|
+
|
|
3
|
+
A JavaScript library that defines and executes homeomorphic conversion between two plane coordinate systems based on control points.
|
|
4
|
+
This is part of the [Maplat](https://github.com/code4history/Maplat/) project.
|
|
5
|
+
|
|
6
|
+
日本語のREADMEは[こちら](./README.ja.md)
|
|
7
|
+
|
|
8
|
+
## Key Features
|
|
9
|
+
|
|
10
|
+
- **Generate Transformation Definitions:** Create coordinate transformation definitions based on control points and edge constraints
|
|
11
|
+
- **Bidirectional Coordinate Transformation:** Convert coordinates between two planes in both directions
|
|
12
|
+
- **Topology Preservation:** Maintains homeomorphic properties during transformation
|
|
13
|
+
- **Flexible Configuration:**
|
|
14
|
+
- Vertex handling modes (normal/bird's-eye view)
|
|
15
|
+
- Topology check modes (strict/auto/loose)
|
|
16
|
+
- Y-axis direction control
|
|
17
|
+
- **Edge Constraints:** Ability to specify constrained edges for more accurate transformation
|
|
18
|
+
- **State Management:** Save and restore transformation definitions
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
### npm
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
# Install the main package
|
|
26
|
+
npm install @maplat/tin
|
|
27
|
+
|
|
28
|
+
# Install required dependency
|
|
29
|
+
npm install delaunator
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### JSR (JavaScript Registry)
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
# For Deno
|
|
36
|
+
deno add @maplat/tin
|
|
37
|
+
|
|
38
|
+
# For npm/Node.js
|
|
39
|
+
npx jsr add @maplat/tin
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Deno
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
// Using JSR (recommended)
|
|
46
|
+
import Tin from "jsr:@maplat/tin";
|
|
47
|
+
|
|
48
|
+
// Using deno.json import map
|
|
49
|
+
import Tin from "@maplat/tin";
|
|
50
|
+
|
|
51
|
+
// Or directly from npm
|
|
52
|
+
import Tin from "npm:@maplat/tin@0.11.3";
|
|
53
|
+
|
|
54
|
+
// Use the library
|
|
55
|
+
const tin = new Tin({
|
|
56
|
+
wh: [500, 500],
|
|
57
|
+
yaxisMode: Tin.YAXIS_FOLLOW
|
|
58
|
+
});
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Development Setup
|
|
62
|
+
|
|
63
|
+
This project supports using local dependencies for development. We recommend using `yalc` for managing local package dependencies.
|
|
64
|
+
|
|
65
|
+
### Using yalc for Local Development
|
|
66
|
+
|
|
67
|
+
1. **Install yalc globally:**
|
|
68
|
+
```sh
|
|
69
|
+
npm install -g yalc
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
2. **Publish local dependencies:**
|
|
73
|
+
```sh
|
|
74
|
+
# In the MaplatTransform directory
|
|
75
|
+
cd ../MaplatTransform
|
|
76
|
+
yalc publish
|
|
77
|
+
|
|
78
|
+
# In the MaplatEdgeBound directory
|
|
79
|
+
cd ../MaplatEdgeBound
|
|
80
|
+
yalc publish
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
3. **Link local dependencies in this project:**
|
|
84
|
+
```sh
|
|
85
|
+
# In the MaplatTin directory
|
|
86
|
+
yalc add @maplat/transform @maplat/edgebound
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
4. **Update local dependencies when changed:**
|
|
90
|
+
```sh
|
|
91
|
+
# In the dependency directory (e.g., MaplatTransform)
|
|
92
|
+
yalc publish --push
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
5. **Remove local dependencies (to use npm packages):**
|
|
96
|
+
```sh
|
|
97
|
+
# In the MaplatTin directory
|
|
98
|
+
yalc remove @maplat/transform @maplat/edgebound
|
|
99
|
+
npm install
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**Note:** The `.yalc` directory and `yalc.lock` file are ignored by git and will not be committed.
|
|
103
|
+
|
|
104
|
+
### Browser
|
|
105
|
+
|
|
106
|
+
When using in the browser, you need to include the peer dependencies:
|
|
107
|
+
|
|
108
|
+
```html
|
|
109
|
+
<!-- Required dependencies -->
|
|
110
|
+
<script src="https://unpkg.com/delaunator@5.0.0/delaunator.min.js"></script>
|
|
111
|
+
<script src="https://unpkg.com/@turf/helpers@7.2.0/dist/turf-helpers.min.js"></script>
|
|
112
|
+
<script src="https://unpkg.com/@turf/boolean-point-in-polygon@7.2.0/dist/turf-boolean-point-in-polygon.min.js"></script>
|
|
113
|
+
<script src="https://unpkg.com/@turf/centroid@7.2.0/dist/turf-centroid.min.js"></script>
|
|
114
|
+
<script src="https://unpkg.com/@turf/convex@7.2.0/dist/turf-convex.min.js"></script>
|
|
115
|
+
<script src="https://unpkg.com/@turf/line-intersect@7.2.0/dist/turf-line-intersect.min.js"></script>
|
|
116
|
+
|
|
117
|
+
<!-- Maplat Tin (UMD) -->
|
|
118
|
+
<script src="https://unpkg.com/@maplat/tin/dist/tin.umd.js"></script>
|
|
119
|
+
<script>
|
|
120
|
+
// Use the library
|
|
121
|
+
const tin = new tin.default({
|
|
122
|
+
wh: [500, 500]
|
|
123
|
+
});
|
|
124
|
+
</script>
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Or using ES modules:
|
|
128
|
+
|
|
129
|
+
```html
|
|
130
|
+
<!-- Maplat Tin (ESM) -->
|
|
131
|
+
<script type="module">
|
|
132
|
+
import Tin from "https://unpkg.com/@maplat/tin/dist/index.js";
|
|
133
|
+
// Use the library
|
|
134
|
+
const tin = new Tin({
|
|
135
|
+
wh: [500, 500]
|
|
136
|
+
});
|
|
137
|
+
</script>
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Basic Usage
|
|
141
|
+
|
|
142
|
+
```javascript
|
|
143
|
+
// Create a new instance with basic configuration
|
|
144
|
+
const tin = new Tin({
|
|
145
|
+
wh: [500, 500], // Width and height of the source plane
|
|
146
|
+
yaxisMode: Tin.YAXIS_FOLLOW // Y-axis direction handling
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
// Set control points: Array of [source, target] coordinates
|
|
150
|
+
tin.setPoints([
|
|
151
|
+
[[100,100], [200, 200]], // Point 1
|
|
152
|
+
[[200,200], [400, 400]], // Point 2
|
|
153
|
+
[[150,150], [320, 350]], // Point 3
|
|
154
|
+
[[200,100], [420, 220]] // Point 4
|
|
155
|
+
]);
|
|
156
|
+
|
|
157
|
+
// Initialize the TIN network
|
|
158
|
+
tin.updateTin();
|
|
159
|
+
|
|
160
|
+
// Check topology status
|
|
161
|
+
if (tin.strict_status === Tin.STATUS_STRICT) {
|
|
162
|
+
console.log('Topology OK: Roundtrip transform is guaranteed');
|
|
163
|
+
} else if (tin.strict_status === Tin.STATUS_LOOSE) {
|
|
164
|
+
console.log('Topology warning: Roundtrip transform is not guaranteed');
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Forward transform: source to target
|
|
168
|
+
const transformed = tin.transform([160, 160], false);
|
|
169
|
+
|
|
170
|
+
// Backward transform: target to source
|
|
171
|
+
const restored = tin.transform(transformed, true);
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Configuration
|
|
175
|
+
|
|
176
|
+
### Constructor Options
|
|
177
|
+
|
|
178
|
+
| **Option** | **Type** | **Description** | **Default** |
|
|
179
|
+
| ------------- | --------------------------- | ------------------------- | ------------- |
|
|
180
|
+
| `bounds` | `Position[]` | **Boundary polygon vertices** | `-` |
|
|
181
|
+
| `wh` | `number[]` | **Width and height [w, h]** | `-` |
|
|
182
|
+
| `vertexMode` | `"plain"|"birdeye"` | **Vertex handling mode** | `"plain"` |
|
|
183
|
+
| `strictMode` | `"strict"|"auto"|"loose"` | **Topology check mode** | `"auto"` |
|
|
184
|
+
| `yaxisMode` | `"follow"|"invert"` | **Y-axis direction** | `"invert"` |
|
|
185
|
+
| `importance` | `number` | **Map importance** | `0` |
|
|
186
|
+
| `priority` | `number` | **Map priority** | `0` |
|
|
187
|
+
|
|
188
|
+
Either `bounds` or `wh` must be specified.
|
|
189
|
+
|
|
190
|
+
### Methods
|
|
191
|
+
|
|
192
|
+
| **Method** | **Description** |
|
|
193
|
+
| ---------------------------- | --------------------------------- |
|
|
194
|
+
| `setPoints(points)` | **Set control points** |
|
|
195
|
+
| `setEdges(edges)` | **Set constrained edges** |
|
|
196
|
+
| `updateTin()` | **Initialize/update TIN network** |
|
|
197
|
+
| `transform(coords, inverse)` | **Execute coordinate transformation** |
|
|
198
|
+
| `getCompiled()` | **Get serializable state** |
|
|
199
|
+
| `setCompiled(state)` | **Restore from serialized state** |
|
|
200
|
+
|
|
201
|
+
### Error Handling
|
|
202
|
+
|
|
203
|
+
The library may throw errors in the following cases:
|
|
204
|
+
|
|
205
|
+
- `"TOO LINEAR1"`,`"TOO LINEAR2"`: Control points are too linear
|
|
206
|
+
- `"SOME POINTS OUTSIDE"`: Points outside boundary
|
|
207
|
+
- Custom error when attempting backward transformation in a disallowed state
|
|
208
|
+
|
|
209
|
+
## License
|
|
210
|
+
|
|
211
|
+
Maplat Limited License 1.1
|
|
212
|
+
|
|
213
|
+
Copyright (c) 2024 Code for History
|
|
214
|
+
|
|
215
|
+
## Developers
|
|
216
|
+
|
|
217
|
+
- Kohei Otsuka
|
|
218
|
+
- Code for History
|
|
219
|
+
|
|
220
220
|
We welcome your contributions! Feel free to submit [issues and pull requests](https://github.com/code4history/MaplatTin/issues).
|
package/dist/index.html
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="ja">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<title>MaplatTin Test</title>
|
|
6
|
-
<script src="https://unpkg.com/@turf/turf/turf.min.js"></script>
|
|
7
|
-
<script src="https://unpkg.com/delaunator/delaunator.min.js"></script>
|
|
8
|
-
<script src="https://unpkg.com/@kninnug/constrainautor/lib/Constrainautor.min.js"></script>
|
|
9
|
-
</head>
|
|
10
|
-
<body>
|
|
11
|
-
<h1>MaplatTin Test</h1>
|
|
12
|
-
<div id="output"></div>
|
|
13
|
-
<script type="module">
|
|
14
|
-
import Tin from '/src/index.ts';
|
|
15
|
-
|
|
16
|
-
const tin = new Tin({
|
|
17
|
-
bounds: [[100, 50], [150, 150], [150, 200], [60, 190], [50, 100]],
|
|
18
|
-
strictMode: Tin.MODE_STRICT
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
tin.setPoints([
|
|
22
|
-
[[80, 90], [160, -90]],
|
|
23
|
-
[[120, 120], [240, -120]],
|
|
24
|
-
[[100, 140], [200, -140]],
|
|
25
|
-
[[130, 180], [260, -180]],
|
|
26
|
-
[[70, 150], [140, -150]]
|
|
27
|
-
]);
|
|
28
|
-
|
|
29
|
-
tin.updateTinAsync().then(() => {
|
|
30
|
-
const output = document.getElementById('output');
|
|
31
|
-
const result1 = tin.transform([140, 150]);
|
|
32
|
-
const result2 = tin.transform(result1, true);
|
|
33
|
-
|
|
34
|
-
output.innerHTML = `
|
|
35
|
-
<h2>Test Results:</h2>
|
|
36
|
-
<p>Forward transform [140, 150] => [${result1.join(', ')}]</p>
|
|
37
|
-
<p>Backward transform [${result1.join(', ')}] => [${result2.join(', ')}]</p>
|
|
38
|
-
`;
|
|
39
|
-
});
|
|
40
|
-
</script>
|
|
41
|
-
</body>
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="ja">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<title>MaplatTin Test</title>
|
|
6
|
+
<script src="https://unpkg.com/@turf/turf/turf.min.js"></script>
|
|
7
|
+
<script src="https://unpkg.com/delaunator/delaunator.min.js"></script>
|
|
8
|
+
<script src="https://unpkg.com/@kninnug/constrainautor/lib/Constrainautor.min.js"></script>
|
|
9
|
+
</head>
|
|
10
|
+
<body>
|
|
11
|
+
<h1>MaplatTin Test</h1>
|
|
12
|
+
<div id="output"></div>
|
|
13
|
+
<script type="module">
|
|
14
|
+
import Tin from '/src/index.ts';
|
|
15
|
+
|
|
16
|
+
const tin = new Tin({
|
|
17
|
+
bounds: [[100, 50], [150, 150], [150, 200], [60, 190], [50, 100]],
|
|
18
|
+
strictMode: Tin.MODE_STRICT
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
tin.setPoints([
|
|
22
|
+
[[80, 90], [160, -90]],
|
|
23
|
+
[[120, 120], [240, -120]],
|
|
24
|
+
[[100, 140], [200, -140]],
|
|
25
|
+
[[130, 180], [260, -180]],
|
|
26
|
+
[[70, 150], [140, -150]]
|
|
27
|
+
]);
|
|
28
|
+
|
|
29
|
+
tin.updateTinAsync().then(() => {
|
|
30
|
+
const output = document.getElementById('output');
|
|
31
|
+
const result1 = tin.transform([140, 150]);
|
|
32
|
+
const result2 = tin.transform(result1, true);
|
|
33
|
+
|
|
34
|
+
output.innerHTML = `
|
|
35
|
+
<h2>Test Results:</h2>
|
|
36
|
+
<p>Forward transform [140, 150] => [${result1.join(', ')}]</p>
|
|
37
|
+
<p>Backward transform [${result1.join(', ')}] => [${result2.join(', ')}]</p>
|
|
38
|
+
`;
|
|
39
|
+
});
|
|
40
|
+
</script>
|
|
41
|
+
</body>
|
|
42
42
|
</html>
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.11.
|
|
7
|
+
"version": "0.11.3",
|
|
8
8
|
"description": "JavaScript library which performs homeomorphic conversion mutually between the coordinate systems of two planes based on the control points.",
|
|
9
9
|
"type": "module",
|
|
10
10
|
"main": "./dist/maplat_edgebound.cjs",
|
|
@@ -62,8 +62,8 @@
|
|
|
62
62
|
"deno"
|
|
63
63
|
],
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@maplat/edgebound": "^0.2.
|
|
66
|
-
"@maplat/transform": "^0.2.
|
|
65
|
+
"@maplat/edgebound": "^0.2.3",
|
|
66
|
+
"@maplat/transform": "^0.2.3"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
69
|
"@turf/boolean-point-in-polygon": "^7.2.0",
|
|
@@ -77,6 +77,7 @@
|
|
|
77
77
|
"@eslint/js": "^9.17.0",
|
|
78
78
|
"@testing-library/jest-dom": "^6.6.3",
|
|
79
79
|
"@types/delaunator": "^5.0.3",
|
|
80
|
+
"@types/estree": "^1.0.8",
|
|
80
81
|
"@types/geojson": "^7946.0.15",
|
|
81
82
|
"@types/node": "^22.10.2",
|
|
82
83
|
"@typescript-eslint/eslint-plugin": "^8.18.2",
|
|
@@ -96,4 +97,4 @@
|
|
|
96
97
|
"vite-plugin-dts": "^4.4.0",
|
|
97
98
|
"vitest": "^3.2.4"
|
|
98
99
|
}
|
|
99
|
-
}
|
|
100
|
+
}
|