Exemple #1
0
        private void InitBlockGroup()
        {
            List <BlockItemGroup> blockDef = new List <BlockItemGroup>();

            cbCustom.Items.Add("无");
            blockDef.Add(new BlockItemGroup("无", "", ""));
            DefinedRegionParse defineRegion = new DefinedRegionParse();
            BlockDefined       blockDefined = defineRegion.BlockDefined;

            if (blockDefined == null || blockDefined.BlockItemGroups == null || blockDefined.BlockItemGroups.Length == 0)
            {
                return;
            }
            foreach (BlockItemGroup group in blockDefined.BlockItemGroups)
            {
                if (group.Name == "005" || group.Name == "010")
                {
                    continue;
                }
                cbCustom.Items.Add(string.IsNullOrEmpty(group.Description) ? group.Name : group.Description);
                blockDef.Add(group);
            }
            cbCustom.Tag           = blockDef;
            cbCustom.SelectedIndex = 0;
        }
Exemple #2
0
        protected override void ApplyAttributesOfLayoutTemplate(ILayoutTemplate template)
        {
            string instanceIdentify = _argumentProvider.GetArg("OutFileIdentify") as string;

            if (instanceIdentify == "NCSI" || instanceIdentify == "NMCS")
            {
                string[]       files = GetStringArray("SelectedPrimaryFiles");
                RasterIdentify rstId = new RasterIdentify(files[0]);
                if (!string.IsNullOrWhiteSpace(rstId.RegionIdentify))
                {
                    DefinedRegionParse reg        = new DefinedRegionParse();
                    BlockItemGroup     blockGroup = reg.BlockDefined.FindGroup("积雪");
                    PrjEnvelopeItem    envItem    = blockGroup.GetPrjEnvelopeItem(rstId.RegionIdentify);
                    if (envItem != null)
                    {
                        RasterProject.PrjEnvelope prjEnvelope = RasterProject.PrjEnvelope.CreateByCenter(envItem.PrjEnvelope.CenterX, envItem.PrjEnvelope.CenterY, 10, 10);
                        ILayout layout = template.Layout;
                        if (layout.Size.Width != 1000 || layout.Size.Height != 1000)
                        {
                            ChangeTemplateSize(layout, 1000, 1000);
                        }
                        _envelope = new Layout.GxdEnvelope(prjEnvelope.MinX, prjEnvelope.MaxX, prjEnvelope.MinY, prjEnvelope.MaxY);
                    }
                }
            }
        }
Exemple #3
0
        public Main()
        {
            InitializeComponent();
            _regex = new Regex(@"\S+_\S+_(?<region>(0D|0S)\d{2})", RegexOptions.Compiled);
            DefinedRegionParse parse = new DefinedRegionParse();
            BlockDefined       block = parse.BlockDefined;

            _group = block.FindGroup("干旱");
        }
Exemple #4
0
        /// <summary>
        /// 005 5度分幅
        /// 010 10度分幅
        /// </summary>
        /// <param name="blockIdentify"></param>
        /// <returns></returns>
        private BlockDef[] GenericBlockIdentify(string blockIdentify)
        {
            DefinedRegionParse p = new DefinedRegionParse();

            PrjEnvelopeItem[] ps = p.GetEnvelopeItems(blockIdentify);
            if (ps == null || ps.Length == 0)
            {
                return(null);
            }
            List <BlockDef> l = new List <BlockDef>();

            foreach (PrjEnvelopeItem i in ps)
            {
                l.Add(new BlockDef(i.Name, i.PrjEnvelope.MinX, i.PrjEnvelope.MinY, i.PrjEnvelope.MaxX, i.PrjEnvelope.MaxY));
            }
            return(l.ToArray());
        }
Exemple #5
0
        private IExtractResult IMGAlgorithm()
        {
            object obj = _argumentProvider.GetArg("ThemeGraphyGenerator");

            if (obj == null)
            {
                return(null);
            }
            IThemeGraphGenerator tgg = obj as IThemeGraphGenerator;

            if (tgg == null)
            {
                return(null);
            }
            string aoiTemplateName         = string.Empty;
            Dictionary <string, int[]> aoi = null;

            GetAOI(out aoiTemplateName, out aoi);
            string outFileIdentify = GetStringArgument("OutFileIdentify");
            string templatName     = GetStringArgument("ThemeGraphTemplateName");

            string[] files = GetStringArray("SelectedPrimaryFiles");
            if (files == null || files.Length == 0)
            {
                return(null);
            }
            foreach (string item in files)
            {
                if (!File.Exists(item))
                {
                    return(null);
                }
            }
            //计算网络二值图dat文件
            string dir = AppDomain.CurrentDomain.BaseDirectory + "SystemData\\RasterTemplate\\China_LandRaster.dat";

            if (!File.Exists(dir))
            {
                return(null);
            }
            string datFileName = GenerateNetImageFile(dir, files[0]);

            if (string.IsNullOrEmpty(datFileName))
            {
                return(null);
            }
            string colorTabelName = GetColorTableName("colortablename");

            if (outFileIdentify == "NSNI")  //需要限定输出范围
            {
                RasterIdentify rstId = new RasterIdentify(files[0]);
                if (!string.IsNullOrWhiteSpace(rstId.RegionIdentify))
                {
                    DefinedRegionParse reg        = new DefinedRegionParse();
                    BlockItemGroup     blockGroup = reg.BlockDefined.FindGroup("积雪");
                    PrjEnvelopeItem    envItem    = blockGroup.GetPrjEnvelopeItem(rstId.RegionIdentify);
                    if (envItem != null)
                    {
                        RasterProject.PrjEnvelope prjEnvelope = RasterProject.PrjEnvelope.CreateByCenter(envItem.PrjEnvelope.CenterX, envItem.PrjEnvelope.CenterY, 10, 10);
                        (tgg as CmaThemeGraphGenerator).SetEnvelope(new Layout.GxdEnvelope(prjEnvelope.MinX, prjEnvelope.MaxX, prjEnvelope.MinY, prjEnvelope.MaxY));
                        (tgg as ThemeGraphGenerator).IsFitToTemplateWidth = false;
                    }
                }
            }
            tgg.Generate(datFileName, templatName, null, null, outFileIdentify, colorTabelName);
            string resultFilename = tgg.Save();

            if (string.IsNullOrEmpty(resultFilename))
            {
                return(null);
            }
            return(new FileExtractResult(outFileIdentify, resultFilename));
        }
Exemple #6
0
        //根据文件名提取区域标识,限定专题图输出数据范围。一般用于制作网络图。
        public static IExtractResult CreateThemeGraphyBase(ISmartSession session, string algorithmName, string outFileIdentify, string colorTableName, string dataIdentify, string templateName, bool isCustom, bool multiSelect, bool isUseRegion, int genralAndTheme)
        {
            IMonitoringSubProduct msp = (session.MonitoringSession as IMonitoringSession).ActiveMonitoringSubProduct;

            if (msp == null)
            {
                return(null);
            }
            string[]      files     = null;
            CoordEnvelope customEnv = null;

            if (genralAndTheme == 0)
            {
                object obj = msp.ArgumentProvider.GetArg("SelectedPrimaryFiles");
                if (!SetSelectedPrimaryFiles(session, ref obj, msp.ArgumentProvider, algorithmName))
                {
                    return(null);
                }
                files = obj as string[];
                if (files == null || files.Length == 0)
                {
                    if (File.Exists(obj.ToString()))
                    {
                        files = new string[] { obj.ToString() }
                    }
                    ;
                    else
                    {
                        return(null);
                    }
                }
                //by chennan 20130319 根据需要查找相应文件
                UpdateFilesByDataIdentify(ref files, dataIdentify);

                //添加对生成专题图文件类型的判断,排除生成的专题图和统计结果文件,add by wangyu,20120923
                foreach (string fname in files)
                {
                    CanCreatThemegraph(fname);
                }
                msp.ArgumentProvider.SetArg("SelectedPrimaryFiles", files);

                if (isCustom && !SetAOIArugment(files, msp, multiSelect, out customEnv))//用户自定义区域
                {
                    return(null);
                }
                else if (!isCustom)
                {
                    msp.ArgumentProvider.SetArg("AOI", null);
                }
            }
            IThemeGraphGenerator tgg = new GeoDo.RSS.MIF.Prds.Comm.CmaThemeGraphGenerator(session);

            msp.ArgumentProvider.SetArg("ThemeGraphyGenerator", tgg);
            msp.ArgumentProvider.SetArg("OutFileIdentify", outFileIdentify);
            msp.ArgumentProvider.SetArg("ThemeGraphTemplateName", templateName);
            if (customEnv != null)
            {
                RasterProject.PrjEnvelope prjEnvelope = new RasterProject.PrjEnvelope(customEnv.MinX, customEnv.MaxX, customEnv.MinY, customEnv.MaxY);
                msp.ArgumentProvider.SetArg("UseRegion", prjEnvelope);
            }
            else if (isUseRegion)// 换为字符串,为区域定义分组名称regionGroupName,为空代表不指定区域。
            {
                RasterIdentify rstId = new RasterIdentify(files[0]);
                if (!string.IsNullOrWhiteSpace(rstId.RegionIdentify))
                {
                    DefinedRegionParse reg        = new DefinedRegionParse();
                    BlockItemGroup     blockGroup = reg.BlockDefined.FindGroup("积雪");
                    PrjEnvelopeItem    envItem    = blockGroup.GetPrjEnvelopeItem(rstId.RegionIdentify);
                    if (envItem != null)
                    {
                        RasterProject.PrjEnvelope prjEnvelope = RasterProject.PrjEnvelope.CreateByCenter(envItem.PrjEnvelope.CenterX, envItem.PrjEnvelope.CenterY, 10, 10);
                        msp.ArgumentProvider.SetArg("UseRegion", prjEnvelope);
                    }
                }
            }
            if (!string.IsNullOrEmpty(colorTableName))
            {
                msp.ArgumentProvider.SetArg("colortablename", "colortablename=" + colorTableName);
            }

            IProgressMonitor     tracker  = null;
            Action <int, string> progress = null;

            try
            {
                tracker = session.ProgressMonitorManager.DefaultProgressMonitor;
                if (tracker != null)
                {
                    tracker.Start(false);
                    tracker.Reset("正在生成...", 100);
                    progress = (p, txt) =>
                    {
                        tracker.Boost(p, txt);
                    };
                }
                IExtractResult result = msp.Make(progress);
                DisplayResultClass.DisplayResult(session, msp, result, false);
                return(result);
            }
            finally
            {
                if (tracker != null)
                {
                    tracker.Finish();
                }
            }
        }
Exemple #7
0
        //根据文件名提取区域标识,限定专题图输出数据范围。一般用于制作网络图。
        public static IExtractResult CreateThemeGraphyBase(ISmartSession session, string algorithmName, string outFileIdentify, string colorTableName, string dataIdentify, string templateName, bool isCustom, bool multiSelect, bool isUseRegion)
        {
            IMonitoringSubProduct msp = (session.MonitoringSession as IMonitoringSession).ActiveMonitoringSubProduct;

            if (msp == null)
            {
                return(null);
            }
            object obj = msp.ArgumentProvider.GetArg("SelectedPrimaryFiles");

            //if (obj == null)
            //{
            if (!SetSelectedPrimaryFiles(session, ref obj, msp.ArgumentProvider, algorithmName))
            {
                return(null);
            }
            //}
            string[] files = obj as string[];
            if (files == null || files.Length == 0)
            {
                if (File.Exists(obj.ToString()))
                {
                    files = new string[] { obj.ToString() }
                }
                ;
                else
                {
                    return(null);
                }
            }
            //添加对生成专题图文件类型的判断,排除生成的专题图和统计结果文件,add by wangyu,20120923
            foreach (string fname in files)
            {
                CanCreatThemegraph(fname);
            }
            if (isCustom && !SetAOIArugment(files, msp, multiSelect))
            {
                return(null);
            }
            else if (!isCustom)
            {
                msp.ArgumentProvider.SetArg("AOI", null);
            }
            IThemeGraphGenerator tgg = (session.MonitoringSession as IMonitoringSession).ThemeGraphGenerator;

            msp.ArgumentProvider.SetArg("ThemeGraphyGenerator", tgg);
            msp.ArgumentProvider.SetArg("OutFileIdentify", outFileIdentify);
            msp.ArgumentProvider.SetArg("ThemeGraphTemplateName", templateName);
            if (isUseRegion)// 换为字符串,为区域定义分组名称regionGroupName,为空代表不指定区域。
            {
                RasterIdentify rstId = new RasterIdentify(files[0]);
                if (!string.IsNullOrWhiteSpace(rstId.RegionIdentify))
                {
                    DefinedRegionParse        reg         = new DefinedRegionParse();
                    BlockItemGroup            blockGroup  = reg.BlockDefined.FindGroup("积雪");
                    PrjEnvelopeItem           envItem     = blockGroup.GetPrjEnvelopeItem(rstId.RegionIdentify);
                    RasterProject.PrjEnvelope prjEnvelope = RasterProject.PrjEnvelope.CreateByCenter(envItem.PrjEnvelope.CenterX, envItem.PrjEnvelope.CenterY, 1000, 1000);
                    msp.ArgumentProvider.SetArg("UseRegion", prjEnvelope);
                }
            }
            if (!string.IsNullOrEmpty(colorTableName))
            {
                msp.ArgumentProvider.SetArg("colortablename", "colortablename=" + colorTableName);
            }
            IExtractResult result = msp.Make(null);

            DisplayResultClass.DisplayResult(session, msp, result, false);
            return(result);
        }