예제 #1
0
 public RasterOp(RasterReader reader)
 {
     if (reader == null)
     {
         throw new ArgumentNullException("栅格文件读取为null");
     }
     _raster = reader.Convert2Matrix();
 }
        private void Confirm()
        {
            if (string.IsNullOrEmpty(_rasterFilePath)) return;
            string folderPath = DialogHelper.OpenFolderDialog(true);
            if (!string.IsNullOrEmpty(folderPath))
            {
                string rasterWorkSpace = Path.GetDirectoryName(_rasterFilePath);
                _rasterReader = new RasterReader(rasterWorkSpace, RasterFileName + ".tif");
                if (WriteCityRaster(folderPath))
                {
                    Messenger.Default.Send(new GenericMessage<string>("空间可达性计算成功"), "Message");
                }
                else
                {
                    Messenger.Default.Send(new GenericMessage<string>("空间可达性计算失败"), "Message");
                }
            }

        }
예제 #3
0
 private void Run(RasterReader reader, CalculatorCity city, string folderPath)
 {
     RasterOp rasterOp=new RasterOp(reader);
     Postion pos = reader.Coordinate(city.XCoord,city.YCoord);
     var result = rasterOp.Calculator(pos);
     RasterWriter writer=new RasterWriter(folderPath,city.Name+"_高铁未通车",reader.RasterInfo);
     result.WriteRaster(writer, "TIFF");
 }
        //private void Wirte(RasterOp op, string foldePath, string name)
        //{
        //    RasterWriter writer = new RasterWriter(foldePath, name,Info);
        //    op.WriteRaster(writer,"TIFF");
        //}

        /// <summary>
        /// 
        /// </summary>
        /// <param name="basic"></param>
        /// <param name="rasterFolderPath"></param>
        /// <param name="fileName"></param>
        /// <param name="cityName"></param>
        private void Overlay(RasterOp basic, string rasterFolderPath,string fileName,string cityName)
        {
            RasterReader reader = new RasterReader(rasterFolderPath, fileName + ".tif");
            RasterOp op=new RasterOp(reader);
            Overlay(basic, op, CityValues[cityName]);
        }
예제 #5
0
 private void Run(object p)
 {
     Hashtable para= p as Hashtable;
     var wait = para["wait"] as ProgressWait;
     string folderPath = para["folderPath"].ToString();
     string rasterFolderPath = Path.GetDirectoryName(_rasterFilePath);
     try
     {
         RasterReader reader = new RasterReader(rasterFolderPath, RasterFileName + ".tif");
         int totalCount = Cities.Count(item => item.IsSelected);
         int count = 0;
         foreach (var calculatorCity in Cities)
         {
             if (calculatorCity.IsSelected)
             {
                 wait.SetProgress((double) count++/totalCount);
                 Run(reader, calculatorCity, folderPath);
                 GC.Collect();
             }
         }
         para["ret"] = true;
     }
     catch (ArgumentOutOfRangeException e)
     {
         Messenger.Default.Send(new GenericMessage<string>("存在城市不在计算范围内"), "Exception");
         para["ret"] = false;
     }
     catch (Exception e)
     {
         _log.Error(e.Message+e.StackTrace);
         para["ret"] = false;
     }
     finally
     {
         wait.CloseWait();
     }
     
 }
 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();
     }
 }
예제 #7
0
 public RasterOp(RasterReader reader)
 {
     if (reader == null) throw new ArgumentNullException("栅格文件读取为null");
     _raster = reader.Convert2Matrix();
 }
예제 #8
0
 private void Init()
 {
     var firstCity = Cities.First(item => item.IsSelected);
     RasterReader reader = new RasterReader(HighTrainNoFolderPath, firstCity.Name + "_高铁未通车" + ".tif");
     Info = reader.RasterInfo;
     RasterOp = new RasterOp(reader);   
     RasterOp.Reset();
 }
 private bool WriteTimeCostRaster(string folderPath)
 {
     try
     {
         //读取两个文件
         var landReader = new RasterReader(folderPath, LandUse + ".tif");
         var roadReader = new RasterReader(folderPath, TrafficRoad + ".tif");
         RasterOp landOp = new RasterOp(landReader);
         RasterOp roadOp = new RasterOp(roadReader);
         //取最小值
         landOp.Overlay(roadOp,RasterAlgorithm.MinPixel);
         ////写入文件
         RasterWriter writer = new RasterWriter(folderPath, TimeCostName, landReader.RasterInfo);
         landOp.WriteRaster(writer,"TIFF");
         return true;
     }
     catch (Exception e)
     {
         _log.Error(e.Message + e.StackTrace);
     }
     return false;
 }