Browse Source

xuanranyouhua

lbj
sd 2 months ago
parent
commit
42595d2482
  1. 86
      ruoyi-ui/src/views/cesiumMap/index.vue

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

@ -826,7 +826,14 @@ export default {
mapProjection: new Cesium.WebMercatorProjection(), mapProjection: new Cesium.WebMercatorProjection(),
imageryProvider: false, imageryProvider: false,
terrainProvider: new Cesium.EllipsoidTerrainProvider(), terrainProvider: new Cesium.EllipsoidTerrainProvider(),
baseLayer: false baseLayer: false,
contextOptions: {
webgl: {
antialias: true,
msaa: true,
msaaSamples: 8
}
}
}) })
this.viewer.cesiumWidget.creditContainer.style.display = "none" this.viewer.cesiumWidget.creditContainer.style.display = "none"
this.loadOfflineMap() this.loadOfflineMap()
@ -847,6 +854,8 @@ export default {
this.initMouseCoordinates() this.initMouseCoordinates()
console.log('Cesium离线二维地图已加载') console.log('Cesium离线二维地图已加载')
console.log('Cesium离线二维地图已加载') console.log('Cesium离线二维地图已加载')
// FXAA 齿
this.viewer.scene.postProcessStages.fxaa.enabled = true
// 1. // 1.
this.handler = new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas); this.handler = new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas);
this.handler.setInputAction((click) => { this.handler.setInputAction((click) => {
@ -1483,7 +1492,7 @@ export default {
width: this.defaultStyles.polygon.width, width: this.defaultStyles.polygon.width,
// 使线 // 使线
material: Cesium.Color.fromCssColorString(this.defaultStyles.polygon.color), material: Cesium.Color.fromCssColorString(this.defaultStyles.polygon.color),
clampToGround: true arcType: Cesium.ArcType.NONE
} }
}); });
} }
@ -1580,7 +1589,7 @@ export default {
}, false), }, false),
width: this.defaultStyles.rectangle.width, width: this.defaultStyles.rectangle.width,
material: Cesium.Color.fromCssColorString(this.defaultStyles.rectangle.color), material: Cesium.Color.fromCssColorString(this.defaultStyles.rectangle.color),
clampToGround: true // arcType: Cesium.ArcType.NONE
} }
}); });
} }
@ -1640,7 +1649,7 @@ export default {
positions: borderPositions, positions: borderPositions,
width: this.defaultStyles.rectangle.width, width: this.defaultStyles.rectangle.width,
material: Cesium.Color.fromCssColorString(this.defaultStyles.rectangle.color), material: Cesium.Color.fromCssColorString(this.defaultStyles.rectangle.color),
clampToGround: true arcType: Cesium.ArcType.NONE
} }
}); });
// 4. // 4.
@ -1787,10 +1796,9 @@ export default {
}, false), }, false),
// //
material: Cesium.Color.fromCssColorString(this.defaultStyles.circle.color).withAlpha(this.defaultStyles.circle.opacity), material: Cesium.Color.fromCssColorString(this.defaultStyles.circle.color).withAlpha(this.defaultStyles.circle.opacity),
// outline polyline arcType: Cesium.ArcType.NONE
clampToGround: true
}, },
// // - 使 polyline
polyline: { polyline: {
// 使 CallbackProperty 线 // 使 CallbackProperty 线
positions: new Cesium.CallbackProperty(() => { positions: new Cesium.CallbackProperty(() => {
@ -1811,7 +1819,7 @@ export default {
}, false), }, false),
width: this.defaultStyles.circle.width, width: this.defaultStyles.circle.width,
material: Cesium.Color.fromCssColorString(this.defaultStyles.circle.color), material: Cesium.Color.fromCssColorString(this.defaultStyles.circle.color),
clampToGround: true arcType: Cesium.ArcType.NONE
} }
}); });
} }
@ -1854,24 +1862,21 @@ export default {
// 线 // 线
const circlePositions = this.generateCirclePositions(centerPoint, radius); const circlePositions = this.generateCirclePositions(centerPoint, radius);
//
const finalEntity = this.viewer.entities.add({ const finalEntity = this.viewer.entities.add({
id: id, id: id,
position: centerPoint, position: centerPoint,
//
ellipse: { ellipse: {
semiMajorAxis: radius, semiMajorAxis: radius,
semiMinorAxis: radius, semiMinorAxis: radius,
//
material: Cesium.Color.fromCssColorString(this.defaultStyles.circle.color).withAlpha(this.defaultStyles.circle.opacity), material: Cesium.Color.fromCssColorString(this.defaultStyles.circle.color).withAlpha(this.defaultStyles.circle.opacity),
clampToGround: true arcType: Cesium.ArcType.NONE
}, },
// //
polyline: { polyline: {
positions: circlePositions, positions: circlePositions,
width: this.defaultStyles.circle.width, width: this.defaultStyles.circle.width,
material: Cesium.Color.fromCssColorString(this.defaultStyles.circle.color), material: Cesium.Color.fromCssColorString(this.defaultStyles.circle.color),
clampToGround: true arcType: Cesium.ArcType.NONE
} }
}); });
// 4. // 4.
@ -1903,8 +1908,7 @@ export default {
}, },
// //
startSectorDrawing() { startSectorDrawing() {
// this.drawingPoints = [];
this.drawingPoints = []; //
// 1. // 1.
if (this.tempEntity) this.viewer.entities.remove(this.tempEntity); if (this.tempEntity) this.viewer.entities.remove(this.tempEntity);
if (this.tempPreviewEntity) this.viewer.entities.remove(this.tempPreviewEntity); if (this.tempPreviewEntity) this.viewer.entities.remove(this.tempPreviewEntity);
@ -1939,14 +1943,14 @@ export default {
color: Cesium.Color.fromCssColorString(this.defaultStyles.sector.color), color: Cesium.Color.fromCssColorString(this.defaultStyles.sector.color),
dashLength: 16 dashLength: 16
}), }),
clampToGround: true arcType: Cesium.ArcType.NONE
} }
}); });
} }
// --- B --- // --- B ---
else if (this.drawingPoints.length === 1) { else if (this.drawingPoints.length === 1) {
this.drawingPoints.push(position); this.drawingPoints.push(position);
this.activeCursorPosition = position; // activeCursorPosition this.activeCursorPosition = position;
const centerPoint = this.drawingPoints[0]; const centerPoint = this.drawingPoints[0];
const radiusPoint = this.drawingPoints[1]; const radiusPoint = this.drawingPoints[1];
const fixedRadius = Cesium.Cartesian3.distance(centerPoint, radiusPoint); const fixedRadius = Cesium.Cartesian3.distance(centerPoint, radiusPoint);
@ -1973,9 +1977,7 @@ export default {
} }
return new Cesium.PolygonHierarchy([]); return new Cesium.PolygonHierarchy([]);
}, false), }, false),
// material: Cesium.Color.fromCssColorString(this.defaultStyles.sector.color).withAlpha(this.defaultStyles.sector.opacity)
material: Cesium.Color.fromCssColorString(this.defaultStyles.sector.color).withAlpha(this.defaultStyles.sector.opacity),
clampToGround: true
}, },
// //
polyline: { polyline: {
@ -1995,14 +1997,14 @@ export default {
}, false), }, false),
width: this.defaultStyles.sector.width, width: this.defaultStyles.sector.width,
material: Cesium.Color.fromCssColorString(this.defaultStyles.sector.color), material: Cesium.Color.fromCssColorString(this.defaultStyles.sector.color),
clampToGround: true arcType: Cesium.ArcType.NONE
} }
}); });
} }
// --- C --- // --- C ---
else if (this.drawingPoints.length === 2) { else if (this.drawingPoints.length === 2) {
this.drawingPoints.push(position); this.drawingPoints.push(position);
this.activeCursorPosition = null; // this.activeCursorPosition = null;
// //
this.finishSectorDrawing(this.drawingPoints[0], this.drawingPoints[1], this.drawingPoints[2]); this.finishSectorDrawing(this.drawingPoints[0], this.drawingPoints[1], this.drawingPoints[2]);
} }
@ -2032,16 +2034,14 @@ export default {
// //
polygon: { polygon: {
hierarchy: new Cesium.PolygonHierarchy(positions), hierarchy: new Cesium.PolygonHierarchy(positions),
// material: Cesium.Color.fromCssColorString(this.defaultStyles.sector.color).withAlpha(this.defaultStyles.sector.opacity)
material: Cesium.Color.fromCssColorString(this.defaultStyles.sector.color).withAlpha(this.defaultStyles.sector.opacity),
clampToGround: true
}, },
// //
polyline: { polyline: {
positions: positions, positions: positions,
width: this.defaultStyles.sector.width, width: this.defaultStyles.sector.width,
material: Cesium.Color.fromCssColorString(this.defaultStyles.sector.color), material: Cesium.Color.fromCssColorString(this.defaultStyles.sector.color),
clampToGround: true arcType: Cesium.ArcType.NONE
} }
}); });
// 4. // 4.
@ -2055,8 +2055,8 @@ export default {
endAngle: endAngle, endAngle: endAngle,
positions: positions, positions: positions,
entity: finalEntity, entity: finalEntity,
color: this.defaultStyles.sector.color, // color: this.defaultStyles.sector.color,
borderColor: this.defaultStyles.sector.color, // borderColor: this.defaultStyles.sector.color,
opacity: 0.5, opacity: 0.5,
width: this.defaultStyles.sector.width, width: this.defaultStyles.sector.width,
label: `扇形 ${this.entityCounter}` label: `扇形 ${this.entityCounter}`
@ -2066,7 +2066,7 @@ export default {
this.drawingPoints = []; this.drawingPoints = [];
}, },
// 线 // 线
generateCirclePositions(center, radius, numPoints = 128) { generateCirclePositions(center, radius, numPoints = 1024) {
const positions = []; const positions = [];
const ellipsoid = this.viewer.scene.globe.ellipsoid; const ellipsoid = this.viewer.scene.globe.ellipsoid;
@ -2143,7 +2143,7 @@ export default {
// //
angleDiff = Math.max(0.01, angleDiff); 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); const angleStep = angleDiff / (numPoints - 1);
// //
for (let i = 0; i < numPoints; i++) { for (let i = 0; i < numPoints; i++) {
@ -2158,6 +2158,14 @@ export default {
positions.push(center); positions.push(center);
return positions; 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) { calculateDistance(point1, point2) {
return Cesium.Cartesian3.distance(point1, point2); return Cesium.Cartesian3.distance(point1, point2);
@ -2199,12 +2207,12 @@ export default {
} }
return []; return [];
}, false), }, false),
width: 8, // width: 12, //
// 使 // 使
material: new Cesium.PolylineArrowMaterialProperty( material: new Cesium.PolylineArrowMaterialProperty(
Cesium.Color.fromCssColorString(this.defaultStyles.arrow.color) Cesium.Color.fromCssColorString(this.defaultStyles.arrow.color)
), ),
clampToGround: true, // arcType: Cesium.ArcType.NONE,
widthInMeters: false // 使 widthInMeters: false // 使
} }
}); });
@ -2252,11 +2260,11 @@ export default {
name: `箭头 ${this.entityCounter}`, name: `箭头 ${this.entityCounter}`,
polyline: { polyline: {
positions: positions, positions: positions,
width: 8, // width: 12, //
material: new Cesium.PolylineArrowMaterialProperty( material: new Cesium.PolylineArrowMaterialProperty(
Cesium.Color.fromCssColorString(this.defaultStyles.arrow.color) Cesium.Color.fromCssColorString(this.defaultStyles.arrow.color)
), ),
clampToGround: true, arcType: Cesium.ArcType.NONE,
// 使 // 使
widthInMeters: false widthInMeters: false
} }
@ -2584,7 +2592,7 @@ export default {
positions: polygonPositions, positions: polygonPositions,
width: this.defaultStyles.polygon.width, width: this.defaultStyles.polygon.width,
material: Cesium.Color.fromCssColorString(this.defaultStyles.polygon.color), material: Cesium.Color.fromCssColorString(this.defaultStyles.polygon.color),
clampToGround: true arcType: Cesium.ArcType.NONE
} }
}) })
const entityData = { const entityData = {
@ -2636,13 +2644,13 @@ export default {
position: center, // position: center, //
// 使 ellipse () // 使 ellipse ()
ellipse: { ellipse: {
semiMinorAxis: validRadius, // = semiMinorAxis: validRadius,
semiMajorAxis: validRadius, // = semiMajorAxis: validRadius,
//
material: Cesium.Color.TRANSPARENT, material: Cesium.Color.TRANSPARENT,
outline: true, outline: true,
outlineColor: Cesium.Color.fromCssColorString(this.defaultStyles.circle.color), outlineColor: Cesium.Color.fromCssColorString(this.defaultStyles.circle.color),
outlineWidth: this.defaultStyles.circle.width outlineWidth: this.defaultStyles.circle.width,
arcType: Cesium.ArcType.NONE
} }
}) })
// entity // entity

Loading…
Cancel
Save