/// <summary> /// 保存面图层对应的线图层中的实体到临时数据文件 /// </summary> private void SaveLineNodesToTemp(LineNodeTable pLineNodeTable, string strPolygonTableName) { //暂时不考虑面与面之间的关联 MetaTable metaTable = MetaDataFile.GetMetaTalbleByName(strPolygonTableName); List <string> arrFeatureCode = null; if (metaTable != null) { arrFeatureCode = metaTable.LinkFeatureCode; } if (arrFeatureCode != null && arrFeatureCode.Count > 0) { ESRIData.FeatureLayer featureLayer; int m = 1; for (int i = 0; i < m_nLayerCount; i++) { //获取图层对象 featureLayer = m_dataset.GetFeatureLayerByIndex(i) as ESRIData.FeatureLayer; ESRIData.LineLayer lineLayer = featureLayer as ESRIData.LineLayer; if (lineLayer != null) { if (arrFeatureCode.Contains(lineLayer.FeatureCode) == true) { List <ESRIData.FeatureEntity> arrFeatureEntity = lineLayer.FeatureEntys; if (arrFeatureEntity == null) { return; } for (int j = 0; j < arrFeatureEntity.Count; j++) { FileData.LineNode lineNode = arrFeatureEntity[j].GetEntityNode() as FileData.LineNode; if (lineNode != null) { //拆分线:多点一线拆为两点一线 for (int k = 0; k < lineNode.SegmentNodes.Count; k++) { FileData.BrokenLineNode brokenLineNode = lineNode.SegmentNodes[k] as FileData.BrokenLineNode; if (brokenLineNode != null) { for (int n = 1; n < brokenLineNode.PointInfoNodes.Count; n++) { FileData.PointInfoNodes pointInfoNodes = new FileData.PointInfoNodes(); pointInfoNodes.Add(brokenLineNode.PointInfoNodes[n - 1]); pointInfoNodes.Add(brokenLineNode.PointInfoNodes[n]); FileData.BrokenLineNode brokenLineNodeNew = new FileData.BrokenLineNode(); brokenLineNodeNew.PointInfoNodes = pointInfoNodes; FileData.SegmentNodes segmentNodes = new FileData.SegmentNodes(); segmentNodes.Add(brokenLineNodeNew); FileData.LineNode lineNodeNew = new FileData.LineNode(); lineNodeNew.SegmentNodes = segmentNodes; lineNodeNew.EntityID = lineNode.EntityID; lineNodeNew.FeatureCode = lineNode.FeatureCode; lineNodeNew.LineType = lineNode.LineType; lineNodeNew.Representation = lineNode.Representation; //arrLineNode.Add(lineNodeNew); //写入临时数据文件 //if (m_pTempFile.LineNodeExs != null) //{ pLineNodeTable.AddRow(lineNodeNew); //} if (m % pLineNodeTable.MaxRecordCount == 0) { pLineNodeTable.Save(true); } m++; } } } } } } } } pLineNodeTable.Save(true); } //return arrLineNode; }
/// <summary> /// 写入面节点 /// </summary> public void Write() { if (m_pTempFile.DbConnection != null && m_pTempFile.DbConnection.State == ConnectionState.Open) { ESRIData.FeatureLayer featureLayer; while (this.m_nLayerIndex < m_nLayerCount) { //获取图层对象 featureLayer = m_dataset.GetFeatureLayerByIndex(this.m_nLayerIndex) as ESRIData.FeatureLayer; ESRIData.PolygonLayer polygonLayer = featureLayer as ESRIData.PolygonLayer; if (polygonLayer != null) { List <ESRIData.FeatureEntity> arrFeatureEntity = polygonLayer.FeatureEntys; if (arrFeatureEntity != null && arrFeatureEntity.Count > 0) { m_pTempFile.IsFirst = m_bIsFirst; ////清除临时数据 PolygonNodeTable pPolygonNodeTable = new PolygonNodeTable(m_pTempFile.DbConnection, true, m_bIsFirst); LineNodeExTable pLineNodeExTable = new LineNodeExTable(m_pTempFile.DbConnection, true, m_bIsFirst); LineNodeTable pLineNodeTable = new LineNodeTable(m_pTempFile.DbConnection, true, m_bIsFirst); ///处理每个图层下的所有要素 //using (BackgroundWorker workerPolygon = new BackgroundWorker()) //{ // workerPolygon.DoWork += delegate // { timeBeginPolygon = DateTime.Now; int j = 1, n = 1; FileData.PolygonNode polygonNode = null; while (arrFeatureEntity.Count > 0) { polygonNode = arrFeatureEntity[0].GetEntityNode() as FileData.PolygonNode; if (polygonNode != null) { pPolygonNodeTable.AddRow(polygonNode); for (int k = 0; k < polygonNode.LineNodes.Count; k++) { polygonNode.LineNodes[k].LineIndex = k; pLineNodeExTable.AddRow(polygonNode.LineNodes[k]); if (n % pLineNodeExTable.MaxRecordCount == 0) { pLineNodeExTable.Save(true); } n++; } } //m_pTempFile.PolygonNodes.AddRow(polygonNode); if (j % pPolygonNodeTable.MaxRecordCount == 0 || 1 == arrFeatureEntity.Count) { //if (j == arrFeatureEntity.Count) pLineNodeExTable.Save(true); pPolygonNodeTable.Save(true); } arrFeatureEntity.RemoveAt(0); j++; } TimeSpan span = DateTime.Now - this.timeBeginPolygon; Logger.WriteLog("写入构面线临时数据耗时" + span.ToString()); // }; // workerPolygon.RunWorkerCompleted += WritePolygonCompleted; // workerPolygon.RunWorkerAsync(); //} //保存关联的线图层中的线结点到临时图层/* //using (BackgroundWorker workerLine = new BackgroundWorker()) //{ timeBeginLine = DateTime.Now; // workerLine.DoWork += delegate // { SaveLineNodesToTemp(pLineNodeTable, featureLayer.StructureNode.TableName); span = DateTime.Now - this.timeBeginLine; Logger.WriteLog("写入引用线临时数据耗时" + span.ToString()); // }; // workerLine.RunWorkerCompleted += WriteLineCompleted; // workerLine.RunWorkerAsync(); //}; WritePolygonLineCompleted(); if (m_bIsFirst == true) { m_bIsFirst = false; } } break; } else { this.m_nLayerIndex++; } } //if (this.m_nLayerIndex == m_nLayerCount) //{ // m_pTempFile.Close(); // if (WriteCommplete != null) // WriteCommplete(true); //} } }