コード例 #1
0
ファイル: VCTFile.cs プロジェクト: hy1314200/HyDM
        /// <summary>
        /// ��ȡVCT���Ա�ṹ�ڵ�
        /// </summary>
        private TableStructureNode ReadTableStructureNode()
        {
            if (this.m_streamReader != null)
            {
                string strLine = "";    //��ȡ�������ֻ���

                if (m_bFoundTableStructureBegin == false)
                {
                    strLine = this.ReadLine(true);
                    //���ұ�ṹ�ڵ�Ŀ�ʼ��ǡ�TableStructureBegin��
                    if (strLine.IndexOf("TableStructureBegin", System.StringComparison.OrdinalIgnoreCase) > -1)
                    {
                        m_bFoundTableStructureBegin = true;
                    }
                }
                if (m_bFoundTableStructureBegin == true)
                {
                    strLine = this.ReadLine(true);

                    //���ұ�ṹ�ڵ�Ľ�����ǡ�TableStructureEnd��
                    if (strLine.IndexOf("TableStructureEnd", System.StringComparison.OrdinalIgnoreCase) > -1)
                        return null;
                    else
                    {
                        //�Ȼ�ȡ�������ֶθ���
                        string[] arrTemp = strLine.Split(HeadNode.Separator);
                        if (arrTemp.LongLength >= 2)
                        {
                            TableStructureNode tableStructureNode = new TableStructureNode();
                            tableStructureNode.TableName = arrTemp[0];

                            ///�ж�VCT���Ա�ṹ�Ƿ��ȡ��ȷ
                            int nFieldCound = -1;
                            if (!VCTFile.ConvertToInt32(arrTemp[1],out nFieldCound))
                            {
                                LogAPI.WriteLog("��ȡVCT���Ա��"+tableStructureNode.TableName+"�����ֶθ��������쳣����ȷ�ϸ������Ƿ���ϱ�׼��");
                                return null;
                            }
                            if (arrTemp.Length > 2)
                            {
                                if (arrTemp[2].ToLower() == "nonegeometry")//NoneGeometry
                                    tableStructureNode.IsGeometryTable = false;
                            }

                            //�ٻ�ȡ�ֶζ���
                            List<FieldNode> arrFieldNode = new List<FieldNode>();
                            for (int i = 0; i < nFieldCound; i++)
                            {
                                strLine = this.ReadLine(true);    //��ȡ�������ֻ���
                                FieldNode fieldNode = new FieldNode(strLine);
                                arrFieldNode.Add(fieldNode);
                            }
                            tableStructureNode.FieldNodes = arrFieldNode;

                            return tableStructureNode;
                        }
                    }
                }

             }
            return null;
        }
コード例 #2
0
ファイル: LineLayer.cs プロジェクト: hy1314200/HyDM
        /// <summary>
        /// ����
        /// </summary>
        public override bool Create(TableStructureNode tableStructureNode)
        {
            base.Create(tableStructureNode);

            return true;
        }
コード例 #3
0
ファイル: TableLayer.cs プロジェクト: hy1314200/HyDM
        /// <summary>
        /// 创建
        /// </summary>
        public virtual bool Create(TableStructureNode tableStructureNode)
        {
            m_TableStructureNode = tableStructureNode;

            return true;
        }
コード例 #4
0
ファイル: TableLayer.cs プロジェクト: hy1314200/HyDM
        /// <summary>
        /// 获取VCT表结构节点
        /// </summary>
        private TableStructureNode GetTableStructureNode()
        {
            try
            {

                m_TableStructureNode = new TableStructureNode();
                ///判断当前是否为空间数据表
                if (m_pITable is IFeatureClass)
                {
                    m_TableStructureNode.IsGeometryTable = true;
                    IFeatureClass pFeatureCls = this.m_pITable as IFeatureClass;
                    ///获取表名称
                    m_TableStructureNode.TableName = (m_pITable as IDataset).Name;
                }
                else
                {
                    m_TableStructureNode.IsGeometryTable = false;
                    //m_TableStructureNode.TableName = (m_pITable as IObjectClass).AliasName;
                    m_TableStructureNode.TableName = (m_pITable as IDataset).Name;

                }
                //获取字段信息
                m_TableStructureNode.FieldNodes = GetFieldNodes(m_pITable.Fields);

                ///通过配置获取标识码字段名称
                string sKeyFieldName = "";
                sKeyFieldName = Metadata.MetaDataFile.GetEntityIDFieldName(m_TableStructureNode.TableName);
                if (sKeyFieldName != "")
                    m_strEntityFieldName = sKeyFieldName;

                ///通过配置获取要素代码字段名称
                sKeyFieldName = Metadata.MetaDataFile.GetYSDMFieldName(m_TableStructureNode.TableName);
                if (sKeyFieldName != "")
                    m_strEntityFieldName = sKeyFieldName;
                return m_TableStructureNode;
            }
            catch (Exception ex)
            {
                LogAPI.WriteErrorLog(ex);
                return null;
            }
        }
コード例 #5
0
ファイル: FeatureEntity.cs プロジェクト: hy1314200/HyDM
        /// <summary>
        /// ��ȡVCT���Լ�¼�ڵ�
        /// </summary>
        public RecordNode GetRecordNode(TableStructureNode pTableStructNode)
        {
            try
            {
                RecordNode pRecordNode = new RecordNode();
                /////��ʶ�븳ֵ
                //int dBSMIndex = -1;
                //dBSMIndex = this.Feature.Fields.FindField("BSM");
                //if (dBSMIndex != -1)
                //    pRecordNode.EntityID = Convert.ToInt32(this.Feature.get_Value(dBSMIndex));
                List<string> sListValues = new List<string>();

                for (int i = 0; i < pTableStructNode.FieldNodes.Count; i++)
                {
                    //IField pField = this.Feature.Fields.get_Field(i);
                    //string sValue = this.Feature.get_Value(i).ToString();
                    /////ֻ������������
                    //if (pField.Type != esriFieldType.esriFieldTypeOID
                    //    && pField.Type != esriFieldType.esriFieldTypeGeometry
                    //    && pField.Name.ToUpper() != "SHAPE_LENGTH"
                    //    && pField.Name.ToUpper() != "SHAPE_AREA")
                    //{]

                    FieldNode pFieldNode = pTableStructNode.FieldNodes[i];
                    if (pFieldNode.FieldName == m_strEntityIDFiled)
                    {
                        sListValues.Insert(0, this.Feature.get_Value(pFieldNode.FieldIndex).ToString());
                        pRecordNode.EntityID =Convert.ToInt32( this.Feature.get_Value(pFieldNode.FieldIndex));
                    }
                    else
                    sListValues.Add(this.Feature.get_Value(pFieldNode.FieldIndex).ToString());
                    //}
                }
                pRecordNode.FieldValues = sListValues;
                return pRecordNode;
            }
            catch (Exception ex)
            {
                Logger.WriteErrorLog(ex);
                return null;
            }
        }
コード例 #6
0
ファイル: MDB2VCT.cs プロジェクト: zj8487/HyDM
/*
        /// <summary>
        /// 处理面实体中引用线对象的标识码
        /// </summary>
        /// <param name="arrLineNode">VCT线实体节点集合</param>
        /// <param name="arrFeatureCode">关联图层要素编码集合</param>
        /// <param name="arrLineNodeEx">VCT面实体中的线实体节点集合</param>
        private void MatchPolygonToLine(ref List<FileData.LineNode> arrLineNode, List<string> arrFeatureCode, ref List<FileData.LineNodeEx> arrLineNodeEx)
        {

            
            if (arrFeatureCode != null && arrFeatureCode.Count > 0)
            {
                List<FileData.LineNode> arrLinkLineNode = new List<FileData.LineNode>();
                for (int i = 0; i < arrLineNode.Count; i++)
                {
                    if (arrFeatureCode.Contains(arrLineNode[i].FeatureCode))
                    {
                        arrLinkLineNode.Add(arrLineNode[i]);
                    }
                }
                if (arrLinkLineNode.Count > 0)
                {
                    //排序
                    arrLinkLineNode.Sort();
                    arrLineNodeEx.Sort();

                    //更新构面线的标识码
                    int j = 0;
                    for (int i = 0; i < arrLinkLineNode.Count; i++)
                    {
                        for (; j < arrLineNodeEx.Count; j++)
                        {
                            //必须是未找到标识码的
                            if (arrLineNodeEx[j].EntityID == -1)
                            {
                                if (arrLinkLineNode[i] == arrLineNodeEx[j])
                                {
                                    arrLineNodeEx[j].IsFromLine = true;
                                    arrLineNodeEx[j].EntityID = arrLinkLineNode[i].EntityID;
                                }
                                else if (arrLinkLineNode[i] > arrLineNodeEx[j])
                                {

                                }
                                else
                                {
                                    break;
                                }
                            }
                        }
                    }
                    //反向
                    List<FileData.LineNodeEx> arrLineNodeExReverse = new List<FileData.LineNodeEx>();
                    for (int i = 0; i < arrLineNodeEx.Count; i++)
                    {
                        //必须是未找到标识码的
                        if (arrLineNodeEx[i].EntityID == -1)
                        {
                            FileData.LineNodeEx lineNodeEx = arrLineNodeEx[i];
                            lineNodeEx.Reverse();
                            arrLineNodeExReverse.Add(lineNodeEx);
                        }
                    }
                    arrLineNodeExReverse.Sort();//反向后排序
                    j = 0;
                    for (int i = 0; i < arrLinkLineNode.Count; i++)
                    {
                        for (; j < arrLineNodeExReverse.Count; j++)
                        {
                            if (arrLinkLineNode[i] == arrLineNodeExReverse[j])
                            {
                                arrLineNodeExReverse[j].IsFromLine = true;
                                arrLineNodeExReverse[j].EntityID = arrLinkLineNode[i].EntityID;
                            }
                            else if (arrLinkLineNode[i] > arrLineNodeExReverse[j])
                            {
                            }
                            else
                            {
                                break;
                            }
                        }
                    }

                    arrLineNodeEx.Clear();
                    for (int i = 0; i < arrLineNodeExReverse.Count; i++)
                    {
                        //必须是未找到标识码的
                        if (arrLineNodeExReverse[i].EntityID == -1)
                        {
                            arrLineNodeEx.Add(arrLineNodeExReverse[i]);
                        }
                    }
                }
            }
            return arrLineNodeEx;
        }
*/
        //public FileData.LineNodeEx CloneLineNodeEx(FileData.LineNodeEx lineNodeExSource)
        //{
        //    //m_InitiallyLineNode = this;
            

        //    try
        //    {
        //        MemoryStream stream = new MemoryStream();
        //        BinaryFormatter formatter = new BinaryFormatter();
        //        formatter.Serialize(stream, lineNodeExSource);
        //        stream.Position = 0;

        //        FileData.LineNodeEx lineNodeEx = formatter.Deserialize(stream) as FileData.LineNodeEx;

        //        lineNodeEx.InitiallyLineNode = lineNodeExSource;
        //        return lineNodeEx;
        //    }
        //    catch (Exception ex)
        //    {
        //        LogAPI.WriteErrorLog(ex);
        //    }
        //     /* 
        //    try
        //    {
        //        FileData.LineNodeEx lineNodeEx = new FileData.LineNodeEx();
        //        lineNodeEx.IsReverse = lineNodeExSource.IsReverse;
        //        lineNodeEx.PolygonID = lineNodeExSource.PolygonID;
        //        lineNodeEx.LineIndex = lineNodeExSource.LineIndex;
        //        lineNodeEx.IsFromLine = lineNodeExSource.IsFromLine;

        //        lineNodeEx.LineType = lineNodeExSource.LineType;
        //        lineNodeEx.SegmentNodes = new FileData.SegmentNodes();
        //        for (int i = 0; i < lineNodeExSource.SegmentNodes.Count; i++)
        //        {
        //            lineNodeEx.SegmentNodes.Add(lineNodeExSource.SegmentNodes[i]);
        //            //BrokenLineNode brokenLineNode1 = this.SegmentNodes[i] as BrokenLineNode;
        //            //if (brokenLineNode1 != null)
        //            //{
        //            //    BrokenLineNode brokenLineNode2 = new BrokenLineNode();
        //            //    brokenLineNode2.PointInfoNodes = new PointInfoNodes();
        //            //    for (int j = 0; j < brokenLineNode1.PointInfoNodes.Count; j++)
        //            //    {
        //            //        PointInfoNode pointInfoNode = new PointInfoNode();
        //            //        pointInfoNode.X = brokenLineNode1.PointInfoNodes[j].X;
        //            //        pointInfoNode.Y = brokenLineNode1.PointInfoNodes[j].Y;
        //            //        brokenLineNode2.PointInfoNodes.Add(pointInfoNode);
        //            //    }
        //            //    lineNodeEx.SegmentNodes.Add(brokenLineNode2);
        //            //}
        //        }

        //        lineNodeEx.EntityID = lineNodeExSource.EntityID;
        //        lineNodeEx.FeatureCode = lineNodeExSource.FeatureCode;
        //        lineNodeEx.Representation = lineNodeExSource.Representation;

        //        lineNodeEx.InitiallyLineNode = lineNodeExSource;
        //        return lineNodeEx;
        //    }
        //    catch (Exception ex)
        //    {
        //        LogAPI.WriteErrorLog(ex);
        //    }*/
        //    return null;
        //}

/*

        /// <summary>
        /// 处理面实体中引用线对象的标识码
        /// </summary>
        /// <param name="arrLineNodeExNew">VCT面实体中的线实体节点集合(需要新建)</param>
        private void MatchPolygonToLine(ref List<FileData.LineNodeEx> arrLineNodeExNew)
        {
            List<FileData.LineNodeEx> arrLineNodeNewClone = new List<VCT.FileData.LineNodeEx>();
            for (int i = 0; i < arrLineNodeExNew.Count; i++)
            {
                //克隆对象,并反向
                FileData.LineNodeEx lineNodeEx = CloneLineNodeEx(arrLineNodeExNew[i]);//.Clone() as FileData.LineNodeEx;
                if (lineNodeEx != null)
                {
                    lineNodeEx.Reverse();
                    arrLineNodeNewClone.Add(lineNodeEx);
                }
            }

            arrLineNodeExNew.Sort();
            arrLineNodeNewClone.Sort();

            int j = 0;
            for (int i = 0; i < arrLineNodeExNew.Count; i++)
            {
                if (arrLineNodeExNew[i].EntityID == -1)
                {
                    //需要创建要素编码
                    arrLineNodeExNew[i].EntityID = this.m_nNewEntityID;
                    ////未做合并处理
                    //m_VCTFile.WritePolygonLineNode(arrLineNodeExNew[i]);
                }
                for (; j < arrLineNodeNewClone.Count; j++)
                {
                    if (arrLineNodeNewClone[j].InitiallyLineNode.EntityID == -1)
                    {
                        if (arrLineNodeExNew[i] == arrLineNodeNewClone[j])
                        {
                            arrLineNodeNewClone[j].InitiallyLineNode.EntityID = arrLineNodeExNew[i].EntityID;
                            arrLineNodeNewClone[j].InitiallyLineNode.Reverse();
                            //arrLineNodeNewClone[j].InitiallyLineNode.IsReverse = arrLineNodeNewClone[j].IsReverse;

                            arrLineNodeNewClone[j].InitiallyLineNode.OtherPolygonLineNode = arrLineNodeExNew[i];
                            arrLineNodeExNew[i].OtherPolygonLineNode = arrLineNodeNewClone[j].InitiallyLineNode;
                        }
                        if (arrLineNodeExNew[i] > arrLineNodeNewClone[j])
                        {
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }



            //for (int i = 0; i < arrLineNodeExNew.Count; i++)
            //{
            //    if ((arrLineNodeExNew[i].InitiallyLineNode == null && arrLineNodeExNew[i].EntityID == -1) ||                      //非克隆对象
            //        (arrLineNodeExNew[i].InitiallyLineNode != null && arrLineNodeExNew[i].InitiallyLineNode.EntityID == -1))      //克隆对象
            //    {
            //        if (i > 0)
            //        {
            //            if (arrLineNodeExNew[i] == arrLineNodeExNew[i - 1])
            //            {
            //                arrLineNodeExNew[i].EntityID = arrLineNodeExNew[i - 1].EntityID;
            //                if (arrLineNodeExNew[i].InitiallyLineNode != null)
            //                {
            //                    //arrLineNodeExNew[i]是克隆对象,需要更新原始对象的标识码和方向标识
            //                    arrLineNodeExNew[i].InitiallyLineNode.EntityID = arrLineNodeExNew[i].EntityID;
            //                    arrLineNodeExNew[i].InitiallyLineNode.IsReverse = arrLineNodeExNew[i].IsReverse;
            //                }



                            
            //                continue;
            //            }
            //        }
            //        //需要创建要素编码
            //        arrLineNodeExNew[i].EntityID = this.NewEntityID;
            //        if (arrLineNodeExNew[i].InitiallyLineNode != null)
            //        {
            //            //arrLineNodeExNew[i]是克隆对象,需要更新原始对象的标识码和方向标识
            //            arrLineNodeExNew[i].InitiallyLineNode.EntityID = arrLineNodeExNew[i].EntityID;
            //            arrLineNodeExNew[i].InitiallyLineNode.IsReverse = arrLineNodeExNew[i].IsReverse;
            //        }
            //        m_VCTFile.WritePolygonLineNode(arrLineNodeExNew[i]);
            //    }
            //}
        }
        */
        ///// <summary>
        ///// 处理面实体中引用线对象的标识码
        ///// </summary>
        ///// <param name="arrLineNode">VCT线实体节点集合</param>
        //private void WritePolygonLineNodes(ref List<FileData.LineNodeEx> arrLineNode)
        //{
        //    ////按标识码、在面的边界线集合中的索引排序
        //    FileData.LineNodeExComparer lineNodeExComparer = new FileData.LineNodeExComparer();
        //    arrLineNode.Sort(lineNodeExComparer);

        //    FileData.LineNodeEx lineNode = null;
        //    for (int i = 0; i < arrLineNode.Count; i++)
        //    {
        //        if (lineNode == null)
        //        {
        //            lineNode = arrLineNode[i];
        //        }
        //        else
        //        {
        //            if (arrLineNode[i].EntityID == lineNode.EntityID)
        //            {
        //                lineNode.SegmentNodes.AddRange(arrLineNode[i].SegmentNodes);
        //            }
        //            else
        //            {
        //                m_VCTFile.WritePolygonLineNode(lineNode);
        //                lineNode = arrLineNode[i];
        //            }

        //            if (i == arrLineNode.Count - 1)
        //            {
        //                m_VCTFile.WritePolygonLineNode(lineNode);
        //            }
        //        }
        //    }
        //}

 



        /// <summary>
        /// 执行转换
        /// </summary>
        public EnumMDB2VCTExchangeInfo Exchange()
        {
            ///指示当前转换的执行位置
            int nExcutePosition = 0;
            ///1.表结构 2.点 3.线 4.面
            try
            {
                //获取PGDB数据集
                m_dataset =  m_MDBFile.GetDataset();
                if (m_dataset != null)
                {
                    //获取当前数据的最大实体标识码
                    this.m_nNewEntityID = m_dataset.GetMaxEntityID() + 1;
                    //获取VCT头节点
                    ESRIData.Projection projection = m_dataset.GetProjection();
                    if (projection != null)
                    {
                        FileData.HeadNode headNode = projection.GetHeadNode();
                        ///生成头文件错误
                        if (headNode == null)
                        {
                            return EnumMDB2VCTExchangeInfo.HEADFILEERROR;
                        }
                        //1、写入VCT头节点
                        m_VCTFile.WriteHeadNode(headNode);

                        //获取图层集合
                        ESRIData.TableLayer tableLayer;
                        m_nLayerCount = m_dataset.GetLayerCount();
                        List<FileData.FeatureCodeNode> arrFeatureCodeNode = new List<FileData.FeatureCodeNode>();
                        List<FileData.TableStructureNode> arrTableStructureNode = new List<FileData.TableStructureNode>();

                        nExcutePosition++;
                        for (int i = 0; i < m_nLayerCount; i++)
                        {
                            //获取图层对象
                            tableLayer = m_dataset.GetFeatureLayerByIndex(i);
                            //获取图层要素参数信息
                            FileData.FeatureCodeNode featureCodeNode = tableLayer.GetFeatureCodeNode();
                            arrFeatureCodeNode.Add(featureCodeNode);
                            //获取图层表结构信息
                            FileData.TableStructureNode tableStructureNode = tableLayer.StructureNode;
                            arrTableStructureNode.Add(tableStructureNode);
                        }
                        //2、写入VCT要素参数节点
                        m_VCTFile.WriteFeatureCodeNodes(arrFeatureCodeNode);
                        //3、写入VCT表结构节点
                        m_VCTFile.WriteTableStructureNode(arrTableStructureNode);

                        ///释放不在使用的对象,减少内存使用率 add by 曾平
                        //m_VCTFile.Flush();
                        arrFeatureCodeNode.Clear();
                        arrTableStructureNode.Clear();

                        nExcutePosition++;

                        //4、写入点实体节点
                        for (int i = 0; i < m_nLayerCount; i++)
                        {
                            //获取图层对象
                            tableLayer = m_dataset.GetFeatureLayerByIndex(i);
                            ESRIData.PointLayer pointLayer = tableLayer as ESRIData.PointLayer;
                            if (pointLayer != null)
                            {
                                if (pointLayer.FeatureEntys != null)
                                {
                                    for (int j = 0; j < pointLayer.FeatureEntys.Count; j++)
                                    {
                                        m_VCTFile.WritePointNode(pointLayer.FeatureEntys[j].GetEntityNode() as FileData.PointNode);
                                    }
                                }
                            }
                        }

                        nExcutePosition++;
                        ////5、写入线实体节点
                        //List<FileData.LineNode> arrLineNode = new List<FileData.LineNode>();
                        for (int i = 0; i < m_nLayerCount; i++)
                        {
                            //获取图层对象
                            tableLayer = m_dataset.GetFeatureLayerByIndex(i);
                            ESRIData.LineLayer lineLayer = tableLayer as ESRIData.LineLayer;
                            if (lineLayer != null)
                            {
                                if (lineLayer.FeatureEntys != null)
                                {
                                    for (int j = 0; j < lineLayer.FeatureEntys.Count; j++)
                                    {
                                        FileData.LineNode lineNode = lineLayer.FeatureEntys[j].GetEntityNode() as FileData.LineNode;
                                        if (lineNode != null)
                                        {
                                            m_VCTFile.WriteLineNode(lineNode);
                                        }
                                    }
                                }
                            }
                        }

                        ////处理面实体中引用线对象的标识码
                        ////List<FileData.PolygonNode> arrPolygonNode = MatchPolygonToLine(dataset, ref arrLineNode);
                        ////6、写入面实体节点
                        nExcutePosition++;
                        WritePolygonNodes pWritePolygonNodes = new WritePolygonNodes(m_dataset, this.m_pTempFile, this.m_VCTFile, this.m_nNewEntityID);
                        //pWritePolygonNodes.WriteCommplete += new WriteCommpleteEventHandler(WritePolygonNodes_WriteCommplete);
                        pWritePolygonNodes.Write();

                        WritePolygonNodes_WriteCommplete(true);
                        return EnumMDB2VCTExchangeInfo.EXCHANGESUCCESS;

                    }
                    else
                    {
                        return EnumMDB2VCTExchangeInfo.PROJCTIONERROR;
                    }
                }
                else
                {
                    return EnumMDB2VCTExchangeInfo.DATASETERROR;
                }

            }
            catch(Exception ex)
            {
                LogAPI.WriteErrorLog(ex);
                EnumMDB2VCTExchangeInfo pInfo = EnumMDB2VCTExchangeInfo.EXCHANGUNKNOWEERROR;
                if (nExcutePosition == 1)
                    pInfo = EnumMDB2VCTExchangeInfo.FEATUREINFOERROR;
                else if (nExcutePosition == 2)
                    pInfo = EnumMDB2VCTExchangeInfo.POINTERROR;
                else if (nExcutePosition == 3)
                    pInfo = EnumMDB2VCTExchangeInfo.LINEERROR;
                else if (nExcutePosition == 4)
                    pInfo = EnumMDB2VCTExchangeInfo.PLOYGONERROR;

                return pInfo;
            }
        }
コード例 #7
0
ファイル: FeatureEntity.cs プロジェクト: hy1314200/HyDM
 /// <summary>
 /// ��������
 /// </summary>
 /// <param name="recordNode">������Ϣ</param>
 public void AttachAttribute(RecordNode recordNode, TableStructureNode pTableStructNode)
 {
     try
     {
         if (m_pIFeature != null)
         {
             if (m_pIFeature is IAnnotationFeature)
             {
                 ///���ע������
             }
             else
             {
                 for (int i = 0; i < pTableStructNode.FieldNodes.Count; i++)
                 {
                     FieldNode pFieldNode = pTableStructNode.FieldNodes[i];
                     string sValue = recordNode.FieldValues[i];
                     m_pIFeature.set_Value(pFieldNode.FieldIndex, sValue);
                 }
                 m_pIFeature.Store();
             }
         }
     }
     catch (Exception ex)
     {
         Logger.WriteErrorLog(ex);
     }
 }
コード例 #8
0
ファイル: FeatureLayerFactory.cs プロジェクト: hy1314200/HyDM
        /// <summary>
        /// �������Ա�
        /// </summary>
        /// <param name="pFeatureWorkspace"></param>
        /// <param name="tableStructureNode"></param>
        /// <param name="featureCodeNode"></param>
        /// <returns></returns>
        private TableLayer CreateTableLayer(IFeatureWorkspace pFeatureWorkspace, TableStructureNode tableStructureNode, FeatureCodeNode featureCodeNode)
        {
            try
            {
                if (pFeatureWorkspace != null&&tableStructureNode!=null&&featureCodeNode!=null)
                {
                    IObjectClassDescription ocDescription = new ObjectClassDescriptionClass();
                    ///�������ݱ��ֶ�
                    IFieldChecker fieldChecker = new FieldCheckerClass();
                    IFields validatedFields = CreateFileds(tableStructureNode, featureCodeNode);
                    ///�ֶ���Ϣ��֤
                    IFields fixFields = null;
                    fieldChecker.ValidateWorkspace = pFeatureWorkspace as IWorkspace;
                    IEnumFieldError enumFieldError = null;
                    fieldChecker.Validate(validatedFields, out enumFieldError, out fixFields);

                    ITable pTable = pFeatureWorkspace.CreateTable(tableStructureNode.TableName, fixFields,
                        ocDescription.InstanceCLSID, null, "");
                    if (pTable != null)
                    {
                        TableLayer pTableLayer = new TableLayer();

                        //�������ļ���ȡͼ������
                        string sGeometryType = "";
                        Metadata.MetaTable pMetaTalbe = Metadata.MetaDataFile.MetaTabls[tableStructureNode.TableName] as Metadata.MetaTable;
                        if (pMetaTalbe != null)
                        {
                            sGeometryType = pMetaTalbe.Type;
                        }
                        else
                            return null;

                        pTableLayer.GeometryType = sGeometryType;
                        pTableLayer.Table = pTable;
                        pTableLayer.UpdateFieldIndex();
                        return pTableLayer;
                    }
                    return null;
                }
                return null;
            }
            catch (Exception ex)
            {
                LogAPI.WriteErrorLog(ex);
                return null;
            }
        }
コード例 #9
0
ファイル: FeatureLayerFactory.cs プロジェクト: hy1314200/HyDM
        /// <summary>
        /// �����ֶμ���
        /// </summary>
        /// <param name="ocDescription">Ҫ��������</param>
        /// <param name="tableStructureNode">��ṹ�ڵ�</param>
        /// <returns></returns>
        private IFields CreateFileds(TableStructureNode tableStructureNode, FeatureCodeNode featureCodeNode)
        {
            try
            {
                ///�����ֶμ���
                IFeatureClassDescription fcDescription = new FeatureClassDescriptionClass();
                IObjectClassDescription ocDescription = new ObjectClassDescriptionClass();
                IFields fields = ocDescription.RequiredFields;

                //�������ļ���ȡͼ������
                string sGeometryType = "";
                Metadata.MetaTable pMetaTalbe = Metadata.MetaDataFile.MetaTabls[tableStructureNode.TableName] as Metadata.MetaTable;
                if (pMetaTalbe != null)
                {
                    sGeometryType = Metadata.MetaDataFile.GraphConfig.GetGraphTypeMark(pMetaTalbe.Type);
                }

                //����ͼ������
                if (sGeometryType != "NoneGeometry")
                {
                    ocDescription = (IObjectClassDescription)fcDescription;
                    fields = ocDescription.RequiredFields;
                    int shapeFieldIndex = fields.FindField(fcDescription.ShapeFieldName);
                    IField pGeometryfield = fields.get_Field(shapeFieldIndex);
                    IGeometryDef geometryDef = pGeometryfield.GeometryDef;
                    IGeometryDefEdit geometryDefEdit = (IGeometryDefEdit)geometryDef;
                    if (sGeometryType == "Point")
                        geometryDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPoint;
                    else if (sGeometryType == "Line")
                        geometryDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPolyline;
                    else if (sGeometryType == "Polygon")
                        geometryDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPolygon;

                }
                IFieldsEdit fieldsEdit = fields as IFieldsEdit;
                // ������ṹ����
                int FieldCount = tableStructureNode.FieldNodes.Count;
                for (int i = 0; i < FieldCount; i++)
                {
                    IField field = new FieldClass();
                    IFieldEdit fieldEdit = (IFieldEdit)field;
                    ///��ȡ�ֶ���Ϣ
                    FieldNode pFieldNode = tableStructureNode.FieldNodes[i];
                    if (pFieldNode != null)
                    {
                        ///�����ֶ�ֵ
                        fieldEdit.Name_2 = pFieldNode.FieldName;

                        //�������л�ȡ����
                        if (pMetaTalbe != null)
                            fieldEdit.AliasName_2 = pMetaTalbe.GetFiledALisNameByCode(pFieldNode.FieldName);
                        esriFieldType type = esriFieldType.esriFieldTypeString;
                        switch (pFieldNode.FieldType)
                        {
                            case "Char":
                                type = esriFieldType.esriFieldTypeString;
                                break;
                            case "Int":
                                type = esriFieldType.esriFieldTypeInteger;
                                break;
                            case "Float":
                                type = esriFieldType.esriFieldTypeDouble;
                                break;
                            case "Time":
                                type = esriFieldType.esriFieldTypeDate;
                                break;
                            case "DateTime":
                                type = esriFieldType.esriFieldTypeDate;
                                break;
                            case "Varchar":
                                type = esriFieldType.esriFieldTypeString;
                                break;
                            case "Varbin":
                                type = esriFieldType.esriFieldTypeString;
                                break;
                            default:
                                break;
                        }
                        fieldEdit.Type_2 = type;
                        fieldEdit.Length_2 = pFieldNode.FieldLength;
                        fieldEdit.Precision_2 = pFieldNode.FieldPrecision;
                        fieldsEdit.AddField(field);
                    }
                }
                return fields;
            }
            catch(Exception ex)
            {
                LogAPI.WriteErrorLog(ex);
                return null;
            }
        }
コード例 #10
0
ファイル: FeatureLayerFactory.cs プロジェクト: hy1314200/HyDM
        /// <summary>
        /// �����ռ�ͼ��
        /// </summary>
        /// <param name="tableStructureNode">VCT��ṹ�ڵ�</param>
        /// <param name="featureCodeNode">VCTҪ�ر���ڵ�</param>
        private FeatureLayer CreateFeatureLayer(TableStructureNode tableStructureNode, FeatureCodeNode featureCodeNode)
        {
            try
            {
                FeatureLayer featureLayer = null;
                ///��ȡҪ�ؼ�
                IFeatureDataset featureDataset = m_pIDataset as IFeatureDataset;

                //�������ļ���ȡͼ������
                string sGeometryType = "";
                Metadata.MetaTable pMetaTalbe = Metadata.MetaDataFile.MetaTabls[tableStructureNode.TableName] as Metadata.MetaTable;
                if (pMetaTalbe != null)
                {
                    sGeometryType = Metadata.MetaDataFile.GraphConfig.GetGraphTypeMark(pMetaTalbe.Type);
                }
                else
                {
                    LogAPI.WriteLog("δ�ܻ�ȡ��" + tableStructureNode.TableName + "����ͼ�����ͣ�");
                    return null;
                }
                ///������ʵ��
                if (sGeometryType == "Point")
                {
                    featureLayer = new PointLayer();

                }
                 ///������ʵ��
                else if (sGeometryType == "Line")
                {
                    featureLayer = new LineLayer();

                }
                ///������ʵ��
                else if (sGeometryType == "Polygon")
                {
                    featureLayer = new PolygonLayer();
                }
                else if (sGeometryType == "Annotation")
                {
                    featureLayer = new AnnotationLayer();
                }

                if (featureLayer != null)
                {
                    featureLayer.StructureNode = tableStructureNode;

                    IFeatureClass pFcls = CreateFeatureClass(featureDataset, tableStructureNode, featureCodeNode);
                    featureLayer.Table = pFcls as ITable;
                    featureLayer.UpdateFieldIndex();
                    return featureLayer;
                }
            }
            catch(Exception ex)
            {
                LogAPI.WriteErrorLog(ex);
            }
            return null;
        }
コード例 #11
0
ファイル: FeatureLayerFactory.cs プロジェクト: hy1314200/HyDM
        private IFeatureClass CreateFeatureClass(IFeatureDataset featureDataset,TableStructureNode tableStructureNode, FeatureCodeNode featureCodeNode)
        {
            try
            {
                if (featureDataset != null)
                {
                    IFeatureClassDescription fcDesc = new FeatureClassDescriptionClass();
                    IObjectClassDescription ocDesc = (IObjectClassDescription)fcDesc;

                    ///�������ݱ��ֶ�
                    IFieldChecker fieldChecker = new FieldCheckerClass();
                    IEnumFieldError enumFieldError = null;
                    IFields validatedFields = CreateFileds(tableStructureNode, featureCodeNode);
                    ///�ֶ���Ϣ��֤
                    IFields fixFields = null;
                    fieldChecker.ValidateWorkspace = featureDataset.Workspace;
                    fieldChecker.Validate(validatedFields, out enumFieldError, out fixFields);

                    ////����FeatureClass
                    IFeatureClass featureClass = null;
                    if (tableStructureNode.IsGeometryTable)
                    {
                        ////������ע��FeatureClass
                        if (featureCodeNode.GeometryType != "")
                        {
                            featureClass = featureDataset.CreateFeatureClass(featureCodeNode.TableName,
                               fixFields, ocDesc.InstanceCLSID, ocDesc.ClassExtensionCLSID,
                               esriFeatureType.esriFTSimple, fcDesc.ShapeFieldName, "");
                        }
                        else
                        {
                            ///����ע��
                            IFormattedTextSymbol pTxtSymbo=new TextSymbolClass();

                            IFeatureWorkspaceAnno pFeatureWorkspaceAnno = this.m_pIDataset.Workspace as IFeatureWorkspaceAnno;

                            IGraphicsLayerScale pGraphSacle = new GraphicsLayerScaleClass();
                            pGraphSacle.Units = ESRI.ArcGIS.esriSystem.esriUnits.esriFeet;
                            //pGraphSacle.ReferenceScale=1000;

                            ISymbolCollection pSymbolCollection = new SymbolCollectionClass();

                            IAnnotateLayerProperties pAnnoLayerProp = new LabelEngineLayerPropertiesClass();
                            pAnnoLayerProp.FeatureLinked = true;
                            pAnnoLayerProp.CreateUnplacedElements = false;
                            pAnnoLayerProp.DisplayAnnotation = true;
                            pAnnoLayerProp.UseOutput = true;

                            IAnnotationExpressionEngine pAnnoExpressionEngine =new AnnotationVBScriptEngineClass();
                            ILabelEngineLayerProperties pLabelEngineLayerProperties = pAnnoLayerProp as ILabelEngineLayerProperties;
                            pLabelEngineLayerProperties.ExpressionParser = pAnnoExpressionEngine;
                            pLabelEngineLayerProperties.Expression = "[DESCRIPTION]";
                            pLabelEngineLayerProperties.IsExpressionSimple = true;
                            pLabelEngineLayerProperties.Offset = 0;
                            pLabelEngineLayerProperties.SymbolID = 0;
                            pLabelEngineLayerProperties.Symbol = pTxtSymbo;

                            IAnnotateLayerTransformationProperties pAnnoLayerTransProp = pAnnoLayerProp as IAnnotateLayerTransformationProperties;
                            pAnnoLayerTransProp.ReferenceScale=200;
                            pAnnoLayerTransProp.Units= ESRI.ArcGIS.esriSystem.esriUnits.esriFeet;
                            pAnnoLayerTransProp.ScaleRatio=1;

                            IAnnotateLayerPropertiesCollection pAnnoLayerProptyCollection =new AnnotateLayerPropertiesCollectionClass();
                           pAnnoLayerProptyCollection.Add(pAnnoLayerProp);

                           featureClass= pFeatureWorkspaceAnno.CreateAnnotationClass(featureCodeNode.TableName,fixFields,ocDesc.InstanceCLSID
                               ,ocDesc.ClassExtensionCLSID,fcDesc.ShapeFieldName,"",featureDataset,null,
                               pAnnoLayerProptyCollection, pGraphSacle, pSymbolCollection,true);
                        }
                    }
                    else
                    {
                        ///�����ǿռ�����
                    }
                    return featureClass;
                }
                return null;
            }
            catch(Exception ex)
            {
                LogAPI.WriteErrorLog(ex);
                return null;
            }
        }