void FloodStart() { //读入dem,manning,rain DemPath = txbDemIpute.Text; GISdataManager.readRaster(DemPath, ref demRaster); dem = GISdataManager.Raster2Mat(demRaster); ManningPath = txbManingInput.Text; GISdataManager.readRaster(ManningPath, ref manningRaster); manNing = GISdataManager.Raster2Mat(manningRaster); RainRecordPath = txbRaintxt.Text; rainRecordList = TxTReader.txt2List2(RainRecordPath); if (rainRecordList.Count > 0) { string[] record = rainRecordList[0]; string path; path = record[1]; GISdataManager.readRaster(path, ref rainDeepRaster); rainDeepMat = GISdataManager.Raster2Mat(rainDeepRaster); } else { MessageBox.Show("请重新输入有效降雨数据!"); return; } //获取栅格分辨率 IRasterInfo rasterinfo = (demRaster.Raster as IRawBlocks).RasterInfo; flowLength = Convert.ToInt32(rasterinfo.CellSize.X); flowLength2 = flowLength * 1.141f; //判断DEM与曼宁系数栅格是否一致! if (demRaster.ColumnCount != manningRaster.ColumnCount || demRaster.RowCount != manningRaster.RowCount) { MessageBox.Show("请保证曼宁糙率栅格行列是否与DEM一致,请对应后重新输入!"); return; } rowCount = demRaster.RowCount; colCount = demRaster.ColumnCount; //初始化中间参数 slope = new float[rowCount, colCount]; flowDir = new byte[rowCount, colCount]; canCuculate = new bool[rowCount, colCount]; waterDeep = new float[rowCount, colCount]; tempDeep = new float[rowCount, colCount]; flowVel = new float[rowCount, colCount]; arrived = new bool[rowCount, colCount]; for (int i = 0; i < rowCount; i++) { for (int j = 0; j < colCount; j++) { slope[i, j] = 0f; flowDir[i, j] = 0; waterDeep[i, j] = 0f; tempDeep[i, j] = 0f; flowVel[i, j] = 0f; arrived[i, j] = false; } } DBpointPath = txbDBpoint.Text; GISdataManager.readSHP(DBpointPath, ref DBpointshp); IFeatureClass featureClass = DBpointshp.FeatureClass; int count = featureClass.FeatureCount(new QueryFilter()); for (int i = 0; i < count; i++) { IFeature feature = featureClass.GetFeature(i); IGeometry Geo = feature.Shape; IPoint point = Geo as IPoint; double x, y; x = point.X; y = point.Y; //获取出水点在Mit中的位置 IRaster raster = demRaster.Raster; IRaster2 raster2 = raster as IRaster2; DPcolIndex = raster2.ToPixelColumn(x); DProwIndex = raster2.ToPixelRow(y); dbPointList.Add(new int[2] { DProwIndex, DPcolIndex }); arrived[DProwIndex, DPcolIndex] = true; } //读取流量过程线表格 HydroPath = txbHydroghraph.Text; HydroRecordList = TxTReader.txt2List3(HydroPath, dbPointList.Count); //初始化计算范围 for (int i = 0; i < rowCount; i++) { for (int j = 0; j < colCount; j++) { if (dem[i, j] != nodataValue) { canCuculate[i, j] = true; } } } }
Boolean FloodStart() { //读入dem,manning,rain this.Invoke(pm.addInfomation, new object[] { "正在读取DEM文件..." }); DemPath = txbDemIpute.Text; GISdataManager.readRaster(DemPath, ref demRaster); dem = GISdataManager.Raster2Mat(demRaster); this.Invoke(pm.addInfomation, new object[] { "DEM数据读取完毕,并写入DEM数组中" }); this.Invoke(pm.addInfomation, new object[] { "正在读取曼宁系数文件..." }); ManningPath = txbManingInput.Text; GISdataManager.readRaster(ManningPath, ref manningRaster); manNing = GISdataManager.Raster2Mat(manningRaster); this.Invoke(pm.addInfomation, new object[] { "曼宁系数数据读取完毕,并写入曼宁系数数组中" }); RainRecordPath = txbRaintxt.Text; rainRecordList = TxTReader.txt2List2(RainRecordPath); this.Invoke(pm.addInfomation, new object[] { "正在判断雨量格式是否正确..." }); if (rainRecordList.Count > 0) { this.Invoke(pm.addInfomation, new object[] { "雨量数据格式正确" }); } else { this.Invoke(pm.addInfomation, new object[] { "请重新输入有效降雨数据" }); return(false); } //获取栅格分辨率 IRasterInfo rasterinfo = (demRaster.Raster as IRawBlocks).RasterInfo; flowLength = Convert.ToInt32(rasterinfo.CellSize.X); this.Invoke(pm.addInfomation, new object[] { String.Format("DEM栅格宽度为:{0}m", flowLength) }); //maxSpeed = (float)Math.Sqrt(flowLength * 10); maxSpeed = 10f; flowLength2 = flowLength * 1.141f; //判断DEM与曼宁系数栅格是否一致! if (demRaster.ColumnCount != manningRaster.ColumnCount || demRaster.RowCount != manningRaster.RowCount) { this.Invoke(pm.addInfomation, new object[] { "曼宁糙率栅格行列与DEM不一致,请对应后重新输入!" }); return(false); } rowCount = demRaster.RowCount; colCount = demRaster.ColumnCount; Console.WriteLine(rowCount + "," + colCount); //初始化中间参数 slope = new float[colCount, rowCount]; //坡度矩阵 flowDir = new Dirction[colCount, rowCount]; //流向矩阵 canCuculate = new bool[colCount, rowCount]; //用于判断矩阵中的点是否在DEM范围内 waterDeep = new float[colCount, rowCount]; //水深矩阵 tempDeep = new float[colCount, rowCount]; // flowVel = new float[colCount, rowCount]; for (int i = 0; i < colCount; i++) { for (int j = 0; j < rowCount; j++) { slope[i, j] = 0f; flowDir[i, j] = new Dirction() { x = 0, y = 0 }; if (dem[i, j] == nodataValue) { waterDeep[i, j] = nodataValue; } else { waterDeep[i, j] = 0f; } tempDeep[i, j] = 0f; flowVel[i, j] = 0f; } } for (int i = 0; i < colCount; i++) { for (int j = 0; j < rowCount; j++) { if (dem[i, j] != nodataValue) { canCuculate[i, j] = true; } } } return(true); }