@maplat/tin 0.9.4 → 0.11.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 +176 -0
- package/README.md +143 -77
- package/dist/constrained-tin.d.ts +29 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.html +42 -0
- package/dist/kinks.d.ts +8 -0
- package/dist/searchutils.d.ts +21 -0
- package/dist/tin.cjs +3 -0
- package/dist/tin.d.ts +100 -0
- package/dist/tin.js +2090 -0
- package/dist/tin.umd.js +3 -0
- package/dist/vertexutils.d.ts +24 -0
- package/package.json +97 -81
- package/src/constrained-tin.ts +79 -0
- package/src/index.ts +41 -0
- package/src/kinks.ts +1035 -0
- package/src/searchutils.ts +67 -0
- package/src/tin.ts +894 -0
- package/src/types/cdt2d.d.ts +4 -0
- package/src/types/constrainautor.d.ts +6 -0
- package/src/types/kinks.d.ts +36 -0
- package/src/types/tin.d.ts +54 -0
- package/src/vertexutils.ts +83 -0
- package/es5/index.js +0 -3
- package/es5/index.js.LICENSE.txt +0 -10
- package/es5/index.js.map +0 -1
- package/lib/booleanPointInPolygon.d.ts +0 -4
- package/lib/booleanPointInPolygon.js +0 -103
- package/lib/booleanPointInPolygon.js.map +0 -1
- package/lib/constrained-tin.d.ts +0 -4
- package/lib/constrained-tin.js +0 -41
- package/lib/constrained-tin.js.map +0 -1
- package/lib/index.d.ts +0 -157
- package/lib/index.js +0 -1472
- package/lib/index.js.map +0 -1
- package/lib/kinks.d.ts +0 -2
- package/lib/kinks.js +0 -669
- package/lib/kinks.js.map +0 -1
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export interface IntersectionPoint {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export type ArcCallback = (i: number, j: number, xx: Float64Array, yy: Float64Array) => void;
|
|
8
|
+
export type ForEachSegmentCallback = (v1: number, v2: number, xx: Float64Array, yy: Float64Array) => void;
|
|
9
|
+
|
|
10
|
+
export interface Arc {
|
|
11
|
+
i: number;
|
|
12
|
+
j: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export class ArcIter {
|
|
16
|
+
_xx: Float64Array | null;
|
|
17
|
+
_yy: Float64Array | null;
|
|
18
|
+
_zz: Float64Array | null;
|
|
19
|
+
_arc: Arc | null;
|
|
20
|
+
_i: number;
|
|
21
|
+
_n: number;
|
|
22
|
+
_inc: number;
|
|
23
|
+
_useZ: boolean;
|
|
24
|
+
x: number;
|
|
25
|
+
y: number;
|
|
26
|
+
z: number;
|
|
27
|
+
|
|
28
|
+
constructor(xx: Float64Array | null, yy: Float64Array | null, zz?: Float64Array | null);
|
|
29
|
+
init(i: number, len: number, fw: boolean, zlim?: number): ArcIter;
|
|
30
|
+
hasNext(): boolean;
|
|
31
|
+
next(): void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export class FilteredArcIter extends ArcIter {
|
|
35
|
+
constructor();
|
|
36
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { Point, Position, FeatureCollection, Polygon } from "geojson";
|
|
2
|
+
|
|
3
|
+
export interface PointsSetBD {
|
|
4
|
+
forw: FeatureCollection<Point>;
|
|
5
|
+
bakw: FeatureCollection<Point>;
|
|
6
|
+
edges: number[][];
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface VertexDelta {
|
|
10
|
+
forw: [number, number];
|
|
11
|
+
bakw?: [number, number];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface WeightBuffer {
|
|
15
|
+
[target: string]: {
|
|
16
|
+
[vertexKey: string]: {
|
|
17
|
+
[edgeKey: string]: number;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type LengthItem = [Position, number, number, number, string?];
|
|
23
|
+
|
|
24
|
+
export interface EdgeProperties {
|
|
25
|
+
a?: any;
|
|
26
|
+
b?: any;
|
|
27
|
+
c?: any;
|
|
28
|
+
index?: string | number;
|
|
29
|
+
geom?: Position;
|
|
30
|
+
target?: {
|
|
31
|
+
geom: Position;
|
|
32
|
+
index: string | number;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type VertexParams = [number[], FeatureCollection<Polygon>[]];
|
|
37
|
+
|
|
38
|
+
export interface TriangleProperties {
|
|
39
|
+
a?: any; // This should match the z parameter type from @maplat/transform
|
|
40
|
+
b?: any;
|
|
41
|
+
c?: any;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface VertexPosition {
|
|
45
|
+
forw: Position;
|
|
46
|
+
bakw: Position;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface ExpandConvexItem {
|
|
50
|
+
forw: Position;
|
|
51
|
+
bakw: Position;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export type ExpandConvexArray = ExpandConvexItem[][];
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { point } from "@turf/helpers";
|
|
2
|
+
import { featureCollection, polygon } from "@turf/helpers";
|
|
3
|
+
import type { Feature, Point, Position } from "geojson";
|
|
4
|
+
import type { Tins } from "@maplat/transform";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 座標と属性から点オブジェクトを生成する
|
|
8
|
+
* @param xy 座標値
|
|
9
|
+
* @param geom 変換先での座標値
|
|
10
|
+
* @param index インデックス
|
|
11
|
+
* @returns 生成された点オブジェクト
|
|
12
|
+
*/
|
|
13
|
+
function createPoint(xy: Position, geom: Position, index: string | number): Feature<Point> {
|
|
14
|
+
return point(xy, { target: { geom, index } });
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 点オブジェクトの座標系を反転する
|
|
19
|
+
* @param apoint 元の点オブジェクト
|
|
20
|
+
* @returns 座標系が反転された点オブジェクト
|
|
21
|
+
*/
|
|
22
|
+
function counterPoint(apoint: Feature<Point>): Feature<Point> {
|
|
23
|
+
return point(apoint.properties!.target.geom, {
|
|
24
|
+
target: {
|
|
25
|
+
geom: apoint.geometry!.coordinates,
|
|
26
|
+
index: apoint.properties!.target.index
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 頂点リストから頂点パラメータを計算する
|
|
33
|
+
* @param list 頂点リスト
|
|
34
|
+
* @param centroid 重心点
|
|
35
|
+
* @returns [角度リスト, 三角形リスト]
|
|
36
|
+
*/
|
|
37
|
+
function vertexCalc(list: Feature<Point>[], centroid: Feature<Point>): [number[], Tins[]?] {
|
|
38
|
+
const centCoord = centroid.geometry!.coordinates;
|
|
39
|
+
return [0, 1, 2, 3]
|
|
40
|
+
.map(i => {
|
|
41
|
+
const j = (i + 1) % 4;
|
|
42
|
+
const itemi = list[i];
|
|
43
|
+
const itemj = list[j];
|
|
44
|
+
const coord = itemi.geometry!.coordinates;
|
|
45
|
+
const radian = Math.atan2(
|
|
46
|
+
coord[0] - centCoord[0],
|
|
47
|
+
coord[1] - centCoord[1]
|
|
48
|
+
);
|
|
49
|
+
const coordinates = [centroid, itemi, itemj, centroid].map(
|
|
50
|
+
point => point.geometry!.coordinates
|
|
51
|
+
);
|
|
52
|
+
const properties = {
|
|
53
|
+
a: {
|
|
54
|
+
geom: centroid.properties!.target.geom,
|
|
55
|
+
index: centroid.properties!.target.index
|
|
56
|
+
},
|
|
57
|
+
b: {
|
|
58
|
+
geom: itemi.properties!.target.geom,
|
|
59
|
+
index: itemi.properties!.target.index
|
|
60
|
+
},
|
|
61
|
+
c: {
|
|
62
|
+
geom: itemj.properties!.target.geom,
|
|
63
|
+
index: itemj.properties!.target.index
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
const tin = featureCollection([polygon([coordinates], properties)]) as Tins;
|
|
67
|
+
return [radian, tin] as [number, Tins];
|
|
68
|
+
})
|
|
69
|
+
.reduce(
|
|
70
|
+
(prev, curr) => {
|
|
71
|
+
prev[0].push(curr[0]);
|
|
72
|
+
prev[1].push(curr[1]);
|
|
73
|
+
return prev;
|
|
74
|
+
},
|
|
75
|
+
[[] as number[], [] as Tins[]]
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export {
|
|
80
|
+
createPoint,
|
|
81
|
+
counterPoint,
|
|
82
|
+
vertexCalc
|
|
83
|
+
};
|