Browse Source

常规上传

Koishi 3 months ago
parent
commit
f7c80804f1
2 changed files with 51 additions and 46 deletions
  1. BIN
      public/static/image/output.png
  2. 51 46
      src/views/cesium.vue

BIN
public/static/image/output.png


+ 51 - 46
src/views/cesium.vue

@@ -242,11 +242,11 @@ export default {
       showtempImg: false,
       handlerAction: null,
       sidebarRightData: null,
-      buildings: null
+      buildings: null,
     };
   },
   created() {
-    this.getWeatherData()
+    this.getWeatherData();
   },
 
   mounted() {
@@ -257,6 +257,7 @@ export default {
     }
     this.cityModel();
     // this.getData();
+    // this.test();
   },
 
   unmounted() {
@@ -267,8 +268,8 @@ export default {
       this.windLayerTimmer = null;
     }
     if (this.buildings) {
-        this.viewer.scene.primitives.remove(this.buildings); // 从场景中移除
-        this.buildings = null; // 释放引用,帮助垃圾回收
+      this.viewer.scene.primitives.remove(this.buildings); // 从场景中移除
+      this.buildings = null; // 释放引用,帮助垃圾回收
     }
 
     clearInterval(this.systemInfoTimmer);
@@ -277,19 +278,24 @@ export default {
 
   methods: {
     test() {
-      axios.post("http://localhost:3000/api/getWeather", {
-        longitude: 106.169866,
-        latitude: 38.46637,
-        level: "surface",
-        variable: "PRATE,PRES,SUNSD,VEG,VIS,VRATE,LCDC",
-      });
+      axios
+        // .get("http://localhost:3007/api/test", {
+        .post("http://localhost:3007/weather/getAreaWeatherData", {
+          longitude: 106.169866,
+          latitude: 38.46637,
+          level: "surface",
+          variable: "PRATE,PRES,SUNSD,VEG,VIS,VRATE,LCDC",
+        })
+        .then((res) => {
+          console.log(11111, res.data);
+        });
     },
     async cityModel() {
       // 添加OSM建筑 3D 模型
       try {
         Cesium.createOsmBuildingsAsync().then((buildings) => {
-            this.buildings = buildings
-            this.viewer.scene.primitives.add(buildings);
+          this.buildings = buildings;
+          this.viewer.scene.primitives.add(buildings);
         });
 
         this.viewer.terrainProvider = await Cesium.createWorldTerrainAsync({
@@ -302,36 +308,36 @@ export default {
     },
 
     getData() {
-      getWWTempData().then(res =>{
-        console.log("res===>>>", res)
-      })
+      getWWTempData().then((res) => {
+        console.log("res===>>>", res);
+      });
     },
     async getWeatherData() {
-        let that = this
-        await that.weatherJsonChange(jsonData.data)
-        // let params = {
-        //     cityname: "上海天气"
-        // }
-        // await getBaiduTempData(params).then(res =>{
-        //     if (res && res.data) {
-        //         that.weatherJsonChange(res.data)
-        //     }
-        // })
+      let that = this;
+      await that.weatherJsonChange(jsonData.data);
+      // let params = {
+      //     cityname: "上海天气"
+      // }
+      // await getBaiduTempData(params).then(res =>{
+      //     if (res && res.data) {
+      //         that.weatherJsonChange(res.data)
+      //     }
+      // })
     },
     weatherJsonChange(datas) {
-        let obj = {
-            base: datas.base,
-            weather: datas.weather,
-            zhishu: datas.recommend_zhishu,
-            pm25: datas.ps_pm25,
-            position: datas.position,
-            // fiftyDay: datas['15_day_forecast'],
-            '15tq': datas['15_day_forecast'].info,
-            '24tg': datas['24_hour_forecast'].info,
-            '40tq': datas['long_day_forecast'].info,
-            feature: datas.feature
-        }
-        this.sidebarRightData = obj
+      let obj = {
+        base: datas.base,
+        weather: datas.weather,
+        zhishu: datas.recommend_zhishu,
+        pm25: datas.ps_pm25,
+        position: datas.position,
+        // fiftyDay: datas['15_day_forecast'],
+        "15tq": datas["15_day_forecast"].info,
+        "24tg": datas["24_hour_forecast"].info,
+        "40tq": datas["long_day_forecast"].info,
+        feature: datas.feature,
+      };
+      this.sidebarRightData = obj;
     },
     // 初始化一些监听事件
     initEventListener() {
@@ -902,11 +908,7 @@ export default {
       // 设置初始视图为宁夏
       const that = this;
       this.viewer.camera.flyTo({
-        destination: Cesium.Cartesian3.fromDegrees(
-          121.47,
-          31.23,
-          10000000
-        ),
+        destination: Cesium.Cartesian3.fromDegrees(121.47, 31.23, 10000000),
         // orientation: {
         //   heading: 1,
         //   pitch: -0.2,
@@ -992,8 +994,11 @@ export default {
       // 调用云层底图
       const cloudLayer = this.viewer.imageryLayers.addImageryProvider(
         new Cesium.UrlTemplateImageryProvider({
-          url: "https://tile.openweathermap.org/map/clouds_new/{z}/{x}/{y}.png?appid=3b66d35579770393051599f8d518df4a",
+          // url: "https://tile.openweathermap.org/map/clouds_new/{z}/{x}/{y}.png?appid=3b66d35579770393051599f8d518df4a",
+          url: "http://localhost:3007/tiles/cloud/{z}/{x}/{y}",
           credit: "云层影像地图",
+          minimumLevel: 2,
+          maximumLevel: 5,
         })
       );
 
@@ -1003,7 +1008,7 @@ export default {
       cloudLayer.contrast = 1; // 对比度
 
       this.cloudLayer = cloudLayer;
-      this.resetViewport1()
+      this.resetViewport1();
     },
     //显示降雨图
     showRainLayer() {
@@ -1029,7 +1034,7 @@ export default {
       this.viewer.imageryLayers.addImageryProvider(rainLayer);
       this.csceneElliposid(this.viewer, "rain");
       this.rainLayer = rainLayer;
-      this.resetViewport1()
+      this.resetViewport1();
     },
 
     showTemperatureLayer() {