|
@@ -560,6 +560,34 @@ export default {
|
|
|
}
|
|
}
|
|
|
return aliases;
|
|
return aliases;
|
|
|
},
|
|
},
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 当前场景在指定几何槽位是否声明了 Z 型参数(如 pointZ、polylineZ、polygonZ 及别名 lineZ 等)。
|
|
|
|
|
+ * 仅该槽位绘制出的坐标使用 [lon, lat, z]。
|
|
|
|
|
+ */
|
|
|
|
|
+ elementTypesHasZVariant(geometryCanon) {
|
|
|
|
|
+ if (
|
|
|
|
|
+ !this.dmsServerItem ||
|
|
|
|
|
+ !Array.isArray(this.dmsServerItem.elementTypes) ||
|
|
|
|
|
+ !geometryCanon
|
|
|
|
|
+ ) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ const zCandidates = this.expandParameterTypeAliases(geometryCanon).filter((a) =>
|
|
|
|
|
+ String(a).toLowerCase().endsWith("z")
|
|
|
|
|
+ );
|
|
|
|
|
+ if (zCandidates.length === 0) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ const declared = this.dmsServerItem.elementTypes.map((t) => String(t).toLowerCase());
|
|
|
|
|
+ return zCandidates.some((c) => declared.includes(String(c).toLowerCase()));
|
|
|
|
|
+ },
|
|
|
|
|
+ /** 按几何槽位(point / polyline / polygon)生成 GeoJSON 坐标:含 Z 型参数时为 [lon, lat, z] */
|
|
|
|
|
+ lonLatToGeoJsonCoord(lon, lat, geometryCanon, z = 0) {
|
|
|
|
|
+ if (geometryCanon && this.elementTypesHasZVariant(geometryCanon)) {
|
|
|
|
|
+ return [lon, lat, z];
|
|
|
|
|
+ }
|
|
|
|
|
+ return [lon, lat];
|
|
|
|
|
+ },
|
|
|
ifHasType(type) {
|
|
ifHasType(type) {
|
|
|
if (
|
|
if (
|
|
|
!this.dmsServerItem ||
|
|
!this.dmsServerItem ||
|
|
@@ -2820,7 +2848,7 @@ export default {
|
|
|
// 转换为geometry格式并保存
|
|
// 转换为geometry格式并保存
|
|
|
const geometry = {
|
|
const geometry = {
|
|
|
type: "Point",
|
|
type: "Point",
|
|
|
- coordinates: [longitude, latitude],
|
|
|
|
|
|
|
+ coordinates: that.lonLatToGeoJsonCoord(longitude, latitude, "point"),
|
|
|
};
|
|
};
|
|
|
that.geometries.push(geometry);
|
|
that.geometries.push(geometry);
|
|
|
that.changeGeometries();
|
|
that.changeGeometries();
|
|
@@ -2924,10 +2952,13 @@ export default {
|
|
|
const coordinates = [];
|
|
const coordinates = [];
|
|
|
that.currentPositions.forEach((pos) => {
|
|
that.currentPositions.forEach((pos) => {
|
|
|
const cartographic = SkyScenery.Cartographic.fromCartesian(pos);
|
|
const cartographic = SkyScenery.Cartographic.fromCartesian(pos);
|
|
|
- coordinates.push([
|
|
|
|
|
- SkyScenery.Math.toDegrees(cartographic.longitude),
|
|
|
|
|
- SkyScenery.Math.toDegrees(cartographic.latitude),
|
|
|
|
|
- ]);
|
|
|
|
|
|
|
+ coordinates.push(
|
|
|
|
|
+ that.lonLatToGeoJsonCoord(
|
|
|
|
|
+ SkyScenery.Math.toDegrees(cartographic.longitude),
|
|
|
|
|
+ SkyScenery.Math.toDegrees(cartographic.latitude),
|
|
|
|
|
+ "polyline"
|
|
|
|
|
+ )
|
|
|
|
|
+ );
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
const geometry = {
|
|
const geometry = {
|
|
@@ -3100,16 +3131,22 @@ export default {
|
|
|
const mainRing = [];
|
|
const mainRing = [];
|
|
|
for (let i = 0; i < closedPositions.length; i++) {
|
|
for (let i = 0; i < closedPositions.length; i++) {
|
|
|
const cartographic = SkyScenery.Cartographic.fromCartesian(closedPositions[i]);
|
|
const cartographic = SkyScenery.Cartographic.fromCartesian(closedPositions[i]);
|
|
|
- mainRing.push([
|
|
|
|
|
- SkyScenery.Math.toDegrees(cartographic.longitude),
|
|
|
|
|
- SkyScenery.Math.toDegrees(cartographic.latitude),
|
|
|
|
|
- ]);
|
|
|
|
|
|
|
+ mainRing.push(
|
|
|
|
|
+ this.lonLatToGeoJsonCoord(
|
|
|
|
|
+ SkyScenery.Math.toDegrees(cartographic.longitude),
|
|
|
|
|
+ SkyScenery.Math.toDegrees(cartographic.latitude),
|
|
|
|
|
+ "polygon"
|
|
|
|
|
+ )
|
|
|
|
|
+ );
|
|
|
}
|
|
}
|
|
|
const cartographic = SkyScenery.Cartographic.fromCartesian(closedPositions[0]);
|
|
const cartographic = SkyScenery.Cartographic.fromCartesian(closedPositions[0]);
|
|
|
- mainRing.push([
|
|
|
|
|
- SkyScenery.Math.toDegrees(cartographic.longitude),
|
|
|
|
|
- SkyScenery.Math.toDegrees(cartographic.latitude),
|
|
|
|
|
- ]);
|
|
|
|
|
|
|
+ mainRing.push(
|
|
|
|
|
+ this.lonLatToGeoJsonCoord(
|
|
|
|
|
+ SkyScenery.Math.toDegrees(cartographic.longitude),
|
|
|
|
|
+ SkyScenery.Math.toDegrees(cartographic.latitude),
|
|
|
|
|
+ "polygon"
|
|
|
|
|
+ )
|
|
|
|
|
+ );
|
|
|
coordinates.push(mainRing);
|
|
coordinates.push(mainRing);
|
|
|
|
|
|
|
|
const geometry = {
|
|
const geometry = {
|
|
@@ -3255,17 +3292,23 @@ export default {
|
|
|
const holeCoordinates = [];
|
|
const holeCoordinates = [];
|
|
|
for (let i = 0; i < closedPositions.length; i++) {
|
|
for (let i = 0; i < closedPositions.length; i++) {
|
|
|
const cartographic = SkyScenery.Cartographic.fromCartesian(closedPositions[i]);
|
|
const cartographic = SkyScenery.Cartographic.fromCartesian(closedPositions[i]);
|
|
|
- holeCoordinates.push([
|
|
|
|
|
- SkyScenery.Math.toDegrees(cartographic.longitude),
|
|
|
|
|
- SkyScenery.Math.toDegrees(cartographic.latitude),
|
|
|
|
|
- ]);
|
|
|
|
|
|
|
+ holeCoordinates.push(
|
|
|
|
|
+ this.lonLatToGeoJsonCoord(
|
|
|
|
|
+ SkyScenery.Math.toDegrees(cartographic.longitude),
|
|
|
|
|
+ SkyScenery.Math.toDegrees(cartographic.latitude),
|
|
|
|
|
+ "polygon"
|
|
|
|
|
+ )
|
|
|
|
|
+ );
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const cartographic = SkyScenery.Cartographic.fromCartesian(closedPositions[0]);
|
|
const cartographic = SkyScenery.Cartographic.fromCartesian(closedPositions[0]);
|
|
|
- holeCoordinates.push([
|
|
|
|
|
- SkyScenery.Math.toDegrees(cartographic.longitude),
|
|
|
|
|
- SkyScenery.Math.toDegrees(cartographic.latitude),
|
|
|
|
|
- ]);
|
|
|
|
|
|
|
+ holeCoordinates.push(
|
|
|
|
|
+ this.lonLatToGeoJsonCoord(
|
|
|
|
|
+ SkyScenery.Math.toDegrees(cartographic.longitude),
|
|
|
|
|
+ SkyScenery.Math.toDegrees(cartographic.latitude),
|
|
|
|
|
+ "polygon"
|
|
|
|
|
+ )
|
|
|
|
|
+ );
|
|
|
// 添加到几何对象的镂空数组
|
|
// 添加到几何对象的镂空数组
|
|
|
if (!this.currentPolygonGeometry.holes) {
|
|
if (!this.currentPolygonGeometry.holes) {
|
|
|
this.currentPolygonGeometry.holes = [];
|
|
this.currentPolygonGeometry.holes = [];
|
|
@@ -3299,7 +3342,9 @@ export default {
|
|
|
// 将外部环转换为Cartesian3数组
|
|
// 将外部环转换为Cartesian3数组
|
|
|
const outerRingPositions = [];
|
|
const outerRingPositions = [];
|
|
|
outerRing.forEach((coord) => {
|
|
outerRing.forEach((coord) => {
|
|
|
- const cartesian = SkyScenery.Cartesian3.fromDegrees(coord[0], coord[1]);
|
|
|
|
|
|
|
+ const z =
|
|
|
|
|
+ coord.length > 2 && typeof coord[2] === "number" ? coord[2] : 0;
|
|
|
|
|
+ const cartesian = SkyScenery.Cartesian3.fromDegrees(coord[0], coord[1], z);
|
|
|
outerRingPositions.push(cartesian);
|
|
outerRingPositions.push(cartesian);
|
|
|
});
|
|
});
|
|
|
// 闭合外部环
|
|
// 闭合外部环
|
|
@@ -3313,7 +3358,9 @@ export default {
|
|
|
hierarchy.holes = holes.map((hole) => {
|
|
hierarchy.holes = holes.map((hole) => {
|
|
|
const holePositions = [];
|
|
const holePositions = [];
|
|
|
hole.forEach((coord) => {
|
|
hole.forEach((coord) => {
|
|
|
- const cartesian = SkyScenery.Cartesian3.fromDegrees(coord[0], coord[1]);
|
|
|
|
|
|
|
+ const z =
|
|
|
|
|
+ coord.length > 2 && typeof coord[2] === "number" ? coord[2] : 0;
|
|
|
|
|
+ const cartesian = SkyScenery.Cartesian3.fromDegrees(coord[0], coord[1], z);
|
|
|
holePositions.push(cartesian);
|
|
holePositions.push(cartesian);
|
|
|
});
|
|
});
|
|
|
// 闭合镂空环
|
|
// 闭合镂空环
|