| | |
| | | using Newtonsoft.Json; |
| | | using OSGeo.GDAL; |
| | | using OSGeo.OGR; |
| | | using SimuTools.Domain; |
| | | using System; |
| | | using System.Collections.Generic; |
| | |
| | | /// </summary> |
| | | public static void Run(string terrainFile, string waterPath, string flowPath, string outPath) |
| | | { |
| | | Layer layer = new Layer(); |
| | | layer.terrain = new Terrain(); |
| | | Domain.Layer layer = new Domain.Layer(); |
| | | layer.duration = new Duration(); |
| | | layer.extension = new Extension(); |
| | | layer.waters = new Water(); |
| | | |
| | | CopeTerrain(terrainFile, outPath, layer); |
| | |
| | | /// <summary> |
| | | /// 处理地形 |
| | | /// </summary> |
| | | private static void CopeTerrain(string terrainFile, string outPath, Layer layer) |
| | | private static void CopeTerrain(string terrainFile, string outPath, Domain.Layer layer) |
| | | { |
| | | Dataset ds = null; |
| | | try |
| | | { |
| | | ds = Gdal.Open(terrainFile, Access.GA_ReadOnly); |
| | | if (null == ds || 0 == ds.RasterCount || null == ds.GetSpatialRef()) return; |
| | | |
| | | SetTerrainInfo(ds, layer); |
| | | } |
| | | finally |
| | | { |
| | | if (null != ds) ds.Dispose(); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 设置地形信息 |
| | | /// </summary> |
| | | private static void SetTerrainInfo(Dataset ds, Domain.Layer layer) |
| | | { |
| | | Geometry minPoint = GdalHelper.GetMinPoint(ds); |
| | | Geometry maxPoint = GdalHelper.GetMaxPoint(ds); |
| | | layer.extension = new Extension(minPoint.GetX(0), minPoint.GetY(0), maxPoint.GetX(0), maxPoint.GetY(0)); |
| | | |
| | | Band band = ds.GetRasterBand(1); |
| | | double[] mm = new double[2]; |
| | | band.ComputeRasterMinMax(mm, 0); |
| | | layer.extension.SetHeight(mm[0], mm[1]); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 处理水面 |
| | | /// </summary> |
| | | private static void CopeWater(string waterPath, string outPath, Layer layer) |
| | | private static void CopeWater(string waterPath, string outPath, Domain.Layer layer) |
| | | { |
| | | |
| | | } |
| | |
| | | /// <summary> |
| | | /// 处理流速流向 |
| | | /// </summary> |
| | | private static void CopeFlow(string flowPath, string outPath, Layer layer) |
| | | private static void CopeFlow(string flowPath, string outPath, Domain.Layer layer) |
| | | { |
| | | |
| | | } |
| | |
| | | /// <summary> |
| | | /// 处理元数据 |
| | | /// </summary> |
| | | private static void CopeLayerJson(string outPath, Layer layer) |
| | | private static void CopeLayerJson(string outPath, Domain.Layer layer) |
| | | { |
| | | if (null == layer) return; |
| | | |