Beispiel #1
0
        private IExtractResult FLDTFQI()
        {
            string outFileIdentify          = GetStringArgument("OutFileIdentify");
            SubProductInstanceDef instatnce = GetSubProductInstanceByOutIdentify(outFileIdentify);

            if (instatnce != null)
            {
                outFileIdentify = instatnce.OutFileIdentify;
            }
            string templatName = GetStringArgument("ThemeGraphTemplateName");

            //获取边缘数据
            string[] shpFiles = _argumentProvider.GetArg("ShpFile") as string[];
            if (!CheckShpFile(ref shpFiles))
            {
                PrintInfo("边缘线获取失败!");
                return(null);
            }
            _shpFiles = shpFiles;
            ApplyMcd(_shpFiles, @"SystemData\ProductArgs\长序列水体边缘线专题图文档.mcd");
            CreateLegendItems(_shpFiles);
            IExtractResult        result   = null;
            SubProductInstanceDef instance = new SubProductInstanceDef();

            instance.OutFileIdentify = outFileIdentify;
            instance.LayoutName      = templatName;
            instance.isautogenerate  = false;
            result   = ThemeGraphyByInstance(instance);
            _gxdFile = (result as FileExtractResult).FileName;
            AddShpLayerToGxd();
            (result as FileExtractResult).Add2Workspace = true;
            return(result as IExtractResult);
        }
Beispiel #2
0
        public IExtractResult CHAZStatRaster <T>(SubProductInstanceDef instance, Dictionary <string, Func <T, bool> > filters, Action <int, string> progressTracker) where T : struct, IConvertible
        {
            switch (instance.AOIProvider)
            {
            case "当前区域":    //CCAR--CARC
                return(CHAZStatRasterByVector <T>(instance.Name + "差值", "CARC", null, filters, progressTracker));

            case "省市县行政区划":    //0CCC--CCCC
            {
                string statString = AreaStatProvider.GetAreaStatItemFileName("三级行政区划");
                return(CHAZStatRasterXJ <T>(_subProductDef.ProductDef.Name, _subProductDef.ProductDef.Identify, instance.Name + "差值", instance.AOIProvider, statString, "CCCC", filters, progressTracker));
            }

            case "省级行政区划":    //0CBP--CBPC
            {
                string statString = AreaStatProvider.GetAreaStatItemFileName("行政区划");
                return(CHAZStatRasterByVector <T>(instance.Name + "差值", "CBPC", statString, filters, progressTracker));
            }

            case "土地利用类型":    //CLUT--LUTC
            {
                string statString = AreaStatProvider.GetAreaStatItemFileName("土地利用类型");
                return(CHAZStatRasterByVector <T>(instance.Name + "差值", "LUTC", statString, filters, progressTracker));
            }

            case "自定义区域":    //
            default:
                break;
            }
            return(null);
        }
Beispiel #3
0
        private SubProductInstanceDef TryGetInstanceFromOutFileIdentify()
        {
            if (_activeMonitoringSubProduct == null || _activeMonitoringSubProduct.ArgumentProvider == null)
            {
                return(null);
            }
            string instanceIdentify = _activeMonitoringSubProduct.ArgumentProvider.GetArg("OutFileIdentify") as string;

            if (!string.IsNullOrWhiteSpace(instanceIdentify))
            {
                SubProductDef subProductDef = _activeMonitoringSubProduct.Definition;
                if (subProductDef == null || subProductDef.SubProductInstanceDefs == null)
                {
                    return(null);
                }
                foreach (SubProductInstanceDef instance in subProductDef.SubProductInstanceDefs)
                {
                    if (instance.OutFileIdentify == instanceIdentify)
                    {
                        SubProductInstanceDef instance2 = instance;
                        string themeGraphTemplateName   = _activeMonitoringSubProduct.ArgumentProvider.GetArg("HEAThemeGraphTemplateName") as string;
                        if (!string.IsNullOrWhiteSpace(themeGraphTemplateName))
                        {
                            instance2.LayoutName = themeGraphTemplateName;
                        }
                        return(instance);
                    }
                }
            }
            return(null);
        }
Beispiel #4
0
 public IStatResult CalcAreaByAlgorithmOneFile(IArgumentProvider argProvider, Action <int, string> progressTracker, string filename)
 {
     if (argProvider.GetArg("AlgorithmName").ToString() == "TSTAAlgorithmByFiles")
     {
         //按照Instance执行统计操作
         string instanceIdentify = _argumentProvider.GetArg("OutFileIdentify") as string;
         if (instanceIdentify != null)
         {
             SubProductInstanceDef instance = FindSubProductInstanceDefs(instanceIdentify);
             if (instance != null)
             {
                 if (instance.OutFileIdentify == "TCCC" || instance.OutFileIdentify == "TLUT")     //省市县面积统计
                 {
                     return(StatRasterToStatResult <short>(instance, (v) => { return v == 1; }, progressTracker));
                 }
                 if (!string.IsNullOrEmpty(instance.AOIProvider))
                 {
                     _argumentProvider.SetArg("AOI", instance.AOIProvider);
                 }
             }
         }
         if (argProvider.GetArg("AlgorithmName").ToString() == "TSTAAlgorithmByFiles")
         {
             return(STATAlgorithm(filename));
         }
     }
     return(null);
 }
Beispiel #5
0
 public override IExtractResult Make(Action <int, string> progressTracker)
 {
     if (_argumentProvider == null)
     {
         return(null);
     }
     if (_argumentProvider.GetArg("AlgorithmName") == null)
     {
         return(null);
     }
     if (_argumentProvider.GetArg("AlgorithmName").ToString() == "0IMGAlgorithm")
     {
         string instanceIdentify = _argumentProvider.GetArg("OutFileIdentify") as string;
         if (string.IsNullOrWhiteSpace(instanceIdentify))
         {
             return(null);
         }
         SubProductInstanceDef instance = FindSubProductInstanceDefs(instanceIdentify);
         if (instance == null)
         {
             return(ThemeGraphyResult(null));
         }
         if (instanceIdentify == "0MSI" || instanceIdentify == "MOSI" || instanceIdentify == "TNCI" || instanceIdentify == "ONCI")
         {
             return(ThemeGraphyMCSIDBLV(instance));
         }
         return(ThemeGraphyResult(null));
     }
     return(null);
 }
Beispiel #6
0
        private IExtractResult CMAAlgorithm()
        {
            string colorFileName = _argumentProvider.GetArg("DensitySetting").ToString();

            if (string.IsNullOrEmpty(colorFileName))
            {
                return(null);
            }
            CreateLegendItems(colorFileName);
            //专题图
            string outIdentify = _argumentProvider.GetArg("OutFileIdentify") as string;

            if (string.IsNullOrEmpty(outIdentify))
            {
                return(null);
            }
            SubProductInstanceDef instance = FindSubProductInstanceDefs(outIdentify);
            IExtractResult        er       = ThemeGraphyMCSI(instance);

            _gxdFile = (er as FileExtractResult).FileName;
            //矢量
            if (_argumentProvider.GetArg("ShpFile") != null)
            {
                string fileName = _argumentProvider.GetArg("ShpFile").ToString();
                if (!string.IsNullOrEmpty(fileName))
                {
                    _shpFile = GenerateShpFormTxt(fileName);
                    AddShpToGxd();
                }
            }
            return(er);
        }
Beispiel #7
0
 public override IExtractResult Make(Action <int, string> progressTracker)
 {
     if (_argumentProvider == null)
     {
         return(null);
     }
     if (_argumentProvider.GetArg("AlgorithmName") == null)
     {
         return(null);
     }
     if (_argumentProvider.GetArg("AlgorithmName").ToString() == "STATAlgorithm")
     {
         string instanceIdentify = _argumentProvider.GetArg("OutFileIdentify") as string;
         if (instanceIdentify != null)
         {
             SubProductInstanceDef instance = FindSubProductInstanceDefs(instanceIdentify);
             if (instance == null || instance.OutFileIdentify == "CCCA" || instance.OutFileIdentify == "CCAR")
             {
                 return(STATAlgorithm());
             }
             else
             {
                 return(StatRaster <short>(instance, (v) => { return v == 1; }, progressTracker));
             }
         }
     }
     return(null);
 }
Beispiel #8
0
        private IExtractResult AreasCHAZSTAT(SortedDictionary <float, float> lstRegions, Action <int, string> progressTracker)
        {
            if (_argumentProvider.GetArg("mainfiles") == null)
            {
                PrintInfo("请选择城市热岛指数(被减数)数据。");
                return(null);
            }
            string bjianshu = _argumentProvider.GetArg("mainfiles").ToString();

            if (!File.Exists(bjianshu))
            {
                PrintInfo("所选择的数据:\"" + bjianshu + "\"不存在。");
                return(null);
            }
            if (_argumentProvider.GetArg("jianshu") == null)
            {
                PrintInfo("请选择城市热岛指数(减数)数据。");
                return(null);
            }
            string jianshu = _argumentProvider.GetArg("jianshu").ToString();

            if (!File.Exists(jianshu))
            {
                PrintInfo("所选择的数据:\"" + jianshu + "\"不存在。");
                return(null);
            }
            string zoom       = _argumentProvider.GetArg("resultZoom").ToString();
            float  resultZoom = 100;

            if (!string.IsNullOrEmpty(zoom))
            {
                resultZoom = float.Parse(zoom);
            }
            string outId = _argumentProvider.GetArg("OutFileIdentify") as string;

            if (outId != null)
            {
                SubProductInstanceDef instance = FindSubProductInstanceDefs(outId);
                if (instance != null)
                {
                    Dictionary <string, Func <short, bool> > filters = new Dictionary <string, Func <short, bool> >();
                    foreach (float key in lstRegions.Keys)
                    {
                        float  min       = key;
                        float  max       = lstRegions[key];
                        string filterKey = min + "—" + max;
                        filters.Add(filterKey, (v) =>
                        {
                            float value = v / resultZoom;
                            return(value >= min && value < max);
                        });
                    }
                    return(CHAZStatRaster <short>(instance, filters, progressTracker));
                }
            }
            return(null);
        }
Beispiel #9
0
        private IExtractResult ICETFRI()
        {
            string outFileIdentify          = GetStringArgument("OutFileIdentify");
            SubProductInstanceDef instatnce = GetSubProductInstanceByOutIdentify(outFileIdentify);

            if (instatnce != null)
            {
                outFileIdentify = instatnce.OutFileIdentify;
            }
            string templatName = GetStringArgument("ThemeGraphTemplateName");

            //获取冰缘线数据
            string[] shpFiles = _argumentProvider.GetArg("ShpFile") as string[];
            if (shpFiles == null || shpFiles.Length == 0)
            {
                ISmartSession      session = _argumentProvider.GetArg("SmartSession") as ISmartSession;
                IMonitoringSession ms      = session.MonitoringSession as IMonitoringSession;
                IWorkspace         wks     = ms.GetWorkspace();
                if (wks.ActiveCatalog != null)
                {
                    string[] fs = wks.ActiveCatalog.GetSelectedFiles("EDGE");
                    if (fs != null && fs.Length != 0)
                    {
                        shpFiles = fs;
                        _argumentProvider.SetArg("SelectedPrimaryFiles", shpFiles);
                    }
                }
            }
            if (!CheckShpFile(ref shpFiles))
            {
                PrintInfo("冰缘线获取失败!");
                //return null;
            }
            else
            {
                _shpFiles = shpFiles;
                //if (_shpFiles.Length == 1)
                //    _iceControlPointShpFile = GeoDo.RSS.MIF.Prds.ICE.IceEdgeFileNameHelper.GetIceEdgeControlInfoFilename(_shpFiles[0]);
                ApplyMcd(_shpFiles, @"SystemData\ProductArgs\长序列冰缘线专题图文档.mcd");
                CreateLegendItems(_shpFiles);
            }
            IExtractResult        result   = null;
            SubProductInstanceDef instance = new SubProductInstanceDef();

            instance.OutFileIdentify = outFileIdentify;
            instance.isautogenerate  = false;
            instance.LayoutName      = templatName;
            result   = ThemeGraphyByInstance(instance);
            _gxdFile = (result as FileExtractResult).FileName;
            if (CheckShpFile(ref shpFiles))
            {
                AddShpLayerToGxd();
            }
            (result as FileExtractResult).Add2Workspace = true;
            return(result as IExtractResult);
        }
Beispiel #10
0
        private IExtractResult IceDegree()
        {
            string outFileIdentify          = GetStringArgument("OutFileIdentify");
            SubProductInstanceDef instatnce = GetSubProductInstanceByOutIdentify(outFileIdentify);

            if (instatnce != null)
            {
                outFileIdentify = instatnce.OutFileIdentify;
            }

            //string templatName = GetStringArgument("ThemeGraphTemplateName");
            string xIntervalStr = GetStringArgument("XInterval");
            string yIntervalStr = GetStringArgument("YInterval");
            float  xInterval = 0, yInterval = 0;

            if (string.IsNullOrWhiteSpace(xIntervalStr) || string.IsNullOrWhiteSpace(yIntervalStr))
            {
                return(null);
            }
            if (!float.TryParse(xIntervalStr, out xInterval) || !float.TryParse(yIntervalStr, out yInterval))
            {
                return(null);
            }
            string outidentify = _subProductDef.Identify;

            dblvFile = GetIceDblv();
            Feature[] features = GetIceDegreeShp(dblvFile, xInterval, yInterval);

            string gxd         = GenOutFiename(dblvFile, outFileIdentify, ".gxd");
            string shpFilename = Path.ChangeExtension(gxd, ".shp");

            SaveToShp(shpFilename, features);
            ApplyMcdToGxd(shpFilename);

            if (string.IsNullOrWhiteSpace(shpFilename) || !File.Exists(shpFilename))
            {
                return(null);
            }
            CreaterShpLayers(shpFilename);

            IExtractResult result = null;

            if (instatnce != null)
            {
                result = ThemeGraphyByInstance(instatnce);
            }
            else
            {
                result = VectoryThemeGraphy(null);
            }
            string gxdFile = (result as FileExtractResult).FileName;

            AddShpLayerToGxd(gxdFile);
            (result as FileExtractResult).Add2Workspace = true;
            return(result as IExtractResult);
        }
Beispiel #11
0
        private IExtractResult AreasSTAT(SortedDictionary <float, float> lstRegions, Action <int, string> progressTracker)
        {
            string[] fname = GetStringArray("SelectedPrimaryFiles");
            if (fname == null || fname.Length <= 0)
            {
                PrintInfo("请选择统计文件!");
                return(null);
            }
            foreach (string name in fname)
            {
                if (!File.Exists(name))
                {
                    PrintInfo("需要统计的文件不存在!");
                    return(null);
                }
            }
            string zoom       = _argumentProvider.GetArg("resultZoom").ToString();
            float  resultZoom = 100;

            if (!string.IsNullOrEmpty(zoom))
            {
                resultZoom = float.Parse(zoom);
            }
            string outId = _argumentProvider.GetArg("OutFileIdentify") as string;

            if (outId != null)
            {
                SubProductInstanceDef instance = FindSubProductInstanceDefs(outId);
                if (instance == null)
                {
                    return(STATAlgorithm());
                }
                else
                {
                    Dictionary <string, Func <short, bool> > filters = new Dictionary <string, Func <short, bool> >();
                    foreach (float key in lstRegions.Keys)
                    {
                        float  min       = key;
                        float  max       = lstRegions[key];
                        string filterKey = min + "—" + max;
                        filters.Add(filterKey, (v) =>
                        {
                            float value = v / resultZoom;
                            return(value >= min && value < max);
                        });
                    }
                    return(StatRaster <short>(instance, filters, progressTracker));
                }
            }
            return(null);
        }
Beispiel #12
0
 public override IExtractResult Make(Action <int, string> progressTracker)
 {
     if (_argumentProvider == null)
     {
         return(null);
     }
     if (_argumentProvider.GetArg("AlgorithmName") == null)
     {
         return(null);
     }
     if (_argumentProvider.GetArg("AlgorithmName").ToString() == "0IMGAlgorithm")
     {
         try
         {
             string instanceIdentify = _argumentProvider.GetArg("OutFileIdentify") as string;
             if (string.IsNullOrWhiteSpace(instanceIdentify))
             {
                 return(null);
             }
             SubProductInstanceDef instance = FindSubProductInstanceDefs(instanceIdentify);
             if (instance == null || instanceIdentify == "MCSI" || instanceIdentify == "OMCS")
             {
                 return(ThemeGraphyResult(null));
             }
             if ((instance.FileProvider.Contains("DBLV") || instance.FileProvider.Contains("DBHL")) &&
                 instance.OutFileIdentify != "TDBI")
             {
                 string[] selectedFileNames = _argumentProvider.GetArg("SelectedPrimaryFiles") as string[];
                 if (!string.IsNullOrEmpty(selectedFileNames[0]))
                 {
                     CreateLegendItems(selectedFileNames[0], instanceIdentify);
                 }
                 if (_colorTable != null)
                 {
                     instance.ColorTableName = _colorTable.ColorTableName;
                 }
                 else
                 {
                     throw new Exception("无法获取合适的颜色表");
                 }
             }
             return(ThemeGraphyByInstance(instance));
         }
         finally
         {
             _colorTable = null;
             _legendItems.Clear();
         }
     }
     return(null);
 }
Beispiel #13
0
        private IExtractResult GFRFAlgorithm()
        {
            string instanceIdentify = _argumentProvider.GetArg("OutFileIdentify") as string;

            if (string.IsNullOrWhiteSpace(instanceIdentify))
            {
                return(null);
            }
            SubProductInstanceDef instance = FindSubProductInstanceDefs(instanceIdentify);

            if (instance != null)
            {
                return(ThemeGraphyResult(null));
            }
            return(null);
        }
Beispiel #14
0
        private void CreatTemplateTypeRadioButton(SubProductInstanceDef instance, int i)
        {
            RadioButton radio = new RadioButton();

            radio.Tag  = instance;
            radio.Text = instance.Name;
            radio.Font = new Font("微软雅黑", 11);
            this.Controls.Add(radio);
            radio.AutoSize = true;
            radio.Top      = (int)(radio.Height * 1.5 * i) + 25;
            if (_isFirst)
            {
                _leftBlank = (this.Width - radio.Width) / 2 - 5;
                _isFirst   = false;
            }
            radio.Left = _leftBlank;
            _radioes.Add(radio);
        }
Beispiel #15
0
        private IExtractResult IMGAlgorithm()
        {
            string instanceIdentify = _argumentProvider.GetArg("OutFileIdentify") as string;

            if (string.IsNullOrWhiteSpace(instanceIdentify))
            {
                return(null);
            }
            SubProductInstanceDef instance = FindSubProductInstanceDefs(instanceIdentify);

            if (instance == null)
            {
                return(ThemeGraphyResult(null));
            }
            if (instance.Name.Contains("多通道合成图"))
            {
                _isMCSI = true;
                return(ThemeGraphyResult(null));
            }
            return(ThemeGraphyByInstance(instance));
        }
Beispiel #16
0
        private IExtractResult IMGAlgorithm()
        {
            string instanceIdentify = _argumentProvider.GetArg("OutFileIdentify") as string;

            if (string.IsNullOrWhiteSpace(instanceIdentify))
            {
                return(null);
            }
            SubProductInstanceDef instance = FindSubProductInstanceDefs(instanceIdentify);

            if (instance == null)
            {
                return(ThemeGraphyResult(null));
            }
            if (instanceIdentify == "0MSI" || instanceIdentify == "MOSI" || instanceIdentify == "TNCI" || instanceIdentify == "ONCI" ||
                instanceIdentify == "0SSI")
            {
                return(ThemeGraphyMCSIDBLV(instance));
            }
            return(ThemeGraphyResult(null));
        }
Beispiel #17
0
        public override IExtractResult Make(Action <int, string> progressTracker)
        {
            if (_argumentProvider == null)
            {
                return(null);
            }
            if (_argumentProvider.GetArg("AlgorithmName") == null)
            {
                return(null);
            }
            object obj          = _argumentProvider.GetArg("IsBackGround");
            bool   IsBackGround = false;

            if (obj != null && !string.IsNullOrEmpty(obj.ToString()))
            {
                IsBackGround = bool.Parse(obj.ToString());
            }
            if (_argumentProvider.GetArg("AlgorithmName").ToString() == "0IMGAlgorithm")
            {
                string instanceIdentify = _argumentProvider.GetArg("OutFileIdentify") as string;
                if (string.IsNullOrWhiteSpace(instanceIdentify))
                {
                    return(null);
                }
                SubProductInstanceDef instance = FindSubProductInstanceDefs(instanceIdentify);
                if (instance == null)
                {
                    return(ThemeGraphyResult(null));
                }
                if (instanceIdentify == "0MSI" || instanceIdentify == "ONCI" ||
                    instanceIdentify == "NCIM" || instanceIdentify == "TNCI" || instanceIdentify == "0SDI" ||
                    (IsBackGround && instanceIdentify == "HAEI") || (IsBackGround && instanceIdentify == "OHAI"))
                {
                    return(ThemeGraphyMCSIDBLV(instance));
                }
                return(ThemeGraphyResult(null));
            }
            return(null);
        }
Beispiel #18
0
 private void ok_Click(object sender, EventArgs e)
 {
     if (_radioes == null || _radioes.Count == 0)
     {
         return;
     }
     foreach (RadioButton radio in _radioes)
     {
         if (radio.Checked)
         {
             SubProductInstanceDef instance = radio.Tag as SubProductInstanceDef;
             if (instance == null)
             {
                 break;
             }
             _outFileIdentify = instance.OutFileIdentify;
             _templateName    = instance.LayoutName;
             DialogResult     = System.Windows.Forms.DialogResult.OK;
             return;
         }
     }
 }
Beispiel #19
0
        private IExtractResult TauL55Algorithm()
        {
            IFileExtractResult U5TTResult       = null;
            string             instanceIdentify = _argumentProvider.GetArg("OutFileIdentify") as string;

            if (string.IsNullOrWhiteSpace(instanceIdentify))
            {
                return(null);
            }
            SubProductInstanceDef instance = FindSubProductInstanceDefs(instanceIdentify);

            if (instance != null)
            {
                U5TTResult = ThemeGraphyResult(null) as IFileExtractResult;
                IExtractResultArray array      = new ExtractResultArray("气溶胶产品");
                IFileExtractResult  U5TIResult = new FileExtractResult("U5TI", _055TauFname, true);
                U5TIResult.SetDispaly(false);
                array.Add(U5TTResult);
                array.Add(U5TIResult);
                return(array);
            }
            return(null);
        }
        public override IExtractResult Make(Action <int, string> progressTracker, IContextMessage contextMessage)
        {
            _contextMessage = contextMessage;
            if (_argumentProvider == null)
            {
                return(null);
            }
            if (_argumentProvider.GetArg("SelectedPrimaryFiles") == null)
            {
                PrintInfo("请选择统计文件!");
                return(null);
            }
            string[] fname = GetStringArray("SelectedPrimaryFiles");
            if (fname == null || fname.Length <= 0)
            {
                PrintInfo("请选择统计文件!");
                return(null);
            }
            foreach (string name in fname)
            {
                if (!File.Exists(name))
                {
                    PrintInfo("需要统计的文件不存在!");
                    return(null);
                }
            }
            if (_argumentProvider.GetArg("NDVIRegion") == null)
            {
                PrintInfo("请设置需要统计的植被指数分段值!");
                return(null);
            }
            SortedDictionary <float, float> ndviRegions = _argumentProvider.GetArg("NDVIRegion") as SortedDictionary <float, float>;

            if (ndviRegions == null || ndviRegions.Count == 0)
            {
                return(null);
            }
            if (_argumentProvider.GetArg("AlgorithmName") == null)
            {
                PrintInfo("参数\"AlgorithmName\"为空。");
                return(null);
            }
            string algorith = _argumentProvider.GetArg("AlgorithmName").ToString();

            if (algorith != "VTAT")
            {
                PrintInfo("指定的算法\"" + algorith + "\"没有实现。");
                return(null);
            }
            string zoom       = _argumentProvider.GetArg("resultZoom").ToString();
            float  resultZoom = 1000;

            if (!string.IsNullOrEmpty(zoom))
            {
                resultZoom = float.Parse(zoom);
            }
            string outId     = _argumentProvider.GetArg("OutFileIdentify") as string;
            string outFileId = CreatTitleByFileName(fname[0], outId);
            bool   isCustom  = false;

            if (_argumentProvider.GetArg("IsCustom") != null)
            {
                string s = _argumentProvider.GetArg("IsCustom").ToString();
                if (!string.IsNullOrEmpty(s))
                {
                    isCustom = bool.Parse(s);
                }
            }
            if (isCustom)
            {
                Dictionary <string, int[]> aoi = GetAOIArugment(fname[0], true);
                if (aoi != null && aoi.Count > 0)
                {
                    return(CreatCustomStatResult(aoi, ndviRegions, resultZoom, fname, outFileId));
                }
            }
            else
            {
                SubProductInstanceDef instance = FindSubProductInstanceDefs(outFileId);
                if (instance == null)
                {
                    return(STATAlgorithm());
                }
                else
                {
                    _argumentProvider.SetArg("OutFileIdentify", outFileId);
                    Dictionary <string, Func <short, bool> > filters = new Dictionary <string, Func <short, bool> >();
                    foreach (float key in ndviRegions.Keys)
                    {
                        float  min       = key;
                        float  max       = ndviRegions[key];
                        string filterKey = min + "-" + max;
                        filters.Add(filterKey, (v) =>
                        {
                            float value = v / resultZoom;
                            return(value >= min && value < max);
                        });
                    }
                    return(StatProcentRaster <short>(fname[0], filters, progressTracker));
                }
            }
            return(null);
        }
Beispiel #21
0
        public override IExtractResult Make(Action <int, string> progressTracker, IContextMessage contextMessage)
        {
            _contextMessage = contextMessage;
            if (_argumentProvider == null)
            {
                return(null);
            }
            string[] fname = GetStringArray("SelectedPrimaryFiles");
            if (fname == null || fname.Length <= 0)
            {
                PrintInfo("请选择统计文件!");
                return(null);
            }
            foreach (string name in fname)
            {
                if (!File.Exists(name))
                {
                    PrintInfo("需要统计的文件不存在!");
                    return(null);
                }
            }
            string argFileName = _argumentProvider.GetArg("RegionFileName").ToString();

            if (string.IsNullOrEmpty(argFileName))
            {
                PrintInfo("请设置需要统计的指数分段值参数文件!");
                return(null);
            }
            SortedDictionary <float, float> lstRegions = GetArgFileRegion(argFileName);

            if (lstRegions == null || lstRegions.Count == 0)
            {
                return(null);
            }
            if (_argumentProvider.GetArg("AlgorithmName") == null)
            {
                PrintInfo("参数\"AlgorithmName\"为空。");
                return(null);
            }
            string algorith = _argumentProvider.GetArg("AlgorithmName").ToString();

            if (algorith != "CSTAAlgorithm")
            {
                PrintInfo("指定的算法\"" + algorith + "\"没有实现。");
                return(null);
            }
            string zoom       = _argumentProvider.GetArg("resultZoom").ToString();
            float  resultZoom = 100;

            if (!string.IsNullOrEmpty(zoom))
            {
                resultZoom = float.Parse(zoom);
            }
            string outId = _argumentProvider.GetArg("OutFileIdentify") as string;

            if (outId != null)
            {
                SubProductInstanceDef instance = FindSubProductInstanceDefs(outId);
                if (instance == null)
                {
                    return(STATAlgorithm());
                }
                else
                {
                    float K2T = -273;
                    Dictionary <string, Func <short, bool> > filters = new Dictionary <string, Func <short, bool> >();
                    foreach (float key in lstRegions.Keys)
                    {
                        float  min       = key;
                        float  max       = lstRegions[key];
                        string filterKey = (min + K2T) + "~" + (max + K2T) + "℃";
                        filters.Add(filterKey, (v) =>
                        {
                            float value = v / resultZoom;
                            return(value >= min && value < max);
                        });
                    }
                    if (instance.AOIProvider == "省级行政区划")
                    {
                        return(StatProcentRaster <short>(fname[0], filters, progressTracker));
                    }
                    return(StatRaster <short>(instance, filters, progressTracker));
                }
            }
            return(null);
        }
Beispiel #22
0
        private IExtractResult TSTATAlgorithmStat(string outId, SubProductInstanceDef instance, Dictionary <string, Func <short, bool> > filters, Action <int, string> progressTracker)
        {
            string[]        files     = GetStringArray("SelectedPrimaryFiles");
            IStatResult     temp      = null;
            List <string>   colums    = new List <string>();
            List <string[]> rowTemp   = new List <string[]>();
            IStatResult     dstResult = null;
            RasterIdentify  rid       = null;
            string          dateStr   = _argumentProvider.GetArg("tostringtype").ToString();
            int             fileIndex = 0;
            float           step      = 90f / files.Length;

            try
            {
                if (outId == "CCAR")
                {
                    foreach (string file in files)
                    {
                        if (progressTracker != null)
                        {
                            progressTracker.Invoke((int)Math.Ceiling(fileIndex * step), "正在统计第[" + fileIndex + "]个文件,请稍后...");
                        }
                        temp = StatRasterToStatResult <short>(instance, new string[] { file }, filters, progressTracker);
                        rid  = new RasterIdentify(file);
                        foreach (string[] cols in temp.Rows)
                        {
                            cols[0] = rid.OrbitDateTime.ToString(dateStr);
                            rowTemp.Add(cols);
                        }
                        if (colums.Count == 0)
                        {
                            colums.AddRange(temp.Columns);
                        }
                    }
                    rowTemp.Sort((before, last) => before.First().CompareTo(last.First()));
                    dstResult = new StatResult(null, colums.ToArray(), rowTemp.ToArray());
                    if (progressTracker != null)
                    {
                        progressTracker.Invoke(95, "正在写入统计信息,请稍后...");
                    }
                    return(new FileExtractResult("LST", StatResultToFile(files, dstResult, "LST", "T" + outId.Substring(0, 3), "", "", 1, false)));
                }
                if (instance.AOIProvider == "省级行政区划" || instance.AOIProvider == "土地利用类型")
                {
                    string        statVector = instance.AOIProvider == "省级行政区划" ? "行政区划" : "土地利用类型";
                    string        title;
                    string[]      colDescs;
                    IStatResult[] tempArray      = null;
                    IStatResult[] dstResultArray = null;
                    List <string> tempList       = null;
                    foreach (string file in files)
                    {
                        fileIndex++;
                        if (progressTracker != null)
                        {
                            progressTracker.Invoke((int)Math.Ceiling(fileIndex * step), "正在统计第[" + fileIndex + "]个文件,请稍后...");
                        }
                        tempArray = StatProcentRasterToStatResult(file, statVector, filters, null, out title, out colDescs, true);
                        if (dstResultArray == null)
                        {
                            dstResultArray = new IStatResult[tempArray.Length];
                        }
                        rid = new RasterIdentify(file);
                        for (int i = 0; i < dstResultArray.Length; i++)
                        {
                            try
                            {
                                foreach (string[] cols in tempArray[i].Rows)
                                {
                                    tempList = new List <string>();
                                    tempList.AddRange(cols);
                                    tempList.Insert(1, rid.OrbitDateTime.ToString(dateStr));
                                    rowTemp.Add(tempList.ToArray());
                                }
                                if (colums.Count == 0)
                                {
                                    tempList = new List <string>();
                                    tempList.AddRange(tempArray[i].Columns);
                                    tempList.Insert(1, "日期");
                                    colums.AddRange(tempList.ToArray());
                                }
                                if (dstResultArray[i] == null)
                                {
                                    dstResultArray[i] = new StatResult(null, colums.ToArray(), rowTemp.ToArray());
                                }
                                else
                                {
                                    List <string[]> tempRowsFromArray = new List <string[]>();
                                    tempRowsFromArray.AddRange(dstResultArray[i].Rows);
                                    tempRowsFromArray.AddRange(rowTemp.ToArray());
                                    StringArrayComparer comparer = new StringArrayComparer(true);
                                    tempRowsFromArray.Sort(comparer);
                                    dstResultArray[i] = new StatResult(null, colums.ToArray(), tempRowsFromArray.ToArray());
                                }
                            }
                            finally
                            {
                                colums.Clear();
                                rowTemp.Clear();
                            }
                        }
                    }
                    if (progressTracker != null)
                    {
                        progressTracker.Invoke(95, "正在写入统计信息,请稍后...");
                    }
                    string              outFileIdentify  = GetStringArgument("OutFileIdentify");
                    string[]            outFileIdentifys = new string[] { "T" + outFileIdentify.Substring(0, 3), "T" + outFileIdentify.Substring(0, 2) + "P" };
                    IExtractResultArray array            = new ExtractResultArray("LST");
                    for (int i = 0; i < dstResultArray.Length; i++)
                    {
                        List <RowDisplayDef> rowRulers     = new List <RowDisplayDef>();
                        List <int>           displayRowNum = new List <int>();
                        int    count  = -1;
                        string befStr = dstResultArray[i].Rows[0].First();
                        for (int row = 0; row < dstResultArray[i].Rows.Length; row++)
                        {
                            count++;
                            if (dstResultArray[i].Rows[row].First() == befStr)
                            {
                                displayRowNum.Add(count + 3);
                                continue;
                            }
                            AddRowRuler(ref rowRulers, displayRowNum, dstResultArray[i].Rows[row - 1][0], true, false, false);
                            displayRowNum.Clear();
                            befStr = dstResultArray[i].Rows[row].First();
                            displayRowNum.Add(count + 3);
                        }
                        AddRowRuler(ref rowRulers, displayRowNum, befStr, true, false, false);
                        array.Add(new FileExtractResult("LST", StatResultToFile(files, dstResultArray[i], "LST", outFileIdentifys[i], "", "", 1, rowRulers, 3, (dstResultArray[i].Columns.Length - 2))));
                    }
                    return(array);
                }
            }
            finally
            {
                if (progressTracker != null)
                {
                    progressTracker.Invoke(100, "完成统计分析!");
                }
            }
            PrintInfo("指定的算法\"" + instance.Name + "\"没有实现。");
            return(null);
        }
        private IExtractResult STATAlgorithm(Action <int, string> progressTracker)
        {
            object aioObj                  = _argumentProvider.GetArg("AOI");
            string outFileIdentify         = GetStringArgument("OutFileIdentify");
            SubProductInstanceDef instance = FindSubProductInstanceDefs(outFileIdentify);

            string[] files    = GetStringArray("SelectedPrimaryFiles");
            string   extInfos = GetStringArgument("extinfo");

            if (files == null || files.Length == 0)
            {
                return(null);
            }
            _argumentProvider.SetArg("statname", "变化水体");
            if (outFileIdentify == "COCC")
            {
                Dictionary <string, Func <short, bool> > dic = new Dictionary <string, Func <short, bool> >();
                dic.Add("扩大水体面积(平方公里)", (v) => { return(v == 4); });
                dic.Add("未变水体面积(平方公里)", (v) => { return(v == 1); });
                dic.Add("缩小水体面积(平方公里)", (v) => { return(v == 5); });
                return(StatRaster <short>(instance, dic, progressTracker));
            }
            if (outFileIdentify == "COCU")
            {
                _argumentProvider.SetArg("statname", "洪涝水体");
                Dictionary <string, Func <short, bool> > dic = new Dictionary <string, Func <short, bool> >();
                dic.Add("洪涝水体面积", (v) => { return(v == 4); });
                return(StatRaster <short>(instance, dic, progressTracker));
            }
            if (outFileIdentify == "CODU")
            {
                _argumentProvider.SetArg("statname", "洪涝水体");
                using (IRasterDataProvider rdp = GeoDataDriver.Open(files[0]) as IRasterDataProvider)
                {
                    LastDaysSetValue           outLastDays = (rdp as MemoryRasterDataProvider).GetExtHeader <LastDaysSetValue>();
                    Dictionary <string, int[]> coduDic     = new Dictionary <string, int[]>();
                    coduDic.Add("<" + outLastDays.LastDaysColor[0].ToString() + "日", new int[] { outLastDays.LastDaysColor[0], 0 });
                    for (int i = 1; i < outLastDays.LastDaysColor.Length; i++)
                    {
                        if (outLastDays.LastDaysColor[i] == 0)
                        {
                            break;
                        }
                        coduDic.Add(outLastDays.LastDaysColor[i - 1].ToString() + "日~" +
                                    outLastDays.LastDaysColor[i].ToString() + "日", new int[] { outLastDays.LastDaysColor[i - 1], outLastDays.LastDaysColor[i] });
                    }
                    Dictionary <string, Func <short, bool> > dic = new Dictionary <string, Func <short, bool> >();
                    int index = -1;
                    foreach (string key in coduDic.Keys)
                    {
                        index++;
                        string funKey = key;
                        if (index == 0)
                        {
                            dic.Add("洪涝" + key, (v) => { return(v > 0 && v <= coduDic[funKey][0]); });
                        }
                        else
                        {
                            dic.Add("洪涝" + key, (v) => { return(v > coduDic[funKey][0] && v <= coduDic[funKey][1]); });
                        }
                    }
                    return(StatRaster <short>(instance, dic, progressTracker));
                }
            }

            string title = string.Empty;

            StatResultItem[] floodResult  = CommProductStat.AreaStat <Int16>("变化水体", files[0], ref title, aioObj, (v) => { return(v == 4); });
            StatResultItem[] sameResult   = CommProductStat.AreaStat <Int16>("变化水体", files[0], ref title, aioObj, (v) => { return(v == 1); });
            StatResultItem[] reduceResult = CommProductStat.AreaStat <Int16>("变化水体", files[0], ref title, aioObj, (v) => { return(v == 5); });
            if (floodResult == null && sameResult == null && reduceResult == null)
            {
                return(null);
            }
            //增加单次面积统计百分比计算

            bool   isTotal = true;
            double floodPercent = 0, samePercent = 0, reducePercent = 0;

            if (floodResult.Length == 1 && sameResult.Length == 1 && reduceResult.Length == 1)
            {
                double histroyArea = sameResult[0].Value + reduceResult[0].Value;
                floodPercent  = Math.Round(floodResult[0].Value / histroyArea * 100, 2);
                samePercent   = Math.Round(sameResult[0].Value / histroyArea * 100, 2);
                reducePercent = Math.Round(reduceResult[0].Value / histroyArea * 100, 2);

                floodResult  = AddPercent(floodResult, floodPercent);
                sameResult   = AddPercent(sameResult, samePercent);
                reduceResult = AddPercent(reduceResult, reducePercent);
                isTotal      = false;
            }

            //
            Dictionary <string, string[]> result = new Dictionary <string, string[]>();

            StatResultItem[][] resultArray       = new StatResultItem[][] { floodResult, sameResult, reduceResult };
            for (int i = 0; i < 3; i++)
            {
                if (resultArray[i] != null && resultArray[i].Length > 0)
                {
                    foreach (StatResultItem item in resultArray[i])
                    {
                        if (result.ContainsKey(item.Name))
                        {
                            result[item.Name][i] = item.Value.ToString();
                        }
                        else
                        {
                            result.Add(item.Name, new string[3]);
                            result[item.Name][i] = item.Value.ToString();
                        }
                    }
                }
            }
            if (result.Count == 0)
            {
                return(null);
            }
            List <string[]> resultList = new List <string[]>();

            foreach (string key in result.Keys)
            {
                resultList.Add(new string[] { key, result[key][0], result[key][1], result[key][2] });
            }
            string         sentitle = "统计日期:" + DateTime.Now.ToShortDateString();
            RasterIdentify id       = new RasterIdentify(files[0]);

            if (id.MinOrbitDate != DateTime.MinValue && id.MaxOrbitDate != DateTime.MaxValue && id.MaxOrbitDate != id.MinOrbitDate)
            {
                sentitle += "    背景水体日期:" + id.MinOrbitDate.ToShortDateString();
                sentitle += "    轨道日期:" + id.MaxOrbitDate.ToShortDateString();
            }
            else
            {
                if (id.OrbitDateTime != null)
                {
                    sentitle += "    轨道日期:" + id.OrbitDateTime.ToShortDateString();
                }
            }
            string[]    columns        = new string[] { "矢量分区", "扩大水体面积(平方公里)", "未变水体面积(平方公里)", "缩小水体面积(平方公里)" };
            IStatResult fresult        = new StatResult(sentitle, columns, resultList.ToArray());
            string      outputIdentify = _argumentProvider.GetArg("OutFileIdentify").ToString();
            string      filename       = StatResultToFile(files, fresult, "FLD", outputIdentify, title, null, 1, isTotal, 1);


            return(new FileExtractResult(outputIdentify, filename));
        }
        private IExtractResult ASTATAlgorithm(Action <int, string> progressTracker, IContextMessage contextMessage)
        {
            _contextMessage = contextMessage;
            if (_argumentProvider == null)
            {
                return(null);
            }
            string[] fname = GetStringArray("SelectedPrimaryFiles");
            if (fname == null || fname.Length <= 0)
            {
                PrintInfo("请选择统计文件!");
                return(null);
            }
            foreach (string name in fname)
            {
                if (!File.Exists(name))
                {
                    PrintInfo("需要统计的文件不存在!");
                    return(null);
                }
            }
            if (_argumentProvider.GetArg("UCRegionSnowDepth") == null)
            {
                PrintInfo("请设置需要统计的指数分段值!");
                return(null);
            }
            SortedDictionary <float, float> sdRegions = _argumentProvider.GetArg("UCRegionSnowDepth") as SortedDictionary <float, float>;

            if (sdRegions == null || sdRegions.Count == 0)
            {
                return(null);
            }

            if (_argumentProvider.GetArg("AlgorithmName") == null)
            {
                PrintInfo("参数\"AlgorithmName\"为空。");
                return(null);
            }

            string outId     = _argumentProvider.GetArg("OutFileIdentify") as string;
            string outFileId = CreatTitleByFileName(fname[0], outId);

            SubProductInstanceDef instance = FindSubProductInstanceDefs(outId);

            if (instance == null)
            {
                return(AreaStatResult <Int16>("雪深", "MWS", (v) => { return v == 1; }));
            }
            else
            {
                _argumentProvider.SetArg("OutFileIdentify", outFileId);
                Dictionary <string, Func <float, bool> > filters = new Dictionary <string, Func <float, bool> >();
                foreach (float key in sdRegions.Keys)
                {
                    float  min       = key;
                    float  max       = sdRegions[key];
                    string filterKey = min + "—" + max + "厘米 " + "覆盖面积(平方公里)";
                    filters.Add(filterKey, (v) =>
                    {
                        double value = v;
                        return(value >= min && value < max);
                    });
                }
                string fieldName;
                string shapeFilename;
                int    fieldIndex = -1;
                if (instance.AOIProvider == "当前区域" || instance.AOIProvider == "土地利用类型")
                {
                    return(StatRaster <float>(instance, filters, progressTracker));
                }
                else
                {
                    if (instance.AOIProvider == "县级行政区划")
                    {
                        using (frmStatSXRegionTemplates frm = new frmStatSXRegionTemplates())
                        {
                            if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            {
                                Feature[] fets = frm.GetSelectedFeatures();
                                fets = frm.GetStatFeatures(out fieldName, out shapeFilename, out fieldIndex);
                                if (fets == null)
                                {
                                    PrintInfo("未选择任何地区");
                                }
                                fieldValues.Clear();
                                foreach (Feature fet in fets)
                                {
                                    fieldValues.Add(fet.GetFieldValue(fieldIndex));     //获得选择区域名称
                                }
                            }
                        }
                        string statString = AreaStatProvider.GetAreaStatItemFileName("县级行政区划");
                        return(StatRasterByVector(instance.Name, statString, filters, progressTracker));
                    }
                    else
                    {
                        if (instance.AOIProvider == "省级行政区划")
                        {
                            using (frmStatProvinceRegionTemplates frm = new frmStatProvinceRegionTemplates())
                            {
                                if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                                {
                                    Feature[] fets = frm.GetSelectedFeatures();
                                    fets = frm.GetStatFeatures(out fieldName, out shapeFilename, out fieldIndex);
                                    if (fets == null)
                                    {
                                        PrintInfo("未选择任何地区");
                                    }
                                    fieldValues.Clear();
                                    foreach (Feature fet in fets)
                                    {
                                        fieldValues.Add(fet.GetFieldValue(fieldIndex));     //获得选择区域名称
                                    }
                                }
                            }
                            string statString = AreaStatProvider.GetAreaStatItemFileName("行政区划");
                            return(StatRasterByVector(instance.Name, statString, filters, progressTracker));
                        }
                    }
                }
            }

            return(null);
        }
Beispiel #25
0
        private void TrySetInstanceArgs()
        {
            _instanceDef = TryGetInstanceFromOutFileIdentify();
            if (_instanceDef == null)
            {
                return;
            }
            IArgumentProvider argumentProvider = _activeMonitoringSubProduct.ArgumentProvider;
            bool   isSpecifyFiles = false;
            object obj            = argumentProvider.GetArg("isSpecifyFiles");

            if (obj != null && !string.IsNullOrEmpty(obj.ToString()))
            {
                isSpecifyFiles = bool.Parse(obj.ToString());
            }
            string fileProvider = _instanceDef.FileProvider;

            string[] fps = fileProvider.Split(':');
            if (fps == null || fps.Length != 2)
            {
                return;
            }
            string key          = fps[0];
            string needIdentify = fps[1];

            if (key == "ContextEnvironment")
            {
                if (needIdentify == "CurrentRasterFile")    //多通道合成图,当前区域
                {
                    //(_currentCanvasViewer.ActiveDrawing as RasterDrawing).DataProvider;
                }
                else
                {
                    if (!isSpecifyFiles)
                    {
                        IWorkspace wks = Workspace;
                        if (wks == null)
                        {
                            return;
                        }

                        string[] selectedFiles = null;
                        if (wks.ActiveCatalog != null)
                        {
                            selectedFiles = wks.ActiveCatalog.GetSelectedFiles(needIdentify);
                        }
                        if (selectedFiles == null)
                        {
                            ICatalog cat = wks.GetCatalogByIdentify(needIdentify);
                            if (cat != null)
                            {
                                selectedFiles = cat.GetSelectedFiles(needIdentify);
                            }
                        }
                        _selectedFiles = selectedFiles;
                        if (selectedFiles != null)
                        {
                            argumentProvider.SetArg("SelectedPrimaryFiles", selectedFiles);
                        }
                    }
                }
            }

            //IEnvironmentVarProvider varPrd = argumentProvider.EnvironmentVarProvider;
        }
Beispiel #26
0
        private IExtractResult FRDSAlgorithm(Action <int, string> progressTracker)
        {
            string[] fileNames = GetStringArray("SelectedPrimaryFiles");
            if (fileNames == null || fileNames.Count() == 0)
            {
                PrintInfo("请选择参与积雪天数统计的数据!");
                return(null);
            }
            foreach (string f in fileNames)
            {
                if (!File.Exists(f))
                {
                    PrintInfo("所选择的数据:\"" + f + "\"不存在。");
                    return(null);
                }
            }
            int bandNo = 1;
            ExtractResultArray array = new ExtractResultArray("SNW");
            //输出文件准备(作为输入栅格并集处理)
            RasterIdentify ri          = GetRasterIdentifyID(ref fileNames);
            string         outFileName = ri.ToWksFullFileName(".dat");
            //输入文件准备
            List <RasterMaper> rms = new List <RasterMaper>();
            string             tempFilename;

            try
            {
                for (int i = 0; i < fileNames.Length; i++)
                {
                    tempFilename = ProcessCloud(fileNames[i], bandNo);
                    IRasterDataProvider inRaster = RasterDataDriver.Open(tempFilename) as IRasterDataProvider;
                    if (inRaster.BandCount < bandNo)
                    {
                        PrintInfo("请选择正确的数据进行积雪天数统计。");
                        return(null);
                    }
                    RasterMaper rm = new RasterMaper(inRaster, new int[] { tempFilename == fileNames[i] ? bandNo : 1 });
                    rms.Add(rm);
                }
                using (IRasterDataProvider outRaster = CreateOutRaster(outFileName, rms.ToArray()))
                {
                    //栅格数据映射
                    RasterMaper[] fileIns  = rms.ToArray();
                    RasterMaper[] fileOuts = new RasterMaper[] { new RasterMaper(outRaster, new int[] { 1 }) };
                    //创建处理模型
                    RasterProcessModel <Int16, Int16> rfr = null;
                    rfr = new RasterProcessModel <Int16, Int16>(progressTracker);
                    rfr.SetRaster(fileIns, fileOuts);
                    Int16[] nanValues     = GetNanValues("CloudyValue");
                    Int16[] waterValues   = GetNanValues("WaterValue");
                    Int16[] invailValues  = GetNanValues("InvailValue");
                    Int16   currTimeValue = 0;
                    rfr.RegisterCalcModel(new RasterCalcHandler <Int16, Int16>((rvInVistor, rvOutVistor, aoi) =>
                    {
                        int dataLength         = rvOutVistor[0].SizeY * rvOutVistor[0].SizeX;
                        Int16[] timeValue      = new Int16[dataLength];
                        List <Int16> tempValue = new List <Int16>();
                        for (int i = 0; i < dataLength; i++)
                        {
                            timeValue[i] = 0;
                        }
                        for (int index = 0; index < dataLength; index++)
                        {
                            foreach (RasterVirtualVistor <Int16> rvs in rvInVistor)
                            {
                                Int16[] dt = rvs.RasterBandsData[0];
                                if (dt == null)
                                {
                                    continue;
                                }
                                tempValue.Add(dt[index]);
                            }

                            if (tempValue.Count == 0)
                            {
                                continue;
                            }
                            if (TimeValue(tempValue.ToArray(), nanValues, invailValues, waterValues, out currTimeValue))
                            {
                                timeValue[index] = currTimeValue;
                            }
                            tempValue.Clear();
                        }
                        for (int index = 0; index < dataLength; index++)
                        {
                            rvOutVistor[0].RasterBandsData[0][index] = timeValue[index];
                        }
                    }));
                    //执行
                    rfr.Excute(0);
                    FileExtractResult res = new FileExtractResult(_subProductDef.Identify, outFileName, true);
                    array.Add(res);
                    res.SetDispaly(false);
                }
            }
            finally
            {
                foreach (RasterMaper rm in rms)
                {
                    rm.Raster.Dispose();
                }
            }

            _argumentProvider.SetArg("SelectedPrimaryFiles", new string[] { outFileName });
            string instanceIdentify = _argumentProvider.GetArg("OutFileIdentify") as string;

            if (string.IsNullOrWhiteSpace(instanceIdentify))
            {
                return(array);
            }
            SubProductInstanceDef instance = FindSubProductInstanceDefs(instanceIdentify);
            IExtractResult        ress     = ThemeGraphyByInstance(instance);

            if (ress != null)
            {
                array.Add(ress as IFileExtractResult);
            }
            return(array);
        }
Beispiel #27
0
        private IExtractResult STATAlgorithm(Action <int, string> progressTracker)
        {
            object aioObj                  = _argumentProvider.GetArg("AOI");
            string outFileIdentify         = GetStringArgument("OutFileIdentify");
            SubProductInstanceDef instance = FindSubProductInstanceDefs(outFileIdentify);

            string[] files    = GetStringArray("SelectedPrimaryFiles");
            string   extInfos = GetStringArgument("extinfo");

            if (files == null || files.Length == 0)
            {
                return(null);
            }
            _argumentProvider.SetArg("statname", "变化积雪");
            if (outFileIdentify == "COCC")
            {
                Dictionary <string, Func <short, bool> > dic = new Dictionary <string, Func <short, bool> >();
                dic.Add("新增冰面积(平方公里)", (v) => { return(v == 4); });
                dic.Add("持续冰面积(平方公里)", (v) => { return(v == 1); });
                dic.Add("融化冰面积(平方公里)", (v) => { return(v == 5); });
                return(StatRaster <short>(instance, dic, progressTracker));
            }
            string title = string.Empty;

            StatResultItem[] floodResult  = CommProductStat.AreaStat <Int16>("变化冰", files[0], ref title, aioObj, (v) => { return(v == 4); });
            StatResultItem[] sameResult   = CommProductStat.AreaStat <Int16>("变化冰", files[0], ref title, aioObj, (v) => { return(v == 1); });
            StatResultItem[] reduceResult = CommProductStat.AreaStat <Int16>("变化冰", files[0], ref title, aioObj, (v) => { return(v == 5); });
            if (floodResult == null && sameResult == null && reduceResult == null)
            {
                return(null);
            }
            Dictionary <string, string[]> result = new Dictionary <string, string[]>();

            StatResultItem[][] resultArray = new StatResultItem[][] { floodResult, sameResult, reduceResult };
            for (int i = 0; i < 3; i++)
            {
                if (resultArray[i] != null && resultArray[i].Length > 0)
                {
                    foreach (StatResultItem item in resultArray[i])
                    {
                        if (result.ContainsKey(item.Name))
                        {
                            result[item.Name][i] = item.Value.ToString();
                        }
                        else
                        {
                            result.Add(item.Name, new string[3] {
                                "0", "0", "0"
                            });
                            result[item.Name][i] = item.Value.ToString();
                        }
                    }
                }
            }
            if (result.Count == 0)
            {
                return(null);
            }
            List <string[]> resultList = new List <string[]>();

            foreach (string key in result.Keys)
            {
                resultList.Add(new string[] { key, result[key][0], result[key][1], result[key][2] });
            }
            string         sentitle = "统计日期:" + DateTime.Now.ToShortDateString();
            RasterIdentify id       = new RasterIdentify(files[0]);

            if (id.OrbitDateTime != null)
            {
                sentitle += "    轨道日期:" + id.OrbitDateTime.ToShortDateString();
            }
            string[]    columns        = new string[] { "矢量分区", "新增冰面积(平方公里)", "持续冰面积(平方公里)", "融化冰面积(平方公里)" };
            IStatResult fresult        = new StatResult(sentitle, columns, resultList.ToArray());
            string      outputIdentify = _argumentProvider.GetArg("OutFileIdentify").ToString();
            //string filename = StatResultToFile(files, fresult, "SNW", outputIdentify, title, null, 1, true, 1);
            string filename = StatResultToFile(files, fresult, "SNW", outputIdentify, title, null, 1, true, 1);

            return(new FileExtractResult(outputIdentify, filename));
        }
Beispiel #28
0
        public override IExtractResult Make(Action <int, string> progressTracker, IContextMessage contextMessage)
        {
            _contextMessage = contextMessage;
            if (_argumentProvider == null)
            {
                return(null);
            }
            string[] fname = GetStringArray("SelectedPrimaryFiles");
            if (fname == null || fname.Length <= 0)
            {
                PrintInfo("请选择统计文件!");
                return(null);
            }
            foreach (string name in fname)
            {
                if (!File.Exists(name))
                {
                    PrintInfo("需要统计的文件不存在!");
                    return(null);
                }
            }
            string[] argFileArg  = _argumentProvider.GetArg("RegionFileName") as string[];
            string   argFileName = argFileArg[0];
            bool     argFileIsCY = bool.Parse(argFileArg[1]);

            if (string.IsNullOrEmpty(argFileName))
            {
                PrintInfo("请设置需要统计的指数分段值参数文件!");
                return(null);
            }
            SortedDictionary <float, float> lstRegions = GetArgFileRegion(argFileName);

            if (lstRegions == null || lstRegions.Count == 0)
            {
                return(null);
            }
            if (_argumentProvider.GetArg("AlgorithmName") == null)
            {
                PrintInfo("参数\"AlgorithmName\"为空。");
                return(null);
            }
            string algorith = _argumentProvider.GetArg("AlgorithmName").ToString();

            if (algorith != "FSTAAlgorithm")
            {
                PrintInfo("指定的算法\"" + algorith + "\"没有实现。");
                return(null);
            }
            string zoom       = _argumentProvider.GetArg("resultZoom").ToString();
            float  resultZoom = 100;

            if (!string.IsNullOrEmpty(zoom))
            {
                resultZoom = float.Parse(zoom);
            }
            string outId = _argumentProvider.GetArg("OutFileIdentify") as string;

            Int16[] nanValues   = GetNanValues("CloudyValue");
            Int16[] waterValues = GetNanValues("WaterValue");
            bool    isWeight    = bool.Parse(_argumentProvider.GetArg("isWeight").ToString());

            if (outId != null)
            {
                SubProductInstanceDef instance = FindSubProductInstanceDefs(outId);
                if (instance == null)
                {
                    return(STATAlgorithm());
                }
                else
                {
                    float maxmin_max = float.MinValue;
                    float maxmin_min = float.MaxValue;

                    Dictionary <string, Func <short, bool> > filters = new Dictionary <string, Func <short, bool> >();
                    foreach (float key in lstRegions.Keys)
                    {
                        float  min       = key == float.MinValue ? float.MinValue : (key * resultZoom);
                        float  max       = lstRegions[key] == float.MaxValue ? float.MaxValue : (lstRegions[key] * resultZoom);
                        string filterKey = min == float.MinValue ? "<" + max / resultZoom :
                                           max == float.MaxValue ? ">=" + min / resultZoom :
                                           min / resultZoom + "~" + max / resultZoom;
                        filters.Add(filterKey, (v) =>
                        {
                            if (IsNanValue(v, nanValues) || IsNanValue(v, waterValues))
                            {
                                return(false);
                            }
                            return(v >= min && v < max);
                        });
                        if (maxmin_max < max)
                        {
                            maxmin_max = max;
                        }
                        if (maxmin_min > min)
                        {
                            maxmin_min = min;
                        }
                    }
                    string sumKey = maxmin_min / resultZoom + "~" + maxmin_max / resultZoom;
                    if (filters.ContainsKey(sumKey))
                    {
                        filters.Add("合计", filters[sumKey]);
                        filters.Remove(sumKey);
                    }

                    if (instance.AOIProvider == "省级行政区划")
                    {
                        return(StatProcentRaster <short>(fname[0], "行政区划", filters, progressTracker, isWeight, resultZoom));
                    }
                    if (instance.AOIProvider == "土地利用类型")
                    {
                        return(StatProcentRaster <short>(fname[0], "土地利用类型", filters, progressTracker, isWeight, resultZoom));
                    }
                    return(StatRaster <short>(instance, filters, progressTracker, isWeight, resultZoom));
                }
            }
            return(null);
        }
Beispiel #29
0
        public override IExtractResult Make(Action <int, string> progressTracker, IContextMessage contextMessage)
        {
            _contextMessage = contextMessage;
            if (_argumentProvider == null || _argumentProvider.DataProvider == null)
            {
                PrintInfo("参数配置不正确!");
                return(null);
            }
            IRasterDataProvider prd = _argumentProvider.DataProvider as IRasterDataProvider;
            string fname            = prd.fileName;

            if (fname.Contains("ISCCP_D2") && Path.GetExtension(fname).ToUpper() == ".LDF")
            {
                //PrintInfo("目前仅支持ISCCP_D2格式数据!");
                //return null;
                if (fname.Contains("MCA"))
                {
                    _argumentProvider.SetArg("OutFileIdentify", "TCAM");
                }
                else if (fname.Contains("MTAU"))
                {
                    _argumentProvider.SetArg("OutFileIdentify", "TAUM");
                }
                else if (fname.Contains("MPC"))
                {
                    _argumentProvider.SetArg("OutFileIdentify", "0PCM");
                }
                else if (fname.Contains("MTC"))
                {
                    _argumentProvider.SetArg("OutFileIdentify", "0TCM");
                }
                else if (fname.Contains("MWP"))
                {
                    _argumentProvider.SetArg("OutFileIdentify", "0WPM");
                }
                _argumentProvider.SetArg("SelectedPrimaryFiles", fname);
            }
            else if (fname.Contains("SVD") && fname.Contains("模态"))
            {
                _argumentProvider.SetArg("OutFileIdentify", "MSVD");
                _SVDLRModeNo = Path.GetFileNameWithoutExtension(fname).Split('_')[1];
                string tempf = CreateNewColorTable(prd, fname, progressTracker);
                _argumentProvider.SetArg("SelectedPrimaryFiles", tempf);
            }

            if (_argumentProvider.GetArg("AlgorithmName") == null)
            {
                PrintInfo("参数\"AlgorithmName\"为空。");
                return(null);
            }
            string outId = _argumentProvider.GetArg("OutFileIdentify") as string;

            if (outId != null)
            {
                SubProductInstanceDef instance = FindSubProductInstanceDefs(outId);
                if (instance != null)
                {
                    return(ThemeGraphyResult(null));
                }
                PrintInfo("指定的子产品\"" + outId + "\"的instance没有实现。");
                return(null);
            }
            PrintInfo("指定的子产品\"" + outId + "\"没有实现。");
            return(null);
        }
Beispiel #30
0
        private IExtractResult LTLREAlgorithm(Action <int, string> progressTracker)
        {
            float  tempratureMin = (float)_argumentProvider.GetArg("TempratureMin");
            double lftrZoom      = (double)_argumentProvider.GetArg("LTFRZoom");
            bool   isChaz        = (bool)_argumentProvider.GetArg("isChaz");
            Int16  maxLst        = (Int16)((isChaz ? tempratureMin : (273 + tempratureMin)) * lftrZoom);

            string[] fileNames = GetStringArray("SelectedPrimaryFiles");
            if (fileNames == null || fileNames.Count() == 0)
            {
                PrintInfo("请选择参与低温天数统计的数据!");
                return(null);
            }
            foreach (string f in fileNames)
            {
                if (!File.Exists(f))
                {
                    PrintInfo("所选择的数据:\"" + f + "\"不存在。");
                    return(null);
                }
            }
            int bandNo = 1;
            //输出文件准备(作为输入栅格并集处理)
            RasterIdentify ri          = GetRasterIdentifyID(fileNames);
            string         outFileName = ri.ToWksFullFileName(".dat");
            //输入文件准备
            List <RasterMaper> rms = new List <RasterMaper>();

            try
            {
                for (int i = 0; i < fileNames.Length; i++)
                {
                    IRasterDataProvider inRaster = RasterDataDriver.Open(fileNames[i]) as IRasterDataProvider;
                    if (inRaster.BandCount < bandNo)
                    {
                        PrintInfo("请选择正确的数据进行低温天数统计。");
                        return(null);
                    }
                    RasterMaper rm = new RasterMaper(inRaster, new int[] { bandNo });
                    rms.Add(rm);
                }
                using (IRasterDataProvider outRaster = CreateOutRaster(outFileName, rms.ToArray()))
                {
                    //栅格数据映射
                    RasterMaper[] fileIns  = rms.ToArray();
                    RasterMaper[] fileOuts = new RasterMaper[] { new RasterMaper(outRaster, new int[] { 1 }) };
                    //创建处理模型
                    RasterProcessModel <Int16, Int16> rfr = null;
                    rfr = new RasterProcessModel <Int16, Int16>(progressTracker);
                    rfr.SetRaster(fileIns, fileOuts);
                    Int16[] nanValues     = GetNanValues("CloudyValue");
                    Int16[] waterValues   = GetNanValues("WaterValue");
                    Int16[] invailValues  = GetNanValues("InvailValue");
                    Int16   currTimeValue = 0;
                    rfr.RegisterCalcModel(new RasterCalcHandler <Int16, Int16>((rvInVistor, rvOutVistor, aoi) =>
                    {
                        int dataLength    = rvOutVistor[0].SizeY * rvOutVistor[0].SizeX;
                        Int16[] timeValue = new Int16[dataLength];
                        for (int i = 0; i < dataLength; i++)
                        {
                            timeValue[i] = 0;
                        }
                        for (int index = 0; index < dataLength; index++)
                        {
                            foreach (RasterVirtualVistor <Int16> rvs in rvInVistor)
                            {
                                Int16[] dt = rvs.RasterBandsData[0];
                                if (dt == null)
                                {
                                    continue;
                                }
                                if (invailValues.Contains(dt[index]))
                                {
                                    continue;
                                }
                                if (TimeValue(dt[index], nanValues, waterValues, invailValues, timeValue[index], maxLst, out currTimeValue))
                                {
                                    timeValue[index] = currTimeValue;
                                }
                            }
                        }
                        for (int index = 0; index < dataLength; index++)
                        {
                            rvOutVistor[0].RasterBandsData[0][index] = timeValue[index];
                        }
                    }));
                    //执行
                    rfr.Excute(0);
                    FileExtractResult res = new FileExtractResult(_subProductDef.Identify, outFileName, true);
                    res.SetDispaly(false);
                }
            }
            finally
            {
                foreach (RasterMaper rm in rms)
                {
                    rm.Raster.Dispose();
                }
            }

            _argumentProvider.SetArg("SelectedPrimaryFiles", new string[] { outFileName });
            string instanceIdentify = _argumentProvider.GetArg("OutFileIdentify") as string;

            if (string.IsNullOrWhiteSpace(instanceIdentify))
            {
                return(null);
            }
            SubProductInstanceDef instance = FindSubProductInstanceDefs(instanceIdentify);

            return(ThemeGraphyByInstance(instance));
        }