@jorgmoritz/gis-manager 0.1.37 → 0.1.38
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 +48 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +48 -10
- package/dist/index.js.map +1 -1
- package/dist/vue/index.cjs +47 -9
- package/dist/vue/index.cjs.map +1 -1
- package/dist/vue/index.js +47 -9
- package/dist/vue/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1376,6 +1376,11 @@ declare class PolygonEditor {
|
|
|
1376
1376
|
height?: number;
|
|
1377
1377
|
}>;
|
|
1378
1378
|
}): Cesium.Entity | null;
|
|
1379
|
+
/**
|
|
1380
|
+
* 辅助方法:使用地形采样创建标签
|
|
1381
|
+
* 先尝试获取地形高度,如果失败则使用 heightReference
|
|
1382
|
+
*/
|
|
1383
|
+
private createLabelWithTerrainHeight;
|
|
1379
1384
|
/**
|
|
1380
1385
|
* 辅助方法:从实体中提取经纬度高度数组
|
|
1381
1386
|
* @param entity 多边形实体
|
package/dist/index.d.ts
CHANGED
|
@@ -1376,6 +1376,11 @@ declare class PolygonEditor {
|
|
|
1376
1376
|
height?: number;
|
|
1377
1377
|
}>;
|
|
1378
1378
|
}): Cesium.Entity | null;
|
|
1379
|
+
/**
|
|
1380
|
+
* 辅助方法:使用地形采样创建标签
|
|
1381
|
+
* 先尝试获取地形高度,如果失败则使用 heightReference
|
|
1382
|
+
*/
|
|
1383
|
+
private createLabelWithTerrainHeight;
|
|
1379
1384
|
/**
|
|
1380
1385
|
* 辅助方法:从实体中提取经纬度高度数组
|
|
1381
1386
|
* @param entity 多边形实体
|
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
11
11
|
// package.json
|
|
12
12
|
var package_default = {
|
|
13
13
|
name: "@jorgmoritz/gis-manager",
|
|
14
|
-
version: "0.1.
|
|
14
|
+
version: "0.1.37"};
|
|
15
15
|
|
|
16
16
|
// src/utils/version.ts
|
|
17
17
|
var version = package_default.version;
|
|
@@ -8314,7 +8314,9 @@ var PolygonEditor = class {
|
|
|
8314
8314
|
polygon: {
|
|
8315
8315
|
hierarchy: positions,
|
|
8316
8316
|
material: faceColor,
|
|
8317
|
-
outline: false
|
|
8317
|
+
outline: false,
|
|
8318
|
+
// 🔧 修复:设置 heightReference 使多边形贴合地形
|
|
8319
|
+
heightReference: C.HeightReference.CLAMP_TO_GROUND
|
|
8318
8320
|
}
|
|
8319
8321
|
});
|
|
8320
8322
|
const ring = positions.slice();
|
|
@@ -8327,15 +8329,51 @@ var PolygonEditor = class {
|
|
|
8327
8329
|
width: 1,
|
|
8328
8330
|
material: lineColor,
|
|
8329
8331
|
clampToGround: true
|
|
8332
|
+
// 轮廓线已经设置了 clampToGround
|
|
8330
8333
|
},
|
|
8331
8334
|
properties: { _ownerId: id, _type: "polygon-outline" }
|
|
8332
8335
|
});
|
|
8333
8336
|
this.applyDashedOutlineStyle(outlineEntity, lineColor, 3, 10);
|
|
8334
8337
|
const displayText = name.includes("_") ? name.split("_")[1] : name;
|
|
8338
|
+
const firstPoint = points[0];
|
|
8339
|
+
this.createLabelWithTerrainHeight(
|
|
8340
|
+
layer,
|
|
8341
|
+
id,
|
|
8342
|
+
displayText,
|
|
8343
|
+
firstPoint.lon,
|
|
8344
|
+
firstPoint.lat,
|
|
8345
|
+
lineColor
|
|
8346
|
+
);
|
|
8347
|
+
return entity;
|
|
8348
|
+
} catch (err) {
|
|
8349
|
+
console.error(`[PolygonEditor] \u521B\u5EFA\u591A\u8FB9\u5F62\u5931\u8D25:`, err);
|
|
8350
|
+
return null;
|
|
8351
|
+
}
|
|
8352
|
+
}
|
|
8353
|
+
/**
|
|
8354
|
+
* 辅助方法:使用地形采样创建标签
|
|
8355
|
+
* 先尝试获取地形高度,如果失败则使用 heightReference
|
|
8356
|
+
*/
|
|
8357
|
+
async createLabelWithTerrainHeight(layer, ownerId, displayText, lon, lat, lineColor) {
|
|
8358
|
+
const C = this.CesiumNS;
|
|
8359
|
+
try {
|
|
8360
|
+
let terrainHeight = 0;
|
|
8361
|
+
const terrainProvider = this.viewer.terrainProvider;
|
|
8362
|
+
if (terrainProvider && typeof C.sampleTerrainMostDetailed === "function") {
|
|
8363
|
+
try {
|
|
8364
|
+
const positions = [C.Cartographic.fromDegrees(lon, lat)];
|
|
8365
|
+
const updatedPositions = await C.sampleTerrainMostDetailed(terrainProvider, positions);
|
|
8366
|
+
if (updatedPositions && updatedPositions[0] && updatedPositions[0].height !== void 0) {
|
|
8367
|
+
terrainHeight = updatedPositions[0].height;
|
|
8368
|
+
}
|
|
8369
|
+
} catch (e) {
|
|
8370
|
+
}
|
|
8371
|
+
}
|
|
8372
|
+
const labelPosition = C.Cartesian3.fromDegrees(lon, lat, terrainHeight + 1);
|
|
8335
8373
|
layer.entities.add({
|
|
8336
|
-
id: `${
|
|
8374
|
+
id: `${ownerId}-label`,
|
|
8337
8375
|
name: "Polygon Label",
|
|
8338
|
-
position:
|
|
8376
|
+
position: labelPosition,
|
|
8339
8377
|
label: {
|
|
8340
8378
|
text: displayText,
|
|
8341
8379
|
font: "bold 16px Microsoft YaHei, SimHei, sans-serif",
|
|
@@ -8345,14 +8383,14 @@ var PolygonEditor = class {
|
|
|
8345
8383
|
style: C.LabelStyle.FILL_AND_OUTLINE,
|
|
8346
8384
|
verticalOrigin: C.VerticalOrigin.BOTTOM,
|
|
8347
8385
|
pixelOffset: new C.Cartesian2(0, -10),
|
|
8348
|
-
disableDepthTestDistance: Number.POSITIVE_INFINITY
|
|
8386
|
+
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
8387
|
+
// 仍然设置 heightReference 作为备用
|
|
8388
|
+
heightReference: C.HeightReference.CLAMP_TO_GROUND
|
|
8349
8389
|
},
|
|
8350
|
-
properties: { _ownerId:
|
|
8390
|
+
properties: { _ownerId: ownerId, _type: "polygon-label" }
|
|
8351
8391
|
});
|
|
8352
|
-
|
|
8353
|
-
|
|
8354
|
-
console.error(`[PolygonEditor] \u521B\u5EFA\u591A\u8FB9\u5F62\u5931\u8D25:`, err);
|
|
8355
|
-
return null;
|
|
8392
|
+
} catch (e) {
|
|
8393
|
+
console.warn(`[PolygonEditor] \u521B\u5EFA\u6807\u7B7E\u5931\u8D25:`, e);
|
|
8356
8394
|
}
|
|
8357
8395
|
}
|
|
8358
8396
|
/**
|