rapid-spreadjs 1.0.172 → 1.0.173
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/index.cjs.js +72 -0
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs.min.js +1 -1
- package/dist/index.cjs.min.js.map +1 -1
- package/dist/index.esm.js +72 -0
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -23802,6 +23802,78 @@ const FormulaUtils = {
|
|
|
23802
23802
|
return qdhsz;
|
|
23803
23803
|
},
|
|
23804
23804
|
},
|
|
23805
|
+
{
|
|
23806
|
+
funName: 'YJZBPD',
|
|
23807
|
+
funDesc: '报告上根据技术要求进行坐标判定',
|
|
23808
|
+
funDefaultVal: null,
|
|
23809
|
+
funParams: [
|
|
23810
|
+
{
|
|
23811
|
+
name: '四边形坐标,格式如 (0,0):(3,7):(15,8):(9.5,3.3)',
|
|
23812
|
+
repeatable: false,
|
|
23813
|
+
optional: false,
|
|
23814
|
+
},
|
|
23815
|
+
{
|
|
23816
|
+
name: '目标点x坐标',
|
|
23817
|
+
repeatable: false,
|
|
23818
|
+
optional: false,
|
|
23819
|
+
},
|
|
23820
|
+
{
|
|
23821
|
+
name: '目标点y坐标',
|
|
23822
|
+
repeatable: false,
|
|
23823
|
+
optional: false,
|
|
23824
|
+
},
|
|
23825
|
+
],
|
|
23826
|
+
funCallback: (spread, sheet, retData) => {
|
|
23827
|
+
// 如果传递的参数小于3个,则返回/
|
|
23828
|
+
if (retData.allCellVals.length < 3) {
|
|
23829
|
+
return '/';
|
|
23830
|
+
}
|
|
23831
|
+
let points = retData.allCellVals[0], xPoint = retData.allCellVals[1], yPoint = retData.allCellVals[2];
|
|
23832
|
+
// 1. 格式校验
|
|
23833
|
+
if (typeof points !== 'string' || !points)
|
|
23834
|
+
return '/';
|
|
23835
|
+
const regex = /^\s*\(\s*(-?\d+(?:\.\d+)?)\s*,\s*(-?\d+(?:\.\d+)?)\s*\)\s*:\s*\(\s*(-?\d+(?:\.\d+)?)\s*,\s*(-?\d+(?:\.\d+)?)\s*\)\s*:\s*\(\s*(-?\d+(?:\.\d+)?)\s*,\s*(-?\d+(?:\.\d+)?)\s*\)\s*:\s*\(\s*(-?\d+(?:\.\d+)?)\s*,\s*(-?\d+(?:\.\d+)?)\s*\)\s*$/;
|
|
23836
|
+
const match = points.match(regex);
|
|
23837
|
+
if (!match)
|
|
23838
|
+
return '/';
|
|
23839
|
+
// 2. 解析坐标
|
|
23840
|
+
const coords = [];
|
|
23841
|
+
for (let i = 1; i < match.length; i += 2) {
|
|
23842
|
+
coords.push({ x: parseFloat(match[i]), y: parseFloat(match[i + 1]) });
|
|
23843
|
+
}
|
|
23844
|
+
const tx = Number(xPoint), ty = Number(yPoint);
|
|
23845
|
+
if (isNaN(tx) || isNaN(ty))
|
|
23846
|
+
return '/';
|
|
23847
|
+
// 3. 【新增】边界判定:点到线段距离 ≤ 容差 → 直接合格
|
|
23848
|
+
const EPSILON = 1e-9;
|
|
23849
|
+
function pointToSegmentDistSq(px, py, ax, ay, bx, by) {
|
|
23850
|
+
const dx = bx - ax, dy = by - ay;
|
|
23851
|
+
const lenSq = dx * dx + dy * dy;
|
|
23852
|
+
if (lenSq === 0)
|
|
23853
|
+
return (px - ax) ** 2 + (py - ay) ** 2; // 退化为点
|
|
23854
|
+
let t = ((px - ax) * dx + (py - ay) * dy) / lenSq;
|
|
23855
|
+
t = Math.max(0, Math.min(1, t)); // 钳制到 [0,1]
|
|
23856
|
+
const projX = ax + t * dx, projY = ay + t * dy;
|
|
23857
|
+
return (px - projX) ** 2 + (py - projY) ** 2;
|
|
23858
|
+
}
|
|
23859
|
+
const n = coords.length;
|
|
23860
|
+
for (let i = 0, j = n - 1; i < n; j = i++) {
|
|
23861
|
+
const distSq = pointToSegmentDistSq(tx, ty, coords[j].x, coords[j].y, coords[i].x, coords[i].y);
|
|
23862
|
+
if (distSq <= EPSILON * EPSILON)
|
|
23863
|
+
return '合格';
|
|
23864
|
+
}
|
|
23865
|
+
// 4. 射线法判定内部
|
|
23866
|
+
let inside = false;
|
|
23867
|
+
for (let i = 0, j = n - 1; i < n; j = i++) {
|
|
23868
|
+
const xi = coords[i].x, yi = coords[i].y;
|
|
23869
|
+
const xj = coords[j].x, yj = coords[j].y;
|
|
23870
|
+
const intersect = yi > ty !== yj > ty && tx < ((xj - xi) * (ty - yi)) / (yj - yi) + xi;
|
|
23871
|
+
if (intersect)
|
|
23872
|
+
inside = !inside;
|
|
23873
|
+
}
|
|
23874
|
+
return inside ? '合格' : '不合格';
|
|
23875
|
+
},
|
|
23876
|
+
},
|
|
23805
23877
|
{
|
|
23806
23878
|
funName: 'YJTEST',
|
|
23807
23879
|
funDesc: '云检测试函数',
|