Пример #1
0
        public RasterSourceTypesInfo(XmlElement xe)
        {
            Describe = xe.GetAttribute("describe").ToString();
            XmlNodeList xnl = xe.SelectNodes("RasterSourceType");
            List <RasterSourceTypeSingleInfo> RasterSourceTypeSingles = new List <RasterSourceTypeSingleInfo>();
            List <RasterSourceTypeGroupInfo>  RasterSourceTypeGroups  = new List <RasterSourceTypeGroupInfo>();

            foreach (var xnode in xnl)
            {
                XmlElement xmlElement = xnode as XmlElement;
                if (xmlElement.Attributes["datasetsID"] != null)
                {
                    RasterSourceTypeSingleInfo RasterSourceTypeSingleInfo = new RasterSourceTypeSingleInfo(xmlElement);
                    RasterSourceTypeSingles.Add(RasterSourceTypeSingleInfo);
                }
                else if (xmlElement.Attributes["groupids"] != null)
                {
                    RasterSourceTypeGroupInfo RasterSourceTypeGroupInfo = new RasterSourceTypeGroupInfo(xmlElement);
                    RasterSourceTypeGroups.Add(RasterSourceTypeGroupInfo);
                    //string groupids = xmlElement.GetAttribute("groupids").ToString();
                    //string[] groupArr = groupids.Split(',');
                    //if (groupArr.Length > 0)
                    //{
                    //    string firstStr = groupArr[0];
                    //    XmlNode xnParent = xmlElement.ParentNode;
                    //    XmlNodeList xnChilds = xnParent.ChildNodes;
                    //    foreach (var item in xnChilds)
                    //    {
                    //        XmlElement xe1 = item as XmlElement;
                    //        //for (int i = 0; i < groupArr.Length; i++)
                    //        //{
                    //        //    if (xe1.GetAttribute("ID").ToString().Contains(groupArr[i]))
                    //        //    {
                    //        //        //获取group组合中第一个数据集类型的配置信息
                    //        //        RasterSourceTypeGroupInfo RasterSourceTypeGroupInfo = new RasterSourceTypeGroupInfo(xe1, groupids);
                    //        //        RasterSourceTypeGroups.Add(RasterSourceTypeGroupInfo);
                    //        //        break;
                    //        //    }
                    //        //}
                    //        if (xe1.GetAttribute("ID").ToString().Contains(firstStr))
                    //        {
                    //            //获取group组合中第一个数据集类型的配置信息
                    //            RasterSourceTypeGroupInfo RasterSourceTypeGroupInfo = new RasterSourceTypeGroupInfo(xe1, groupids);
                    //            RasterSourceTypeGroups.Add(RasterSourceTypeGroupInfo);
                    //            break;
                    //        }
                    //    }
                    //}
                }
            }
            RasterSourceTypeSingleCol = RasterSourceTypeSingles;
            RasterSourceTypeGroupCol  = RasterSourceTypeGroups;
        }
Пример #2
0
        /// <summary>
        /// 通过输入文件获取其相应卫星
        /// </summary>
        /// <param name="inputfilePath">输入文件名</param>
        /// <returns></returns>
        public RasterDatasetInfo GetRasterDatasetInfo(string inputfilePath)
        {
            try
            {
                string upperFileName = Path.GetFileNameWithoutExtension(inputfilePath).ToUpper();
                RasterSourceTypeSingleInfo single = GetInputfileRasterSourceInfo(inputfilePath);
                if (single != null)
                {
                    var dataSet = from item in RasterDatasetInfoCol
                                  where item.ID.ToUpper().Equals(single.datasetsID.ToUpper())
                                  select item;
                    if (dataSet != null && dataSet.FirstOrDefault() != null)
                    {
                        return(dataSet.FirstOrDefault());
                    }
                }
                else
                {
                    foreach (var rasterDataset in RasterDatasetInfoCol)
                    {
                        string[] singleKeys = rasterDataset.ID.ToUpper().Split('-');
                        int      count      = 0;
                        if (singleKeys != null && singleKeys.Length > 0)
                        {
                            for (int i = 0; i < singleKeys.Length; i++)
                            {
                                if (upperFileName.Contains(singleKeys[i]))
                                {
                                    count++;
                                }
                            }
                        }

                        if (count == singleKeys.Length)
                        {
                            return(rasterDataset);
                        }
                    }
                }

                Console.WriteLine(
                    string.Format("Info :GetRasterDatasetInfo()\r\n   InputfilePath:{0}", inputfilePath));
            }
            catch (Exception ex)
            {
                Console.WriteLine(string.Format("RasterSourceManager.GetRasterDatasetInfo()", inputfilePath), ex);
            }

            return(null);
        }