管道基础大数据平台系统开发-【CS】-ExportMap
13693261870
2023-08-28 1686db280b8bad0944adddb93b9e4387e6101c43
修改坐标转换功能
已修改2个文件
61 ■■■■ 文件已修改
DataLoader/CS/GdalHelper.cs 57 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DataLoader/CS/StaticData.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DataLoader/CS/GdalHelper.cs
@@ -108,23 +108,20 @@
            try
            {
                ds = Gdal.Open(vd.FilePath, Access.GA_ReadOnly);
                if (null == ds || ds.RasterCount == 0) return;
                if (null == ds || ds.RasterCount == 0 || null == ds.GetSpatialRef()) return;
                vd.Meta.gridsize = string.Format("{0},{1}", ds.RasterXSize, ds.RasterYSize); // 行列数
                SpatialReference sr = ds.GetSpatialRef();
                if (sr != null)
                vd.Meta.coor_sys = sr.GetName(); // 坐标系统
                if (MOON200 == vd.Meta.coor_sys)
                {
                    vd.Meta.coor_sys = sr.GetName(); // 坐标系统
                    if (MOON200 == vd.Meta.coor_sys)
                    {
                        vd.Meta.epsg = "ESRI:104903"; // EPSG编码
                    }
                    else
                    {
                        string code = sr.GetAuthorityCode(null);
                        vd.Meta.epsg = string.IsNullOrEmpty(code) ? null : "EPSG:" + code; // EPSG编码
                    }
                    vd.Meta.epsg = "ESRI:104903"; // EPSG编码
                }
                else
                {
                    string code = sr.GetAuthorityCode(null); // PROJCS、GEOGCS、GEOGCS|UNIT 或 NULL
                    vd.Meta.epsg = string.IsNullOrEmpty(code) ? null : "EPSG:" + code; // EPSG编码
                }
                vd.Meta.bands = ds.RasterCount.ToString(); // 波段数
@@ -133,11 +130,11 @@
                vd.Meta.ct = null == ct ? null : ct.ToString(); // 数据颜色表
                vd.Meta.h_datum = null; // 高程基准
                double[] transform = new double[6];
                ds.GetGeoTransform(transform);
                vd.Meta.resolution = string.Format("{0},{1}", transform[1], transform[5]); // 分辨率
                double[] tr = new double[6];
                ds.GetGeoTransform(tr);
                vd.Meta.resolution = string.Format("{0},{1}", tr[1], tr[5]); // 分辨率
                if (!EPSGS.Contains(vd.Meta.epsg)) return;
                if (tr[0] == 0.0 && tr[1] == 1.0 && tr[2] == 0.0 && tr[3] == 0.0 && tr[4] == 0.0 && tr[5] == 1.0) return;
                Geometry minPoint = GetMinPoint(ds);
                Geometry maxPoint = GetMaxPoint(ds);
@@ -182,6 +179,15 @@
        /// </summary>
        private Geometry GetMaxPoint(Dataset ds)
        {
            /**
             * transform[0] 左上角x坐标
             * transform[1] 东西方向分辨率
             * transform[2] 旋转角度, 0表示图像 "北方朝上"
             *
             * transform[3] 左上角y坐标
             * transform[4] 旋转角度, 0表示图像 "北方朝上"
             * transform[5] 南北方向分辨率
             */
            double[] transform = new double[6];
            ds.GetGeoTransform(transform);
@@ -200,24 +206,14 @@
        /// </summary>
        private Geometry Transform(Dataset ds, Geometry point, string epsg)
        {
            if (string.IsNullOrEmpty(epsg))
            point.AssignSpatialReference(ds.GetSpatialRef());
            if (ds.GetSpatialRef().IsGeographic() > 0)
            {
                point.AssignSpatialReference(sr104903);
                return point;
            }
            if ("4326" == epsg)
            {
                point.AssignSpatialReference(sr4326);
                return point;
            }
            if ("4490" == epsg)
            {
                point.AssignSpatialReference(sr4490);
                return point;
            }
            point.AssignSpatialReference(ds.GetSpatialRef());
            if (ds.GetSpatialRef().GetName().Contains("CGCS2000"))
            string srsName = ds.GetSpatialRef().GetName();
            if (srsName.Contains("CGCS2000"))
            {
                point.TransformTo(sr4490);
            }
@@ -225,6 +221,7 @@
            {
                point.TransformTo(sr4326);
            }
            point.SwapXY();
            return point;
        }
DataLoader/CS/StaticData.cs
@@ -45,7 +45,7 @@
        /// <summary>
        /// 栅格数据扩展名
        /// </summary>
        public static readonly List<String> RASTER_EXT = new List<String> { ".img", ".tif", ".tiff", "jpg", "jp2" };
        public static readonly List<String> RASTER_EXT = new List<String> { ".img", ".tif", ".tiff", ".jpg", ".jp2" };
        /// <summary>
        /// 16进制
@@ -95,7 +95,7 @@
        /// <summary>
        /// Mapper排除扩展名
        /// </summary>
        public readonly static List<String> MAPPER_EXCLUDE_EXT = new List<String> { ".jpg.aux.xml", ".jpg.xml", ".jp2.aux.xml", ".jp2.xml", ".jp2.html", ".jp2.txt", ".img.aux.xml", ".img.xml", ".tif.aux.xml", ".tif.xml", ".tiff.aux.xml", ".tiff.xml", ".shp.xml" };
        public readonly static List<String> MAPPER_EXCLUDE_EXT = new List<String> { ".jpg.aux.xml", ".jpg.xml", ".jp2.aux.xml", ".jp2.xml", ".jp2.html", ".jp2.txt", ".img.aux.xml", ".img.xml", ".tif.aux.xml", ".tif.xml", ".tiff.aux.xml", ".tiff.xml", ".shp.xml", ".ecw.xml", "ecw.aux.xml" };
        /// <summary>
        /// 所有文件扩展名