| | |
| | | watch, |
| | | } from "vue"; |
| | | import { useStore } from "vuex"; // 引入useStore 方法 |
| | | import { selectByPoint, selectByPolygon } from "@/api/api"; |
| | | import WKT from "terraformer-wkt-parser"; |
| | | import * as turf from "@turf/turf"; |
| | | const emits = defineEmits(["setCloseplotting"]); |
| | | const store = useStore(); // 该方法用于返回store 实例 |
| | | let list = ref([]); |
| | |
| | | }); |
| | | const lineColor = ref(null); |
| | | const metiaColor = ref(null); |
| | | |
| | | //点查询接口 |
| | | const selectPoint = async () => { |
| | | const dt = await selectByPoint(); |
| | | }; |
| | | //线查询接口 |
| | | const selectPolygon = async () => { |
| | | const dt = await selectByPolygon(); |
| | | }; |
| | | const setLayerLocation = (res) => { |
| | | var entities = Viewer.entities._entities._array; |
| | | for (var i in entities) { |
| | |
| | | disableDepthTestDistance: Number.POSITIVE_INFINITY, |
| | | }, |
| | | }); |
| | | var point = turf.point([geom.lat, geom.lng]); |
| | | |
| | | var wkt = WKT.convert(point.geometry); |
| | | |
| | | list.value.push({ |
| | | name: name, |
| | | layer: layer, |
| | | icon: "d.png", |
| | | wkt: wkt, |
| | | lng: geom.lng, |
| | | lat: geom.lat, |
| | | }); |
| | | plotNum.value.point++; |
| | | }; |
| | |
| | | clampToGround: true, |
| | | }, |
| | | }); |
| | | var linestring = turf.lineString([ |
| | | [-24, 63], |
| | | [-23, 60], |
| | | [-25, 65], |
| | | [-20, 69], |
| | | ]); |
| | | |
| | | var wkt = WKT.convert(linestring.geometry); |
| | | list.value.push({ |
| | | wkt: wkt, |
| | | name: name, |
| | | layer: layer, |
| | | icon: "x.png", |
| | |
| | | const setAddEntityPolygon = (res) => { |
| | | var std = []; |
| | | var res_val = res.polygon.hierarchy.getValue().positions; |
| | | |
| | | var geom; |
| | | var coord = []; |
| | | for (var i in res_val) { |
| | | var geom = setCartesianToEightFour(res_val[i]); |
| | | geom = setCartesianToEightFour(res_val[i]); |
| | | std.push(Cesium.Cartesian3.fromDegrees(geom.lng, geom.lat)); |
| | | coord.push([geom.lng, geom.lat]); |
| | | } |
| | | var name = "Polygon#" + plotNum.value.polygon; |
| | | var layer = Viewer.entities.add({ |
| | |
| | | height: 0, |
| | | }, |
| | | }); |
| | | |
| | | coord.push(coord[0]); |
| | | |
| | | var polygon = turf.polygon([coord]); |
| | | var wkt = WKT.convert(polygon.geometry); |
| | | console.log(polygon.geometry); |
| | | let turfPoint = []; |
| | | polygon.geometry.coordinates[0].forEach((e) => { |
| | | turfPoint.push(turf.point(e)); |
| | | }); |
| | | var features = turf.featureCollection(turfPoint); |
| | | |
| | | var center = turf.center(features); |
| | | console.log(center); |
| | | list.value.push({ |
| | | wkt: wkt, |
| | | name: name, |
| | | layer: layer, |
| | | icon: "m.png", |
| | | lng: center.geometry.coordinates[0], |
| | | lat: center.geometry.coordinates[1], |
| | | }); |
| | | plotNum.value.polygon++; |
| | | }; |
| | |
| | | if (nVal.entitiesData != {} && nVal.entitiesData.name) { |
| | | for (var i in list.value) { |
| | | if (list.value[i].name == nVal.entitiesData.name) { |
| | | console.log(list.value[i].name); |
| | | list.value.splice(i, 1); |
| | | break; |
| | | } |