@kimap/indoor-positioning-sdk-vue2 4.3.2 → 4.3.4
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 +31 -8
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,25 @@
|
|
|
1021
1022
|
}
|
|
1022
1023
|
|
|
1023
1024
|
if (obstacles.length === 0) {
|
|
1025
|
+
console.warn('⚠️ 没有障碍物数据,返回直线路径');
|
|
1024
1026
|
return [start, end];
|
|
1025
1027
|
}
|
|
1026
1028
|
|
|
1029
|
+
const wallCount = obstacles.filter(o => o.type === 'wall').length;
|
|
1030
|
+
const furnitureCount = obstacles.filter(o => o.type === 'furniture').length;
|
|
1031
|
+
const model3dCount = obstacles.filter(o => o.type === 'model3d').length;
|
|
1032
|
+
const polygonCount = obstacles.filter(o => o.type === 'polygon').length;
|
|
1033
|
+
|
|
1034
|
+
console.log(`📊 障碍物统计: 总数=${obstacles.length}, 墙面=${wallCount}, 家具=${furnitureCount}, 3D模型=${model3dCount}, 多边形=${polygonCount}`);
|
|
1035
|
+
|
|
1036
|
+
// 输出前3个障碍物的详细信息用于调试
|
|
1037
|
+
if (obstacles.length > 0) {
|
|
1038
|
+
console.log('🔍 前3个障碍物详情:');
|
|
1039
|
+
obstacles.slice(0, 3).forEach((obs, idx) => {
|
|
1040
|
+
console.log(` ${idx + 1}. 类型=${obs.type}, 边界=`, obs.bounds);
|
|
1041
|
+
});
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1027
1044
|
// 调整起点和终点,确保它们不在障碍物内
|
|
1028
1045
|
const adjustedStart = findNearestFreePoint(start, obstacles, 2, 0.1);
|
|
1029
1046
|
const adjustedEnd = findNearestFreePoint(end, obstacles, 2, 0.1);
|
|
@@ -1037,26 +1054,32 @@
|
|
|
1037
1054
|
}
|
|
1038
1055
|
|
|
1039
1056
|
// 检查直线是否可行(margin: 0.1米 = 10cm)
|
|
1040
|
-
|
|
1057
|
+
const hasIntersection = pathIntersectsObstacles(adjustedStart.x, adjustedStart.z, adjustedEnd.x, adjustedEnd.z, obstacles, 0.1);
|
|
1058
|
+
console.log(`🔍 直线路径检查: ${hasIntersection ? '有障碍物❌' : '无障碍物✅'}`);
|
|
1059
|
+
|
|
1060
|
+
if (!hasIntersection) {
|
|
1061
|
+
console.log('✅ 直线可达,返回两点路径');
|
|
1041
1062
|
return [adjustedStart, adjustedEnd];
|
|
1042
1063
|
}
|
|
1064
|
+
|
|
1065
|
+
console.log('🚧 需要绕行,开始A*路径规划...');
|
|
1043
1066
|
|
|
1044
1067
|
// 使用A*算法规划路径(gridSize: 0.2米 = 20cm)
|
|
1045
1068
|
const rawPath = aStarPathfinding(adjustedStart, adjustedEnd, obstacles, 0.2);
|
|
1069
|
+
console.log(`🗺️ A*原始路径: ${rawPath.length}个点`);
|
|
1046
1070
|
|
|
1047
1071
|
// 如果路径只有2个点(直线),直接返回
|
|
1048
1072
|
if (rawPath.length <= 2) {
|
|
1073
|
+
console.log('⚠️ A*只返回了2个点,可能没有找到有效路径');
|
|
1049
1074
|
return rawPath;
|
|
1050
1075
|
}
|
|
1051
1076
|
|
|
1052
1077
|
// 第一步:简化路径,移除不必要的中间点
|
|
1053
1078
|
const simplifiedPath = simplifyPath(rawPath, obstacles);
|
|
1079
|
+
console.log(`📐 简化后路径: ${simplifiedPath.length}个点`);
|
|
1054
1080
|
|
|
1055
1081
|
// 第二步:平滑路径(可通过options.smoothPath控制是否启用,默认启用)
|
|
1056
|
-
const
|
|
1057
|
-
if (enableSmoothing && simplifiedPath.length > 2) {
|
|
1058
|
-
return smoothPath(simplifiedPath, obstacles, 0.5, 8);
|
|
1059
|
-
}
|
|
1082
|
+
const ena
|
|
1060
1083
|
|
|
1061
1084
|
return simplifiedPath;
|
|
1062
1085
|
};
|