Selaa lähdekoodia

Merge branch 'master' of http://www.sysuimars.cn:3000/feiniao/feiniao-pc-vue

wangsisi 4 kuukautta sitten
vanhempi
commit
e4cf2af65b
11 muutettua tiedostoa jossa 1519 lisäystä ja 32 poistoa
  1. 1 0
      .env
  2. 1 0
      .env.dev
  3. 1 0
      .env.pro
  4. 2 0
      package.json
  5. 1 1
      src/api/config.js
  6. 1 0
      src/utils/ol-map/Map.js
  7. 1 1
      src/views/authentic/Pdf.vue
  8. 53 21
      src/views/authentic/authenticMap.js
  9. 14 8
      src/views/authentic/index.vue
  10. 2 1
      vue.config.js
  11. 1442 0
      yarn.lock

+ 1 - 0
.env

@@ -1 +1,2 @@
 SERVER = "http://127.0.0.1:81/"
+PYSERVER = "http://127.0.0.1:5000/"

+ 1 - 0
.env.dev

@@ -1 +1,2 @@
 SERVER = "https://feiniaotech-dev.sysuimars.cn/"
+PYSERVER = "https://birds-api-1-2.sysuimars.cn/"

+ 1 - 0
.env.pro

@@ -1 +1,2 @@
 SERVER = "https://birdseye-api.feiniaotech.sysuimars.cn/"
+PYSERVER = "https://birds-api-1-2.sysuimars.cn/"

+ 2 - 0
package.json

@@ -5,6 +5,7 @@
   "scripts": {
     "serve": "vue-cli-service serve --mode dev",
     "serve2": "vue-cli-service serve --mode local",
+    "serve3": "vue-cli-service serve --mode pro",
     "build": "vue-cli-service build --mode pro",
     "build2": "vue-cli-service build --mode dev",
     "lint": "vue-cli-service lint"
@@ -15,6 +16,7 @@
     "@iconify/iconify": "^3.1.0",
     "@iconify/json": "^2.2.42",
     "@iconify/vue": "^4.1.0",
+    "@turf/turf": "^7.1.0",
     "@vueuse/core": "^8.7.5",
     "axios": "^0.27.2",
     "core-js": "^3.23.3",

+ 1 - 1
src/api/config.js

@@ -1,6 +1,6 @@
 let server = VE_ENV.SERVER
 let serverMock = "https://mock.apipark.cn/m1/4662471-4313509-default/"
-let pythonServe = "http://birds-api-1-2.sysuimars.cn/"
+let pythonServe = VE_ENV.PYSERVER
 // let djiCloudBase = "http://127.0.0.1/";
 let djiCloudBase = "https://djiapi.sysuimars.com/";
 

+ 1 - 0
src/utils/ol-map/Map.js

@@ -399,6 +399,7 @@ class Map {
 		if(isView){
 			vm.map.getView().fit(extent, { padding: padding || [20, 20, 20, 20] });
 		}
+		return f
 	}
 
 	addLayer(layer){

+ 1 - 1
src/views/authentic/Pdf.vue

@@ -143,7 +143,7 @@ const handlePrint = () =>{
 onMounted(()=>{
   VE_API.authentic.getDetails({id:rowId.value}).then(({data})=>{
     data.createDate = dateFormat(new Date(), "YYYY-mm-dd HH:MM:SS");
-    data.area = getAreaByWkt(data.geom)
+    data.area = data.mu
     rowData.value = data
     pdfMap.initMap(data,mapRef.value)
     setTimeout(function(){

+ 53 - 21
src/views/authentic/authenticMap.js

@@ -17,6 +17,8 @@ import { register } from "ol/proj/proj4";
 import GeometryCollection from 'ol/geom/GeometryCollection.js';
 import { ElMessage } from "element-plus";
 import { useStore } from "vuex";
+import {bboxToFeature} from "../../utils/map";
+import * as turf from "@turf/turf";
 proj4.defs(
   "EPSG:38572",
   "+proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs +type=crs"
@@ -30,7 +32,8 @@ export let mapData = reactive({
   selectPointArr: [],
   isPointHide: null,
   disabledForm : false,
-  selectPoint:''
+  selectPoint:'',
+  pointIndex:-1
 });
 
 function resetMapData(){
@@ -42,6 +45,7 @@ function resetMapData(){
   mapData.isPointHide= null
   mapData.disabledForm= false
   mapData.selectPoint= ''
+  mapData.pointIndex=-1
 }
 
 /**
@@ -93,7 +97,7 @@ class AuthenticMap {
       },
     });
 
-    this.selectPointLayer = new KMap.VectorLayer("selectPointLayer", 9999, {
+    this.selectPointLayer = new KMap.VectorLayer("selectPointLayer", 10000, {
       style: () => {
         return new Style({
           // geometry: new Point(coord[0][i]),
@@ -222,13 +226,11 @@ class AuthenticMap {
   }
 
   // 开始编辑
-  startModify(type) {
+  startModify(type, feature) {
     this.kmap.startModify();
     this.kmap.endDraw();
     if(type==='upload'){
-      const arr = this.kmap.getLayerFeatures()
-      const lastItem = arr[arr.length - 1]
-      mapData.point = lastItem
+      mapData.point = feature
       mapData.point.set("icon", "point-act");
       this.kmap.polygonStyle(mapData.point);
       mapData.isPointHide = mapData.point;
@@ -295,32 +297,60 @@ class AuthenticMap {
   selectPonitFun(map,evt){
     let that = this
     map.forEachFeatureAtPixel(evt.pixel, function (f, layer) {
+      let d = 0.0002
+      let buff =  bboxToFeature(evt.pixel[0] - d,evt.pixel[1] - d, evt.pixel[0]+ d, evt.pixel[1] + d)
       if (
         layer instanceof VectorLayer &&
         (
           layer.get("name") === "defaultPolygonLayer")
       ) {
-        const features = map.getFeaturesAtPixel(evt.pixel);
-        if (features.length > 0) {
-          const feature = features[0];
+        const fs = map.getFeaturesAtPixel(evt.pixel);
+        let lonlat = map.getCoordinateFromPixel(evt.pixel);
+        if (fs.length > 0) {
+          const feature = fs[0];
           const geometry = feature.getGeometry();
-          const coordinates = geometry.getCoordinates()[0]; // 获取多边形的顶点坐标
-          if(Array.isArray(coordinates)){
-            ElMessage.warning("编辑中")
-          }else{
+          let coordinates = geometry.getCoordinates()[0]; // 获取多边形的顶点坐标
             ElMessage.success("已选择该点位")
             let list 
+            // if(mapData.selectPointArr.length>0){
+            //   list = f.getGeometry().getCoordinates();
+            // }else{
+            //   list = mapData.point.getGeometry().getCoordinates();
+            // }
+            // const arr = list[0][0].find(subArray => subArray.includes(coordinates))
+            // that.selectPointLayer.source.clear();
+            // let point = new Feature(new Point(arr));
+            // that.selectPointLayer.addFeature(point);
             if(mapData.selectPointArr.length>0){
               list = f.getGeometry().getCoordinates();
             }else{
               list = mapData.point.getGeometry().getCoordinates();
             }
-            const arr = list[0][0].find(subArray => subArray.includes(coordinates))
-            that.selectPointLayer.source.clear();
+            coordinates = list[0][0]
+            let arr = []
+            let i = 0;let curDistance = 0
+            for(let subArray of coordinates){
+              let from = turf.point(subArray);
+              let to = turf.point(lonlat);
+              let options = { units: "miles" };
+              let distance = turf.distance(from, to, options);
+              if(distance < 0.1){
+                if(curDistance == 0){
+                  arr = subArray
+                  curDistance = distance
+                  mapData.pointIndex = i
+                }else if(curDistance > distance){
+                  arr = subArray
+                  curDistance = distance
+                  mapData.pointIndex = i
+                }
+              }
+              i++
+            }
+            that.selectPointLayer.refresh();
             let point = new Feature(new Point(arr));
             that.selectPointLayer.addFeature(point);
             mapData.selectPoint = coordinates
-          }
         }
       }
     });
@@ -384,25 +414,27 @@ class AuthenticMap {
   //添加地块
   setAreaGeometry(geometryArr) {
     let that = this;
+    let res = []
     geometryArr.map((item) => {
       item.icon = "point";
       item.iconHide = "false";
-      that.kmap.setLayerWkt(item.featureWkt, item);
+      res.push(that.kmap.setLayerWkt(item.featureWkt, item));
     });
+    return res
   }
 
   deletePointFun(point,callback){
     const coordinates = point.getGeometry().getCoordinates();
     let array = coordinates[0][0]
-    const index = array.findIndex(subArray => subArray.includes(mapData.selectPoint))
     // 如果点存在,则删除它
-    if (index > -1) {
-      coordinates[0][0].splice(index, 1); // 删除点
+    if (mapData.pointIndex > -1) {
+      array.splice(mapData.pointIndex, 1); // 删除点
       // 更新多边形的坐标
       point.getGeometry().setCoordinates(coordinates); // 更新几何形状
+      mapData.pointIndex = -1
     }
     this.clearSelectPoint()
-    callback && callback(index)
+    callback && callback(mapData.pointIndex)
   }
 
   // 移除点的功能

+ 14 - 8
src/views/authentic/index.vue

@@ -228,6 +228,7 @@ import { dateFormat } from "@/utils/date_util";
 import { exportExcel, parseMultiPolygon } from "@/utils/index";
 import { useStore } from "vuex";
 import Pdf from "./Pdf";
+import {Feature} from "ol";
 const pdfShow = ref(false);
 const mouseStyle = ref(1);
 const router = useRouter();
@@ -451,15 +452,15 @@ const onSuccess = (res) => {
         disabledForm.value = false;
         formInline.createDate = dateFormat(new Date(), "YYYY-mm-dd HH:MM:SS");
         const geom = [{ featureWkt: res.data.geom, ...res.data }];
-        authenticMap.setAreaGeometry(geom);
+        let featureList = authenticMap.setAreaGeometry(geom);
         authenticMap.fit([res.data.geom]);
-        updatePointList("upload");
+        updatePointList("upload", geom[0]);
         heightArr.value = res.data.height;
         const arr = pointList.value.map((item, index) => {
             return [...item, res.data.height[index]];
         });
         getArea(arr);
-        authenticMap.startModify("upload");
+        authenticMap.startModify("upload", featureList[0]);
         uploadRef.value.clearFiles();
     } else {
         ElMessage.error("上传失败");
@@ -611,14 +612,19 @@ const getDetailsData = (id) => {
 };
 
 // 添加经纬度列表
-const updatePointList = (type) => {
-    const { geometryArr, area } = authenticMap.getAreaGeometry(type);
-    const lastItem = geometryArr[geometryArr.length - 1];
+const updatePointList = (type, geom) => {
+  const { geometryArr, area } = authenticMap.getAreaGeometry(type);
+  let lastItem = null
+    if(type === 'upload'){
+      lastItem = geom
+    }else{
+      lastItem = geometryArr[geometryArr.length - 1];
+    }
     formInline.geom = lastItem.featureWkt;
-    let result = parseMultiPolygon(lastItem.featureWkt);
+  debugger
+  let result = parseMultiPolygon(lastItem.featureWkt);
     result.pop();
     pointList.value = result;
-
     //判断是否是导入数据
     if (store.state.authentic.isEditStatus) {
         const arr = pointList.value.map((item, index) => {

+ 2 - 1
vue.config.js

@@ -58,7 +58,8 @@ module.exports = {
             {
                 VE_ENV: {
                     MODE: JSON.stringify(process.env.NODE_ENV),
-                    SERVER: JSON.stringify(process.env.SERVER)
+                    SERVER: JSON.stringify(process.env.SERVER),
+                    PYSERVER: JSON.stringify(process.env.PYSERVER)
                 },
             },
         ]);

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1442 - 0
yarn.lock


Kaikkia tiedostoja ei voida näyttää, sillä liian monta tiedostoa muuttui tässä diffissä