Beispiel #1
0
        private void GetAOIArgument(Size maxSize, GeoDo.RSS.Core.DF.CoordEnvelope viewGeoEvp, float resolution, out string name, out int[] aoi)
        {
            Dictionary <string, int[]> aoiDic = null;

            name = null;
            aoi  = null;
            if (viewGeoEvp == null)
            {
                return;
            }
            using (frmStatSubRegionTemplates frm = new frmStatSubRegionTemplates(maxSize, viewGeoEvp, resolution))
            {
                frm.listView1.MultiSelect = false;
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    aoiDic = frm.GetFeatureAOIIndex();
                    if (aoiDic == null)
                    {
                        return;
                    }
                    foreach (string key in aoiDic.Keys)
                    {
                        name = key;
                        aoi  = aoiDic[key];
                        return;
                    }
                }
            }
        }
Beispiel #2
0
        private static IExtractResult StatAnalysisDrt(ISmartSession session, string outFileIdentify, string productTitle, bool isCustom)
        {
            (session.MonitoringSession as IMonitoringSession).ChangeActiveSubProduct("STAT");
            IMonitoringSubProduct msp = (session.MonitoringSession as IMonitoringSession).ActiveMonitoringSubProduct;

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

            if (obj == null || !File.Exists(obj.ToString()))
            {
                if (!SetSelectedPrimaryFiles(session, ref obj, msp.ArgumentProvider))
                {
                    return(null);
                }
            }
            string fname = (obj as string[])[0];
            Dictionary <string, int[]> aoi = null;

            if (isCustom)
            {
                using (IRasterDataProvider prd = GeoDataDriver.Open(fname) as IRasterDataProvider)
                {
                    using (frmStatSubRegionTemplates frm = new frmStatSubRegionTemplates(new Size(prd.Width, prd.Height), prd.CoordEnvelope, prd.ResolutionX))
                    {
                        frm.listView1.MultiSelect = true;
                        if (frm.ShowDialog() == DialogResult.OK)
                        {
                            aoi = frm.GetFeatureAOIIndex();
                        }
                    }
                    if (aoi != null && aoi.Count > 0)
                    {
                        msp.ArgumentProvider.SetArg("AOI", aoi);
                    }
                }
            }
            if (!string.IsNullOrEmpty(outFileIdentify))
            {
                msp.ArgumentProvider.SetArg("OutFileIdentify", outFileIdentify);
            }
            if (!string.IsNullOrEmpty(productTitle))
            {
                msp.ArgumentProvider.SetArg("ProductTitle", productTitle);
            }
            GetCommandAndExecute(session, 6602);
            return(null);
        }
        //private Dictionary<string, int[]> GetAoiDictionary(IRasterDataProvider prd, bool isCustom, string fname)
        //{
        //    if (!isCustom)
        //    {
        //        string statString = AreaStatProvider.GetAreaStatItemFileName("行政区划");
        //        string[] statInfos = statString.Split(':');
        //        return ApplyStatByVectorTemplate(prd, statInfos[1], statInfos[2]);
        //    }
        //    else
        //        return GetAOIArugment(fname, true);
        //}

        private Dictionary <string, int[]> GetAOIArugment(string fname, bool multiSelect)
        {
            using (IRasterDataProvider prd = GeoDataDriver.Open(fname) as IRasterDataProvider)
            {
                using (frmStatSubRegionTemplates frm = new frmStatSubRegionTemplates(new Size(prd.Width, prd.Height), prd.CoordEnvelope, prd.ResolutionX))
                {
                    frm.listView1.MultiSelect = multiSelect;
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        return(frm.GetFeatureAOIIndex());
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
        }
Beispiel #4
0
        //public static bool SetAOIArugment(string fname, IMonitoringSubProduct msp, bool multiSelect)
        //{
        //    using (IRasterDataProvider prd = GeoDataDriver.Open(fname) as IRasterDataProvider)
        //    {
        //        using (frmStatSubRegionTemplates frm = new frmStatSubRegionTemplates(new Size(prd.Width, prd.Height), prd.CoordEnvelope, prd.ResolutionX))
        //        {
        //            frm.listView1.MultiSelect = multiSelect;
        //            if (frm.ShowDialog() == DialogResult.OK)
        //                msp.ArgumentProvider.SetArg("AOI", frm.GetFeatureAOIIndex());
        //            else
        //                return false;
        //        }
        //    }
        //    return true;
        //}

        public static bool SetAOIArugment(string[] fnames, IMonitoringSubProduct msp, bool multiSelect)
        {
            float maxResultion           = 0f;
            IRasterDataProvider prd      = null;
            CoordEnvelope       envelope = new CoordEnvelope(double.MaxValue, double.MinValue, double.MaxValue, double.MinValue);

            foreach (string item in fnames)
            {
                try
                {
                    prd          = GeoDataDriver.Open(item) as IRasterDataProvider;
                    maxResultion = Math.Max(maxResultion, prd.ResolutionX);
                    envelope     = envelope.Union(new CoordEnvelope(prd.CoordEnvelope.MinX, prd.CoordEnvelope.MinX + prd.ResolutionX * prd.Width,
                                                                    prd.CoordEnvelope.MinY, prd.CoordEnvelope.MinY + prd.ResolutionY * prd.Height));
                }
                catch
                {
                    throw new ArgumentException("选择的文件:“" + Path.GetFileName(item) + "”无法进行面积统计。");
                }
                finally
                {
                    if (prd != null)
                    {
                        prd.Dispose();
                        prd = null;
                    }
                }
            }
            Size size = new Size((int)(envelope.Width / maxResultion), (int)(envelope.Height / maxResultion));

            using (frmStatSubRegionTemplates frm = new frmStatSubRegionTemplates(size, envelope, maxResultion))
            {
                frm.listView1.MultiSelect = multiSelect;
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    msp.ArgumentProvider.SetArg("AOI", frm.GetFeatureAOIIndex());
                }
                else
                {
                    return(false);
                }
            }
            return(true);
        }
Beispiel #5
0
        public static bool SetAOIArugment(string[] fnames, IMonitoringSubProduct msp, bool multiSelect, out CoordEnvelope selectedEnvelope)
        {
            float maxResultion           = 0f;
            IRasterDataProvider prd      = null;
            CoordEnvelope       envelope = new CoordEnvelope(double.MaxValue, double.MinValue, double.MaxValue, double.MinValue);

            GeoDo.Project.ISpatialReference prdSpatialRef = null;
            foreach (string item in fnames)
            {
                try
                {
                    prd          = GeoDataDriver.Open(item) as IRasterDataProvider;
                    maxResultion = Math.Max(maxResultion, prd.ResolutionX);
                    envelope     = envelope.Union(new CoordEnvelope(prd.CoordEnvelope.MinX, prd.CoordEnvelope.MinX + prd.ResolutionX * prd.Width,
                                                                    prd.CoordEnvelope.MinY, prd.CoordEnvelope.MinY + prd.ResolutionY * prd.Height));
                    prdSpatialRef = prd.SpatialRef;
                }
                catch
                {
                    throw new ArgumentException("选择的文件:“" + Path.GetFileName(item) + "”无法进行面积统计。");
                }
                finally
                {
                    if (prd != null)
                    {
                        prd.Dispose();
                        prd = null;
                    }
                }
            }
            Size size = new Size((int)(envelope.Width / maxResultion), (int)(envelope.Height / maxResultion));

            using (frmStatSubRegionTemplates frm = new frmStatSubRegionTemplates(size, envelope, maxResultion))
            {
                frm.listView1.MultiSelect = multiSelect;
                if (prdSpatialRef != null)
                {
                    frm.SpatialRef = prdSpatialRef;
                }
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    //Feature[] features = frm.GetSelectedFeatures();
                    //AOIProvider aoiProvider = new AOIProvider(null);
                    //aoiProvider.GetBitmapIndexes
                    msp.ArgumentProvider.SetArg("AOI", frm.GetFeatureAOIIndex());
                    msp.ArgumentProvider.SetArg("AOIFeatures", frm.GetSelectedFeatures());
                    CodeCell.AgileMap.Core.Envelope env = frm.GetSelectedEnvelope();
                    if (env != null)
                    {
                        selectedEnvelope = new CoordEnvelope(env.MinX, env.MaxX, env.MinY, env.MaxY);
                    }
                    else
                    {
                        selectedEnvelope = null;
                    }
                    return(true);
                }
                else
                {
                    selectedEnvelope = null;
                    return(false);
                }
            }
        }