@kimap/indoor-positioning-sdk-vue2 4.3.2 → 4.3.3
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 +1 -1
- package/src/KMUtil.js +14 -4
package/package.json
CHANGED
package/src/KMUtil.js
CHANGED
|
@@ -274,15 +274,16 @@
|
|
|
274
274
|
});
|
|
275
275
|
|
|
276
276
|
// 过滤掉边界异常大的墙面(可能是外围墙或错误数据)
|
|
277
|
-
//
|
|
277
|
+
// 提高阈值到50米,避免过滤掉正常的长墙
|
|
278
|
+
// 只过滤明显异常的数据(如超过50米的墙面)
|
|
278
279
|
obstacles = obstacles.filter(function (obs) {
|
|
279
280
|
if (obs.type === 'wall') {
|
|
280
281
|
var width = obs.bounds.maxX - obs.bounds.minX;
|
|
281
282
|
var depth = obs.bounds.maxZ - obs.bounds.minZ;
|
|
282
283
|
var maxDimension = Math.max(width, depth);
|
|
283
284
|
|
|
284
|
-
// 过滤掉超过
|
|
285
|
-
if (maxDimension >
|
|
285
|
+
// 过滤掉超过50米的墙面(明显异常)
|
|
286
|
+
if (maxDimension > 50) {
|
|
286
287
|
console.warn('过滤掉异常大的墙面:', obs.bounds, '尺寸:', maxDimension.toFixed(2) + 'm');
|
|
287
288
|
return false;
|
|
288
289
|
}
|
|
@@ -1021,9 +1022,12 @@
|
|
|
1021
1022
|
}
|
|
1022
1023
|
|
|
1023
1024
|
if (obstacles.length === 0) {
|
|
1025
|
+
console.warn('⚠️ 没有障碍物数据,返回直线路径');
|
|
1024
1026
|
return [start, end];
|
|
1025
1027
|
}
|
|
1026
1028
|
|
|
1029
|
+
console.log(`📊 障碍物统计: 总数=${obstacles.length}, 墙面=${obstacles.filter(o => o.type === 'wall').length}, 家具=${obstacles.filter(o => o.type === 'furniture').length}`);
|
|
1030
|
+
|
|
1027
1031
|
// 调整起点和终点,确保它们不在障碍物内
|
|
1028
1032
|
const adjustedStart = findNearestFreePoint(start, obstacles, 2, 0.1);
|
|
1029
1033
|
const adjustedEnd = findNearestFreePoint(end, obstacles, 2, 0.1);
|
|
@@ -1037,9 +1041,15 @@
|
|
|
1037
1041
|
}
|
|
1038
1042
|
|
|
1039
1043
|
// 检查直线是否可行(margin: 0.1米 = 10cm)
|
|
1040
|
-
|
|
1044
|
+
const hasIntersection = pathIntersectsObstacles(adjustedStart.x, adjustedStart.z, adjustedEnd.x, adjustedEnd.z, obstacles, 0.1);
|
|
1045
|
+
console.log(`🔍 直线路径检查: ${hasIntersection ? '有障碍物❌' : '无障碍物✅'}`);
|
|
1046
|
+
|
|
1047
|
+
if (!hasIntersection) {
|
|
1048
|
+
console.log('✅ 直线可达,返回两点路径');
|
|
1041
1049
|
return [adjustedStart, adjustedEnd];
|
|
1042
1050
|
}
|
|
1051
|
+
|
|
1052
|
+
console.log('🚧 需要绕行,开始A*路径规划...');
|
|
1043
1053
|
|
|
1044
1054
|
// 使用A*算法规划路径(gridSize: 0.2米 = 20cm)
|
|
1045
1055
|
const rawPath = aStarPathfinding(adjustedStart, adjustedEnd, obstacles, 0.2);
|