@kimap/indoor-positioning-sdk-vue2 3.1.13 → 3.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kimap/indoor-positioning-sdk-vue2",
3
- "version": "3.1.13",
3
+ "version": "3.2.0",
4
4
  "description": "Vue2自包含室内定位SDK - 完全兼容Webpack3+Babel6 | Vue2 Self-Contained Indoor Positioning SDK",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -1282,6 +1282,75 @@
1282
1282
  this.core.controls.update();
1283
1283
  };
1284
1284
 
1285
+ /**
1286
+ * 获取地图配置信息(包含校准数据)
1287
+ */
1288
+ KimapSDK.prototype.getConfig = function() {
1289
+ var config = {
1290
+ maxX: this.config.maxX,
1291
+ maxY: this.config.maxY,
1292
+ origin: this.config.origin
1293
+ };
1294
+
1295
+ // 如果有校准数据,一并返回
1296
+ if (this._mapConfig) {
1297
+ config.calibrationData = {
1298
+ isCalibrated: this._mapConfig.isCalibrated || false,
1299
+ calibrationScale: this._mapConfig.calibrationScale,
1300
+ realWidth: this._mapConfig.realWidth,
1301
+ realHeight: this._mapConfig.realHeight,
1302
+ modelToRealScale: this._mapConfig.modelToRealScale
1303
+ };
1304
+ }
1305
+
1306
+ return config;
1307
+ };
1308
+
1309
+ /**
1310
+ * 获取地图边界信息
1311
+ */
1312
+ KimapSDK.prototype.getBorder = function() {
1313
+ // 如果模型中有边界信息,优先使用
1314
+ if (this._borderInfo) {
1315
+ return this._borderInfo;
1316
+ }
1317
+
1318
+ // 降级方案:根据坐标系统计算
1319
+ var origin = this.config.origin;
1320
+ var maxX = this.config.maxX / 100; // mm to m
1321
+ var maxY = this.config.maxY / 100;
1322
+
1323
+ return {
1324
+ min: {
1325
+ x: origin.x,
1326
+ y: origin.y,
1327
+ z: origin.z
1328
+ },
1329
+ max: {
1330
+ x: origin.x + maxX,
1331
+ y: origin.y + 0.375,
1332
+ z: origin.z + maxY
1333
+ }
1334
+ };
1335
+ };
1336
+
1337
+ /**
1338
+ * 设置边界信息(从OBJ文件解析后调用)
1339
+ * @private
1340
+ */
1341
+ KimapSDK.prototype._setBorderInfo = function(borderInfo) {
1342
+ this._borderInfo = borderInfo;
1343
+ };
1344
+
1345
+ /**
1346
+ * 设置地图配置信息(从OBJ文件解析后调用)
1347
+ * @private
1348
+ */
1349
+ KimapSDK.prototype._setMapConfig = function(mapConfig) {
1350
+ this._mapConfig = mapConfig;
1351
+ console.log('📍 地图配置已保存:', this._mapConfig);
1352
+ };
1353
+
1285
1354
  KimapSDK.prototype.destroy = function() {
1286
1355
  if (this.animationFrameId) {
1287
1356
  cancelAnimationFrame(this.animationFrameId);
package/src/KimapCore.js CHANGED
@@ -215,6 +215,52 @@ function extractBorderFromOBJ(objContent) {
215
215
  return null;
216
216
  }
217
217
 
218
+ /**
219
+ * 从OBJ内容中提取地图配置信息(包含校准数据)
220
+ * 配置信息格式:
221
+ * # KIMAP_CONFIG_CALIBRATED true
222
+ * # KIMAP_CONFIG_CALIBRATION_SCALE 2.5000
223
+ * # KIMAP_CONFIG_REAL_WIDTH 500.00
224
+ * # KIMAP_CONFIG_REAL_HEIGHT 400.00
225
+ * # KIMAP_CONFIG_MODEL_TO_REAL_SCALE 2.0000
226
+ */
227
+ function extractMapConfigFromOBJ(objContent) {
228
+ var config = {
229
+ isCalibrated: false,
230
+ calibrationScale: null,
231
+ realWidth: null,
232
+ realHeight: null,
233
+ modelToRealScale: null
234
+ };
235
+
236
+ var lines = objContent.split('\n');
237
+ var foundConfig = false;
238
+
239
+ for (var i = 0; i < lines.length; i++) {
240
+ var line = lines[i].trim();
241
+
242
+ if (line.indexOf('KIMAP_CONFIG_CALIBRATED') !== -1) {
243
+ config.isCalibrated = line.split(' ')[2] === 'true';
244
+ foundConfig = true;
245
+ } else if (line.indexOf('KIMAP_CONFIG_CALIBRATION_SCALE') !== -1) {
246
+ config.calibrationScale = parseFloat(line.split(' ')[2]);
247
+ } else if (line.indexOf('KIMAP_CONFIG_REAL_WIDTH') !== -1) {
248
+ config.realWidth = parseFloat(line.split(' ')[2]);
249
+ } else if (line.indexOf('KIMAP_CONFIG_REAL_HEIGHT') !== -1) {
250
+ config.realHeight = parseFloat(line.split(' ')[2]);
251
+ } else if (line.indexOf('KIMAP_CONFIG_MODEL_TO_REAL_SCALE') !== -1) {
252
+ config.modelToRealScale = parseFloat(line.split(' ')[2]);
253
+ }
254
+
255
+ // 如果遇到 End Config Info 或其他结束标记,停止解析
256
+ if (line.indexOf('End Config Info') !== -1 || line.indexOf('===== End Border Info =====') !== -1) {
257
+ break;
258
+ }
259
+ }
260
+
261
+ return foundConfig ? config : null;
262
+ }
263
+
218
264
  /**
219
265
  * 从OBJ内容中提取颜色信息
220
266
  */
@@ -483,6 +529,15 @@ SceneCore.prototype.loadMap = function(OBJLoader, MTLLoader) {
483
529
  }
484
530
  }
485
531
 
532
+ // 提取地图配置信息(校准数据)
533
+ var mapConfig = extractMapConfigFromOBJ(objContent);
534
+ if (mapConfig && mapConfig.isCalibrated) {
535
+ console.log('✅ 提取到校准数据:', mapConfig);
536
+ if (self.sdk && self.sdk._setMapConfig) {
537
+ self.sdk._setMapConfig(mapConfig);
538
+ }
539
+ }
540
+
486
541
  // 提取颜色信息(作为备用)
487
542
  var colorMap = materials ? {} : extractColorsFromOBJ(objContent);
488
543
  if (!materials) {
@@ -1145,10 +1200,10 @@ KimapSDK.prototype.getCoordinateSystem = function() {
1145
1200
  };
1146
1201
 
1147
1202
  /**
1148
- * 获取地图配置信息
1203
+ * 获取地图配置信息(包含校准数据)
1149
1204
  */
1150
1205
  KimapSDK.prototype.getConfig = function() {
1151
- return {
1206
+ var config = {
1152
1207
  maxX: this.core.coordinateSystem.maxX,
1153
1208
  maxY: this.core.coordinateSystem.maxY,
1154
1209
  origin: {
@@ -1157,6 +1212,19 @@ KimapSDK.prototype.getConfig = function() {
1157
1212
  z: this.core.coordinateSystem.origin.z
1158
1213
  }
1159
1214
  };
1215
+
1216
+ // 如果有校准数据,一并返回
1217
+ if (this._mapConfig) {
1218
+ config.calibrationData = {
1219
+ isCalibrated: this._mapConfig.isCalibrated || false,
1220
+ calibrationScale: this._mapConfig.calibrationScale,
1221
+ realWidth: this._mapConfig.realWidth,
1222
+ realHeight: this._mapConfig.realHeight,
1223
+ modelToRealScale: this._mapConfig.modelToRealScale
1224
+ };
1225
+ }
1226
+
1227
+ return config;
1160
1228
  };
1161
1229
 
1162
1230
  /**
@@ -1196,6 +1264,15 @@ KimapSDK.prototype._setBorderInfo = function(borderInfo) {
1196
1264
  this._borderInfo = borderInfo;
1197
1265
  };
1198
1266
 
1267
+ /**
1268
+ * 设置地图配置信息(从OBJ文件解析后调用)
1269
+ * @private
1270
+ */
1271
+ KimapSDK.prototype._setMapConfig = function(mapConfig) {
1272
+ this._mapConfig = mapConfig;
1273
+ console.log('📍 地图配置已保存:', this._mapConfig);
1274
+ };
1275
+
1199
1276
  /**
1200
1277
  * 获取楼层列表
1201
1278
  * 注意:当前版本为单楼层,返回默认楼层信息