private void CheckIs0250(AbstractWarpDataset srcRaster)
 {
     try
     {
         Dictionary <string, string> filaAttrs = srcRaster.GetAttributes();
         if (filaAttrs == null || !filaAttrs.ContainsKey("File Alias Name"))
         {
             throw new Exception("不能确认为合法的MERSI轨道数据,尝试获取文件属性File Alias Name的值为空");
         }
         string fileAliasName = filaAttrs["File Alias Name"];
         if (string.IsNullOrWhiteSpace(fileAliasName))
         {
             throw new Exception("不能确认为合法的MERSI轨道数据,尝试获取文件属性File Alias Name的值为空");
         }
         else if (fileAliasName == "MERSI_1KM_L1")
         {
             _dataType = "1KM";
         }
         else if (fileAliasName == "MERSI_QKM_L1" || fileAliasName == "MERSI_250M_L1")
         {
             _dataType = "QKM";
         }
         else
         {
             throw new Exception("不能确认为合法的MERSI轨道数据,文件属性File Alias Name的值为[" + fileAliasName + "]支持的是MERSI_1KM_L1或者MERSI_QKM_L1");
         }
     }
     catch (Exception ex)
     {
         throw new Exception("不能确认为合法的MERSI轨道数据" + ex.Message, ex.InnerException);
     }
 }
        private float[] ReadFileAttributeToFloat(AbstractWarpDataset srcbandpro, string AttrName, int length)
        {
            float[] value = new float[length];
            Dictionary <string, string> dsAtts = srcbandpro.GetAttributes();
            string refSbCalStr = dsAtts[AttrName];

            string[] refSbCals = refSbCalStr.Split(',');
            if (refSbCals.Length >= length)
            {
                for (int i = 0; i < length; i++)
                {
                    value[i] = float.Parse(refSbCals[i]);
                }
                return(value);
            }
            else
            {
                return(null);
            }
        }
Example #3
0
        /// <summary>
        /// 设置_rasterProjector与_srcGeoTrans
        /// </summary>
        /// <param name="srcRaster"></param>
        private void InitLocationArgs(AbstractWarpDataset srcRaster)
        {
            RasterDatasetInfo info       = mRasterSourceManager.GetInstance().GetRasterDatasetInfo(srcRaster.fileName);
            string            resolution = info.BandCol.FirstOrDefault().resolution;
            double            nReslution = 0;

            if (!double.TryParse(resolution, out nReslution))
            {
                throw new Exception("获取FY4A影像分辨率失败");
            }

            int    beginLineNum    = 0;
            var    attrsDic        = srcRaster.GetAttributes();
            string beginlineNumStr = string.Empty;

            if (attrsDic.ContainsKey("Begin Line Number"))
            {
                beginlineNumStr = attrsDic["Begin Line Number"];
            }
            if (string.IsNullOrEmpty(beginlineNumStr))
            {
                if (attrsDic.ContainsKey("geospatial lat lon extent begin line number"))
                {
                    beginlineNumStr = attrsDic["geospatial lat lon extent begin line number"];
                }
                if (string.IsNullOrEmpty(beginlineNumStr))
                {
                    beginLineNum = 183;
                }
            }

            if (!string.IsNullOrEmpty(beginlineNumStr))
            {
                StringBuilder sb = new StringBuilder();
                foreach (char c in beginlineNumStr)
                {
                    if ((c >= '0' && c <= '9') || c == ' ' || c == '-')
                    {
                        sb.Append(c);
                    }
                }

                bool result = int.TryParse(sb.ToString(), out beginLineNum);
            }

            double[] geoTransform = new double[6];
            geoTransform[0] = -5496000;
            geoTransform[1] = nReslution;
            geoTransform[2] = 0;
            geoTransform[3] = 5496000 - beginLineNum * nReslution;
            geoTransform[4] = 0;
            geoTransform[5] = -nReslution;

            //"+proj=geos +h=35785863 +a=6378137.0 +b=6356752.3 +lon_0=104.7 +no_defs"
            string proj =
                "+proj=geos +no_defs +a=6378137.0 +b=6356752.3"; // +h=35785863 +a=6378137.0 +b=6356752.3 +lon_0={0} ";

            if (string.IsNullOrEmpty(NOMCenterLon))
            {
                if (attrsDic.ContainsKey("NOMCenterLon"))
                {
                    proj += string.Format(" +lon_0={0}", attrsDic["NOMCenterLon"]);
                }
                else
                {
                    proj += string.Format(" +lon_0={0}", attrsDic["104.7"]);
                }
            }
            else
            {
                proj += string.Format(" +lon_0={0}", NOMCenterLon);
            }

            if (string.IsNullOrEmpty(NOMSatHeight))
            {
                if (attrsDic.ContainsKey("NOMSatHeight"))
                {
                    proj += string.Format(" +h={0}", attrsDic["NOMSatHeight"]);
                }
                else
                {
                    proj += string.Format(" +h={0}", "35785863");
                }
            }
            else
            {
                proj += string.Format(" +h={0}", NOMSatHeight);
            }

            _srcSpatialRef = new SpatialReference("");
            _srcSpatialRef.ImportFromProj4(proj);
            _srcGeoTrans = geoTransform;
        }