当前位置:网站首页>ArcGIS js api 4. X submergence analysis and water submergence analysis

ArcGIS js api 4. X submergence analysis and water submergence analysis

2022-04-23 20:17:00 Tomorrow's sun

The renderings are as follows :

ArcGIS js 4.x Flooding analysis Inundation analysis

The code is as follows


console.log('[email protected]');

function gradientColor(startColor,endColor,step){
    startRGB = this.colorRgb(startColor);// Convert to rgb Array mode 
    startR = startRGB[0];
    startG = startRGB[1];
    startB = startRGB[2];
    endRGB = this.colorRgb(endColor);
    endR = endRGB[0];
    endG = endRGB[1];
    endB = endRGB[2];
    sR = (endR-startR)/step;// Total difference 
    sG = (endG-startG)/step;
    sB = (endB-startB)/step;
    var colorArr = [];
    for(var i=0;i<step;i++){
    // Calculate the of each step hex value  
     var hex = this.colorHex('rgb('+parseInt((sR*i+startR))+','+parseInt((sG*i+startG))+','+parseInt((sB*i+startB))+')');
     colorArr.push(hex);
    }
    return colorArr;
   }
   //  take hex The representation is converted to rgb Representation ( Return here rgb Array mode )
   gradientColor.prototype.colorRgb = function(sColor){
    var reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
    var sColor = sColor.toLowerCase();
    if(sColor && reg.test(sColor)){
     if(sColor.length === 4){
      var sColorNew = "#";
      for(var i=1; i<4; i+=1){
       sColorNew += sColor.slice(i,i+1).concat(sColor.slice(i,i+1));
      }
      sColor = sColorNew;
     }
     // Handle six bit color values 
     var sColorChange = [];
     for(var i=1; i<7; i+=2){
      sColorChange.push(parseInt("0x"+sColor.slice(i,i+2)));
     }
     return sColorChange;
    }else{
     return sColor;
    }
   };
   //  take rgb The representation is converted to hex Representation 
   gradientColor.prototype.colorHex = function(rgb){
    var _this = rgb;
    var reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
    if(/^(rgb|RGB)/.test(_this)){
     var aColor = _this.replace(/(?:(|)|rgb|RGB)*/g,"").split(",");
     var strHex = "#";
     for(var i=0; i<aColor.length; i++){
      var hex = Number(aColor[i]).toString(16);
      hex = hex<10 ? 0+''+hex :hex;//  Make sure that each rgb The value of is 2 position 
      if(hex === "0"){
       hex += hex;
      }
      strHex += hex;
     }
     if(strHex.length !== 7){
      strHex = _this;
     }
     return strHex;
    }else if(reg.test(_this)){
     var aNum = _this.replace(/#/,"").split("");
     if(aNum.length === 6){
      return _this;
     }else if(aNum.length === 3){
      var numHex = "#";
      for(var i=0; i<aNum.length; i+=1){
       numHex += (aNum[i]+aNum[i]);
      }
      return numHex;
     }
    }else{
     return _this;
    }
   }

版权声明
本文为[Tomorrow's sun]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210553339959.html

随机推荐