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(),
imageryProvider: false,
terrainProvider: new Cesium.EllipsoidTerrainProvider(),
baseLayer: false
baseLayer: false,
contextOptions: {
webgl: {
antialias: true,
msaa: true,
msaaSamples: 8
}
}
})
this.viewer.cesiumWidget.creditContainer.style.display = "none"
this.loadOfflineMap()
@ -847,6 +854,8 @@ export default {
this.initMouseCoordinates()
console.log('Cesium离线二维地图已加载')
console.log('Cesium离线二维地图已加载')
// FXAA 齿
this.viewer.scene.postProcessStages.fxaa.enabled = true
// 1.
this.handler = new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas);
this.handler.setInputAction((click) => {
@ -1483,7 +1492,7 @@ export default {
width: this.defaultStyles.polygon.width,
// 使线
material: Cesium.Color.fromCssColorString(this.defaultStyles.polygon.color),
clampToGround: true
arcType: Cesium.ArcType.NONE
}
});
}
@ -1580,7 +1589,7 @@ export default {
}, false),
width: this.defaultStyles.rectangle.width,
material: Cesium.Color.fromCssColorString(this.defaultStyles.rectangle.color),
clampToGround: true //
arcType: Cesium.ArcType.NONE
}
});
}
@ -1640,7 +1649,7 @@ export default {
positions: borderPositions,
width: this.defaultStyles.rectangle.width,
material: Cesium.Color.fromCssColorString(this.defaultStyles.rectangle.color),
clampToGround: true
arcType: Cesium.ArcType.NONE
}
});
// 4.
@ -1787,10 +1796,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(() => {
@ -1811,7 +1819,7 @@ export default {
}, false),
width: this.defaultStyles.circle.width,
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 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.
@ -1903,8 +1908,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);
@ -1939,14 +1943,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);
@ -1973,9 +1977,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: {
@ -1995,14 +1997,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]);
}
@ -2032,16 +2034,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.
@ -2055,8 +2055,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}`
@ -2066,7 +2066,7 @@ export default {
this.drawingPoints = [];
},
// 线
generateCirclePositions(center, radius, numPoints = 128) {
generateCirclePositions(center, radius, numPoints = 1024) {
const positions = [];
const ellipsoid = this.viewer.scene.globe.ellipsoid;
@ -2143,7 +2143,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++) {
@ -2158,6 +2158,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);
@ -2199,12 +2207,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 // 使
}
});
@ -2252,11 +2260,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
}
@ -2584,7 +2592,7 @@ export default {
positions: polygonPositions,
width: this.defaultStyles.polygon.width,
material: Cesium.Color.fromCssColorString(this.defaultStyles.polygon.color),
clampToGround: true
arcType: Cesium.ArcType.NONE
}
})
const entityData = {
@ -2636,13 +2644,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

Loading…
Cancel
Save