Exemple #1
0
        private IExtractResult THANExtract(Action <int, string> progressTracker)
        {
            object        obj           = _argumentProvider.GetArg("ucAnlysisTool");
            UCAnlysisTool ucAnlysisTool = null;

            if (obj != null)
            {
                ucAnlysisTool = obj as UCAnlysisTool;
                ucAnlysisTool.btnGetInfos_Click(null, null);
            }
            return(null);
        }
Exemple #2
0
        public override IExtractResult MakeExtProduct(IPixelIndexMapper piexd, Action <int, string> progressTracker)
        {
            object        obj           = _argumentProvider.GetArg("ucAnlysisTool");
            UCAnlysisTool ucAnlysisTool = null;

            if (obj != null)
            {
                ucAnlysisTool = obj as UCAnlysisTool;
            }
            else
            {
                return(null);
            }
            IRasterDataProvider sourceraster = _argumentProvider.DataProvider as IRasterDataProvider;
            RasterIdentify      rid          = new RasterIdentify(_argumentProvider.DataProvider.fileName);

            rid.ProductIdentify    = _subProductDef.ProductDef.Identify;
            rid.SubProductIdentify = _subProductDef.Identify;
            string tempFile           = rid.ToWksFullFileName(".dat");
            string outFileName        = Path.Combine(Path.GetDirectoryName(tempFile), Path.GetFileNameWithoutExtension(tempFile) + GetExtInfo(ucAnlysisTool.cmbType.Text) + ".ldf");
            IExtractResultArray array = new ExtractResultArray("BAG");
            bool onlyTxt = bool.Parse(_argumentProvider.GetArg("OnlyTxt").ToString());

            if (!onlyTxt)
            {
                int totalLength = 0;
                //原始影像raster
                List <RasterMaper> listRaster = new List <RasterMaper>();
                RasterMaper        rmsoure    = new RasterMaper(sourceraster, GetBandArray(sourceraster.BandCount));
                int totalbandcount            = sourceraster.BandCount;
                listRaster.Add(rmsoure);
                try
                {
                    using (IRasterDataProvider outRaster = CreateOutM_BandRaster(outFileName, listRaster.ToArray(), totalbandcount))
                    {
                        //波段总数
                        RasterMaper[] fileIns  = listRaster.ToArray();
                        RasterMaper[] fileOuts = new RasterMaper[] { new RasterMaper(outRaster, GetBandArray(totalbandcount)) };
                        //创建处理模型
                        RasterProcessModel <UInt16, UInt16> rfr = null;
                        rfr = new RasterProcessModel <UInt16, UInt16>(progressTracker);
                        rfr.SetRaster(fileIns, fileOuts);
                        rfr.SetFeatureAOI(_argumentProvider.AOIs);
                        rfr.RegisterCalcModel(new RasterCalcHandler <UInt16, UInt16>((rvInVistor, rvOutVistor, aoi) =>
                        {
                            int dataLength = rvOutVistor[0].SizeY * rvOutVistor[0].SizeX;
                            if (rvInVistor[0].RasterBandsData == null || rvInVistor[0].RasterBandsData[0] == null)
                            {
                                totalLength += dataLength;
                                return;
                            }
                            for (int index = 0; index < dataLength; index++)
                            {
                                if (_argumentProvider.AOI.Contains(totalLength + index))
                                {
                                    for (int i = 0; i < totalbandcount; i++)
                                    {
                                        rvOutVistor[0].RasterBandsData[i][index] = rvInVistor[0].RasterBandsData[i][index];
                                    }
                                }
                            }
                            totalLength += dataLength;
                        }
                                                                                     ));
                        //执行
                        rfr.Excute(0);
                    }
                    string dstfilename = outFileName.Replace(".ldf", ".dat");
                    if (File.Exists(dstfilename))
                    {
                        File.Delete(dstfilename);
                    }
                    File.Move(outFileName, dstfilename);
                    FileExtractResult res = new FileExtractResult("BAG", dstfilename, true);
                    res.SetDispaly(false);
                    array.Add(res);
                }
                finally
                {
                }
            }
            if (!string.IsNullOrEmpty(ucAnlysisTool.txtInfos.Text))
            {
                string txtFile = outFileName.Replace(".ldf", ".txt");
                File.WriteAllLines(txtFile, ucAnlysisTool.WriteText, Encoding.Unicode);
                FileExtractResult resTxt = new FileExtractResult("BAG", txtFile, true);
                resTxt.SetDispaly(false);
                array.Add(resTxt);
            }
            return(array);
        }