예제 #1
0
        //统计计算
        private void jctbStatics_Click(object sender, EventArgs e)
        {
            //1、数据完备性判断,必选图层为JCTB和DLTB,其他不是必选
            if (m_monitorLayers.Count <= 0)
            {
                MessageBox.Show("请导入监测图斑图层!");
                return;
            }
            if (m_dltbLayer == null)
            {
                MessageBox.Show("请导入基础库中的DLTB图层,否则无法进行统计计算!");
                return;
            }
            //2、数据准备,拷贝原始数据到BASEDATA
            m_monitorEnv  = Function.getLayersExtent(m_monitorLayers);
            m_lyerEnvelop = new ArrayList();
            m_lyerEnvelop.Add(m_monitorEnv);

            //IFeatureClass monitorSumFC = Function.MergeFeatureClasses(m_monitorLayers);//第一版的合并代码
            IFeatureClass monitorSumFC      = null;
            string        strJCTBMergePath  = Application.StartupPath + "\\tempResult";
            string        strJCTBMergetName = "jctb.shp";

            if (m_monitorLayers.Count == 1)
            {
                ILayer        t_lyr     = m_monitorLayers[0] as ILayer;
                IFeatureLayer t_featLyr = t_lyr as IFeatureLayer;
                IFeatureClass t_featcls = t_featLyr.FeatureClass;
                if (Function.saveFeatureClass(t_featcls, strJCTBMergePath))
                {
                    string strOldName = strJCTBMergePath + "\\" + "GPL0.shp";
                    string strNewName = strJCTBMergePath + "\\" + strJCTBMergetName;
                    Function.reNameShpFile(strOldName, strNewName);
                    monitorSumFC = Function.OpenShpFile(strJCTBMergePath, "jctb");
                }
            }
            else if (m_monitorLayers.Count > 1)
            {
                monitorSumFC = Function.MergeLayers(m_monitorLayers, strJCTBMergePath, "jctb");
                if (monitorSumFC == null)
                {
                    MessageBox.Show("监测图斑图层合并失败!");
                    return;
                }
            }

            if (monitorSumFC == null || !Function.AddSelectedFileds2Layer(ref monitorSumFC))
            {
                MessageBox.Show("为监测图斑图层添加字段失败!");
                return;
            }
            string shpPath = m_prjMan.m_projectPath + "\\" + m_prjMan.m_projectName + "\\" + ProjectManage.m_baseData;// +"\\" + "jctb.shp";
            //Function.saveFeatureClass(monitorSumFC, shpPath);
            string shpSrcPath = shpPath + "\\" + "GPL0.shp";
            string newName    = "";//shpPath + "\\" + "jctb_OLD.shp";

            //Function.reNameShpFile(shpSrcPath, newName);


            if (!CopyLayerToBaseDataFolder(m_dltbLayer, m_dltbEnv, shpPath))//dltb
            {
                MessageBox.Show("数据拷贝失败,无法进行统计计算!");
                return;
            }
            else
            {
                newName = shpPath + "\\" + "dltb.shp";
                Function.reNameShpFile(shpSrcPath, newName);
            }
            if (m_lxdwLayer != null)
            {
                if (!CopyLayerToBaseDataFolder(m_lxdwLayer, m_lxdwEnv, shpPath))//lxdw
                {
                    MessageBox.Show("数据拷贝失败,无法进行统计计算!");
                    return;
                }
                else
                {
                    newName = shpPath + "\\" + "lxdw.shp";
                    Function.reNameShpFile(shpSrcPath, newName);
                }
            }
            if (m_xzdwLayer != null)
            {
                if (!CopyLayerToBaseDataFolder(m_xzdwLayer, m_xzdwEnv, shpPath))//xzdw
                {
                    MessageBox.Show("数据拷贝失败,无法进行统计计算!");
                    return;
                }
                else
                {
                    newName = shpPath + "\\" + "xzdw.shp";
                    Function.reNameShpFile(shpSrcPath, newName);
                }
            }
            if (m_xzqLayer != null)
            {
                if (!CopyLayerToBaseDataFolder(m_xzqLayer, m_xzqEnv, shpPath))//xzq
                {
                    MessageBox.Show("数据拷贝失败,无法进行统计计算!");
                    return;
                }
                else
                {
                    newName = shpPath + "\\" + "xzq.shp";
                    Function.reNameShpFile(shpSrcPath, newName);
                }
            }
            if (m_jbntLayers != null && m_jbntLayers.Count > 0)
            {
                if (!CopyLayerToBaseDataFolder(m_jbntLayers, m_jbntEnv, shpPath + "\\" + "jbnt.shp"))//jbnt
                {
                    MessageBox.Show("数据拷贝失败,无法进行统计计算!");
                    return;
                }
                else
                {
                    newName = shpPath + "\\" + "jbnt.shp";
                    Function.reNameShpFile(shpSrcPath, newName);
                }
            }
            if (m_ydspLayers != null && m_ydspLayers.Count > 0)
            {
                if (!CopyLayerToBaseDataFolder(m_ydspLayers, m_ydspEnv, shpPath + "\\" + "spsj.shp"))//YDSP
                {
                    MessageBox.Show("数据拷贝失败,无法进行统计计算!");
                    return;
                }
                else
                {
                    newName = shpPath + "\\" + "spsj.shp";
                    Function.reNameShpFile(shpSrcPath, newName);
                }
            }
            if (m_redLineLayers != null && m_redLineLayers.Count > 0)
            {
                if (!CopyLayerToBaseDataFolder(m_redLineLayers, m_redLineEnv, shpPath + "\\" + "RedLine.shp"))//GHHX
                {
                    MessageBox.Show("数据拷贝失败,无法进行统计计算!");
                    return;
                }
                else
                {
                    newName = shpPath + "\\" + "RedLine.shp";
                    Function.reNameShpFile(shpSrcPath, newName);
                }
            }

            IFeatureLayer pDLTBFeatLyr = m_dltbLayer as IFeatureLayer;
            IFeatureLayer pLXDWFeatLyr = m_lxdwLayer as IFeatureLayer;
            IFeatureLayer pXZDWFeatLyr = m_xzdwLayer as IFeatureLayer;
            IFeatureClass pLXDWFeatCls = null;
            IFeatureClass pXZDWFeatCls = null;

            if (pLXDWFeatLyr != null)
            {
                pLXDWFeatCls = pLXDWFeatLyr.FeatureClass;
            }
            if (pXZDWFeatLyr != null)
            {
                pXZDWFeatCls = pXZDWFeatLyr.FeatureClass;
            }

            Function.SC_JCTBandXZQ(monitorSumFC, (m_xzqLayer as IFeatureLayer).FeatureClass);
            Function.SC_JCTBandJBNT(monitorSumFC, Function.MergeFeatureClasses(m_jbntLayers));
            Function.SC_JCTBandYDSP(monitorSumFC, Function.MergeFeatureClasses(m_ydspLayers));

            //Function.CalJCTBStatistic(monitorSumFC, pDLTBFeatLyr.FeatureClass, pLXDWFeatCls, pXZDWFeatCls);
            Function.SC_JCTBandTDLY(monitorSumFC, pDLTBFeatLyr.FeatureClass, pLXDWFeatCls, pXZDWFeatCls);
            Function.saveFeatureClass(monitorSumFC, shpPath);

            newName = shpPath + "\\" + "jctb.shp";
            Function.reNameShpFile(shpSrcPath, newName);

            MessageBox.Show("统计计算完成!");
            //1合并监测图层,以及其他可合并的图层

            //2:将字段加入监测图层
            //3统计计算各字段值
            //4将文件存储入basedata
            //5将各值更新
            //6显示计算结果
        }