@dra2020/baseclient 1.0.98 → 1.0.99
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/dist/baseclient.js +21 -1
- package/dist/baseclient.js.map +1 -1
- package/dist/poly/union.d.ts +1 -0
- package/lib/poly/union.ts +24 -0
- package/package.json +1 -1
package/dist/poly/union.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import * as FSM from '../fsm/all';
|
|
|
2
2
|
import * as Poly from './poly';
|
|
3
3
|
import * as Q from './quad';
|
|
4
4
|
export declare function polyIntersects(p1: any, p2: any): boolean;
|
|
5
|
+
export declare function polyIntersectArea(p1: any, p2: any): number;
|
|
5
6
|
export declare function polyDifference(main: any, parts: any[]): any;
|
|
6
7
|
declare class FsmDifference extends FSM.Fsm {
|
|
7
8
|
accum: any;
|
package/lib/poly/union.ts
CHANGED
|
@@ -59,6 +59,30 @@ export function polyIntersects(p1: any, p2: any): boolean
|
|
|
59
59
|
return bIntersects;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
export function polyIntersectArea(p1: any, p2: any): number
|
|
63
|
+
{
|
|
64
|
+
let pp1 = Poly.polyNormalize(p1);
|
|
65
|
+
let pp2 = Poly.polyNormalize(p2);
|
|
66
|
+
let area: number = 0;
|
|
67
|
+
|
|
68
|
+
PP.polyPackEachRing(pp1, (buffer1: Float64Array, iPoly1: number, iRing1: number, iOffset1: number, nPoints1: number) => {
|
|
69
|
+
if (iRing1 == 0)
|
|
70
|
+
{
|
|
71
|
+
let c1 = unpackCoords(buffer1, iOffset1, nPoints1);
|
|
72
|
+
PP.polyPackEachRing(pp2, (buffer2: Float64Array, iPoly2: number, iRing2: number, iOffset2: number, nPoints2: number) => {
|
|
73
|
+
if (iRing2 == 0)
|
|
74
|
+
{
|
|
75
|
+
let c2 = unpackCoords(buffer2, iOffset2, nPoints2);
|
|
76
|
+
let result = _intersection(c1, c2);
|
|
77
|
+
if (result && result.length > 0)
|
|
78
|
+
area += Poly.polyArea(result);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
return area;
|
|
84
|
+
}
|
|
85
|
+
|
|
62
86
|
export function polyDifference(main: any, parts: any[]): any
|
|
63
87
|
{
|
|
64
88
|
main = PP.polyUnpack(coords(main));
|