123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544 |
- <template>
- <div>
- <i class="cesiumbtn" :class="store.state.viewer_flag ? 'el-icon-aim' : 'el-icon-rank'" :title="isbig ? '缩小' : '放大'"
- @click="bigViewerChange"></i>
- <div v-show="store.state.viewer_flag" class="viewer">
- <div class="bg">
- <div class="bg_left"></div>
- <div class="bg_right"></div>
- <div class="bg_bottom"></div>
- </div>
- <datePicker @dateChange="dateChange"></datePicker>
- <!-- <ser-center></ser-center> -->
- <KJZB ref="gkzb_ref" />
- <JCBD />
- <TDSC ref="tdsc_ref" />
- <TDSY ref="tdgy_ref" />
- <GDBH ref="gdbh_ref" />
- <STXF ref="stxf_ref" />
- <WPJG ref="wpjg_ref" />
- <div class="bottom_model">
- <div class="bjxm_box">
- <BJXM ref="bjxm_ref" />
- </div>
- <div class="hysy_box">
- <ydjc ref="ydjc_ref" />
- </div>
- </div>
- </div>
- <Boxcommon v-show="!store.state.viewer_flag"></Boxcommon>
- <InfoVector v-show="!store.state.viewer_flag"></InfoVector>
- </div>
- </template>
- <script>
- //这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
- import KJZB from './cockpit/kjgh';
- import TDSC from './cockpit/tdsc';
- import HYSY from './cockpit/hysy';
- import YDHC from './cockpit/ydjc';
- import TDSY from './cockpit/tdsy';
- import BJXM from './cockpit/bjxm';
- import GDBH from './cockpit/gdbh';
- import STXF from './cockpit/stxf';
- import WPJG from './cockpit/wpjg';
- import JCBD from './cockpit/jcbd';
- import Boxcommon from '@/views/cockpit/common/VectorSpace/BoxCommonVector.vue';
- import InfoVector from '@/views/cockpit/common/VectorSpace/InfoVector.vue';
- import datePicker from './cockpit/datePicker.vue';
- import xzqh from "../../static/data/460200_full.json";
- import hyqy from "../../static/data/460200_hyqy.json";
- import * as tdsy from "@/views/cockpit/js/tdsy";
- import { cockpitInfo } from '@/api/cockpit'
- import * as cockpit from "@/common/js/cockpit.js";
- import Ydjc from './cockpit/ydjc.vue';
- export default {
- name: 'viewer',
- components: { KJZB, BJXM, TDSC, HYSY, TDSY, GDBH, STXF, WPJG, datePicker, JCBD, Boxcommon, InfoVector, YDHC, Ydjc },
- data() {
- return {
- params: {
- beginTime: '',
- endTime: '',
- id: 4602,
- name: ""
- },
- flag: true,
- xzqh_color_click: "rgba(46, 177, 251, 0.6)",
- xzqh_color: "rgba(10, 95, 152, 0.5)",
- primitivesL: [],
- };
- },
- //监听属性 类似于data概念
- computed: {
- isViewer_flag() {
- return store.state.viewer_flag; //需要监听的数据
- },
- isxzqh_flag() {
- return store.state.xzqh_flag; //需要监听的数据
- },
- },
- //监控data中的数据变化
- watch: {
- isViewer_flag(newVal, oldVal) {
- cockpit.hidden_xzqh(newVal);
- cockpit.hidden_wall(newVal);
- if (newVal) {
- viewer.camera.flyTo({ //定位到范围中心点
- destination: {
- x: -2040463.7901390342,
- y: 5793227.819015942,
- z: 1894583.1762108966
- },
- orientation: {
- heading: 0.000005686606919574899,
- pitch: -0.41034310444770905,
- roll: 0.0
- },
- })
- }
- },
- isxzqh_flag(newVal, oldVal) {
- cockpit.hidden_xzqh(newVal);
- cockpit.hidden_wall(newVal);
- }
- },
- //方法集合
- methods: {
- bigViewerChange() {
- store.setViewerFlagb(!store.state.viewer_flag);
- store.setToolBarShow(!store.state.viewer_flag);
- tdsy.remove();
- store.state.vectorData = [];
- // store.setToolBarShow(true);
- // // 隐藏行政区划
- // cockpit.hidden_xzqh(store.state.viewer_flag);
- // // 隐藏墙体
- // cockpit.hidden_wall(store.state.viewer_flag);
- },
- switch() {
- this.flag = !this.flag;
- },
- setDatas() {
- // 耕地保护
- this.$refs.gdbh_ref.init_zbph(this.params);
- this.$refs.gdbh_ref.init_info(this.params);
- this.$refs.gdbh_ref.init_zbph_hz(this.params);
- this.$refs.gdbh_ref.init_jcpg_hz(this.params);
- this.$refs.gdbh_ref.init_jcph_table(this.params);
- // this.$refs.stxf_ref.setData({ id: this.params.id });
- // this.$refs.wpjg_ref.setData(this.params);
- // 卫片监管
- this.$refs.wpjg_ref.switch_xzqh(this.params);
- this.$refs.wpjg_ref.init_wpjg_title(this.params);
- // 土地收储
- this.$refs.tdsc_ref.init_tdsc_jg(this.params);
- this.$refs.tdsc_ref.init_scjd(this.params);
- // 土地供应
- this.$refs.tdgy_ref.init_tdgy_gy_jd(this.params);
- this.$refs.tdgy_ref.init_tdgy_gy_jg(this.params);
- this.$refs.tdgy_ref.init_tdgy_jt_jg(this.params);
- this.$refs.tdgy_ref.getInfo(this.params);
- this.$refs.tdgy_ref.init_tdgy_jt_jd(this.params);
- this.$refs.tdgy_ref.init_echart_data(this.params);
- this.$refs.tdgy_ref.init_info(this.params);
- // 海域使用
- // this.$refs.hysy_ref.init_info(this.params);
- // this.$refs.hysy_ref.init_echart_data(this.params);
- // 报建项目
- this.$refs.bjxm_ref.switch_xzqh(this.params);
- this.$refs.bjxm_ref.init_info(this.params);
- // this.$refs.bjxm_ref.init_bjxm_echart_info(this.params);
- // 生态修复
- this.$refs.stxf_ref.getInfo(this.params);
- this.$refs.stxf_ref.tdzz(this.params);
- // 用地监管
- this.$refs.ydjc_ref.switch_xzqh(this.params);
- },
- dateChange(date) {
- this.params.beginTime = date[0]
- this.params.endTime = date[1]
- store.setCockpitDate(date);
- this.setDatas()
- },
- async gkzb_xzqh(address) {
- let obj = {
- // beginTime: store.state.cockpit_date[0],
- // endTime: store.state.cockpit_date[1],
- jscType: 'jsc_gkzb_ztgu_stbh',
- id: address
- };
- let data = await cockpitInfo(obj);
- let obj_yjjbntmj = {
- jscType: 'jsc_gdbh_ztgh_nt',
- id: address
- };
- let obj_yjjbntmj_data = await cockpitInfo(obj_yjjbntmj);
- let obj_kfbjmj = {
- jscType: 'jsc_gkzb_ztgh_kfbj',
- id: address
- };
- let obj_kfbjmj_data = await cockpitInfo(obj_kfbjmj);
- let obj_gdbhmb = {
- jscType: 'jsc_gkzb_ztgu_gdbhmb',
- id: address
- };
- let obj_gdbhmb_data = await cockpitInfo(obj_gdbhmb);
- store.setCockpitGkzb({
- mj: data.data[0].mj,// 生态保护红线面积
- ly_mj: data.data[0].ly_mj,// 路域生态保护红线
- hy_mj: data.data[0].hy_mj,//近海岸面积
- yjjbntmj: obj_yjjbntmj_data.data[0].yjjbntmj,// 永久基本农田保护面积
- kfbjmj: obj_kfbjmj_data.data[0].kfbjmj,// 城市开发边界
- bfb: (obj_kfbjmj_data.data[0].bfb * 100).toFixed(2),// 覆盖城镇开发边界
- tbmj_ys: obj_gdbhmb_data.data[0].tbmj_ys,//耕地保护目标
- ghdkmj: obj_kfbjmj_data.data[0].ghdkmj//已入库管控范围
- });
- },
- async gkzb() {
- const that = this;
- that.$refs.gkzb_ref["initData"]();
- },
- async pick_xzqh() {
- const that = this;
- const handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
- handler.setInputAction(async event => {
- let pickObj = viewer.scene.pick(event.position);
- var position = viewer.scene.pickPosition(event.position);
- if (!position)//点击到地球之外
- return false;
- var cartographic = Cesium.Cartographic.fromCartesian(position);
- let longitude = Cesium.Math.toDegrees(cartographic.longitude);
- let latitude = Cesium.Math.toDegrees(cartographic.latitude);
- let height = cartographic.height;
- let heading = viewer.scene.camera.heading;
- let pitch = viewer.scene.camera.pitch;
- if (!position) {
- position = Cesium.Cartesian3.fromDegrees(0, 0, 0);
- return;
- }
- if (store.state.viewer_flag) {
- if (Cesium.defined(pickObj)) {
- if (pickObj.primitive instanceof Cesium.Primitive) {//点击primitive
- //primitive相关操作
- let obj = JSON.parse(pickObj.id);
- let pri_name = obj.name;
- let adcode = obj.adcode
- that.params.id = adcode
- that.params.name = pri_name
- store.setCockpitRegion(obj)
- that.setDatas()
- // 管控指标
- that.gkzb_xzqh(adcode);
- cockpit.pick_xzqh(pri_name);
- }
- } else {
- // 暂时点击周围数据显示三亚市
- // 清除所有xzqh状态
- cockpit.pick_xzqh();
- // 管控指标
- that.gkzb();
- that.params.id = '4602'
- that.setDatas()
- store.setCockpitRegion({ id: '4602', name: '三亚市' })
- }
- }
- }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
- },
- colorFun(color) {
- // * `czm_material czm_getMaterial(czm_materialInput materialInput) {...}`: 这是一个名为 `czm_getMaterial` 的函数,它接受一个 `czm_materialInput` 类型的参数并返回一个 `czm_material` 类型的对象。这是 Cesium 中的一个约定,允许你通过编写自定义的 GLSL 代码来定义材质。
- // * `czm_material material = czm_getDefaultMaterial(materialInput);`: 获取默认的材质设置。
- // * `vec2 st = materialInput.st;`: 从输入中获取纹理坐标(texture coordinates)。
- // * `float dis = distance(st, vec2(0.5));`: 计算纹理坐标与中心 `(0.5, 0.5)` 的距离。
- // * `material.diffuse = color.rgb;`: 设置材质的漫反射颜色为你提供的 `color` 的 RGB 部分。
- // * `material.alpha = clamp(dis * 2.0, 0.1, 0.7);`: 根据与中心的距离设置材质的透明度(alpha)。使用 `clamp` 函数确保透明度值在 0.1 和 0.7 之间。
- const fs = `czm_material czm_getMaterial(czm_materialInput materialInput)
-
- {
- czm_material material = czm_getDefaultMaterial(materialInput);
- vec2 st = materialInput.st;
- float dis = distance(st,vec2(0.5));
- material.diffuse = color.rgb;
- material.alpha = clamp( dis * 2.0, 0.1, 0.3);
- return material;
- }
- `
- const material = new Cesium.Material({
- fabric: {
- uniforms: {
- color: color
- },
- source: fs,
- }
- })
- const aper = new Cesium.MaterialAppearance({
- material,
- source: fs,
- })
- return aper;
- },
- init_xzqh() {
- const that = this;
- xzqh.features.forEach((res) => {
- let obj = {
- 'type': "cockpit",
- 'name': res.properties.name,
- 'centroid': res.properties.centroid,
- 'adcode': res.properties.adcode,
- }
- res.geometry.coordinates.forEach((item) => {
- const twoDArray = item[0];
- const oneDArray = twoDArray.reduce((accumulator, currentValue) => accumulator.concat(currentValue), []);
- that.primitivesL.push(JSON.stringify(obj));
- // 行政区划
- let polygon = new Cesium.GeometryInstance({
- id: JSON.stringify(obj),
- geometry: new Cesium.PolygonGeometry({
- minimum: new Cesium.Cartesian3(0, 0, 0),
- maximum: new Cesium.Cartesian3(100000, 100000, 100000),
- polygonHierarchy: new Cesium.PolygonHierarchy(
- Cesium.Cartesian3.fromDegreesArray(oneDArray)
- ),
- height: 100,
- extrudedHeight: res.properties.extrudedHeight,
- })
- })
- let addPolygonGeometry = new Cesium.Primitive({
- geometryInstances: polygon,
- appearance: that.colorFun(Cesium.Color.fromCssColorString('#139FF0')),
- show: true,
- })
- // manager.add(addPolygonGeometry)
- cockpit.addPrimitive(addPolygonGeometry);
- viewer.scene.primitives.add(addPolygonGeometry)
- // 墙体流动效果
- var positions = Cesium.Cartesian3.fromDegreesArray(oneDArray);
- cockpit.add_wall(obj, positions, res);
- })
- })
- },
- init_hyqy() {
- const that = this;
- hyqy.features.forEach((res) => {
- let obj = {
- 'type': "cockpit",
- 'name': res.properties.name,
- 'centroid': res.properties.centroid,
- 'adcode': res.properties.adcode,
- }
- const twoDArray = res.geometry.coordinates[0];
- const oneDArray = twoDArray.reduce((accumulator, currentValue) => accumulator.concat(currentValue), []);
- cockpit.add_hy(obj, res, oneDArray, that.xzqh_color);
- })
- },
- addSceneFun() {
- var pitch = viewer.camera.pitch;
- //获取当前视角的heading
- var heading = viewer.camera.heading;
- //获取当前视角的postion(位置)
- var position = viewer.camera.position;
- var x = position.x;
- var y = position.y;
- var z = position.z;
- var testPitch = pitch;
- var testHeading = heading;
- // console.log("获取当前视角x,y,z", position.x, position.y, position.z, "pitch", pitch, "heading", heading);
- var obj = {
- "x": x,
- "y": y,
- "z": z,
- "pitch": pitch,
- "heading": heading,
- }
- console.log(obj, "asd");
- },
- flatten3DArray(arr) {
- let stack = [...arr]; // 初始化栈,并将数组元素压入栈中
- let result = []; // 用于存储结果的一维数组
- while (stack.length > 0) {
- let current = stack.pop(); // 弹出栈顶元素
- if (Array.isArray(current)) {
- // 如果当前元素是数组,则将其元素压入栈中(逆序)
- for (let i = current.length - 1; i >= 0; i--) {
- stack.push(current[i]);
- }
- } else {
- // 如果当前元素不是数组,则将其添加到结果数组中
- result.push(current);
- }
- }
- // 注意:因为我们是逆序压入栈中的,所以结果数组的顺序与原始三维数组中的顺序相反
- // 如果需要保持原始顺序,可以在压入栈时使用unshift代替push,但这样会降低性能
- return result;
- },
- },
- beforeCreate() { }, //生命周期 - 创建之前
- created() { }, //生命周期 - 创建完成(可以访问当前this实例)
- beforeMount() { }, //生命周期 - 挂载之前
- async mounted() {
- this.$nextTick((res) => {
- cockpit.init(viewer);
- this.pick_xzqh();
- this.init_xzqh();
- this.init_hyqy();
- // viewer.scene.debugShowFramesPerSecond = true;
- });
- }, //生命周期 - 挂在完成
- beforeUpdate() { }, //生命周期 - 更新之前
- updated() { }, //生命周期 - 更新之后
- beforeDestroy() { }, //生命周期 - 销毁之前
- destroy() { },//生命周期 - 销毁完成
- activated() {
- cockpit.hidden_xzqh(true);
- cockpit.hidden_wall(true);
- }, //若组件实例是 <KeepAlive> 缓存树的一部分,当组件被插入到 DOM 中时调用。
- deactivated() {
- cockpit.hidden_xzqh(false);
- cockpit.hidden_wall(false);
- } //若组件实例是 <KeepAlive> 缓存树的一部分,当组件从 DOM 中被移除时调用。
- };
- </script>
- <style scoped lang="scss" >
- .viewer {
- width: 100%;
- height: 100%;
- }
- .bg {
- width: 100%;
- height: 100%;
- .bg_left {
- width: 21.6%;
- height: calc(100% + 60px);
- position: absolute;
- top: -60px;
- left: 0;
- z-index: 100;
- background: linear-gradient(to right, rgba(6, 37, 66, 1), rgba(26, 28, 53, 0));
- }
- .bg_right {
- width: 21.6%;
- height: calc(100% + 60px);
- position: absolute;
- top: -60px;
- right: 0;
- z-index: 100;
- background: linear-gradient(to left, rgba(6, 37, 66, 1), rgba(26, 28, 53, 0));
- }
- .bg_bottom {
- width: 100%; // 56.8%;
- height: 30%;
- position: absolute;
- // left: 21.6%;
- bottom: 0;
- z-index: 100;
- background: linear-gradient(to top, rgba(6, 37, 66, 0.5), rgba(26, 28, 53, 0));
- }
- }
- .bottom_model {
- // border: 1px solid red;
- position: absolute;
- left: 28.5vw;
- width: 44vw;
- height: 29vh;
- z-index: 100;
- top: 63vh;
- .bjxm_box {
- // border: 1px solid red;
- width: 48%;
- height: 100%;
- display: inline-block;
- }
- .hysy_box {
- // border: 1px solid red;
- width: 48%;
- height: 100%;
- display: inline-block;
- float: right;
- }
- }
- </style>
|