@maplat/tin 0.14.2 → 1.0.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/README.ja.md +12 -5
- package/README.md +13 -6
- package/dist/maplat_tin.js +2799 -2639
- package/dist/maplat_tin.umd.js +5 -5
- package/dist/strict-overlap.d.ts +22 -1
- package/dist/tin.d.ts +1 -1
- package/package.json +16 -16
- package/src/strict-overlap.ts +37 -14
- package/src/tin.ts +11 -2
package/src/strict-overlap.ts
CHANGED
|
@@ -7,6 +7,12 @@ import { insertSearchIndex, removeSearchIndex } from "./searchutils.ts";
|
|
|
7
7
|
|
|
8
8
|
type ConstraintEdges = number[][];
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* pointsSet 内の配列位置 → 頂点 index(properties.target.index)の対応表。
|
|
12
|
+
* GCP は数値、エッジ中間ノードは "e12"、境界頂点は "b3" のような文字列。
|
|
13
|
+
*/
|
|
14
|
+
export type PointIndices = readonly (number | string)[];
|
|
15
|
+
|
|
10
16
|
/** Matches the shape of PropertyTri in @maplat/transform (not publicly exported). */
|
|
11
17
|
type VertexInfo = {
|
|
12
18
|
prop: { index: number | string; geom: Position };
|
|
@@ -35,20 +41,35 @@ function isDegenerate(triangle: [number, number][], epsilon = 1e-6): boolean {
|
|
|
35
41
|
return doubleArea < epsilon;
|
|
36
42
|
}
|
|
37
43
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
/**
|
|
45
|
+
* 制約エッジを searchIndex のキー形式へ正規化した集合を作る。
|
|
46
|
+
*
|
|
47
|
+
* 二つの名前空間が混在している点に注意すること:
|
|
48
|
+
* - `edges` の要素は **pointsSet 内の配列位置**(数値)
|
|
49
|
+
* - searchIndex のキーは **頂点 index**(properties.target.index。
|
|
50
|
+
* GCP は数値だがエッジ中間ノードは "e58" のような文字列)
|
|
51
|
+
*
|
|
52
|
+
* GCP は「配列位置 == index」なので偶然一致するが、エッジ中間ノードは
|
|
53
|
+
* 配列位置と `e` の連番が別物であり、対応表なしでは一致しない。
|
|
54
|
+
* そのため pointIndices で配列位置を頂点 index へ引き直してからキー化する。
|
|
55
|
+
*
|
|
56
|
+
* キーの作り方は searchutils.ts の calcSearchKeys と厳密に揃える
|
|
57
|
+
* (String 化 → sort(既定の文字列比較)→ "-" 連結)。
|
|
58
|
+
*/
|
|
59
|
+
export function buildConstraintEdgeKeys(
|
|
60
|
+
edges: ConstraintEdges,
|
|
61
|
+
pointIndices?: PointIndices,
|
|
62
|
+
): Set<string> {
|
|
63
|
+
const keys = new Set<string>();
|
|
64
|
+
edges.forEach((edge) => {
|
|
65
|
+
if (edge.length !== 2) return;
|
|
66
|
+
const resolved = edge.map((position) => {
|
|
67
|
+
const index = pointIndices?.[position];
|
|
68
|
+
return `${index ?? position}`;
|
|
69
|
+
});
|
|
70
|
+
keys.add(resolved.sort().join("-"));
|
|
51
71
|
});
|
|
72
|
+
return keys;
|
|
52
73
|
}
|
|
53
74
|
|
|
54
75
|
function extractVertices(tri: Tri) {
|
|
@@ -174,7 +195,9 @@ export function resolveOverlaps(
|
|
|
174
195
|
tins: TinsBD,
|
|
175
196
|
searchIndex: SearchIndex,
|
|
176
197
|
edges: ConstraintEdges,
|
|
198
|
+
pointIndices?: PointIndices,
|
|
177
199
|
): boolean {
|
|
200
|
+
const constraintEdgeKeys = buildConstraintEdgeKeys(edges, pointIndices);
|
|
178
201
|
const processedKeys = new Set<string>();
|
|
179
202
|
let repaired = false;
|
|
180
203
|
|
|
@@ -191,7 +214,7 @@ export function resolveOverlaps(
|
|
|
191
214
|
const sharedKeys = key.split("-");
|
|
192
215
|
if (sharedKeys.length !== 2) continue;
|
|
193
216
|
|
|
194
|
-
if (
|
|
217
|
+
if (constraintEdgeKeys.has(key)) continue;
|
|
195
218
|
|
|
196
219
|
const tri0Bakw = extractVertices(trises[0].bakw);
|
|
197
220
|
const tri1Bakw = extractVertices(trises[1].bakw);
|
package/src/tin.ts
CHANGED
|
@@ -298,7 +298,7 @@ export class Tin extends Transform {
|
|
|
298
298
|
/**
|
|
299
299
|
* 厳密なTINを計算します
|
|
300
300
|
*/
|
|
301
|
-
|
|
301
|
+
calculateStrictTin(): void {
|
|
302
302
|
const bakTins = this.tins!.forw!.features.map((tri: Tri) =>
|
|
303
303
|
counterTri(tri)
|
|
304
304
|
);
|
|
@@ -310,10 +310,19 @@ export class Tin extends Transform {
|
|
|
310
310
|
insertSearchIndex(searchIndex, { forw: forTri, bakw: bakTri });
|
|
311
311
|
});
|
|
312
312
|
|
|
313
|
+
// pointsSet.edges の要素は pointsSet 内の「配列位置」だが、searchIndex の
|
|
314
|
+
// キーは頂点 index(properties.target.index)で作られている。
|
|
315
|
+
// エッジ中間ノードは配列位置と index("e58" 等)が一致しないため、
|
|
316
|
+
// 対応表を渡して resolveOverlaps 側でキーを揃えさせる。
|
|
317
|
+
const pointIndices = (this.pointsSet?.forw.features ?? []).map(
|
|
318
|
+
(point: Feature<Point>) => point.properties!.target.index as number | string,
|
|
319
|
+
);
|
|
320
|
+
|
|
313
321
|
resolveOverlaps(
|
|
314
322
|
this.tins!,
|
|
315
323
|
searchIndex,
|
|
316
324
|
this.pointsSet?.edges || [],
|
|
325
|
+
pointIndices,
|
|
317
326
|
);
|
|
318
327
|
|
|
319
328
|
const kinks = ["forw", "bakw"].map((direction) => {
|
|
@@ -770,7 +779,7 @@ export class Tin extends Transform {
|
|
|
770
779
|
|
|
771
780
|
// Calculate strict TIN if needed
|
|
772
781
|
if (strict === Tin.MODE_STRICT || strict === Tin.MODE_AUTO) {
|
|
773
|
-
this.
|
|
782
|
+
this.calculateStrictTin();
|
|
774
783
|
}
|
|
775
784
|
|
|
776
785
|
// Generate backward TIN if needed
|