Example #1
0
        private Dictionary <string, int[]> GetAOIForRaster(IRasterDataProvider dataProvider)
        {
            Dictionary <string, string> templates = BAGStatisticHelper.GetAOITemplateList();

            if (templates == null || templates.Count == 0)
            {
                return(null);
            }
            Dictionary <string, int[]> aoiValues = new Dictionary <string, int[]>();

            foreach (string templateName in templates.Keys)
            {
                //分湖区
                Dictionary <string, int[]> aois = VectorTemplateToAOIConvertor.GetFeatureAOIIndex(templates[templateName],
                                                                                                  "NAME", dataProvider.CoordEnvelope, new Size(dataProvider.Width, dataProvider.Height));
                if (aois != null && aois.Count != 0)
                {
                    foreach (string key in aois.Keys)
                    {
                        aoiValues.Add(key, aois[key]);
                    }
                }
            }
            return(aoiValues);
        }
Example #2
0
        private IExtractResult STATAlgorithm(string[] files)
        {
            string outFileIdentify = _argumentProvider.GetArg("OutFileIdentify").ToString();

            if (outFileIdentify == "CCCA")
            {
                return(base.AreaStatResult <Int16>("蓝藻", "BAG", (v) => { return v == 1; }));
            }
            Dictionary <string, string> templates = BAGStatisticHelper.GetAOITemplateList();

            if (templates == null || templates.Count == 0)
            {
                return(AreaStatResult <Int16>("蓝藻", "BAG", (v) => { return v == 1; }));
            }
            else
            {
                Dictionary <string, int[]> aoiValues = new Dictionary <string, int[]>();
                Size          size;
                CoordEnvelope envelope;
                GetArgument(out size, out envelope, files);
                foreach (string templateName in templates.Keys)
                {
                    //分湖区
                    Dictionary <string, int[]> aois = VectorTemplateToAOIConvertor.GetFeatureAOIIndex(templates[templateName], "NAME", envelope, size);
                    //整个湖区
                    if (aois != null && aois.Count != 0)
                    {
                        foreach (string key in aois.Keys)
                        {
                            aoiValues.Add(key, aois[key]);
                        }
                    }
                }
                if (aoiValues.Count > 0)
                {
                    _argumentProvider.SetArg("AOI", aoiValues);
                    return(AreaStatResult((v) => { return v == 1; }, files));
                }
                else
                {
                    return(AreaStatResult <Int16>("蓝藻", "BAG", (v) => { return v == 1; }));
                }
            }
        }
        private Dictionary <string, int[]> GetAOIForRaster(IRasterDataProvider dataProvider)
        {
            Dictionary <string, string> templates = BAGStatisticHelper.GetAOITemplateList();

            if (templates == null || templates.Count == 0)
            {
                return(null);
            }
            Dictionary <string, int[]> aoiValues = new Dictionary <string, int[]>();

            foreach (string templateName in templates.Keys)
            {
                //分湖区
                Dictionary <string, int[]> aois = VectorTemplateToAOIConvertor.GetFeatureAOIIndex(templates[templateName],
                                                                                                  "NAME", dataProvider.CoordEnvelope, new Size(dataProvider.Width, dataProvider.Height));
                if (aois != null && aois.Count != 0)
                {
                    //List<int> indexForOneLake=new List<int>();
                    foreach (string key in aois.Keys)
                    {
                        aoiValues.Add(key, aois[key]);
                        //if (indexForOneLake.Count == 0)
                        //{
                        //    indexForOneLake.AddRange(aois[key]);
                        //}
                        //else
                        //{
                        //    for (int i = 0; i < aois[key].Length; i++)
                        //    {
                        //        if (indexForOneLake.Contains(aois[key][i]))
                        //            continue;
                        //        else
                        //            indexForOneLake.Add(aois[key][i]);
                        //    }
                        //}
                    }
                    //aoiValues.Add(templateName, indexForOneLake.ToArray());
                }
            }
            return(aoiValues);
        }
Example #4
0
        public override IExtractResult Make(Action <int, string> progressTracker)
        {
            if (_argumentProvider == null || _argumentProvider.GetArg("BPCDFile") == null)
            {
                return(null);
            }
            string bPCDFName = _argumentProvider.GetArg("BPCDFile").ToString();
            string algName   = _argumentProvider.GetArg("AlgorithmName").ToString();
            string extinfo   = GetStringArgument("extinfo");

            if (string.IsNullOrEmpty(bPCDFName) || !File.Exists(bPCDFName) || string.IsNullOrEmpty(algName))
            {
                return(null);
            }
            if (_argumentProvider.AOI == null)
            {
                return(null);
            }
            //若云判识文件未给出或者文件不存在,则不计算云覆盖度
            string cloudName = string.Empty;

            if (_argumentProvider.GetArg("CLMFile") != null)
            {
                cloudName = _argumentProvider.GetArg("CLMFile").ToString();
                if (!string.IsNullOrEmpty(cloudName) && File.Exists(cloudName))
                {
                    _isComputCloudCD = true;
                }
            }
            if (algName == "BACD")
            {
                IRasterDataProvider bPCDDataProvider  = null;
                IRasterDataProvider cloudDataProvider = null;
                try
                {
                    bPCDDataProvider = GeoDataDriver.Open(bPCDFName) as IRasterDataProvider;
                    if (bPCDDataProvider == null)
                    {
                        return(null);
                    }
                    if (_isComputCloudCD)
                    {
                        cloudDataProvider = GeoDataDriver.Open(cloudName) as IRasterDataProvider;
                    }
                    //_pixelArea = new BAGStatisticHelper().CalPixelArea(bPCDDataProvider.ResolutionX);
                    //总覆盖度
                    float totalCD = StatTotalConvertDegree(bPCDDataProvider, _argumentProvider.AOI);
                    //计算实际覆盖度
                    float actualCD = CalcActualConvertDegree(bPCDDataProvider, _argumentProvider.AOI);
                    //计算相对覆盖度
                    float absoluteCD = CalcAbsoluteConvertDegree(bPCDDataProvider, _argumentProvider.AOI);
                    //计算云覆盖度(参数:云判识结果文件)
                    float           cloudCD    = CalcCloudConvertDegree(cloudDataProvider, _argumentProvider.AOI);
                    List <string[]> valueItems = new List <string[]>();
                    List <string>   valueRow   = new List <string>();
                    valueRow.Add("整个湖区");
                    valueRow.Add(Math.Round((totalCD * 100), 2).ToString() + "%");
                    valueRow.Add(Math.Round((actualCD * 100), 2).ToString() + "%");
                    valueRow.Add(Math.Round((absoluteCD * 100), 2).ToString() + "%");
                    valueRow.Add(Math.Round((cloudCD * 100), 2).ToString() + "%");
                    valueItems.Add(valueRow.ToArray());
                    Dictionary <string, string> templates = BAGStatisticHelper.GetAOITemplateList();
                    if (templates != null && templates.Count > 0)
                    {
                        Dictionary <string, int[]> aoiValues = new Dictionary <string, int[]>();
                        foreach (string templateName in templates.Keys)
                        {
                            Dictionary <string, int[]> aois = VectorTemplateToAOIConvertor.GetFeatureAOIIndex(templates[templateName], "NAME",
                                                                                                              bPCDDataProvider.CoordEnvelope, new Size(bPCDDataProvider.Width, bPCDDataProvider.Height));
                            if (aois != null && aois.Count != 0)
                            {
                                foreach (string key in aois.Keys)
                                {
                                    aoiValues.Add(key, aois[key]);
                                }
                            }
                        }
                        if (aoiValues.Count > 0)
                        {
                            foreach (string name in aoiValues.Keys)
                            {
                                //总覆盖度
                                float total = StatTotalConvertDegree(bPCDDataProvider, aoiValues[name]);
                                //计算实际覆盖度
                                float actual = CalcActualConvertDegree(bPCDDataProvider, aoiValues[name]);
                                //计算相对覆盖度
                                float absolute = CalcAbsoluteConvertDegree(bPCDDataProvider, aoiValues[name]);
                                //计算云覆盖度(参数:云判识结果文件)
                                float         cloud = CalcCloudConvertDegree(cloudDataProvider, aoiValues[name]);
                                List <string> row   = new List <string>();
                                row.Add(name);
                                row.Add(Math.Round((total * 100), 2).ToString() + "%");
                                row.Add(Math.Round((actual * 100), 2).ToString() + "%");
                                row.Add(Math.Round((absolute * 100), 2).ToString() + "%");
                                row.Add(Math.Round((cloud * 100), 2).ToString() + "%");
                                valueItems.Add(row.ToArray());
                            }
                        }
                    }
                    if (valueItems != null && valueItems.Count > 0)
                    {
                        //float resolution = bPCDDataProvider.ResolutionX;
                        string      title    = "统计日期:" + DateTime.Now.ToShortDateString();
                        string[]    columns  = new string[] { "区域名称", "总覆盖度", "实际覆盖度", "相对覆盖度", "云覆盖度" };
                        IStatResult result   = new StatResult(title, columns, valueItems.ToArray());
                        string      filename = StatResultToFile(new string[] { bPCDFName }, result, "BAG", "BACD", "蓝藻覆盖度统计", extinfo, 1, false);
                        return(new FileExtractResult("BACD", filename));
                    }
                }
                finally
                {
                    if (bPCDDataProvider != null)
                    {
                        bPCDDataProvider.Dispose();
                    }
                    if (cloudDataProvider != null)
                    {
                        cloudDataProvider.Dispose();
                    }
                }
            }
            return(null);
        }