ebta-workflow-prod 4.1.4 → 4.1.5

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ebta-workflow-prod",
3
3
  "private": false,
4
- "version": "4.1.4",
4
+ "version": "4.1.5",
5
5
  "description": "",
6
6
  "license": "UNLICENSED",
7
7
  "author": "",
@@ -4,9 +4,9 @@ import { FormElementProps, FormElementRegistration } from "@vertigis/workflow";
4
4
  import { ColorInput, ColorPicker } from '@mantine/core';
5
5
  type ColorFormat = "hex" | "rgba" | "rgb" | "hsl" | "hsla";
6
6
 
7
- //import "@mantine/core/styles.css";
7
+ import "@mantine/core/styles.css";
8
8
  //Causing shrink
9
- import "../styles/mantine-scoped.css";
9
+ //import "../styles/mantine-scoped.css";
10
10
  import Color from "@arcgis/core/Color";
11
11
 
12
12
 
@@ -80,7 +80,7 @@ function CsColorPickerV2(props: CsColorPickerV2Props): React.ReactElement {
80
80
  };
81
81
 
82
82
  return (
83
- <div className="vertigis-mantine-scope">
83
+
84
84
  <MantineProvider withStaticClasses withGlobalClasses classNamesPrefix="ebta-mantime">
85
85
  {componentType === "ColorInput" ? (
86
86
  <ColorInput
@@ -107,7 +107,6 @@ function CsColorPickerV2(props: CsColorPickerV2Props): React.ReactElement {
107
107
  />
108
108
  )}
109
109
  </MantineProvider>
110
- </div>
111
110
  );
112
111
  }
113
112
 
@@ -2,7 +2,7 @@ import * as React from "react";
2
2
  import { FormElementProps, FormElementRegistration } from "@vertigis/workflow";
3
3
  import { Timeline as MainTimeLine, Text } from '@mantine/core';
4
4
  import { MantineProvider } from '@mantine/core';
5
- import "../styles/mantine-scoped.css";
5
+ //import "../styles/mantine-scoped.css";
6
6
 
7
7
  /**
8
8
  * The generic type argument provided to `FormElementProps<T>` controls the type
@@ -41,7 +41,7 @@ function Timeline(props: TimelineProps): React.ReactElement {
41
41
  const { itemDetails, iconSize, lineWidth, active, color, reverseActive } = props;
42
42
  iconSize * 0.6
43
43
  return (
44
- <div className="vertigis-mantine-scope">
44
+
45
45
  <MantineProvider>
46
46
  <MainTimeLine active={active} bulletSize={iconSize} lineWidth={lineWidth} color={color} reverseActive={reverseActive}>
47
47
 
@@ -64,7 +64,6 @@ function Timeline(props: TimelineProps): React.ReactElement {
64
64
  </MainTimeLine>
65
65
 
66
66
  </MantineProvider>
67
- </div>
68
67
  );
69
68
  }
70
69
 
package/src/index.ts CHANGED
@@ -41,6 +41,3 @@ export { default as DrapGeometryActivity } from "./activities/DrapGeometry";
41
41
  export { default as SampleActivity } from "./activities/Sample";
42
42
  export { default as SampleInputRegistration } from "./elements/SampleInput";
43
43
 
44
-
45
-
46
- export { default as SimplifyGeometryActivity } from "./activities/SimplifyGeometry";
Binary file
@@ -1,239 +0,0 @@
1
- import type { IActivityHandler } from "@vertigis/workflow";
2
-
3
- import Polygon from "@arcgis/core/geometry/Polygon";
4
- import SpatialReference from "@arcgis/core/geometry/SpatialReference";
5
-
6
-
7
- /** An interface that defines the inputs of the activity. */
8
- interface SimplifyGeometryInputs {
9
- /**
10
- * @displayName Geometry
11
- * @description The geometry to be simplified.
12
- * @required
13
- */
14
- geometry: Polygon;
15
-
16
- /**
17
- * @displayName Vertex Limit
18
- * @description The maximum number of vertices allowed in the simplified geometry.
19
- */
20
- vertlimit?: number;
21
- }
22
-
23
- /** An interface that defines the outputs of the activity. */
24
- interface SimplifyGeometryOutputs {
25
- /**
26
- * @description The result of the activity.
27
- */
28
- result: Polygon;
29
- }
30
-
31
- /**
32
- * @displayName SimplifyGeometry
33
- * @category Custom Activities
34
- * @description Simplify geometry - covering the whole geometry and increase minimum extra area, under required vertex amount.
35
- */
36
- export default class SimplifyGeometryActivity implements IActivityHandler {
37
- /** Perform the execution logic of the activity. */
38
-
39
- execute(inputs: SimplifyGeometryInputs): SimplifyGeometryOutputs {
40
-
41
- // Clone the whole result so we never touch the original $permitFeature.result
42
- let simplifyresult = inputs.geometry;
43
- let limit = inputs.vertlimit || 30;
44
-
45
- let ring = simplifyresult.rings[0];
46
-
47
- if (ring.length > limit) {
48
- ring = coveringSimplify(ring, limit);
49
-
50
- simplifyresult.rings[0] = ring;
51
- }
52
-
53
- return { result: simplifyresult };
54
-
55
-
56
-
57
-
58
- // ---- geometry helpers ----
59
- function cross(o, a, b) {
60
- return (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0]);
61
- }
62
- function triangleArea(a, b, c) {
63
- return Math.abs(cross(a, b, c)) / 2;
64
- }
65
- function signedArea(points) {
66
- var area = 0, n = points.length;
67
- for (var i = 0; i < n; i++) {
68
- var p1 = points[i], p2 = points[(i + 1) % n];
69
- area += p1[0] * p2[1] - p2[0] * p1[1];
70
- }
71
- return area / 2;
72
- }
73
-
74
- // orientation: >0 CCW turn, <0 CW turn, 0 collinear
75
- function orient(a, b, c) {
76
- var v = (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]);
77
- if (v > 1e-9) return 1;
78
- if (v < -1e-9) return -1;
79
- return 0;
80
- }
81
-
82
- // true only for a PROPER crossing (interior intersection), not shared endpoints/touching
83
- function properlyIntersects(p1, p2, p3, p4) {
84
- var d1 = orient(p3, p4, p1);
85
- var d2 = orient(p3, p4, p2);
86
- var d3 = orient(p1, p2, p3);
87
- var d4 = orient(p1, p2, p4);
88
- return (d1 !== d2 && d1 !== 0 && d2 !== 0) && (d3 !== d4 && d3 !== 0 && d4 !== 0);
89
- }
90
-
91
- // does chording out vertex i (prev->next) cross any OTHER edge of
92
- // the polygon? Required check — without it, concave removal can
93
- // fold the polygon over itself into a self-intersecting bowtie on
94
- // complex shapes (forks, interchanges, multiple concavities).
95
- function chordIsSafe(pts, i) {
96
- var n = pts.length;
97
- var prev = pts[(i - 1 + n) % n];
98
- var next = pts[(i + 1) % n];
99
-
100
- for (var k = 0; k < n; k++) {
101
- var a = pts[k];
102
- var b = pts[(k + 1) % n];
103
- if (k === (i - 1 + n) % n || k === i) continue; // the two edges being replaced
104
- if (properlyIntersects(prev, next, a, b)) return false;
105
- }
106
- return true;
107
- }
108
-
109
- // Remove reflex (concave) vertices, cheapest-area first, but only
110
- // when the resulting chord doesn't self-intersect the polygon.
111
- // Chording a safe concave notch always ADDS area outside the
112
- // original shape, so coverage is preserved automatically.
113
- function removeReflexVertices(points, maxVertices) {
114
- var pts = points.slice();
115
- var orientSign = signedArea(pts) >= 0 ? 1 : -1;
116
-
117
- var progress = true;
118
- while (pts.length > maxVertices && progress) {
119
- progress = false;
120
- var n = pts.length;
121
- var candidates = [];
122
-
123
- for (var i = 0; i < n; i++) {
124
- var prev = pts[(i - 1 + n) % n];
125
- var curr = pts[i];
126
- var next = pts[(i + 1) % n];
127
- var c = cross(prev, curr, next);
128
- var isReflexOrFlat = c * orientSign <= 1e-9;
129
- if (isReflexOrFlat) {
130
- candidates.push({ idx: i, area: triangleArea(prev, curr, next) });
131
- }
132
- }
133
-
134
- candidates.sort(function (a, b) { return a.area - b.area; });
135
-
136
- for (var ci = 0; ci < candidates.length; ci++) {
137
- var idx = candidates[ci].idx;
138
- if (chordIsSafe(pts, idx)) {
139
- pts.splice(idx, 1);
140
- progress = true;
141
- break; // recompute fresh each removal since indices shift
142
- }
143
- }
144
- }
145
-
146
- return pts;
147
- }
148
-
149
- // Infinite-line intersection of (p1,p2) and (p3,p4).
150
- function lineIntersection(p1, p2, p3, p4) {
151
- var x1 = p1[0], y1 = p1[1], x2 = p2[0], y2 = p2[1];
152
- var x3 = p3[0], y3 = p3[1], x4 = p4[0], y4 = p4[1];
153
- var denom = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4);
154
- if (Math.abs(denom) < 1e-9) return [(x2 + x3) / 2, (y2 + y3) / 2];
155
- var pxNum = (x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - y3 * x4);
156
- var pyNum = (x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - y3 * x4);
157
- return [pxNum / denom, pyNum / denom];
158
- }
159
-
160
- // Standard monotone-chain convex hull — guaranteed simple and
161
- // guaranteed to cover any input point set, regardless of how tangled
162
- // the remaining shape is. Used as a safe fallback.
163
- function convexHull(points) {
164
- var sorted = points.slice().sort(function (a, b) { return a[0] === b[0] ? a[1] - b[1] : a[0] - b[0]; });
165
- var pts = [];
166
- for (var i = 0; i < sorted.length; i++) {
167
- var p = sorted[i], prev = pts[pts.length - 1];
168
- if (!prev || prev[0] !== p[0] || prev[1] !== p[1]) pts.push(p);
169
- }
170
- var n = pts.length;
171
- if (n < 3) return pts.slice();
172
- var lower = [];
173
- for (var i2 = 0; i2 < n; i2++) {
174
- while (lower.length >= 2 && cross(lower[lower.length - 2], lower[lower.length - 1], pts[i2]) <= 0) lower.pop();
175
- lower.push(pts[i2]);
176
- }
177
- var upper = [];
178
- for (var i3 = n - 1; i3 >= 0; i3--) {
179
- while (upper.length >= 2 && cross(upper[upper.length - 2], upper[upper.length - 1], pts[i3]) <= 0) upper.pop();
180
- upper.push(pts[i3]);
181
- }
182
- lower.pop(); upper.pop();
183
- return lower.concat(upper);
184
- }
185
-
186
- // Reduce an already-convex polygon to maxVertices by selecting
187
- // maxVertices of its edges (evenly spaced) as infinite support lines
188
- // and intersecting consecutive ones. Always contains the input.
189
- function reduceConvexBySupportLines(points, maxVertices) {
190
- var n = points.length;
191
- if (n <= maxVertices) return points.slice();
192
- var chosen = [];
193
- for (var k = 0; k < maxVertices; k++) chosen.push(Math.floor((k * n) / maxVertices));
194
- var newPts = [];
195
- for (var k2 = 0; k2 < maxVertices; k2++) {
196
- var iPrevEdge = chosen[(k2 - 1 + maxVertices) % maxVertices];
197
- var iCurrEdge = chosen[k2];
198
- var a1 = points[iPrevEdge], a2 = points[(iPrevEdge + 1) % n];
199
- var b1 = points[iCurrEdge], b2 = points[(iCurrEdge + 1) % n];
200
- newPts.push(lineIntersection(a1, a2, b1, b2));
201
- }
202
- return newPts;
203
- }
204
-
205
- // Simplify a ring to at most maxVertices points, guaranteeing the
206
- // result is both SIMPLE (no self-intersections) and always covers
207
- // (contains) the original shape.
208
- function coveringSimplify(ring, maxVertices) {
209
- var first = ring[0], last = ring[ring.length - 1];
210
- var isClosed = first[0] === last[0] && first[1] === last[1];
211
- var open = isClosed ? ring.slice(0, ring.length - 1) : ring.slice();
212
- var budgetOpen = isClosed ? maxVertices - 1 : maxVertices;
213
-
214
- if (open.length <= budgetOpen) return ring.slice();
215
-
216
- var afterReflex = removeReflexVertices(open, budgetOpen);
217
-
218
- var result;
219
- if (afterReflex.length > budgetOpen) {
220
- // Couldn't safely get all the way there via reflex removal
221
- // (or the remainder is genuinely convex) — fall back to the
222
- // convex hull, which is always simple and always covers.
223
- var hull = convexHull(afterReflex);
224
- result = hull.length > budgetOpen
225
- ? reduceConvexBySupportLines(hull, budgetOpen)
226
- : hull;
227
- } else {
228
- result = afterReflex;
229
- }
230
-
231
- return isClosed ? result.concat([result[0]]) : result;
232
- }
233
-
234
-
235
- return {
236
- result: simplifyresult
237
- };
238
- }
239
- }