@kimap/indoor-positioning-sdk-vue2 4.1.7 → 4.2.0
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/core/KimapSDK.js +7 -0
- package/src/core/SceneCore.js +2 -2
- package/src/core/parsers.js +27 -8
package/package.json
CHANGED
package/src/core/KimapSDK.js
CHANGED
|
@@ -524,6 +524,9 @@ KimapSDK.prototype.getCoordinateSystem = function() {
|
|
|
524
524
|
KimapSDK.prototype.getConfig = function() {
|
|
525
525
|
var config = {};
|
|
526
526
|
|
|
527
|
+
console.log('[getConfig] _mapConfig:', this._mapConfig);
|
|
528
|
+
console.log('[getConfig] _borderInfo:', this._borderInfo);
|
|
529
|
+
|
|
527
530
|
// 从coordinateSystem获取scale
|
|
528
531
|
if (this.core && this.core.coordinateSystem) {
|
|
529
532
|
var coordSys = this.core.coordinateSystem;
|
|
@@ -553,13 +556,16 @@ KimapSDK.prototype.getConfig = function() {
|
|
|
553
556
|
// modelToRealScale: 模型尺寸与真实尺寸的比例
|
|
554
557
|
if (this._mapConfig.modelToRealScale) {
|
|
555
558
|
config.modelToRealScale = this._mapConfig.modelToRealScale;
|
|
559
|
+
console.log('[getConfig] 使用_mapConfig中的modelToRealScale:', config.modelToRealScale);
|
|
556
560
|
} else if (config.mapX && this._mapConfig.realWidth) {
|
|
557
561
|
// 如果没有直接提供modelToRealScale,根据模型尺寸和真实尺寸计算
|
|
558
562
|
// modelToRealScale = 模型宽度(米) / 真实宽度(米)
|
|
559
563
|
config.modelToRealScale = config.mapX / (this._mapConfig.realWidth / 100);
|
|
564
|
+
console.log('[getConfig] 计算modelToRealScale:', config.modelToRealScale, '= mapX:', config.mapX, '/ realWidth:', this._mapConfig.realWidth / 100);
|
|
560
565
|
} else {
|
|
561
566
|
// 默认值
|
|
562
567
|
config.modelToRealScale = 1.0;
|
|
568
|
+
console.log('[getConfig] 使用默认modelToRealScale: 1.0');
|
|
563
569
|
}
|
|
564
570
|
|
|
565
571
|
// 添加完整的mapConfig数据
|
|
@@ -570,6 +576,7 @@ KimapSDK.prototype.getConfig = function() {
|
|
|
570
576
|
config.isCalibrated = false;
|
|
571
577
|
// 默认modelToRealScale为1.0(模型单位=真实单位)
|
|
572
578
|
config.modelToRealScale = 1.0;
|
|
579
|
+
console.log('[getConfig] 没有校准数据,使用默认modelToRealScale: 1.0');
|
|
573
580
|
}
|
|
574
581
|
|
|
575
582
|
return config;
|
package/src/core/SceneCore.js
CHANGED
|
@@ -202,8 +202,8 @@ SceneCore.prototype.addCoordinateHelper = function() {
|
|
|
202
202
|
var origin = this.coordinateSystem.origin;
|
|
203
203
|
var maxX = this.coordinateSystem.maxX;
|
|
204
204
|
var maxY = this.coordinateSystem.maxY;
|
|
205
|
-
var showGrid = this.config.showGrid
|
|
206
|
-
var showAxes = this.config.showAxes
|
|
205
|
+
var showGrid = this.config.showGrid === true;
|
|
206
|
+
var showAxes = this.config.showAxes === true;
|
|
207
207
|
|
|
208
208
|
if (showGrid) {
|
|
209
209
|
var gridSize = Math.max(maxX, maxY) * 1.5;
|
package/src/core/parsers.js
CHANGED
|
@@ -40,30 +40,49 @@ function extractBorderFromOBJ(objContent) {
|
|
|
40
40
|
/**
|
|
41
41
|
* 从OBJ内容中提取地图配置信息
|
|
42
42
|
* 格式示例:
|
|
43
|
+
* # KIMAP_CONFIG_IS_CALIBRATED true
|
|
44
|
+
* # KIMAP_CONFIG_CALIBRATION_SCALE 1.0
|
|
45
|
+
* # KIMAP_CONFIG_REAL_WIDTH 1000.0
|
|
46
|
+
* # KIMAP_CONFIG_REAL_HEIGHT 800.0
|
|
43
47
|
* # KIMAP_CONFIG_MODEL_TO_REAL_SCALE 2.0000
|
|
44
48
|
*/
|
|
45
49
|
function extractMapConfigFromOBJ(objContent) {
|
|
46
50
|
var config = {
|
|
47
51
|
isCalibrated: false,
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
calibrationScale: null,
|
|
53
|
+
realWidth: null,
|
|
54
|
+
realHeight: null,
|
|
55
|
+
modelToRealScale: null
|
|
50
56
|
};
|
|
51
57
|
|
|
52
58
|
var lines = objContent.split('\n');
|
|
59
|
+
var foundConfig = false;
|
|
53
60
|
|
|
54
61
|
for (var i = 0; i < lines.length; i++) {
|
|
55
62
|
var line = lines[i].trim();
|
|
56
63
|
|
|
57
|
-
if (line.indexOf('
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
} else if (line.indexOf('
|
|
64
|
+
if (line.indexOf('KIMAP_CONFIG_CALIBRATED') !== -1) {
|
|
65
|
+
config.isCalibrated = line.split(' ')[2] === 'true';
|
|
66
|
+
foundConfig = true;
|
|
67
|
+
} else if (line.indexOf('KIMAP_CONFIG_CALIBRATION_SCALE') !== -1) {
|
|
68
|
+
config.calibrationScale = parseFloat(line.split(' ')[2]);
|
|
69
|
+
} else if (line.indexOf('KIMAP_CONFIG_REAL_WIDTH') !== -1) {
|
|
70
|
+
config.realWidth = parseFloat(line.split(' ')[2]);
|
|
71
|
+
} else if (line.indexOf('KIMAP_CONFIG_REAL_HEIGHT') !== -1) {
|
|
72
|
+
config.realHeight = parseFloat(line.split(' ')[2]);
|
|
73
|
+
} else if (line.indexOf('KIMAP_CONFIG_MODEL_TO_REAL_SCALE') !== -1) {
|
|
61
74
|
config.modelToRealScale = parseFloat(line.split(' ')[2]);
|
|
62
|
-
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// 只在遇到 End Config Info 时停止
|
|
78
|
+
if (line.indexOf('End Config Info') !== -1) {
|
|
79
|
+
break;
|
|
63
80
|
}
|
|
64
81
|
}
|
|
65
82
|
|
|
66
|
-
|
|
83
|
+
console.log('[Parsers] 提取到的地图配置:', config);
|
|
84
|
+
|
|
85
|
+
return foundConfig ? config : null;
|
|
67
86
|
}
|
|
68
87
|
|
|
69
88
|
/**
|