qa-regulatory-gwj-vue/static/map/cesium91/CesiumUnminified/Workers/VectorDrawer.js

2 lines
4.4 KiB
JavaScript
Raw Normal View History

2023-11-07 10:04:37 +08:00
define((function(){"use strict";function t(t,e,r,i,o,l){this.layerDataMapArr=t,this.level=e,this.control=i,this.highLight=o,this.featureMap=r,this.featureMap.keyArr=[],this.filterLayerId=l,this.index=0}return t.prototype.getBackground=function(){return this.vectorDatas=[],this},t.prototype.getTypeString=function(t){return 1==t||"POINT"==t?"Point":2==t||"LINESTRING"==t?"LineString":3==t||"POLYGON"==t?"Polygon":4==t||"MULTIPOINT"==t?"MultiPoint":5==t||"MULTILINESTRING"==t?"MultiLineString":6==t||"MULTIPOLYGON"==t?"MultiPolygon":7==t||"FEATURECOLLECTION"==t?"FeatureCollection":void 0},t.prototype.getLayer=function(t,e){this.index++,this.vectorDatas=[];let r=!1;if(this.filterLayerId)for(let e=0;e<this.filterLayerId.length;e++){if(t==this.filterLayerId[e]){r=!0;break}}else r=!0;if(0==r)return this;if(this.control&&0==this.control.controlObj.otherDisplay&&-1==this.control.controlObj.controlLayersArr.indexOf(e))return this;for(let r=0;r<this.layerDataMapArr.length;r++){let i=this.layerDataMapArr[r][t];if(null!=i&&(i.features||(i.features=i.datas),i.features))for(let r=0;r<i.features.length;r++){let o=i.features[r];if(o.layerName=t,o.type=this.getTypeString(o[0]),o.properties||(o.properties=this.getFieldValueMap(i,o)),this._filterByStyle(o,e)){let t=this._highLightByStyle(o,e);null!=t.color&&(o.customeColor=t),this.vectorDatas.push(o)}}}return this},t.prototype.getGroupLayer=function(t,e,r){this.index++,this.vectorDatas=[];let i=!1;if(this.filterLayerId)for(let e=0;e<this.filterLayerId.length;e++){if(t==this.filterLayerId[e]){i=!0;break}}if(0==i)return this;let o=e.split(","),l=o.length;if(0==l)return this;if(this.control&&0==this.control.controlObj.otherDisplay&&-1==this.control.controlObj.controlLayersArr.indexOf(r))return this;for(let e=0;e<this.layerDataMapArr.length;e++){let i=this.layerDataMapArr[e][t];if(null!=i&&(i.features||(i.features=i.datas),i.features))for(let n=0;n<l;n++){if(null==i.features[o[n]])continue;let l=i.features[e];if(l.layerName=t,l.type=i.type,l.properties||(l.properties=this.getFieldValueMap(i,l)),this._filterByStyle(l,r)){let t=this._highLightByStyle(l,r);null!=t.color&&(l.customeColor=t),this.vectorDatas.push(l)}}}return this},t.prototype.setStyle=function(t){for(let e=0;e<this.vectorDatas.length;e++){let r=this.vectorDatas[e],i={};i.id=Math.random(),i.layerName=r.layerName,i.customeColor=r.customeColor,i.type=r.type,i.properties=r.properties,Array.isArray(r[2][0])?i.data=r[2]:i.data=[r[2]],i.index=this.index;let o=function(t){return i.properties[t]},l=t.call({},this.level,o);if(("MultiLineString"!=i.type&&"LineString"!=i.type||!l||0!=l.stroke)&&(l&&0!=l.display)){i.style=l,i.customeColor&&(i.style._id=i.customeColor._id,i.style.hasOwnProperty("fillColor")?(i.style.fillColor=i.customeColor.color,i.style.fillOpacity=i.customeColor.opacity):(i.style.strokeColor=i.customeColor.color,i.style.strokeOpacity=i.customeColor.opacity));let t=l._id;if(!this.featureMap[t]){this.featureMap.keyArr.push(t);let e={};e.style=l,e.fillFeatures=[],e.lineFeatues=[],this.featureMap[t]=e}if("MultiLineString"==i.type||"LineString"==i.type){this.featureMap[t].lineFeatues.push(i);continue}"Polygon"!=i.type&&"MultiPolygon"!=i.type||this.featureMap[t].fillFeatures.push(i)}}},t.prototype.getFieldValueMap=function(t,e){let r={};for(let i=0;i<t.fieldsConfig.length;i++){let o=t.fieldsConfig[i].name,l=t.fieldsConfig[i].index;1==t.fieldsConfig[i].id&&(r.primaryId=e.layerName+e[1][l],r.id=e[1][l]),r[o]=e[1][l]}return r},t.prototype.getWaterMark=function(){return this.vectorDatas=[],this},t.prototype.draw=function(){},t.prototype._getProperty=function(t){return t[1]},t.prototype._getPoints=function(t){return t[2]},t.prototype._getType=function(t){return t[0]},t.prototype._filterByStyle=function(t,e){this._getType(t);let r=this._getPoints(t);if(this._getProperty(t),null==r)throw"绘制失败,数据中缺少Geometry";let i={};if(this.control&&"function"==typeof this.control.controlFn){let r=t.properties.id;if(i=this.control.controlFn.call({},r,(function(e){return t.properties[key]}),e),0==i||null==i)return!1}return!0},t.prototype._high