• 关系类处理专题之创建关系类|RelationShipClass


    /// <summary>
            /// 存在于数据库中的数据集中
            /// </summary>
            /// <param name="mdbPath">数据库路径</param>
            /// <param name="ORIFClassName">源要素类的名称</param>
            /// <param name="DESFClassName">目标要素类的名称</param>
            /// <param name="DatasetName">所在数据集的名称</param>
            /// <param name="newRSClassName">生成的关系类的名称</param>
            /// <param name="PrimaryKey">源表主键</param>
            /// <param name="ForeignKey">源表外键</param>
            /// <param name="isComposite">是否复合关系</param>
            public void createRelationShipClass(string mdbPath, string ORIFClassName, string DESFClassName, string DatasetName, string newRSClassName, string PrimaryKey, string ForeignKey, bool isComposite)
            {
                IWorkspaceFactory pWorkspaceFactory = new AccessWorkspaceFactoryClass();
                IWorkspace pWorkspace = pWorkspaceFactory.OpenFromFile(mdbPath, 0);
                IFeatureWorkspace pFeatureWorkspace = pWorkspace as IFeatureWorkspace;
                IFeatureClass pFeatureClassORI = pFeatureWorkspace.OpenFeatureClass(ORIFClassName);
                IFeatureClass pFeatureClassDES = pFeatureWorkspace.OpenFeatureClass(DESFClassName);
                IFeatureDataset pFeatureDataset = pFeatureWorkspace.OpenFeatureDataset(DatasetName);
                IRelationshipClassContainer pRSCContainer = pFeatureDataset as IRelationshipClassContainer;
    
                IRelationshipClass pRelationshipClass = pRSCContainer.CreateRelationshipClass(
                    newRSClassName,   //生成的关系类的名称
                    pFeatureClassORI,   // 参与生成的源要素类/表
                    pFeatureClassDES,   //参与生成的目标要素类/表
                    "",
                    "",
                    esriRelCardinality.esriRelCardinalityOneToMany,  //表间关系
                    esriRelNotification.esriRelNotificationForward,  //通知???
                    isComposite,          //是否复合关系
                    false,        //是否添加属性表
                    null,        //字段集信息
                    PrimaryKey,     //源表主键
                    "",
                    ForeignKey,     //源表外键
                    "");
            }
            /*测试数据*****
                string mdbPath = "c:/Users/Administrator/Desktop/GXLTest.mdb";
                string ORIFClassName="zd";
                string DESFClassName="zrz";
                string DatasetName="GXL";
                string newRSClassName="relation1";
                string PrimaryKey="zddm";
                string ForeignKey = "zddm";
                bool isComposite = true;
                createRelationShipClass(mdbPath,ORIFClassName,DESFClassName,DatasetName,newRSClassName,PrimaryKey,ForeignKey,isComposite);
            */

    使用测试文件

    提取密码:3td1

    创建完成之后,在Arcmap中删除zd中的图块,则他所对应的zrz图块也随之删除

  • 相关阅读:
    tcp/udp并发(大吞吐量)性能测试工具
    postman prerequest动态加密数据构造
    匹配ip的正则表达式
    通过adb命令保存并重命名截图
    python3 urlencode及urldecode
    Android安全测试工具Drozer coverity fortify
    windows下adb shell命令杀进程方式
    postman批量构造数据
    Android app发热功耗思路
    Jenkins+ant+Jenkins接口持续集成测试配置
  • 原文地址:https://www.cnblogs.com/clgis/p/10100656.html
Copyright © 2020-2023  润新知