管道基础大数据平台系统开发-【CS】-ExportMap
OK
13693261870
2024-09-27 566e0d21293a5fe6423fd7a16541bce00eeb2e38
DataLoader/CS/GdalHelper.cs
@@ -129,6 +129,7 @@
                ColorTable ct = ds.GetRasterBand(1).GetRasterColorTable();
                vd.Meta.ct = null == ct ? null : ct.ToString(); // 数据颜色表
                vd.Meta.h_datum = null; // 高程基准
                setMinAndMax(ds, vd.Meta); // 设置最值
                double[] tr = new double[6];
                ds.GetGeoTransform(tr);
@@ -235,6 +236,52 @@
            return geo;
        }
        /// <summary>
        /// 设置最值
        /// GDALRasterBand::GetHistogram ​​统计直方图
        /// </summary>
        private void setMinAndMax(Dataset ds, SysMeta meta)
        {
            List<double> minList = new List<double>();
            List<double> maxList = new List<double>();
            for (int i = 1; i <= ds.RasterCount; i++)
            {
                int hasval;
                double min, max;
                ds.GetRasterBand(i).GetMinimum(out min, out hasval);
                ds.GetRasterBand(i).GetMaximum(out max, out hasval);
                minList.Add(min);
                maxList.Add(max);
            }
            meta.min = string.Join(",", minList.ToArray());
            meta.max = string.Join(",", maxList.ToArray());
        }
        #endregion
        public void CsTransform(double x, double y, int epsg)
        {
            SpatialReference srs = new SpatialReference(null);
            srs.ImportFromEPSG(epsg);
            Geometry point = new Geometry(wkbGeometryType.wkbPoint);
            point.AddPoint(x, y, 0);
            point.AssignSpatialReference(srs);
            if (srs.GetName().Contains("CGCS2000"))
            {
                point.TransformTo(sr4490);
            }
            else
            {
                point.TransformTo(sr4326);
            }
            point.SwapXY();
            double[] xy = new double[] { point.GetX(0), point.GetY(0) };
        }
    }
}