public WritePolygonNodes(ESRIData.Dataset dataset,TempData.TempFile pTempFile, VCTFile pVCTFile, int nNewEntityID) { m_dataset = dataset; m_pTempFile = pTempFile; m_VCTFile = pVCTFile; m_nNewEntityID = nNewEntityID; m_nLayerCount = m_dataset.GetLayerCount(); //WriteCommplete = null; }
public WritePolygonNodes(ESRIData.Dataset dataset, TempData.TempFile pTempFile, VCTFile pVCTFile, int nNewEntityID) { m_dataset = dataset; m_pTempFile = pTempFile; m_VCTFile = pVCTFile; m_nNewEntityID = nNewEntityID; m_nLayerCount = m_dataset.GetLayerCount(); //WriteCommplete = null; }
public virtual void Dispose() { if (m_VCTFile != null) m_VCTFile.CloseFile(); m_VCTFile = null; Metadata.MetaDataFile.Dispose(); if (m_pTempFile != null) m_pTempFile.Close(); m_pTempFile = null; if (m_dataset != null) m_dataset.Dispose(); m_dataset = null; if (m_MDBFile != null) m_MDBFile.Dispose(); m_MDBFile = null; GC.Collect(); }
/// <summary> /// 执行转换 /// </summary> /// <param name="bIgnoreHeadError">是否忽略头文件的错误</param> /// <returns></returns> public EnumVCT2MDBExchangeInfo Exchange(bool bAllowDefaultProjection) { ///指示当前是否在读取VCT实体 bool bIsReadEntity = false; ///指示当前是否在读取VCT属性 bool bIsReadAtti = false; try { //读取头节点 FileData.HeadNode headNode = m_VCTFile.ReadHeadNode(); if (headNode != null) { //创建数据集 ESRIData.Dataset dataset = m_MDBFile.CreateDataset(headNode, m_strDataSetName); ///数据集的空间参考创建失败 if (dataset.ESRIDataset==null) { return EnumVCT2MDBExchangeInfo.DATASETERROR; } IGeoDataset pDataset = dataset.ESRIDataset as IGeoDataset; if (pDataset!=null&& pDataset.SpatialReference is UnknownCoordinateSystemClass && !bAllowDefaultProjection) { return EnumVCT2MDBExchangeInfo.PROJECTIONERROR; } if (dataset != null) { //读取要素参数节点和表结构节点 Hashtable arrFeatureCodeNode = m_VCTFile.ReadFeatureCodeNodes(); ///读取要素代码错误 if (arrFeatureCodeNode == null) { return EnumVCT2MDBExchangeInfo.FEATURECODEERROR; } List<FileData.TableStructureNode> arrTableStructureNode = m_VCTFile.ReadTableStructureNodes(); ///读取要素代码错误 if (arrTableStructureNode == null) { return EnumVCT2MDBExchangeInfo.FEATUREATRRIBUTE; } if (arrFeatureCodeNode != null && arrTableStructureNode != null) { //创建图层 //ESRIData.FeatureLayerFactory featureLayerFactory = new ESRIData.FeatureLayerFactory(dataset.Workspace); //featureLayerFactory.CreateFeatureLayers(arrTableStructureNode, arrFeatureCodeNode); //dataset.LayerFactory = featureLayerFactory; dataset.CreateFeatureLayers(arrTableStructureNode, arrFeatureCodeNode); //读取空间实体节点 string strFeatureCode = "";//上一个实体所属图层的要素代码 ESRIData.FeatureLayer featureLayer = null; ESRIData.TableLayer tableLayer = null; FileData.EntityNode entityNode; bIsReadEntity = true;///开始读取实体 while ((entityNode = m_VCTFile.ReadEntityNode()) != null) { //获取实体所属图层 if (strFeatureCode != entityNode.FeatureCode) tableLayer = dataset.GetFeatureLayerByCode(entityNode.FeatureCode); //创建空间实体对象 featureLayer = tableLayer as FeatureLayer; if (featureLayer != null) { featureLayer.CreateFeatureEntity(entityNode); } strFeatureCode = entityNode.FeatureCode; } //读取属性节点 FileData.TableNode tableNode = null; bIsReadAtti = true;///开始读取VCT属性 while ((tableNode = m_VCTFile.ReadTableNode()) != null) { //获取属性表对象 tableLayer = dataset.GetFeatureLayerByName(tableNode.TableName); featureLayer = tableLayer as FeatureLayer; if (featureLayer != null) { //读取数据表记录 //FileData.RecordNode recordNode = null; //while ((recordNode = m_VCTFile.ReadRecordNode()) != null) //{ // ESRIData.FeatureEntity featureEntity = featureLayer.GetFeatureEntityByID(recordNode.EntityID); // featureEntity.AttachAttribute(recordNode); //} List<FileData.RecordNode> arrRecordNode = m_VCTFile.ReadRecordNodes(); if (arrRecordNode.Count > 0) { arrRecordNode.Sort(); List<ESRIData.FeatureEntity> arrFeatureEntity = featureLayer.GetFeatureEntitys(); if (arrFeatureEntity.Count > 0) { arrFeatureEntity.Sort(); int j = 0; for (int i = 0; i < arrFeatureEntity.Count; i++) { for (; j < arrRecordNode.Count; j++) { if (arrFeatureEntity[i].EntityID == arrRecordNode[j].EntityID) arrFeatureEntity[i].AttachAttribute(arrRecordNode[j], featureLayer.StructureNode); else if (arrFeatureEntity[i].EntityID < arrRecordNode[j].EntityID) { break; } else { //插入 } } } arrFeatureEntity.Clear(); arrFeatureEntity = null; } else { //插入 } arrRecordNode.Clear(); arrRecordNode = null; } } else { ///add by zengping 2011-4-24添加属性记录 if (tableLayer != null) { List<FileData.RecordNode> arrRecordNode = m_VCTFile.ReadRecordNodes(); foreach (FileData.RecordNode Recorditem in arrRecordNode) { tableLayer.InsertAttibuteTableRecord(Recorditem); } arrRecordNode.Clear(); arrRecordNode = null; } else tableNode = null; } } tableLayer = null; arrFeatureCodeNode.Clear(); arrTableStructureNode.Clear(); arrTableStructureNode = null; arrFeatureCodeNode = null; if (bAllowDefaultProjection && dataset.Projection.SpatialReference is UnknownCoordinateSystemClass) return EnumVCT2MDBExchangeInfo.SUCCESSWITHDEFAULTPROJECTION; else return EnumVCT2MDBExchangeInfo.EXCHANGESUCCESS; } dataset.Dispose(); } else { ///获取数据集错误 return EnumVCT2MDBExchangeInfo.DATASETERROR; } headNode = null; } else { return EnumVCT2MDBExchangeInfo.HEADFILEERROR; } return EnumVCT2MDBExchangeInfo.EXCHANGEFAIL; } catch (Exception ex) { LogAPI.WriteErrorLog(ex); ///读取实体过程中出错 if (bIsReadEntity && !bIsReadAtti) return EnumVCT2MDBExchangeInfo.FEATUREENTY; ///读取属性过程中出错 else if (bIsReadEntity && bIsReadAtti) return EnumVCT2MDBExchangeInfo.FEATUREATRRIBUTE; return EnumVCT2MDBExchangeInfo.EXCHANGUNKNOWEERROR; } finally { GC.Collect(); } }
/// <summary> /// �����ݼ� /// </summary> public Dataset GetDataset() { IEnumDataset pEnumDataset = m_pIWorkspace.get_Datasets(esriDatasetType.esriDTFeatureDataset); IDataset pIDataset = pEnumDataset.Next(); if (pIDataset != null) { m_Dataset = new Dataset(pIDataset,m_pIWorkspace,m_bCut,m_CutGeometry); return m_Dataset; } return null; }
public virtual void Dispose() { if (m_Dataset != null) m_Dataset.Dispose(); if (this.Workspace != null) System.Runtime.InteropServices.Marshal.ReleaseComObject(Workspace); m_Dataset = null; Workspace = null; GC.Collect(); }
/// <summary> /// �������ݼ� /// </summary> /// <param name="headNode">VCTͷ�ڵ�</param> public Dataset CreateDataset(HeadNode headNode, string strName) { if (headNode == null) return null; try { m_Dataset = new Dataset(m_pIWorkspace); if (m_Dataset.CreateESRIDataset(strName, headNode)) return m_Dataset; return m_Dataset; } catch (Exception ex) { Logger.WriteErrorLog(ex); return null; } }
/* /// <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; } }
/* /// <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) { Logger.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; } }