Sfoglia il codice sorgente

处理堆栈异常

tengmingxue 3 anni fa
parent
commit
a447906586

+ 7 - 0
README.md

@@ -35,9 +35,11 @@ npm install viewerjs
 npm install shapefile
 
 # 监听元素变化的插件
+
 npm install element-resize-detector
 
 # 启动服务报错缺少 hls.js 运行 (插件说明:安装摄像头视频播放插件)
+
 npm install hls.js --save
 
 ## 发布
@@ -65,3 +67,8 @@ npm run build:stage
 # 构建生产环境(服务器)
 
 npm run build:prod
+
+# 处理内存溢出
+
+npm install --save-dev increase-memory-limit
+npm install --save-dev cross-env

File diff suppressed because it is too large
+ 20486 - 20484
package-lock.json


+ 84 - 81
package.json

@@ -1,81 +1,84 @@
-{
-  "name": "admin",
-  "version": "1.0.0",
-  "description": "Element UI & axios & iconfont & permission control & lint",
-  "scripts": {
-    "dev": "vue-cli-service serve --max-old-space-size=2048",
-    "build:prod": "vue-cli-service build",
-    "build:stage": "vue-cli-service build --mode staging",
-    "preview": "node build/index.js --preview",
-    "lint": "eslint --ext .js,.vue src"
-  },
-  "dependencies": {
-    "@supermap/iclient-ol": "^10.1.2",
-    "axios": "0.18.1",
-    "core-js": "^2.6.11",
-    "echarts": "^4.9.0",
-    "element-ui": "2.13.0",
-    "hls.js": "^1.0.2",
-    "html2canvas": "^1.0.0-rc.7",
-    "jquery": "^3.5.1",
-    "js-cookie": "2.2.0",
-    "kscreenshot": "^1.2.3",
-    "mxgraph": "^4.2.2",
-    "normalize.css": "7.0.0",
-    "nprogress": "0.2.0",
-    "path-to-regexp": "2.4.0",
-    "q": "^1.5.1",
-    "qs": "^6.9.0",
-    "sha1-hex": "^1.0.0",
-    "viewerjs": "^1.9.0",
-    "vue": "2.6.10",
-    "vue-baidu-map": "^0.21.22",
-    "vue-router": "3.0.6",
-    "vue-worker": "^1.2.1",
-    "vuedraggable": "^2.24.3",
-    "vuex": "3.1.0",
-    "vuex-persistedstate": "^3.0.1"
-  },
-  "devDependencies": {
-    "@babel/core": "7.0.0",
-    "@babel/register": "7.0.0",
-    "@vue/cli-plugin-babel": "3.6.0",
-    "@vue/cli-plugin-eslint": "^3.9.1",
-    "@vue/cli-plugin-unit-jest": "3.6.3",
-    "@vue/cli-service": "3.6.0",
-    "@vue/test-utils": "1.0.0-beta.29",
-    "autoprefixer": "^9.5.1",
-    "babel-core": "7.0.0-bridge.0",
-    "babel-eslint": "10.0.1",
-    "babel-jest": "23.6.0",
-    "babel-plugin-transform-remove-strict-mode": "^0.0.2",
-    "chalk": "2.4.2",
-    "compression-webpack-plugin": "^4.0.0",
-    "connect": "3.6.6",
-    "element-resize-detector": "^1.2.1",
-    "element-theme-chalk": "^2.13.2",
-    "eslint": "5.15.3",
-    "eslint-plugin-vue": "5.2.2",
-    "html-webpack-plugin": "3.2.0",
-    "image-webpack-loader": "^6.0.0",
-    "mockjs": "1.0.1-beta3",
-    "node-sass": "^4.9.0",
-    "runjs": "^4.3.2",
-    "sass-loader": "^7.1.0",
-    "script-ext-html-webpack-plugin": "2.1.3",
-    "script-loader": "0.7.2",
-    "serve-static": "^1.13.2",
-    "svg-sprite-loader": "4.1.3",
-    "svgo": "1.2.2",
-    "vue-baidu-map": "^0.21.22",
-    "vue-template-compiler": "2.6.10"
-  },
-  "engines": {
-    "node": ">=8.9",
-    "npm": ">= 3.0.0"
-  },
-  "browserslist": [
-    "> 1%",
-    "last 2 versions"
-  ]
-}
+{
+  "name": "admin",
+  "version": "1.0.0",
+  "description": "Element UI & axios & iconfont & permission control & lint",
+  "scripts": {
+    "dev": "vue-cli-service serve --max-old-space-size=4096",
+    "build:prod": "vue-cli-service build",
+    "build:stage": "vue-cli-service build --mode staging",
+    "preview": "node build/index.js --preview",
+    "lint": "eslint --ext .js,.vue src",
+    "fix-memory-limit": "cross-env LIMIT=4096 increase-memory-limit"
+  },
+  "dependencies": {
+    "@supermap/iclient-ol": "^10.1.2",
+    "axios": "0.18.1",
+    "core-js": "^2.6.11",
+    "echarts": "^4.9.0",
+    "element-ui": "2.13.0",
+    "hls.js": "^1.0.2",
+    "html2canvas": "^1.0.0-rc.7",
+    "jquery": "^3.5.1",
+    "js-cookie": "2.2.0",
+    "kscreenshot": "^1.2.3",
+    "mxgraph": "^4.2.2",
+    "normalize.css": "7.0.0",
+    "nprogress": "0.2.0",
+    "path-to-regexp": "2.4.0",
+    "q": "^1.5.1",
+    "qs": "^6.9.0",
+    "sha1-hex": "^1.0.0",
+    "viewerjs": "^1.9.0",
+    "vue": "2.6.10",
+    "vue-baidu-map": "^0.21.22",
+    "vue-router": "3.0.6",
+    "vue-worker": "^1.2.1",
+    "vuedraggable": "^2.24.3",
+    "vuex": "3.1.0",
+    "vuex-persistedstate": "^3.0.1"
+  },
+  "devDependencies": {
+    "@babel/core": "7.0.0",
+    "@babel/register": "7.0.0",
+    "@vue/cli-plugin-babel": "3.6.0",
+    "@vue/cli-plugin-eslint": "^3.9.1",
+    "@vue/cli-plugin-unit-jest": "3.6.3",
+    "@vue/cli-service": "3.6.0",
+    "@vue/test-utils": "1.0.0-beta.29",
+    "autoprefixer": "^9.5.1",
+    "babel-core": "7.0.0-bridge.0",
+    "babel-eslint": "10.0.1",
+    "babel-jest": "23.6.0",
+    "babel-plugin-transform-remove-strict-mode": "^0.0.2",
+    "chalk": "2.4.2",
+    "compression-webpack-plugin": "^4.0.0",
+    "connect": "3.6.6",
+    "cross-env": "^7.0.3",
+    "element-resize-detector": "^1.2.1",
+    "element-theme-chalk": "^2.13.2",
+    "eslint": "5.15.3",
+    "eslint-plugin-vue": "5.2.2",
+    "html-webpack-plugin": "3.2.0",
+    "image-webpack-loader": "^6.0.0",
+    "increase-memory-limit": "^1.0.7",
+    "mockjs": "1.0.1-beta3",
+    "node-sass": "^4.9.0",
+    "runjs": "^4.3.2",
+    "sass-loader": "^7.1.0",
+    "script-ext-html-webpack-plugin": "2.1.3",
+    "script-loader": "0.7.2",
+    "serve-static": "^1.13.2",
+    "svg-sprite-loader": "4.1.3",
+    "svgo": "1.2.2",
+    "vue-baidu-map": "^0.21.22",
+    "vue-template-compiler": "2.6.10"
+  },
+  "engines": {
+    "node": ">=8.9",
+    "npm": ">= 3.0.0"
+  },
+  "browserslist": [
+    "> 1%",
+    "last 2 versions"
+  ]
+}

+ 3 - 17
src/views/MapView/mapViewTools/featureEditTools.vue

@@ -2,12 +2,11 @@
   <div class="featureEdit">
     <el-dropdown trigger="click" @command="handleCommand">
       <span class="iconfont iconbwzl1">
-        图形编辑
+        数据维护
         <i class="el-icon-arrow-down el-icon--right" />
       </span>
       <el-dropdown-menu slot="dropdown">
-        <el-dropdown-item class="iconfont iconclgj" command="featureEdit2D">二维图形编辑</el-dropdown-item>
-        <el-dropdown-item class="iconfont iconmianji" command="featureEdit3D">三维图形编辑</el-dropdown-item>
+        <el-dropdown-item class="iconfont iconclgj" command="featureEdit2D">空间数据维护</el-dropdown-item>
       </el-dropdown-menu>
     </el-dropdown>
   </div>
@@ -183,18 +182,7 @@ export default {
     },
 
     clickSelectHandle: function (type) {
-      let titleName = "要素编辑";
-      switch(type){
-        case 'featureEdit2D':
-          titleName = "二维数据编辑";
-          break;
-        case 'featureEdit3D':
-          titleName = "三维数据编辑";
-          break;
-        default:
-          titleName = "数据编辑";
-          break;
-      }
+      let titleName = "空间数据维护";
       var info = {
         path: 'featureEdit',
         name: 'featureEdit',
@@ -203,10 +191,8 @@ export default {
         redirect: '',
         type: 'gis',
         component: Layout,
-        // component: () => import('@/views/currentSystem/oneMapManage/functionManage/thematicMapPrint/widget'),
         label: titleName,
         meta: { title: titleName },
-        //param: feature.values_.siteInfo
         param: {
           map:this.map
         }

+ 318 - 38
src/views/currentSystem/oneMapManage/functionManage/featureEdit/widget.vue

@@ -92,12 +92,17 @@
 <script>
 // 图片展示
 import 'viewerjs/dist/viewer.css';
-import {Select,Pointer} from "ol/interaction";
-import { Range,TileSuperMapRest as olTileSuperMapRest } from "ol/source";
-
-import { Image, Vector, Tile as TileLayer } from 'ol/layer';
+import { Style,Fill,Stroke,Circle,Text } from "ol/style";
+import { GeoJSON } from "ol/format";
+import { Polygon } from "ol/geom";
+import { Feature } from "ol";
+import { Select,Pointer } from "ol/interaction";
+import { Range,TileSuperMapRest as olTileSuperMapRest,TileWMS,Vector as SourceVector} from "ol/source";
+import { Image, Vector as LayerVector, Tile as TileLayer } from 'ol/layer'; 
 import { altKeyOnly, click, pointerMove } from "ol/events/condition";
-import { Logo, TileSuperMapRest,FeatureService,MapboxStyles} from '@supermap/iclient-ol';
+import { Logo, TileSuperMapRest,FeatureService,QueryService,MapboxStyles} from '@supermap/iclient-ol';
+// 公共函数
+import commonFunction from '@/views/currentSystem/commonFunction/commonFunction'
 export default {
   components:{},
   data() {
@@ -122,6 +127,7 @@ export default {
       },
       select:null,
       themeSource:null,
+      siteLayers:[]
     }
   },
   computed: {
@@ -155,29 +161,237 @@ export default {
     init(){
       //this.iniSelect();
       //this.initThemeMap();
-      //this.initLayer();
-      this.initLayers();
+      //this.initSource();
+      //this.initLayers();
+      //this.addFeatureSelect();
+      //this.initVector();
+      this.layerQuery();
+    },
+
+    layerQuery(){
+      let url = "http://192.168.2.242:8090/iserver/services/map-kxcgw/rest/maps/pipeline";
+      //miny="103.555941" maxy="103.598975" minx="29.725337" maxx="29.752859" 
+      let polygon = new Polygon([[[103.555941, 29.725337],[103.555941,29.752859], [103.598975, 29.752859], [103.598975,29.725337]]]);
+      let polygonSource = new SourceVector({
+            features: [new Feature(polygon)],
+            wrapX: false
+        });
+      let vectorLayer = new LayerVector({
+            source: polygonSource,
+            style: new Style({
+                stroke: new Stroke({
+                    color: 'red',
+                    width: 3
+                }),
+                fill: new Fill({
+                    color: 'rgba(0, 0, 255, 0.1)'
+                })
+            })
+        });
+      //this.map.addLayer(vectorLayer);
+
+      var param = new SuperMap.QueryByGeometryParameters({
+            queryParams: {name: "pipeline@kxcgw"}, 
+            geometry: polygon
+        });
+      new QueryService(url).queryByGeometry(param,  (serviceResult) => {
+            let vectorSource = new SourceVector({
+                features: (new GeoJSON()).readFeatures(serviceResult.result.recordsets[0].features),
+                wrapX: false
+            });
+            let resultLayer = new LayerVector({
+                source: vectorSource,
+                //style:this.styleFunction
+            });
+
+            var select=new Select({
+              condition: click,  //pointerMove
+              layers:[resultLayer],
+              multi:true,
+              style:function (feature) {
+                console.log('feature',feature);
+              }
+            });
+            select.on("select",function (e) {
+              console.log(e,e.selected,e.selected[0]);
+              // var features=e.selected;
+              // var feature=features[0];
+              // var geometry=feature.getGeometry();
+              // var attribute=  feature.getProperties();
+              // var temp=attribute["NAME"];
+              // temp=attribute.NAME;
+              // var coordinates=geometry.getCoordinates();
+              
+            });
+            this.map.addInteraction(select);
+            this.map.addLayer(resultLayer);
+          });
+    },
+
+    styleFunction(feature,isSelect) {
+        console.log('function',feature);
+        var _name="",
+            _color="rgba(255, 255, 255, 0.8)";
+        return  new Style({
+            fill: new Fill({ //矢量图层填充颜色,以及透明度
+                color:_color
+            }),
+            stroke: new Stroke({ //边界样式
+                color: '#319FD3',
+                width: 1
+            }),
+            text: new Text({ //文本样式
+                text:_name,
+                font: '12px Calibri,sans-serif',
+                fill: new Fill({
+                    color: '#000'
+                }),
+                stroke: new Stroke({
+                    color: 'red',
+                    width: 3
+                }),
+                //textAlign:"left",
+                offsetX:"0"
+            })
+        });
+    },
+
+    initVector(){
+      let vectorSource = new SourceVector({
+        url:"http://192.168.2.242:8090/iserver/services/map-kxcgw/rest/maps/pipeline",
+        format:new GeoJSON()
+      });
+ 
+      let vectorLayer = new LayerVector({
+        source: vectorSource,
+        style: (feature,isSelect) =>{
+            let _name="";
+            let _color="rgba(255, 255, 255, 0.8)";
+            if(isSelect==true)
+            {
+              _name=feature.get("NAME");
+              _color= "rgba(255, 0, 0, 0.8)";
+            }
+            _name=this.map.getView().getZoom()>4?_name:"";
+            return  new Style({
+                fill: Fill({ //矢量图层填充颜色,以及透明度
+                  color:_color
+                }),
+                stroke: new Stroke({ //边界样式
+                  color: '#319FD3',
+                  width: 1
+                }),
+                text: new Text({ //文本样式
+                  text:_name,
+                  font: '12px Calibri,sans-serif',
+                  fill: new Fill({
+                    color: '#000'
+                  }),
+                  stroke: new Stroke({
+                    color: 'red',
+                    width: 3
+                  }),
+                  //textAlign:"left",
+                  offsetX:"0"
+                })
+             });
+        }
+      });
+
+
+      var select=new Select({
+        condition: pointerMove,
+        layers:[vectorLayer],
+        multi:true,
+        style:function (feature,layer) {
+            console.log(feature,layer)
+        }
+      });
+      select.on("select",function (e) {
+        var features=e.selected;
+        var feature=features[0];
+        var geometry=feature.getGeometry();
+        var attribute=  feature.getProperties();
+        var temp=attribute["NAME"];
+        temp=attribute.NAME;
+        var coordinates=geometry.getCoordinates();
+        var polygons=geometry.getPolygons();
+        var polygon=geometry.getPolygon(0);
+        alert(feature.get("NAME"));
+      });
+
+      this.map.addLayer(vectorLayer);
+      this.map.addInteraction(select);
+    },
+
+    initSource(){
+      let layers = this.map.getLayers();
+      let ly = null;
+      for (var i = 0; i < layers.getLength(); i++) {
+        const layer = layers.array_[i];
+        const layerName = layer.values_.name;
+        if (layerName === '专用线缆') {
+          //layer.setVisible(true);
+          // layer.events.on({"layerInitialized": ()=>{
+          //   console.log("000");
+          // }});
+          console.log("layer",layer);
+          ly = layer;
+        }
+      }
+      if(ly == null) return;
+      console.log("layer",ly);
+      let selectClick = new Select({
+        // 事件类型
+        condition: click,
+        layers:[ly],
+        // 点击后的样式
+        style: function(fea, res){ 
+          console.log("----------",fea,res,selectClick.getLayer(fea))
+          return [
+	                new Style({
+	                    stroke: new Stroke({
+	                        color: 'rgba(255,92,92, 0.2)',
+	                        width: 10
+	                    })
+	                }),
+	                new Style({
+	                    stroke: new Stroke({
+	                        color: "rgba(255,92,92, 1)",
+	                        width: 4
+	                    }),
+	                })
+	            ]
+        }
+      });
+      this.map.addInteraction(selectClick);
+      selectClick.on('select', function(e) {
+        console.log("000------------------------1");
+      });
+      
+
     },
 
     iniSelect(){
       if(this.select != null) return;
       if(this.map == null) return;
-      let url = "http://192.168.2.238:8090/iserver/services/map-fd/rest/maps/fddt";
+      let url = "http://192.168.2.242:8090/iserver/services/map-kxcgw/rest/maps/pipeline";
       // 添加图层
-     let layer = new TileLayer({
+      let layer = new TileLayer({
         source: new TileSuperMapRest({
           url: url,
           wrapX: true
         }),
         projection: 'EPSG:4326'
-     });
-     this.map.addLayer(layer);
-
+      });
+      this.map.addLayer(layer); 
       this.select = new Select({
-        condition: click
+        condition: click,
+        layers:[layer]
       });
       this.map.addInteraction(this.select);
       this.select.on("select", e => {
+        console.log('123');
         if (e.selected.length != 0) {
           // 当前点的坐标
           var coordinate = e.mapBrowserEvent.coordinate;
@@ -189,17 +403,97 @@ export default {
           
         }
       });
-      // 设置鼠标划过矢量要素的样式
-      this.map.on("pointermove", e => {
-        var pixel = this.map.getEventPixel(e.originalEvent); //pixel为当前鼠标屏幕坐标,如 [0,0],[304,642]
-        var feature = this.map.forEachFeatureAtPixel(pixel, function(feature) {
-          return feature;
-        });
-        console.log("feature", feature);
-        if (feature == undefined) {
-          this.map.getTargetElement().style.cursor = "auto";
+      
+      let hightStyle = new Style({
+			 //填充色
+          fill: new Fill({
+                color: 'rgba(255, 255, 255, 0.2)'
+            }),
+            //边线颜色
+          stroke: new Stroke({
+                color: '#FF0000',
+                width: 5
+          }),
+            //形状
+          image: new Circle({
+                radius: 7,
+                fill: new Fill({
+                    color: '#ffcc33'
+                })
+          })
+		  }) 
+
+      let lineDedalut = new Style({
+			 //填充色
+            fill: new Fill({
+                color: 'rgba(255, 255, 255, 0.2)'
+            }),
+            //边线颜色
+            stroke: new Stroke({
+                color: '#1E90FF',
+                width: 5
+            }),
+            //形状
+            image: new Circle({
+                radius: 7,
+                fill: new Fill({
+                    color: '#ffcc33'
+                })
+            })
+		  })
+
+      this.map.on('pointermove', (evt) => {
+        let highFeature = null;
+        let pixel = this.map.getEventPixel(evt.originalEvent);
+	      let features = this.map.forEachFeatureAtPixel(pixel, (feature,layer) => {
+		      return {
+		    	  feature:feature,
+			      layer:layer
+		      };
+	      });
+	      if(features){
+          console.log("features",features);
+		      highFeature = features.feature;
+		      features.feature.setStyle(hightStyle)
+	      }else{
+		      if(highFeature)
+		      highFeature.setStyle(lineDedalut)
+	      }
+	    });
+    },
+
+    /**
+     * @description 给地图添加要素选择主组件
+     */
+    addFeatureSelect() {
+      // 给增加的矢量图层增加 点击事件
+      this.select = new Select({
+        // 事件类型
+        condition: click,
+        layers: this.siteLayers.concat([
+          commonFunction.getLayerByName(this.map, '专用线缆')
+        ]),
+        style: (fea, res) => {
+          // 判断是否为点要素
+          if (fea.getGeometry() instanceof Point) {
+            console.log('Point');
+          } else if (fea.getGeometry() instanceof LineString) {
+            console.log('LineString');
+          } else if (fea.getGeometry() instanceof MultiLineString) {
+            console.log('MultiLineString');
+          } else if (fea.getGeometry() instanceof Polygon) {
+            console.log('Polygon');
+          }
+        }
+      });
+      
+      this.map.addInteraction(this.select);
+      this.select.on('select', e => {
+        var aryLen = e.target.getFeatures().getLength();
+        if (aryLen > 0) {
+          
         } else {
-          this.map.getTargetElement().style.cursor = "pointer";
+          
         }
       });
     },
@@ -238,7 +532,7 @@ export default {
 
       const result = getFeaturesEventArgs.result;
         if (result && result.features) {
-            //this.addThemeLayer();
+            this.addThemeLayer();
             //this.themeSource.addFeatures(result.features);   
         }
     },
@@ -317,10 +611,6 @@ export default {
         selectFeature.activate();
     },
 
-
-
-
-
     addThemeLayer(){
       if(this.themeSource != null) return;
       this.themeSource = new Range("ThemeLayer",
@@ -365,16 +655,6 @@ export default {
         this.map.addLayer(themeLayer);
     },
 
-    initLayer(){
-      let url = "http://192.168.2.238:8090/iserver/services/data-kxc_map_test/rest/data";
-      let resolutions = this.getResolutions(10, 0.00000346145499464224, 0, 16);
-      let style = new MapboxStyles({
-            url: url,
-            map: this.map,
-            resolutions: resolutions
-        })
-    },
-
     getResolutions(zoom, scale, targetMinZoom, targetMaxZoom) {
             var res = this.scaleToResolution(scale);
             var minRes = res * Math.pow(2, zoom - targetMinZoom);