Exemplo n.º 1
0
 public void Overlay(RasterOp raster, Func <float, float, float> func)
 {
     if (Width != raster.Width || Height != raster.Height)
     {
         throw new ArgumentException("栅格大小不一致,无法叠加操作");
     }
     for (int i = 0; i < Width; i++)
     {
         for (int j = 0; j < Height; j++)
         {
             if (Read(i, j).HasValue&&raster.Read(i, j).HasValue)
             {
                 float basic   = Read(i, j).GetValueOrDefault();
                 float overlay = raster.Read(i, j).GetValueOrDefault();
                 Write(i, j, func(basic, overlay));
             }
         }
     }
 }
Exemplo n.º 2
0
 public RasterOp(RasterOp op)
 {
     _raster = new float?[op.Width, op.Height];
     for (int i = 0; i < Width; i++)
     {
         for (int j = 0; j < Height; j++)
         {
             _raster[i, j] = op.Read(i, j);
         }
     }
 }
Exemplo n.º 3
0
 public RasterOp(RasterOp op)
 {
     _raster = new float?[op.Width, op.Height];
     for (int i = 0; i < Width; i++)
     {
         for (int j = 0; j < Height; j++)
         {
             _raster[i, j] = op.Read(i, j);
         }
     }
 }
 /// <summary>
 /// 计算一个城市对其中的影响
 /// </summary>
 /// <param name="basic"></param>
 /// <param name="city"></param>
 /// <param name="value"></param>
 private void Overlay(RasterOp basic, RasterOp city,float value)
 {
     for (int i = 0; i < basic.Width; i++)
     {
         for (int j = 0; j < basic.Height; j++)
         {
             if (basic.Read(i,j).HasValue)
             {
                 var timeCost = (float)city.Read(i, j);
                 basic.Write(i,j,(float)basic.Read(i,j)+timeCost*value);
             }
         }
     }
 }
 private void Overlay(RasterOp basic, RasterOp city,string cityName)
 {
     for (int i = 0; i < basic.Width; i++)
     {
         for (int j = 0; j < basic.Height; j++)
         {
             if (basic.Read(i, j).HasValue)
             {
                 
                 var timecost = (float) city.Read(i, j);                       
                 float shorestTimeCost = ShortestTimeCost(i, j, _cityPos[cityName]);
                 if (Math.Abs(shorestTimeCost) < 10e-5)
                 {
                     continue;
                 }
                 basic.Write(i, j, (float)basic.Read(i, j) + timecost/shorestTimeCost * CityValues[cityName]);                                                }
         }
     }
 }
 private void Run(object p)
 {
     Hashtable para=p as Hashtable;
     ContinuousWait wait = para["wait"] as ContinuousWait;
     var folderPath = para["folderPath"].ToString();
     try
     {
         string preWorkSpace = Path.GetDirectoryName(_preRasterFilePath);
         string preFileName = Path.GetFileNameWithoutExtension(_preRasterFilePath);
         string aftWorkSpace = Path.GetDirectoryName(_aftRasterFilePath);
         string aftFileName = Path.GetFileNameWithoutExtension(_aftRasterFilePath);
         RasterReader preReader = new RasterReader(preWorkSpace, preFileName + ".tif");
         RasterReader aftReader = new RasterReader(aftWorkSpace, aftFileName + ".tif");
         RasterOp preOp = new RasterOp(preReader);
         RasterOp aftOp = new RasterOp(aftReader);
         RasterOp res = preOp.Clone();
         res.Reset();
         for (int i = 0; i < preOp.Width; i++)
         {
             for (int j = 0; j < preOp.Height; j++)
             {
                 if (preOp.Read(i, j).HasValue)
                 {
                     float orgin = (float) preOp.Read(i, j);
                     float now = (float) aftOp.Read(i, j);
                     if (Math.Abs(orgin) > 10e-5)
                     {
                         float rate = (now - orgin)/orgin;
                         res.Write(i, j, rate);
                     }
                 }
             }
         }
         RasterWriter writer=new RasterWriter(folderPath,RasterName,preReader.RasterInfo);
         res.WriteRaster(writer,"TIFF");
         para["ret"] = true;
     }
     catch (Exception e)
     {
         _log.Error(e.GetType()+e.Message+e.StackTrace);
         para["ret"] = false;
     }
     finally
     {
         wait.CloseWait();
     }
 }
 private void Overlay(RasterOp basic, RasterOp city, string cityName)
 {
     for (int i = 0; i < basic.Width; i++)
     {
         for (int j = 0; j < basic.Height; j++)
         {
             if (basic.Read(i, j).HasValue)
             {
                 float timeCost = (float)city.Read(i, j);
                 if (Math.Abs(timeCost) < 10e-5)
                 {
                     if (_popDic.ContainsKey(cityName))
                     {
                         float tt = (float)(3*Math.Log10(_popDic[cityName]*10));
                         basic.Write(i,j,(float)basic.Read(i,j)+CityValues[cityName]/tt);
                     }
                 }
                 else
                 {
                     basic.Write(i, j, (float)basic.Read(i, j) + CityValues[cityName] / timeCost);
                 }
             }
         }
     }
 }   
Exemplo n.º 8
0
 public void Overlay(RasterOp raster,Func<float,float,float> func)
 {
     if (Width!=raster.Width||Height!=raster.Height)
     {
         throw new ArgumentException("栅格大小不一致,无法叠加操作");
     }
     for (int i = 0; i < Width; i++)
     {
         for (int j = 0; j < Height; j++)
         {
             if (Read(i,j).HasValue&&raster.Read(i,j).HasValue)
             {
                 float basic =Read(i, j).GetValueOrDefault();
                 float overlay =raster.Read(i, j).GetValueOrDefault();
                 Write(i,j,func(basic,overlay));
             }
         }
     }
 }