@maplat/tin 0.11.4 → 0.13.0
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 +214 -219
- package/README.md +215 -220
- package/dist/boundary-vertices.d.ts +27 -0
- package/dist/edgebound/base.d.ts +31 -0
- package/dist/edgebound/bitset.d.ts +58 -0
- package/dist/edgebound/constrain.d.ts +68 -0
- package/dist/edgebound/index.d.ts +4 -0
- package/dist/index.d.ts +1 -0
- package/dist/maplat_tin.js +2721 -1685
- package/dist/maplat_tin.umd.js +5 -3
- package/dist/searchutils.d.ts +11 -2
- package/dist/strict-overlap.d.ts +5 -0
- package/dist/tin.d.ts +12 -18
- package/dist/weight-buffer.d.ts +11 -0
- package/package.json +47 -50
- package/src/boundary-vertices.ts +283 -0
- package/src/constrained-tin.ts +84 -84
- package/src/edgebound/base.ts +65 -0
- package/src/edgebound/bitset.ts +109 -0
- package/src/edgebound/constrain.license.txt +15 -0
- package/src/edgebound/constrain.ts +498 -0
- package/src/edgebound/index.ts +10 -0
- package/src/index.ts +42 -41
- package/src/kinks.ts +1092 -1039
- package/src/searchutils.ts +102 -68
- package/src/strict-overlap.ts +281 -0
- package/src/tin.ts +703 -1027
- package/src/types/cdt2d.d.ts +4 -4
- package/src/types/constrainautor.d.ts +6 -6
- package/src/types/kinks.d.ts +51 -49
- package/src/types/tin.d.ts +54 -54
- package/src/vertexutils.ts +87 -88
- package/src/weight-buffer.ts +111 -0
- package/dist/index.html +0 -42
- package/dist/maplat_tin.cjs +0 -3
package/README.md
CHANGED
|
@@ -1,220 +1,215 @@
|
|
|
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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
<script src="https://unpkg.com/
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
<script src="https://unpkg.com/@
|
|
114
|
-
<script
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
tin.
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
|
179
|
-
|
|
|
180
|
-
| `
|
|
181
|
-
| `
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
|
193
|
-
|
|
|
194
|
-
| `
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
- Kohei Otsuka
|
|
218
|
-
- Code for History
|
|
219
|
-
|
|
220
|
-
We welcome your contributions! Feel free to submit [issues and pull requests](https://github.com/code4history/MaplatTin/issues).
|
|
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
|
+
|
|
33
|
+
## Development Setup
|
|
34
|
+
|
|
35
|
+
This project supports using local dependencies for development. We recommend using `yalc` for managing local package dependencies.
|
|
36
|
+
|
|
37
|
+
### Using yalc for Local Development
|
|
38
|
+
|
|
39
|
+
1. **Install yalc globally:**
|
|
40
|
+
```sh
|
|
41
|
+
npm install -g yalc
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
2. **Publish local dependencies:**
|
|
45
|
+
```sh
|
|
46
|
+
# In the MaplatTransform directory
|
|
47
|
+
cd ../MaplatTransform
|
|
48
|
+
yalc publish
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
3. **Link local dependencies in this project:**
|
|
52
|
+
```sh
|
|
53
|
+
# In the MaplatTin directory
|
|
54
|
+
yalc add @maplat/transform
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
4. **Update local dependencies when changed:**
|
|
58
|
+
```sh
|
|
59
|
+
# In the dependency directory (e.g., MaplatTransform)
|
|
60
|
+
yalc publish --push
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
5. **Remove local dependencies (to use npm packages):**
|
|
64
|
+
```sh
|
|
65
|
+
# In the MaplatTin directory
|
|
66
|
+
yalc remove @maplat/transform
|
|
67
|
+
npm install
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
**Note:** The `.yalc` directory and `yalc.lock` file are ignored by git and will not be committed.
|
|
71
|
+
|
|
72
|
+
### Testing
|
|
73
|
+
|
|
74
|
+
The project includes comprehensive unit tests for both the TIN transformation logic and the internal EdgeBound constraint engine.
|
|
75
|
+
|
|
76
|
+
**Run all tests:**
|
|
77
|
+
```sh
|
|
78
|
+
pnpm test
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**Run specific test suite:**
|
|
82
|
+
```sh
|
|
83
|
+
# EdgeBound constraint engine tests
|
|
84
|
+
pnpm test tests/edgebound
|
|
85
|
+
|
|
86
|
+
# TIN transformation tests
|
|
87
|
+
pnpm test tests/tin
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**Test coverage:**
|
|
91
|
+
- `tests/edgebound/` - Internal EdgeBound constraint engine tests (455 tests)
|
|
92
|
+
- `constrain.test.ts` - Integration tests for constraint operations
|
|
93
|
+
- `constrain.unit.test.ts` - Unit tests for constraint methods
|
|
94
|
+
- `intersect.test.ts` - Segment intersection detection tests
|
|
95
|
+
- `validators.ts` - Test utilities for validating triangulation integrity
|
|
96
|
+
- `tests/tin.test.ts` - TIN transformation tests with real map data
|
|
97
|
+
- `tests/transform.test.ts` - Coordinate transformation tests
|
|
98
|
+
|
|
99
|
+
### Browser
|
|
100
|
+
|
|
101
|
+
When using in the browser, you need to include the peer dependencies:
|
|
102
|
+
|
|
103
|
+
```html
|
|
104
|
+
<!-- Required dependencies -->
|
|
105
|
+
<script src="https://unpkg.com/delaunator@5.0.0/delaunator.min.js"></script>
|
|
106
|
+
<script src="https://unpkg.com/@turf/helpers@7.2.0/dist/turf-helpers.min.js"></script>
|
|
107
|
+
<script src="https://unpkg.com/@turf/boolean-point-in-polygon@7.2.0/dist/turf-boolean-point-in-polygon.min.js"></script>
|
|
108
|
+
<script src="https://unpkg.com/@turf/centroid@7.2.0/dist/turf-centroid.min.js"></script>
|
|
109
|
+
<script src="https://unpkg.com/@turf/convex@7.2.0/dist/turf-convex.min.js"></script>
|
|
110
|
+
<script src="https://unpkg.com/@turf/line-intersect@7.2.0/dist/turf-line-intersect.min.js"></script>
|
|
111
|
+
|
|
112
|
+
<!-- Maplat Tin (UMD) -->
|
|
113
|
+
<script src="https://unpkg.com/@maplat/tin/dist/tin.umd.js"></script>
|
|
114
|
+
<script>
|
|
115
|
+
// Use the library
|
|
116
|
+
const tin = new tin.default({
|
|
117
|
+
wh: [500, 500]
|
|
118
|
+
});
|
|
119
|
+
</script>
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Or using ES modules:
|
|
123
|
+
|
|
124
|
+
```html
|
|
125
|
+
<!-- Maplat Tin (ESM) -->
|
|
126
|
+
<script type="module">
|
|
127
|
+
import Tin from "https://unpkg.com/@maplat/tin/dist/index.js";
|
|
128
|
+
// Use the library
|
|
129
|
+
const tin = new Tin({
|
|
130
|
+
wh: [500, 500]
|
|
131
|
+
});
|
|
132
|
+
</script>
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Basic Usage
|
|
136
|
+
|
|
137
|
+
```javascript
|
|
138
|
+
// Create a new instance with basic configuration
|
|
139
|
+
const tin = new Tin({
|
|
140
|
+
wh: [500, 500], // Width and height of the source plane
|
|
141
|
+
yaxisMode: Tin.YAXIS_FOLLOW // Y-axis direction handling
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
// Set control points: Array of [source, target] coordinates
|
|
145
|
+
tin.setPoints([
|
|
146
|
+
[[100,100], [200, 200]], // Point 1
|
|
147
|
+
[[200,200], [400, 400]], // Point 2
|
|
148
|
+
[[150,150], [320, 350]], // Point 3
|
|
149
|
+
[[200,100], [420, 220]] // Point 4
|
|
150
|
+
]);
|
|
151
|
+
|
|
152
|
+
// Initialize the TIN network
|
|
153
|
+
tin.updateTin();
|
|
154
|
+
|
|
155
|
+
// Check topology status
|
|
156
|
+
if (tin.strict_status === Tin.STATUS_STRICT) {
|
|
157
|
+
console.log('Topology OK: Roundtrip transform is guaranteed');
|
|
158
|
+
} else if (tin.strict_status === Tin.STATUS_LOOSE) {
|
|
159
|
+
console.log('Topology warning: Roundtrip transform is not guaranteed');
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Forward transform: source to target
|
|
163
|
+
const transformed = tin.transform([160, 160], false);
|
|
164
|
+
|
|
165
|
+
// Backward transform: target to source
|
|
166
|
+
const restored = tin.transform(transformed, true);
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## Configuration
|
|
170
|
+
|
|
171
|
+
### Constructor Options
|
|
172
|
+
|
|
173
|
+
| **Option** | **Type** | **Description** | **Default** |
|
|
174
|
+
| ------------- | --------------------------- | ------------------------- | ------------- |
|
|
175
|
+
| `bounds` | `Position[]` | **Boundary polygon vertices** | `-` |
|
|
176
|
+
| `wh` | `number[]` | **Width and height [w, h]** | `-` |
|
|
177
|
+
| `vertexMode` | `"plain"|"birdeye"` | **Vertex handling mode** | `"plain"` |
|
|
178
|
+
| `strictMode` | `"strict"|"auto"|"loose"` | **Topology check mode** | `"auto"` |
|
|
179
|
+
| `yaxisMode` | `"follow"|"invert"` | **Y-axis direction** | `"invert"` |
|
|
180
|
+
| `importance` | `number` | **Map importance** | `0` |
|
|
181
|
+
| `priority` | `number` | **Map priority** | `0` |
|
|
182
|
+
|
|
183
|
+
Either `bounds` or `wh` must be specified.
|
|
184
|
+
|
|
185
|
+
### Methods
|
|
186
|
+
|
|
187
|
+
| **Method** | **Description** |
|
|
188
|
+
| ---------------------------- | --------------------------------- |
|
|
189
|
+
| `setPoints(points)` | **Set control points** |
|
|
190
|
+
| `setEdges(edges)` | **Set constrained edges** |
|
|
191
|
+
| `updateTin()` | **Initialize/update TIN network** |
|
|
192
|
+
| `transform(coords, inverse)` | **Execute coordinate transformation** |
|
|
193
|
+
| `getCompiled()` | **Get serializable state** |
|
|
194
|
+
| `setCompiled(state)` | **Restore from serialized state** |
|
|
195
|
+
|
|
196
|
+
### Error Handling
|
|
197
|
+
|
|
198
|
+
The library may throw errors in the following cases:
|
|
199
|
+
|
|
200
|
+
- `"TOO LINEAR1"`,`"TOO LINEAR2"`: Control points are too linear
|
|
201
|
+
- `"SOME POINTS OUTSIDE"`: Points outside boundary
|
|
202
|
+
- Custom error when attempting backward transformation in a disallowed state
|
|
203
|
+
|
|
204
|
+
## License
|
|
205
|
+
|
|
206
|
+
Maplat Limited License 1.1
|
|
207
|
+
|
|
208
|
+
Copyright (c) 2024 Code for History
|
|
209
|
+
|
|
210
|
+
## Developers
|
|
211
|
+
|
|
212
|
+
- Kohei Otsuka
|
|
213
|
+
- Code for History
|
|
214
|
+
|
|
215
|
+
We welcome your contributions! Feel free to submit [issues and pull requests](https://github.com/code4history/MaplatTin/issues).
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Position } from 'geojson';
|
|
2
|
+
import { VertexPosition } from "./types/tin.d";
|
|
3
|
+
interface ConvexEntry {
|
|
4
|
+
forw: Position;
|
|
5
|
+
bakw: Position;
|
|
6
|
+
}
|
|
7
|
+
interface BoundaryVerticesParams {
|
|
8
|
+
convexBuf: Record<string, ConvexEntry>;
|
|
9
|
+
centroid: {
|
|
10
|
+
forw: Position;
|
|
11
|
+
bakw: Position;
|
|
12
|
+
};
|
|
13
|
+
bbox: Position[];
|
|
14
|
+
minx: number;
|
|
15
|
+
maxx: number;
|
|
16
|
+
miny: number;
|
|
17
|
+
maxy: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Calculate the standard four boundary vertices around the centroid.
|
|
21
|
+
*/
|
|
22
|
+
export declare function calculatePlainVertices(params: BoundaryVerticesParams): VertexPosition[];
|
|
23
|
+
/**
|
|
24
|
+
* Calculate boundary vertices for bird's-eye mode using quadrant-aware ratios.
|
|
25
|
+
*/
|
|
26
|
+
export declare function calculateBirdeyeVertices(params: BoundaryVerticesParams): VertexPosition[];
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export interface DelaunatorLike {
|
|
2
|
+
coords: {
|
|
3
|
+
readonly length: number;
|
|
4
|
+
readonly [index: number]: number;
|
|
5
|
+
};
|
|
6
|
+
triangles: {
|
|
7
|
+
readonly length: number;
|
|
8
|
+
[index: number]: number;
|
|
9
|
+
};
|
|
10
|
+
halfedges: {
|
|
11
|
+
readonly length: number;
|
|
12
|
+
[index: number]: number;
|
|
13
|
+
};
|
|
14
|
+
hull: {
|
|
15
|
+
readonly length: number;
|
|
16
|
+
readonly [index: number]: number;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export declare function nextEdge(edge: number): number;
|
|
20
|
+
export declare function prevEdge(edge: number): number;
|
|
21
|
+
/**
|
|
22
|
+
* Compute if two line segments [p1, p2] and [p3, p4] intersect.
|
|
23
|
+
*/
|
|
24
|
+
export declare function intersectSegments(p1x: number, p1y: number, p2x: number, p2y: number, p3x: number, p3y: number, p4x: number, p4y: number): boolean;
|
|
25
|
+
export declare class Base {
|
|
26
|
+
/**
|
|
27
|
+
* The triangulation object from Delaunator.
|
|
28
|
+
*/
|
|
29
|
+
del: DelaunatorLike;
|
|
30
|
+
constructor(del: DelaunatorLike);
|
|
31
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A set of numbers, stored as bits in a typed array.
|
|
3
|
+
* The amount of numbers that can be stored is limited by the length,
|
|
4
|
+
* which is fixed at construction time.
|
|
5
|
+
*/
|
|
6
|
+
declare abstract class BitSet {
|
|
7
|
+
protected readonly bs: Uint8Array | Uint16Array | Uint32Array;
|
|
8
|
+
protected readonly width: 8 | 16 | 32;
|
|
9
|
+
protected constructor(width: BitSet["width"], bs: BitSet["bs"]);
|
|
10
|
+
/**
|
|
11
|
+
* Add a number to the set.
|
|
12
|
+
*
|
|
13
|
+
* @param idx The number to add. Must be 0 <= idx < len.
|
|
14
|
+
*/
|
|
15
|
+
add(idx: number): this;
|
|
16
|
+
/**
|
|
17
|
+
* Delete a number from the set.
|
|
18
|
+
*
|
|
19
|
+
* @param idx The number to delete. Must be 0 <= idx < len.
|
|
20
|
+
*/
|
|
21
|
+
delete(idx: number): this;
|
|
22
|
+
/**
|
|
23
|
+
* Add or delete a number in the set, depending on the second argument.
|
|
24
|
+
*
|
|
25
|
+
* @param idx The number to add or delete. Must be 0 <= idx < len.
|
|
26
|
+
* @param val If true, add the number, otherwise delete.
|
|
27
|
+
*/
|
|
28
|
+
set(idx: number, val: boolean): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Whether the number is in the set.
|
|
31
|
+
*
|
|
32
|
+
* @param idx The number to test. Must be 0 <= idx < len.
|
|
33
|
+
*/
|
|
34
|
+
has(idx: number): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Iterate over the numbers that are in the set.
|
|
37
|
+
*/
|
|
38
|
+
forEach(fn: (idx: number) => void): this;
|
|
39
|
+
}
|
|
40
|
+
export type { BitSet };
|
|
41
|
+
/**
|
|
42
|
+
* A bit set using 8 bits per cell.
|
|
43
|
+
*/
|
|
44
|
+
export declare class BitSet8 extends BitSet {
|
|
45
|
+
constructor(len: number);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* A bit set using 16 bits per cell.
|
|
49
|
+
*/
|
|
50
|
+
export declare class BitSet16 extends BitSet {
|
|
51
|
+
constructor(len: number);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* A bit set using 32 bits per cell.
|
|
55
|
+
*/
|
|
56
|
+
export declare class BitSet32 extends BitSet {
|
|
57
|
+
constructor(len: number);
|
|
58
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Base, DelaunatorLike, intersectSegments as baseIntersectSegments } from "./base";
|
|
2
|
+
import { BitSet } from "./bitset";
|
|
3
|
+
export declare class Constrain extends Base {
|
|
4
|
+
vertMap: Uint32Array;
|
|
5
|
+
flips: BitSet;
|
|
6
|
+
consd: BitSet;
|
|
7
|
+
/**
|
|
8
|
+
* Create a Constrain instance.
|
|
9
|
+
*
|
|
10
|
+
* @param del The triangulation output from Delaunator.
|
|
11
|
+
* @param edges If provided, constrain these edges via constrainAll.
|
|
12
|
+
*/
|
|
13
|
+
constructor(del: DelaunatorLike, edges?: readonly [number, number][]);
|
|
14
|
+
/**
|
|
15
|
+
* Constrain the triangulation such that there is an edge between p1 and p2.
|
|
16
|
+
*/
|
|
17
|
+
constrainOne(segP1: number, segP2: number): number;
|
|
18
|
+
/**
|
|
19
|
+
* Fix the Delaunay condition.
|
|
20
|
+
*/
|
|
21
|
+
delaunify(deep?: boolean): this;
|
|
22
|
+
/**
|
|
23
|
+
* Call constrainOne on each edge.
|
|
24
|
+
*/
|
|
25
|
+
constrainAll(edges: readonly [number, number][]): this;
|
|
26
|
+
/**
|
|
27
|
+
* Whether an edge is constrained.
|
|
28
|
+
*/
|
|
29
|
+
isConstrained(edg: number): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Find the edge that points from p1 -> p2. If there is only an edge from
|
|
32
|
+
* p2 -> p1 (i.e. it is on the hull), returns the negative id of it.
|
|
33
|
+
*/
|
|
34
|
+
findEdge(p1: number, p2: number): number;
|
|
35
|
+
/**
|
|
36
|
+
* Mark an edge as constrained, i.e. should not be touched by `delaunify`.
|
|
37
|
+
*/
|
|
38
|
+
private protect;
|
|
39
|
+
/**
|
|
40
|
+
* Mark an edge as flipped unless constrained.
|
|
41
|
+
*/
|
|
42
|
+
private markFlip;
|
|
43
|
+
/**
|
|
44
|
+
* Flip the edge shared by two triangles.
|
|
45
|
+
*/
|
|
46
|
+
private flipDiagonal;
|
|
47
|
+
/**
|
|
48
|
+
* Whether point p1, p2, and p are collinear.
|
|
49
|
+
*/
|
|
50
|
+
private isCollinear;
|
|
51
|
+
/**
|
|
52
|
+
* Whether the triangle formed by p1, p2, p3 keeps px outside the circumcircle.
|
|
53
|
+
*/
|
|
54
|
+
private inCircle;
|
|
55
|
+
/**
|
|
56
|
+
* Whether the triangles sharing edg conform to the Delaunay condition.
|
|
57
|
+
*/
|
|
58
|
+
private isDelaunay;
|
|
59
|
+
/**
|
|
60
|
+
* Update the vertex -> incoming edge map.
|
|
61
|
+
*/
|
|
62
|
+
private updateVert;
|
|
63
|
+
/**
|
|
64
|
+
* Whether the segments between vertices intersect.
|
|
65
|
+
*/
|
|
66
|
+
protected intersectSegments(p1: number, p2: number, p3: number, p4: number): boolean;
|
|
67
|
+
static intersectSegments: typeof baseIntersectSegments;
|
|
68
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export { Tin } from "./tin";
|
|
8
8
|
export type { Options } from "./tin";
|
|
9
|
+
export { Tin as default } from "./tin";
|
|
9
10
|
export { default as constrainedTin } from "./constrained-tin";
|
|
10
11
|
export { default as findIntersections } from "./kinks";
|
|
11
12
|
export { insertSearchIndex } from "./searchutils";
|