Пример #1
0
        /// <summary>
        /// 操作符“>”
        /// </summary>
        /// <param name="xSegmentNodes">线段节点集合</param>
        /// <param name="ySegmentNodes">线段节点集合</param>
        public new void AddRange(IEnumerable<SegmentNode> collection)
        {
            if (this.Count > 0)
            {
                BrokenLineNode segmentNode1 = this[this.Count - 1] as BrokenLineNode;
                if (segmentNode1 != null)
                {
                    IEnumerator<SegmentNode> pIEnumerator = collection.GetEnumerator();
                    pIEnumerator.Reset();
                    bool bFirst = true;
                    while (pIEnumerator.MoveNext())
                    {
                        if (bFirst == true)
                        {
                            BrokenLineNode segmentNode2 = pIEnumerator.Current as BrokenLineNode;
                            if (segmentNode2 != null)
                            {
                                //if (segmentNode1.PointInfoNodes[segmentNode1.PointInfoNodes.Count - 1] == segmentNode2.PointInfoNodes[0])
                                //{
                                    for (int i = 1; i < segmentNode2.PointInfoNodes.Count; i++)
                                    {
                                        segmentNode1.PointInfoNodes.Add(segmentNode2.PointInfoNodes[i]);
                                    }
                                //}
                                //else
                                //{
                                //    for (int i = segmentNode2.PointInfoNodes.Count - 2; i >= 0; i--)
                                //    {
                                //        segmentNode1.PointInfoNodes.Add(segmentNode2.PointInfoNodes[i]);
                                //    }

                                //}
                            }
                            else
                                break;

                            bFirst = false;
                        }
                        else
                        {
                            this.Add(pIEnumerator.Current);
                        }
                    }
                    if (bFirst == false)
                        return;
                }
            }
            
            base.AddRange(collection);
            
        }
Пример #2
0
        /// <summary>
        /// 操作符“!=”
        /// </summary>
        /// <param name="xSegmentNode">线段节点</param>
        /// <param name="ySegmentNode">线段节点</param>
        public static bool operator !=(SegmentNode xSegmentNode, SegmentNode ySegmentNode)
        {
            if (object.Equals(xSegmentNode, null))
            {
                if (object.Equals(ySegmentNode, null))
                    return false;
                else
                    return true;
            }
            else
            {
                if (object.Equals(ySegmentNode, null))
                    return true;

            }

            if (xSegmentNode.SegmentType == ySegmentNode.SegmentType)
            {
                switch (xSegmentNode.SegmentType)
                {
                    case 11:
                        {
                            BrokenLineNode xBrokenLineNode = xSegmentNode as BrokenLineNode;
                            BrokenLineNode yBrokenLineNode = ySegmentNode as BrokenLineNode;
                            return xBrokenLineNode != yBrokenLineNode ? true : false;
                        }
                    case 12:
                        break;
                    case 13:
                        break;
                    case 14:
                        break;
                    case 15:
                        break;
                    case 16:
                        break;
                    case 17:
                        break;
                }
            }
            return false;
        }
Пример #3
0
        /// <summary>
        /// ��ȡVCT��ʵ��ڵ�
        /// </summary>
        private LineNode ReadLineNode()
        {
            if (this.m_streamReader != null)
            {
                string strLine = "";    //��ȡ�������ֻ���

                if (m_bFoundLineBegin == false)
                {
                    strLine = this.ReadLine(true);
                    //������ʵ��ڵ�Ŀ�ʼ��ǡ�LineBegin��
                    if (strLine.IndexOf("LineBegin", System.StringComparison.OrdinalIgnoreCase) > -1)
                    {
                        m_bFoundLineBegin = true;
                    }
                }
                if (m_bFoundLineBegin == true)
                {
                    strLine = this.ReadLine(true);
                    //������ʵ��ڵ�Ľ�����ǡ�LineEnd��
                    if (strLine.IndexOf("LineEnd", System.StringComparison.OrdinalIgnoreCase) > -1)
                        return null;
                    else
                    {
                        LineNode lineNode = new LineNodeEx();

                        ///add by ��ƽ ���ʵ���ʶ��û�л�ȡ�����ж�Ϊ��ȡʧ��
                        //�Ȼ�ȡ��ʵ���ʶ��
                        int nEntityID = -1;
                        if (VCTFile.ConvertToInt32(strLine, out nEntityID))
                            lineNode.EntityID = nEntityID;
                        else
                        {
                            LogAPI.WriteLog("��ȡ��ʵ��ı�ʶ��ʧ�ܣ����������Ƿ���ϱ�׼��");
                            LogAPI.WriteLog("��ȡ���������������" + m_nReadLineCount + "��");
                            return null;
                        }
                        //�ٻ�ȡҪ�ر���
                        lineNode.FeatureCode = this.ReadLine(false);
                        //��ȡͼ�α��ֱ���
                        lineNode.Representation = this.ReadLine(false);
                        //��ȡ�ߵ���������
                        int nLineType = -1;
                        if (VCTFile.ConvertToInt32(this.ReadLine(false),out nLineType))
                            lineNode.LineType = nLineType;
                        else
                        {
                            LogAPI.WriteLog("��ȡ��ʵ�����������ʧ�ܣ����������Ƿ���ϱ�׼��");
                            LogAPI.WriteLog("��ȡ���������������"+m_nReadLineCount+"��");
                            return null;
                        }
                        //��ȡ�߶ε�����
                        int nSegmentCount = 0;
                        if(!VCTFile.ConvertToInt32(this.ReadLine(false), out nSegmentCount))
                        {
                            LogAPI.WriteLog("��ȡ��ʵ��Ľڵ����ʧ�ܣ����������Ƿ���ϱ�׼��");
                            LogAPI.WriteLog("��ȡ���������������" + m_nReadLineCount + "��");
                            return null;
                        }
                        SegmentNodes arrSegmentNode = new SegmentNodes();
                        for (int i = 0; i < nSegmentCount; i++)
                        {
                            //��ȡ�߶�����
                            this.ReadLine(false);
                            ////////////////////////////////////////////////////////////////////////////
                            //Ŀǰֻ��������
                            BrokenLineNode bokenLineNode = new BrokenLineNode();
                            PointInfoNodes arrPointInfoNode = new PointInfoNodes();
                            //��ȡ�����е�ĸ���
                            int nPointCount = 0;
                            if (!VCTFile.ConvertToInt32(this.ReadLine(false), out nPointCount))
                            {
                                LogAPI.WriteLog("��ȡ���ߵĽڵ����ʧ�ܣ����������Ƿ���ϱ�׼��");
                                LogAPI.WriteLog("��ȡ���������������" + m_nReadLineCount + "��");
                                return null;
                            }
                            for (int j = 0; j < nPointCount; j++)
                            {
                                //��ȡ�������
                                arrPointInfoNode.Add(new PointInfoNode(this.ReadLine(false)));
                            }
                            bokenLineNode.PointInfoNodes = arrPointInfoNode;
                            arrSegmentNode.Add(bokenLineNode);
                        }
                        lineNode.SegmentNodes = arrSegmentNode;

                        return lineNode;
                    }
                }

            }
            return null;
        }
Пример #4
0
        //public override void GetEntityNodeByDataRow(DataRow dataRow, ref EntityNode entityNode)
        //{
        //    GetLineNodeByDataRow(dataRow, entityNode, false);
        //}
        public void GetLineNodeByDataRow(DataRow dataRow, ref LineNode lineNode, bool bReverse)
        {
            if (dataRow != null)
            {
                EntityNode entityNode = lineNode as EntityNode;
                base.GetEntityNodeByDataRow(dataRow, ref entityNode);

                lineNode.IndexID = dataRow[FieldName_LineNodeID] == System.DBNull.Value ? -1 : Convert.ToInt32(dataRow[FieldName_LineNodeID]);
                //lineNode.EntityID = dataRow[FieldName_EntityID] == null ? -1 : Convert.ToInt32(dataRow[FieldName_EntityID]);
                //lineNode.FeatureCode = dataRow[FieldName_FeatureCode] == null ? "" : dataRow[FieldName_FeatureCode].ToString();
                lineNode.LineType = dataRow[FieldName_LineType] == System.DBNull.Value ? -1 : Convert.ToInt32(dataRow[FieldName_LineType]);
                //lineNode.Representation = dataRow[FieldName_Representation] == null ? "" : dataRow[FieldName_Representation].ToString();

                if (entityNode.EntityID != 0)
                {
                    SegmentNodes segmentNodes = new SegmentNodes();
                    BrokenLineNode brokenLineNode = new BrokenLineNode();
                    PointInfoNodes pointInfoNodes = new PointInfoNodes();
                    double dX1 = dataRow[FieldName_X1] == DBNull.Value ? 0.0 : Convert.ToDouble(dataRow[FieldName_X1]);
                    double dY1 = dataRow[FieldName_Y1] == DBNull.Value ? 0.0 : Convert.ToDouble(dataRow[FieldName_Y1]);
                    PointInfoNode pointInfoNode1 = new PointInfoNode(dX1, dY1);

                    double dX2 = dataRow[FieldName_X2] == DBNull.Value ? 0.0 : Convert.ToDouble(dataRow[FieldName_X2]);
                    double dY2 = dataRow[FieldName_Y2] == DBNull.Value ? 0.0 : Convert.ToDouble(dataRow[FieldName_Y2]);
                    PointInfoNode pointInfoNode2 = new PointInfoNode(dX2, dY2);

                    if (bReverse == true)
                    {
                        pointInfoNodes.Add(pointInfoNode2);
                        pointInfoNodes.Add(pointInfoNode1);
                    }
                    else
                    {
                        pointInfoNodes.Add(pointInfoNode1);
                        pointInfoNodes.Add(pointInfoNode2);
                    }
                    brokenLineNode.PointInfoNodes = pointInfoNodes;
                    segmentNodes.Add(brokenLineNode);
                    lineNode.SegmentNodes = segmentNodes;
                }
            }
        }
Пример #5
0
        /// <summary>
        /// ��ȡVCT��ʵ��ڵ�
        /// </summary>
        public override EntityNode GetEntityNode()
        {
            try
            {
                LineNode pLineNode = new LineNode();
                pLineNode.SegmentNodes = new SegmentNodes();

                IFeature pFeature = this.Feature as IFeature;

                //��������ͳһ����Ϊ1
                pLineNode.LineType = 1;

                ///��ʶ�븳ֵ
                int dBSMIndex = -1;
                dBSMIndex = this.Feature.Fields.FindField(m_strEntityIDFiled);
                if (dBSMIndex != -1)
                    pLineNode.EntityID = Convert.ToInt32(this.Feature.get_Value(dBSMIndex));

                ///Ҫ�ش��븳ֵ
                //int dSYDMIndex = -1;
                //dSYDMIndex = this.Feature.Fields.FindField(m_strYSDMField);
                //if (dSYDMIndex != -1)
                //    pLineNode.FeatureCode = this.Feature.get_Value(dSYDMIndex).ToString();
                //string sAttriTableName = (pFeature.Class as IDataset).Name;
                //pLineNode.FeatureCode = MetaDataFile.GetFeatureCodeByName(sAttriTableName);
                pLineNode.FeatureCode = this.FeatureCode;

                ///ͼ�α��ֱ���
                //pLineNode.Representation = pFeature.Class.AliasName;
                ///add by ��ƽ 2011-9-7 ��Ӳ���
                IGeometry pFeatureGeometry = null;
                if (m_bCut)
                {
                    pFeatureGeometry = GetSubGeometry();
                    if (pFeatureGeometry == null)
                    {
                        pFeatureGeometry = pFeature.Shape;
                    }
                }
                else
                {
                    pFeatureGeometry = pFeature.Shape;
                }

                IPolyline pPolygon =pFeatureGeometry as IPolyline;
                ///����ڵ�����
                IPointCollection pPointCollection = pPolygon as IPointCollection;
                BrokenLineNode pBLineNode = new BrokenLineNode();
                pBLineNode.PointInfoNodes = new PointInfoNodes();
                for (int i = 0; i < pPointCollection.PointCount; i++)
                {

                    IPoint pPoint = pPointCollection.get_Point(i);
                    PointInfoNode pInfoNode1 = new PointInfoNode(pPoint.X, pPoint.Y);
                    pBLineNode.PointInfoNodes.Add(pInfoNode1);

                }

                pLineNode.SegmentNodes.Add(pBLineNode);
                return pLineNode;
            }
            catch (Exception ex)
            {
                Logger.WriteErrorLog(ex);
                return null;
            }
        }
Пример #6
0
        /// <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;
        }
Пример #7
0
        /// <summary>
        /// ������Ļ��ֽ���߶μ���
        /// </summary>
        /// <param name="pRing">����Ļ�����IRing</param>
        /// <param name="strFeatureCode">�ߵ�Ҫ�ش���</param>
        /// <param name="strRepresentation">ͼ�α��ֱ���</param>
        /// <param name="nEntityID">��ʵ������</param>
        /// <returns>VCT�߶ζ��󼯺�</returns>
        private List<LineNodeEx> GetLineNodeExsByRing(IRing pRing, string strFeatureCode, string strRepresentation, int nEntityID)
        {
            try
            {
                List<LineNodeEx> arrLineNodeEx = new List<LineNodeEx>();

                ///��ȡÿ�����е��߶μ���
                IPointCollection pIPointCollection = pRing as IPointCollection;

                for (int i = 0; i < pIPointCollection.PointCount; i++)
                {
                    if (i > 0)
                    {
                        LineNodeEx pLineNodeEx = new LineNodeEx();//����VCT�߶ζ���
                        pLineNodeEx.SegmentNodes = new SegmentNodes();//�����߶ζ�Ӧ�ĵ㼯��
                        pLineNodeEx.FeatureCode = strFeatureCode;//����Ҫ�ش���
                        pLineNodeEx.Representation = strRepresentation;
                        pLineNodeEx.PolygonID = nEntityID;///������ı�ʶ��

                        BrokenLineNode pBrokenLinNode = new BrokenLineNode();//��������
                        pBrokenLinNode.PointInfoNodes = new PointInfoNodes();

                        IPoint pIPoint1 = pIPointCollection.get_Point(i - 1);
                        IPoint pIPoint2 = pIPointCollection.get_Point(i);
                        pBrokenLinNode.PointInfoNodes.Add(new PointInfoNode(pIPoint1.X, pIPoint1.Y));
                        pBrokenLinNode.PointInfoNodes.Add(new PointInfoNode(pIPoint2.X, pIPoint2.Y));
                        pLineNodeEx.SegmentNodes.Add(pBrokenLinNode);

                        arrLineNodeEx.Add(pLineNodeEx);
                    }
                }

                return arrLineNodeEx;
                /*
                ///��������еĸ����߶�
                for (int i = 0; i < pExRingSegmentCollection.SegmentCount; i++)
                {
                    ISegment pSegment = pExRingSegmentCollection.get_Segment(i);

                    LineNodeEx pLineNodeEx = new LineNodeEx();//����VCT�߶ζ���
                    pLineNodeEx.SegmentNodes = new SegmentNodes();//�����߶ζ�Ӧ�ĵ㼯��
                    //pLineNodeEx.IsReverse = bReverse;//���÷���
                    pLineNodeEx.FeatureCode = strFeatureCode;//����Ҫ�ش���
                    pLineNodeEx.Representation = strRepresentation;
                    pLineNodeEx.PolygonID = nEntityID;///������ı�ʶ��

                    BrokenLineNode pBrokenLinNode = new BrokenLineNode();//��������
                    pBrokenLinNode.PointInfoNodes = new PointInfoNodes();

                    ILine pLine = pSegment as ILine;
                    if (pLine != null)
                    {
                        pBrokenLinNode.PointInfoNodes.Add(new PointInfoNode(pLine.FromPoint.X, pLine.FromPoint.Y));
                        pBrokenLinNode.PointInfoNodes.Add(new PointInfoNode(pLine.ToPoint.X, pLine.ToPoint.Y));
                    }

                    //////����Ƿ���
                    ////if (bReverse)
                    ////{
                    ////    PointInfoNodes tempPointInfoNodes = new PointInfoNodes();
                    ////    foreach (PointInfoNode item in pBrokenLinNode.PointInfoNodes)
                    ////    {
                    ////        tempPointInfoNodes.Add(item);
                    ////    }
                    ////    pBrokenLinNode.PointInfoNodes = tempPointInfoNodes;
                    ////}
                    pLineNodeEx.SegmentNodes.Add(pBrokenLinNode);
                    pListLine.Add(pLineNodeEx);
                }

                return pListLine;*/
            }
            catch (Exception ex)
            {
                LogAPI.WriteErrorLog(ex);
                return null;
            }
        }
Пример #8
0
        /// <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;
        }