cuitw 2 months ago
parent
commit
cc0f6c0ec0
  1. 123
      ruoyi-ui/src/views/cesiumMap/index.vue

123
ruoyi-ui/src/views/cesiumMap/index.vue

@ -492,7 +492,7 @@ export default {
}, false),
width: 3,
material: Cesium.Color.fromCssColorString('#800080'),
clampToGround: true
arcType: Cesium.ArcType.NONE
}
});
}
@ -700,7 +700,7 @@ export default {
positions: linePositions,
width: 3,
material: Cesium.Color.fromCssColorString('#008aff'),
clampToGround: true,
arcType: Cesium.ArcType.NONE,
disableDepthTestDistance: Number.POSITIVE_INFINITY
}
});
@ -1110,7 +1110,7 @@ export default {
finalPathPositions.push(exit);
this.viewer.entities.add({
id: `hold-line-${routeId}-${i}`,
polyline: { positions: [entry, ...arcPoints.slice(1), exit], width: 8, material: Cesium.Color.ORANGE, clampToGround: true, zIndex: 20 },
polyline: { positions: [entry, ...arcPoints.slice(1), exit], width: 8, material: Cesium.Color.ORANGE, arcType: Cesium.ArcType.NONE, zIndex: 20 },
properties: { routeId: routeId }
});
lastPos = exit;
@ -1127,7 +1127,7 @@ export default {
const arcPoints = this.computeArcPositions(lastPos, currPos, nextLogical, radius);
this.viewer.entities.add({
id: `arc-line-${routeId}-${i}`,
polyline: { positions: arcPoints, width: lineWidth, material: lineMaterial, clampToGround: true, zIndex: 20 },
polyline: { positions: arcPoints, width: lineWidth, material: lineMaterial, arcType: Cesium.ArcType.NONE, zIndex: 20 },
properties: { routeId: routeId }
});
// 线dbId wp.id
@ -1178,7 +1178,7 @@ export default {
positions: finalPathPositions,
width: lineWidth,
material: lineMaterial,
clampToGround: true,
arcType: Cesium.ArcType.NONE,
zIndex: 1
},
properties: {isMissionRouteLine: true, routeId: routeId}
@ -1688,16 +1688,16 @@ export default {
imageryProvider: false,
terrainProvider: new Cesium.EllipsoidTerrainProvider(),
baseLayer: false,
// CPU/GPU viewer.scene.requestRender()
requestRenderMode: true,
maximumRenderTimeChange: Infinity,
// canvas readPixels false
contextOptions: {
preserveDrawingBuffer: true,
antialias: true // WebGL 齿
},
// 齿WebGL2 2/4/8
msaaSamples: 4
webgl: {
antialias: true,
msaa: true,
msaaSamples: 8
}
}
})
this.viewer.cesiumWidget.creditContainer.style.display = "none"
//
@ -1735,6 +1735,7 @@ export default {
console.log('Cesium离线二维地图已加载')
// 1.
this.viewer.scene.postProcessStages.fxaa.enabled = true
this.handler = new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas);
this.handler.setInputAction((click) => {
//
@ -2505,7 +2506,7 @@ export default {
positions: this.drawingPoints,
width: this.defaultStyles.line.width,
material: Cesium.Color.fromCssColorString(this.defaultStyles.line.color),
clampToGround: true
arcType: Cesium.ArcType.NONE
}
});
}
@ -2523,7 +2524,7 @@ export default {
color: Cesium.Color.fromCssColorString(this.defaultStyles.line.color),
dashLength: 16
}),
clampToGround: true
arcType: Cesium.ArcType.NONE
}
});
}
@ -2638,7 +2639,7 @@ export default {
width: this.defaultStyles.polygon.width,
// 使线
material: Cesium.Color.fromCssColorString(this.defaultStyles.polygon.color),
clampToGround: true
arcType: Cesium.ArcType.NONE
}
});
}
@ -2706,9 +2707,7 @@ export default {
}
return Cesium.Rectangle.fromDegrees(0, 0, 0, 0);
}, false),
//
material: Cesium.Color.fromCssColorString(this.defaultStyles.rectangle.color).withAlpha(this.defaultStyles.rectangle.opacity),
clampToGround: true //
material: Cesium.Color.fromCssColorString(this.defaultStyles.rectangle.color).withAlpha(this.defaultStyles.rectangle.opacity)
},
//
polyline: {
@ -2735,7 +2734,7 @@ export default {
}, false),
width: this.defaultStyles.rectangle.width,
material: Cesium.Color.fromCssColorString(this.defaultStyles.rectangle.color),
clampToGround: true //
arcType: Cesium.ArcType.NONE
}
});
}
@ -2787,15 +2786,14 @@ export default {
//
rectangle: {
coordinates: rect,
material: Cesium.Color.fromCssColorString(this.defaultStyles.rectangle.color).withAlpha(this.defaultStyles.rectangle.opacity),
clampToGround: true
material: Cesium.Color.fromCssColorString(this.defaultStyles.rectangle.color).withAlpha(this.defaultStyles.rectangle.opacity)
},
//
polyline: {
positions: borderPositions,
width: this.defaultStyles.rectangle.width,
material: Cesium.Color.fromCssColorString(this.defaultStyles.rectangle.color),
clampToGround: true
arcType: Cesium.ArcType.NONE
}
});
// 4.
@ -2942,10 +2940,9 @@ export default {
}, false),
//
material: Cesium.Color.fromCssColorString(this.defaultStyles.circle.color).withAlpha(this.defaultStyles.circle.opacity),
// outline polyline
clampToGround: true
arcType: Cesium.ArcType.NONE
},
//
// - 使 polyline
polyline: {
// 使 CallbackProperty 线
positions: new Cesium.CallbackProperty(() => {
@ -2966,7 +2963,7 @@ export default {
}, false),
width: this.defaultStyles.circle.width,
material: Cesium.Color.fromCssColorString(this.defaultStyles.circle.color),
clampToGround: true
arcType: Cesium.ArcType.NONE
}
});
}
@ -3009,24 +3006,21 @@ export default {
// 线
const circlePositions = this.generateCirclePositions(centerPoint, radius);
//
const finalEntity = this.viewer.entities.add({
id: id,
position: centerPoint,
//
ellipse: {
semiMajorAxis: radius,
semiMinorAxis: radius,
//
material: Cesium.Color.fromCssColorString(this.defaultStyles.circle.color).withAlpha(this.defaultStyles.circle.opacity),
clampToGround: true
arcType: Cesium.ArcType.NONE
},
//
polyline: {
positions: circlePositions,
width: this.defaultStyles.circle.width,
material: Cesium.Color.fromCssColorString(this.defaultStyles.circle.color),
clampToGround: true
arcType: Cesium.ArcType.NONE
}
});
// 4.
@ -3079,8 +3073,7 @@ export default {
},
//
startSectorDrawing() {
//
this.drawingPoints = []; //
this.drawingPoints = [];
// 1.
if (this.tempEntity) this.viewer.entities.remove(this.tempEntity);
if (this.tempPreviewEntity) this.viewer.entities.remove(this.tempPreviewEntity);
@ -3115,14 +3108,14 @@ export default {
color: Cesium.Color.fromCssColorString(this.defaultStyles.sector.color),
dashLength: 16
}),
clampToGround: true
arcType: Cesium.ArcType.NONE
}
});
}
// --- B ---
else if (this.drawingPoints.length === 1) {
this.drawingPoints.push(position);
this.activeCursorPosition = position; // activeCursorPosition
this.activeCursorPosition = position;
const centerPoint = this.drawingPoints[0];
const radiusPoint = this.drawingPoints[1];
const fixedRadius = Cesium.Cartesian3.distance(centerPoint, radiusPoint);
@ -3149,9 +3142,7 @@ export default {
}
return new Cesium.PolygonHierarchy([]);
}, false),
//
material: Cesium.Color.fromCssColorString(this.defaultStyles.sector.color).withAlpha(this.defaultStyles.sector.opacity),
clampToGround: true
material: Cesium.Color.fromCssColorString(this.defaultStyles.sector.color).withAlpha(this.defaultStyles.sector.opacity)
},
//
polyline: {
@ -3171,14 +3162,14 @@ export default {
}, false),
width: this.defaultStyles.sector.width,
material: Cesium.Color.fromCssColorString(this.defaultStyles.sector.color),
clampToGround: true
arcType: Cesium.ArcType.NONE
}
});
}
// --- C ---
else if (this.drawingPoints.length === 2) {
this.drawingPoints.push(position);
this.activeCursorPosition = null; //
this.activeCursorPosition = null;
//
this.finishSectorDrawing(this.drawingPoints[0], this.drawingPoints[1], this.drawingPoints[2]);
}
@ -3208,16 +3199,14 @@ export default {
//
polygon: {
hierarchy: new Cesium.PolygonHierarchy(positions),
//
material: Cesium.Color.fromCssColorString(this.defaultStyles.sector.color).withAlpha(this.defaultStyles.sector.opacity),
clampToGround: true
material: Cesium.Color.fromCssColorString(this.defaultStyles.sector.color).withAlpha(this.defaultStyles.sector.opacity)
},
//
polyline: {
positions: positions,
width: this.defaultStyles.sector.width,
material: Cesium.Color.fromCssColorString(this.defaultStyles.sector.color),
clampToGround: true
arcType: Cesium.ArcType.NONE
}
});
// 4.
@ -3231,8 +3220,8 @@ export default {
endAngle: endAngle,
positions: positions,
entity: finalEntity,
color: this.defaultStyles.sector.color, //
borderColor: this.defaultStyles.sector.color, //
color: this.defaultStyles.sector.color,
borderColor: this.defaultStyles.sector.color,
opacity: 0.5,
width: this.defaultStyles.sector.width,
label: `扇形 ${this.entityCounter}`
@ -3242,7 +3231,7 @@ export default {
this.drawingPoints = [];
},
// 线
generateCirclePositions(center, radius, numPoints = 128) {
generateCirclePositions(center, radius, numPoints = 1024) {
const positions = [];
const ellipsoid = this.viewer.scene.globe.ellipsoid;
@ -3319,7 +3308,7 @@ export default {
//
angleDiff = Math.max(0.01, angleDiff);
//
const numPoints = Math.max(10, Math.ceil(angleDiff * 180 / Math.PI / 5));
const numPoints = Math.max(200, Math.ceil(angleDiff * 180 / Math.PI));
const angleStep = angleDiff / (numPoints - 1);
//
for (let i = 0; i < numPoints; i++) {
@ -3334,6 +3323,14 @@ export default {
positions.push(center);
return positions;
},
//
generateSectorEdgePoint(center, radius, angle) {
const centerLL = Cesium.Cartographic.fromCartesian(center);
const distance = radius / 6378137;
const lat = centerLL.latitude + Math.sin(angle) * distance;
const lng = centerLL.longitude + Math.cos(angle) * distance / Math.cos(centerLL.latitude);
return Cesium.Cartesian3.fromRadians(lng, lat);
},
//
calculateDistance(point1, point2) {
return Cesium.Cartesian3.distance(point1, point2);
@ -3375,12 +3372,12 @@ export default {
}
return [];
}, false),
width: 8, //
width: 12, //
// 使
material: new Cesium.PolylineArrowMaterialProperty(
Cesium.Color.fromCssColorString(this.defaultStyles.arrow.color)
),
clampToGround: true, //
arcType: Cesium.ArcType.NONE,
widthInMeters: false // 使
}
});
@ -3428,11 +3425,11 @@ export default {
name: `箭头 ${this.entityCounter}`,
polyline: {
positions: positions,
width: 8, //
width: 12, //
material: new Cesium.PolylineArrowMaterialProperty(
Cesium.Color.fromCssColorString(this.defaultStyles.arrow.color)
),
clampToGround: true,
arcType: Cesium.ArcType.NONE,
// 使
widthInMeters: false
}
@ -3717,7 +3714,7 @@ export default {
positions: positions,
width: this.defaultStyles.line.width,
material: Cesium.Color.fromCssColorString(this.defaultStyles.line.color),
clampToGround: true
arcType: Cesium.ArcType.NONE
}
})
const entityData = {
@ -3751,16 +3748,14 @@ export default {
//
polygon: {
hierarchy: new Cesium.PolygonHierarchy(polygonPositions),
//
material: Cesium.Color.TRANSPARENT,
clampToGround: true
material: Cesium.Color.TRANSPARENT
},
//
polyline: {
positions: polygonPositions,
width: this.defaultStyles.polygon.width,
material: Cesium.Color.fromCssColorString(this.defaultStyles.polygon.color),
clampToGround: true
arcType: Cesium.ArcType.NONE
}
})
const entityData = {
@ -3812,13 +3807,13 @@ export default {
position: center, //
// 使 ellipse ()
ellipse: {
semiMinorAxis: validRadius, // =
semiMajorAxis: validRadius, // =
//
semiMinorAxis: validRadius,
semiMajorAxis: validRadius,
material: Cesium.Color.TRANSPARENT,
outline: true,
outlineColor: Cesium.Color.fromCssColorString(this.defaultStyles.circle.color),
outlineWidth: this.defaultStyles.circle.width
outlineWidth: this.defaultStyles.circle.width,
arcType: Cesium.ArcType.NONE
}
})
// entity
@ -4483,7 +4478,7 @@ export default {
positions: linePositions,
width: 3,
material: Cesium.Color.fromCssColorString(color),
clampToGround: true
arcType: Cesium.ArcType.NONE
},
label: {
text: entityData.label || '线',
@ -4886,7 +4881,7 @@ export default {
positions: newPositions,
width: selectedLineEntity.width,
material: Cesium.Color.fromCssColorString(selectedLineEntity.color),
clampToGround: true
arcType: Cesium.ArcType.NONE
}
})
// 线
@ -5093,13 +5088,13 @@ export default {
semiMinorAxis: radiusInMeters,
semiMajorAxis: radiusInMeters,
material: Cesium.Color.RED.withAlpha(0),
clampToGround: true
arcType: Cesium.ArcType.NONE
},
polyline: {
positions: circlePositions,
width: 2,
material: Cesium.Color.RED,
clampToGround: true
arcType: Cesium.ArcType.NONE
}
});

Loading…
Cancel
Save