示例#1
0
        /*
         * <Attribute text="产品类别" identify="SubProductIdentify" format="" visible="true"/>
         * <Attribute text="卫星" identify="Satellite" format="" visible="true"/>
         * <Attribute text="传感器" identify="Sensor" format="" visible="true"/>
         * <Attribute text="轨道时间" identify="OrbitDateTime" format="yyyy-MM-dd HH:mm:ss" visible="true"/>
         * <Attribute text="原始文件" identify="SourceFile" format="" visible="true"/>
         * <Attribute text="监测区域" identify="RegionIdentify" format="" visible="true"/>
         * <Attribute text="描述" identify="Description" format="" visible="true"/>
         * <Attribute text="轨道时间分组" identify="OrbitTimeGroup" format="yyyy-MM-dd" visible="true"/>
         * <Attribute text="文件名" identify="FileName" format="" visible="true"/>
         * <Attribute text="路径" identify="FileDir" format="" visible="true"/>
         * <Attribute text="类别中文" identify="CatalogItemCN" format="" visible="false"/>
         * <Attribute text="数据集定义" identify="CatalogDef" format="" visible="false"/>
         * <Attribute text="扩展信息" identify="ExtInfos" format="" visible="false"/>
         * <Attribute text="区域" identify="Region" format="" visible="false"/>
         * <Attribute text="轨道时间段" identify="OrbitTimes" format="yyyy-MM-dd HH:mm:ss ; yyyy-MM-dd HH:mm:ss" visible="false">
         */
        private void TryCreateInfoFromMainFile(string fname, string infoFileName, SubProductCatalogDef catalogDef)
        {
            string fileName = Path.GetFileNameWithoutExtension(fname);

            string[] parts = fileName.Split('_');
            if (parts.Length < 2)
            {
                return;
            }
            RasterIdentify  rst  = new RasterIdentify(fname);
            CatalogItemInfo info = new CatalogItemInfo();

            info.Properties.Add("ProductIdentify", parts[0]);
            info.Properties.Add("SubProductIdentify", parts[1]);
            info.Properties.Add("FileName", Path.GetFileName(fname));
            info.Properties.Add("FileDir", Path.GetDirectoryName(fname));
            info.Properties.Add("CatalogDef", catalogDef == null ? "" : catalogDef.ClassString);
            info.Properties.Add("Satellite", rst.Satellite);
            info.Properties.Add("Sensor", rst.Sensor);
            info.Properties.Add("OrbitDateTime", GetDateFormart(rst.OrbitDateTime, catalogDef, "OrbitDateTime"));
            info.Properties.Add("OrbitTimeGroup", GetDateFormart(rst.OrbitDateTime, catalogDef, "OrbitTimeGroup"));
            info.Properties.Add("CatalogItemCN", GetCatalogCN(info, MifEnvironment.CatalogItemCNDic));
            RasterIdentify ri = new RasterIdentify(fname);

            info.Properties.Add("Region", GetRegionInfo(ri, fname));
            info.Properties.Add("ExtInfos", GetExtInfo(ri, fname));
            info.Properties.Add("CycFlagCN", string.IsNullOrEmpty(ri.CYCFlag) ? "\\" : GetCycFlagCN(info, ri.CYCFlag, MifEnvironment.CatalogItemCNDic));
            info.Properties.Add("OrbitTimes", GetOrbitTimes(ri));
            //.....
            info.SaveTo(infoFileName);
            _info = info;
        }
示例#2
0
        private string GetCatalogCN(CatalogItemInfo info, Dictionary <string, Dictionary <string, string> > catalogCNDic)
        {
            if (!info.Properties.ContainsKey("ProductIdentify") || info.Properties["ProductIdentify"] == null)
            {
                return(string.Empty);
            }
            string result = string.Empty;

            if (catalogCNDic == null || catalogCNDic.Count == 0)
            {
                result = info.Properties["SubProductIdentify"].ToString();
            }
            else if (catalogCNDic.ContainsKey(info.Properties["ProductIdentify"].ToString().ToUpper()))
            {
                if (info.Properties["SubProductIdentify"] == null || !info.Properties.ContainsKey("SubProductIdentify"))
                {
                    return(string.Empty);
                }
                Dictionary <string, string> temp = catalogCNDic[info.Properties["ProductIdentify"].ToString().ToUpper()];
                if (temp.ContainsKey(info.Properties["SubProductIdentify"].ToString().ToUpper()))
                {
                    result = temp[info.Properties["SubProductIdentify"].ToString().ToUpper()];
                }
                else
                {
                    result = info.Properties["SubProductIdentify"].ToString();
                }
            }
            return(result);
        }
示例#3
0
        public CatalogItem(string fname, CatalogItemInfo info)
        {
            _fileName = fname;
            string infoFileName = GetInfoFileName(fname);

            info.SaveTo(infoFileName);
            _info = info;
        }
示例#4
0
        private string GetCycFlagCN(CatalogItemInfo info, string cycFlag, Dictionary <string, Dictionary <string, string> > catalogCNDic)
        {
            if (!info.Properties.ContainsKey("ProductIdentify") || info.Properties["ProductIdentify"] == null)
            {
                return(cycFlag);
            }
            string result = cycFlag;

            if (catalogCNDic.ContainsKey(info.Properties["ProductIdentify"].ToString().ToUpper()))
            {
                Dictionary <string, string> temp = catalogCNDic[info.Properties["ProductIdentify"].ToString().ToUpper()];
                if (temp.ContainsKey(cycFlag.ToUpper()))
                {
                    result = temp[cycFlag.ToUpper()];
                }
            }
            return(result);
        }
示例#5
0
        private static SDatinfo CreateDatinfo(string fname, SubProductCatalogDef catalogDef)
        {
            string          infoFileName = GetInfoFileName(fname);
            CatalogItemInfo ctl;

            if (!File.Exists(infoFileName))
            {
                ctl = TryCreateInfoFromMainFile(fname, infoFileName, catalogDef);
            }
            else
            {
                ctl = new CatalogItemInfo(infoFileName);
                if (!ctl.Properties.ContainsKey("CatalogDef") ||
                    string.IsNullOrEmpty(ctl.Properties["CatalogDef"].ToString()) ||
                    !ctl.Properties.ContainsKey("CycFlagCN"))
                {
                    ctl = TryCreateInfoFromMainFile(fname, infoFileName, catalogDef);
                }
            }
            if (ctl == null)
            {
                ctl = new CatalogItemInfo(infoFileName);
            }
            var datinfo = new SDatinfo
            {
                CatalogDef         = ctl.GetPropertyValue("CatalogDef"),
                CatalogItemCN      = ctl.GetPropertyValue("CatalogItemCN"),
                CycFlagCN          = ctl.GetPropertyValue("CycFlagCN"),
                ExtInfos           = ctl.GetPropertyValue("ExtInfos"),
                FileDir            = ctl.GetPropertyValue("FileDir"),
                FileName           = ctl.GetPropertyValue("FileName"),
                OrbitDateTime      = ctl.GetPropertyValue("OrbitDateTime"),
                OrbitTimeGroup     = ctl.GetPropertyValue("OrbitTimeGroup"),
                OrbitTimes         = ctl.GetPropertyValue("OrbitTimes"),
                ProductIdentify    = ctl.GetPropertyValue("ProductIdentify"),
                Region             = ctl.GetPropertyValue("Region"),
                Satellite          = ctl.GetPropertyValue("Satellite"),
                Sensor             = ctl.GetPropertyValue("Sensor"),
                SubProductIdentify = ctl.GetPropertyValue("SubProductIdentify"),
                SourceFileName     = fname
            };

            return(datinfo);
        }
示例#6
0
        public CatalogItem(string fname, SubProductCatalogDef catalogDef, params object[] args)
        {
            _fileName = fname;
            string infoFileName = GetInfoFileName(fname);

            if (!File.Exists(infoFileName))
            {
                TryCreateInfoFromMainFile(fname, infoFileName, catalogDef);
            }
            else
            {
                _info = new CatalogItemInfo(infoFileName);
                if (!_info.Properties.ContainsKey("CatalogDef") || string.IsNullOrEmpty(_info.Properties["CatalogDef"].ToString()) ||
                    !_info.Properties.ContainsKey("CycFlagCN"))
                {
                    TryCreateInfoFromMainFile(fname, infoFileName, catalogDef);
                }
            }
        }
示例#7
0
        /*
         * <Attribute text="产品类别" identify="SubProductIdentify" format="" visible="true"/>
         * <Attribute text="卫星" identify="Satellite" format="" visible="true"/>
         * <Attribute text="传感器" identify="Sensor" format="" visible="true"/>
         * <Attribute text="轨道时间" identify="OrbitDateTime" format="yyyy-MM-dd HH:mm:ss" visible="true"/>
         * <Attribute text="原始文件" identify="SourceFile" format="" visible="true"/>
         * <Attribute text="监测区域" identify="RegionIdentify" format="" visible="true"/>
         * <Attribute text="描述" identify="Description" format="" visible="true"/>
         * <Attribute text="轨道时间分组" identify="OrbitTimeGroup" format="yyyy-MM-dd" visible="true"/>
         * <Attribute text="文件名" identify="FileName" format="" visible="true"/>
         * <Attribute text="路径" identify="FileDir" format="" visible="true"/>
         * <Attribute text="类别中文" identify="CatalogItemCN" format="" visible="false"/>
         * <Attribute text="数据集定义" identify="CatalogDef" format="" visible="false"/>
         */
        private bool TryGetInfosFromInfoFile(string fname)
        {
            string infoFile = Path.Combine(Path.GetDirectoryName(fname), Path.GetFileNameWithoutExtension(fname) + ".INFO");

            if (!File.Exists(infoFile))
            {
                return(false);
            }
            CatalogItemInfo info = new CatalogItemInfo(infoFile);
            int             flag = 0;

            if (info.Properties.ContainsKey("Satellite"))
            {
                Satellite = info.Properties["Satellite"] == null ? null : info.Properties["Satellite"].ToString();
                flag++;
            }
            if (info.Properties.ContainsKey("Sensor"))
            {
                Sensor = info.Properties["Sensor"] == null ? null : info.Properties["Sensor"].ToString();
                flag++;
            }
            if (info.Properties.ContainsKey("OrbitDateTime"))
            {
                OrbitDateTime = info.Properties["OrbitDateTime"] == null ? DateTime.MinValue : DateTime.Parse(info.Properties["OrbitDateTime"].ToString());
                flag++;
            }
            if (info.Properties.ContainsKey("OrbitTimes"))
            {
                string times = info.Properties["OrbitTimes"].ToString();
                if (!string.IsNullOrEmpty(times))
                {
                    string[] timeArray = times.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                    if (timeArray != null && timeArray.Length == 2)
                    {
                        _minDate = DateTime.Parse(timeArray[0]);
                        _maxDate = DateTime.Parse(timeArray[1]);
                    }
                }
                flag++;
            }
            return(flag >= 3 ? true : false);
        }
示例#8
0
        public CatalogItem(SDatinfo datinfo)
        {
            _fileName = datinfo.SourceFileName;
            var info = new CatalogItemInfo();

            info.Properties.Add("ProductIdentify", datinfo.ProductIdentify);
            info.Properties.Add("SubProductIdentify", datinfo.SubProductIdentify);
            info.Properties.Add("FileName", datinfo.FileName);
            info.Properties.Add("FileDir", datinfo.FileDir);
            info.Properties.Add("CatalogDef", datinfo.CatalogDef);
            info.Properties.Add("Satellite", datinfo.Satellite);
            info.Properties.Add("Sensor", datinfo.Sensor);
            info.Properties.Add("OrbitDateTime", datinfo.OrbitDateTime);
            info.Properties.Add("OrbitTimeGroup", datinfo.OrbitTimeGroup);
            info.Properties.Add("CatalogItemCN", datinfo.CatalogItemCN);
            info.Properties.Add("Region", datinfo.Region);
            info.Properties.Add("ExtInfos", datinfo.ExtInfos);
            info.Properties.Add("CycFlagCN", datinfo.CycFlagCN);
            info.Properties.Add("OrbitTimes", datinfo.OrbitTimes);
            _info = info;
        }