@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.
@@ -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));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dra2020/baseclient",
3
- "version": "1.0.98",
3
+ "version": "1.0.99",
4
4
  "description": "Utility functions for Javascript projects.",
5
5
  "main": "dist/baseclient.js",
6
6
  "types": "./dist/all/all.d.ts",