public void UnifyIndicesPolylines()
        {
            var ParameterInitialize = _ParameterInitialize;
            //List<CPolyline> pCPlLt = this.ObjCGeoLtLt[0].Select(cgeo => cgeo as CPolyline).ToList();

            List <CPolyline> LSCPlLt = this.ObjCGeoLtLt[0].Select(cgeo => cgeo as CPolyline).ToList();
            List <CPolyline> SSCPlLt = this.ObjCGeoLtLt[1].Select(cgeo => cgeo as CPolyline).ToList();

            long lngStartTime = System.Environment.TickCount;

            MatchPolyline(ref LSCPlLt, ref SSCPlLt);
            List <CPolyline>    LSAttentionCPlLt = new List <CPolyline>();
            List <CPolyline>    SSAttentionCPlLt = new List <CPolyline>();
            List <CCorrSegment> pCorrCplLt       = UnifyIndices(ref LSCPlLt, ref SSCPlLt, ref LSAttentionCPlLt, ref SSAttentionCPlLt);


            //CSaveFeature.SaveCGeoEb(SingleCPlLt, esriGeometryType.esriGeometryPolyline, "SingleCPl", ParameterInitialize.pWorkspace, ParameterInitialize.m_mapControl);
            CSaveFeature.SaveCGeoEb(SSAttentionCPlLt, esriGeometryType.esriGeometryPolyline, "SSAttentionCPl");
            CSaveFeature.SaveCGeoEb(LSAttentionCPlLt, esriGeometryType.esriGeometryPolyline, "LSAttentionCPl");

            List <CPolyline> pLSCPlLt = new List <CPolyline>(); //the code has to be checked**************************************
            List <CPolyline> pSSCPlLt = new List <CPolyline>(); //the code has to be checked**************************************

            for (int i = 0; i < pCorrCplLt.Count; i++)          //the code has to be checked**************************************
            {
                pLSCPlLt.Add(pCorrCplLt[i].CFrPolyline);
                pSSCPlLt.Add(pCorrCplLt[i].CToPolyline);
            }

            //pLSCPlLt and pSSCPlLt has to be saved because there are may be LSAttentionCPlLt and SSAttentionCPlLt
            CSaveFeature.SaveCGeoEb(pSSCPlLt, esriGeometryType.esriGeometryPolyline, ParameterInitialize.pFLayerLt[1].Name + "SSCPl");
            CSaveFeature.SaveCGeoEb(pLSCPlLt, esriGeometryType.esriGeometryPolyline, ParameterInitialize.pFLayerLt[0].Name + "LSCPl");
        }
Example #2
0
        public void MatchAndMergePolylines()
        {
            var ParameterInitialize = _ParameterInitialize;
            //List<CPolyline> pCPlLt = this.ObjCGeoLtLt[0].AsExpectedClassEb<CPolyline, CGeoBase>().ToList();

            List <CPolyline> LSCPlLt = this.ObjCGeoLtLt[0].AsExpectedClassEb <CPolyline, CGeoBase>().ToList();
            List <CPolyline> SSCPlLt = this.ObjCGeoLtLt[1].AsExpectedClassEb <CPolyline, CGeoBase>().ToList();

            long                lngStartTime     = System.Environment.TickCount;
            List <CPolyline>    LSAttentionCPlLt = new List <CPolyline>();
            List <CPolyline>    SingleCPlLt      = MatchPolyline(ref LSCPlLt, ref SSCPlLt, ref LSAttentionCPlLt);
            List <CPolyline>    SSAttentionCPlLt = new List <CPolyline>();
            List <CCorrSegment> pCorrCplLt       = UnionLSCPl(ref SSCPlLt, ref LSAttentionCPlLt, ref SSAttentionCPlLt);

            //Save


            CSaveFeature.SaveCGeoEb(SSAttentionCPlLt, esriGeometryType.esriGeometryPolyline, "SSAttentionCPl");
            CSaveFeature.SaveCGeoEb(LSAttentionCPlLt, esriGeometryType.esriGeometryPolyline, "LSAttentionCPl");
            CSaveFeature.SaveCGeoEb(SingleCPlLt, esriGeometryType.esriGeometryPolyline, "SingleCPl");

            List <CPolyline> pLSCPlLt = new List <CPolyline>(); //the code has to be checked**************************************
            List <CPolyline> pSSCPlLt = new List <CPolyline>(); //the code has to be checked**************************************

            for (int i = 0; i < pCorrCplLt.Count; i++)          //the code has to be checked**************************************
            {
                pLSCPlLt.Add(pCorrCplLt[i].CFrPolyline);
                pSSCPlLt.Add(pCorrCplLt[i].CToPolyline);
            }

            //pLSCPlLt and pSSCPlLt has to be saved because there are may be LSAttentionCPlLt and SSAttentionCPlLt
            CSaveFeature.SaveCGeoEb(pSSCPlLt, esriGeometryType.esriGeometryPolyline, ParameterInitialize.pFLayerLt[1].Name + "SSCPl");
            CSaveFeature.SaveCGeoEb(pLSCPlLt, esriGeometryType.esriGeometryPolyline, ParameterInitialize.pFLayerLt[0].Name + "LSCPl");
        }
        public void MergeAndSplitPolylines()
        {
            var ParameterInitialize = _ParameterInitialize;
            List <CPolyline> pCPlLt = this.ObjCGeoLtLt[0].Select(cgeo => cgeo as CPolyline).ToList();

            long lngStartTime = System.Environment.TickCount;

            CDCEL pDCEL = new CDCEL(pCPlLt);

            pDCEL.ConstructDCEL();

            pDCEL.HalfEdgeLt.ForEach(cedge => cedge.isTraversed = false);
            List <CPolyline> OutputCPlLt = new List <CPolyline>();

            int intID = 0;

            foreach (var cedge in pDCEL.HalfEdgeLt)
            {
                if (cedge.isTraversed == true)
                {
                    continue;
                }

                var PreCptLt = new List <CPoint>();
                var SucCptLt = new List <CPoint>();
                SucCptLt.Add(cedge.ToCpt);
                GetCptLtUntilIntersection(SucCptLt, cedge.cedgeNext);
                if (SucCptLt.Count == 1 || SucCptLt.Last().GID != SucCptLt[0].GID)   //if it is not a "hole"
                {
                    PreCptLt.Add(cedge.FrCpt);
                    cedge.isTraversed           = true;
                    cedge.cedgeTwin.isTraversed = true;

                    GetCptLtUntilIntersection(PreCptLt, cedge.cedgeTwin.cedgeNext);
                }

                PreCptLt.Reverse();
                PreCptLt.AddRange(SucCptLt);
                OutputCPlLt.Add(new CPolyline(intID++, PreCptLt));
            }
            CSaveFeature.SaveCGeoEb(OutputCPlLt, esriGeometryType.esriGeometryPolyline,
                                    ParameterInitialize.pFLayerLt[0].Name + "MergeAndSplit");

            long lngEndTime = System.Environment.TickCount;//记录结束时间

            ParameterInitialize.tsslTime.Text = "Running Time: " + Convert.ToString(lngEndTime - lngStartTime) + "ms";
        }
        public void MatchAndMergePolygons()
        {
            var ParameterInitialize = _ParameterInitialize;
            var pLSCPgLt            = this.ObjCGeoLtLt[0].AsExpectedClassEb <CPolygon, CGeoBase>().ToList();
            var pSSCPgLt            = this.ObjCGeoLtLt[1].AsExpectedClassEb <CPolygon, CGeoBase>().ToList();

            long            lngStartTime          = System.Environment.TickCount;
            List <CPolygon> InterLSAttentionCPgLt = new List <CPolygon>();
            List <CPolygon> SSAttentionCPgLt      = new List <CPolygon>();

            MatchCpg(ref pLSCPgLt, ref pSSCPgLt, ref InterLSAttentionCPgLt, ref SSAttentionCPgLt);
            List <CPolygon> ResultCPgLt = MergeCpg(ref pSSCPgLt);

            CSaveFeature.SaveCGeoEb(SSAttentionCPgLt, esriGeometryType.esriGeometryPolygon,
                                    ParameterInitialize.cboLayerLt[1].Text + "_Attention");
            CSaveFeature.SaveCGeoEb(InterLSAttentionCPgLt, esriGeometryType.esriGeometryPolygon,
                                    ParameterInitialize.cboLayerLt[0].Text + "_Attention");
            CSaveFeature.SaveCGeoEb(ResultCPgLt, esriGeometryType.esriGeometryPolygon,
                                    ParameterInitialize.cboLayerLt[0].Text + "_Merged");
        }
Example #5
0
        public void UnifyDirectionsPolylines()
        {
            var ParameterInitialize = _ParameterInitialize;
            //List<CPolyline> pCPlLt = this.ObjCGeoLtLt[0].AsExpectedClassEb<CPolyline, CGeoBase>().ToList();

            List <CPolyline> LSCPlLt = this.ObjCGeoLtLt[0].AsExpectedClassEb <CPolyline, CGeoBase>().ToList();
            List <CPolyline> SSCPlLt = this.ObjCGeoLtLt[1].AsExpectedClassEb <CPolyline, CGeoBase>().ToList();

            for (int i = 0; i < LSCPlLt.Count; i++)
            {
                double dblAngleDiff = CGeoFunc.CalAngle_Counterclockwise(LSCPlLt[i].FrCpt, LSCPlLt[i].ToCpt, SSCPlLt[i].FrCpt, SSCPlLt[i].ToCpt);

                if ((Math.Abs(dblAngleDiff) > (Math.PI / 2) && Math.Abs(dblAngleDiff) < (3 * Math.PI / 2)))
                {
                    LSCPlLt[i].ReverseCpl();
                }
            }

            CSaveFeature.SaveCGeoEb(LSCPlLt, esriGeometryType.esriGeometryPolyline, ParameterInitialize.pFLayerLt[0].Name + "UnifiedDirections");
        }
Example #6
0
        public void IdentifyCorrCpgAddRegionNum()
        {
            var ParameterInitialize = _ParameterInitialize;
            var pLSCPgLt            = this.ObjCGeoLtLt[0].AsExpectedClassEb <CPolygon, CGeoBase>().ToList();
            var pSSCPgLt            = this.ObjCGeoLtLt[1].AsExpectedClassEb <CPolygon, CGeoBase>().ToList();

            long            lngStartTime     = System.Environment.TickCount;
            List <CPolygon> LSAttentionCPgLt = new List <CPolygon>();
            List <CPolygon> SSAttentionCPgLt = new List <CPolygon>();

            CMatchAndMergePolygons.MatchCpg(ref pLSCPgLt, ref pSSCPgLt, ref LSAttentionCPgLt, ref SSAttentionCPgLt);


            List <object> LSRgNumLt = new List <object>(pLSCPgLt.Count);

            LSRgNumLt.EveryElementValue(-1);
            List <object> SSRgNumLt = new List <object>(pSSCPgLt.Count);


            foreach (var sscpg in pSSCPgLt)
            {
                SSRgNumLt.Add(sscpg.ID);

                foreach (var corrcgeo in sscpg.CorrCGeoLt)
                {
                    LSRgNumLt[corrcgeo.ID] = sscpg.ID;
                }
            }

            CSaveFeature.AddFieldandAttribute(ParameterInitialize.pFLayerLt[0].FeatureClass,
                                              esriFieldType.esriFieldTypeInteger, "RegionNum", LSRgNumLt);
            CSaveFeature.AddFieldandAttribute(ParameterInitialize.pFLayerLt[1].FeatureClass,
                                              esriFieldType.esriFieldTypeInteger, "RegionNum", SSRgNumLt);



            CSaveFeature.SaveCGeoEb(SSAttentionCPgLt, esriGeometryType.esriGeometryPolygon,
                                    ParameterInitialize.cboLayerLt[1].Text + "_Attention");
            CSaveFeature.SaveCGeoEb(LSAttentionCPgLt, esriGeometryType.esriGeometryPolygon,
                                    ParameterInitialize.cboLayerLt[0].Text + "_Attention");
        }
        public void Temporary()
        {
            var ParameterInitialize = _ParameterInitialize;

            var pLSCPlLt = this.ObjCGeoLtLt[0].Select(cgeo => cgeo as CPolyline).ToList();
            //var pSSCPlLt = this.ObjCGeoLtLt[1].Select(cgeo => cgeo as CPolyline).ToList();

            var subLSCplLt = new List <CPolyline>(pLSCPlLt.Count / 2);
            var subSSCplLt = new List <CPolyline>(pLSCPlLt.Count / 2);

            int intI = 0;

            while (intI < pLSCPlLt.Count)
            {
                subLSCplLt.Add(pLSCPlLt[intI++]);
                subSSCplLt.Add(pLSCPlLt[intI++]);
            }


            CSaveFeature.SaveCGeoEb(subLSCplLt, esriGeometryType.esriGeometryPolyline, "InterSgLS_203");
            CSaveFeature.SaveCGeoEb(subSSCplLt, esriGeometryType.esriGeometryPolyline, "InterSgSS_203");
        }
        public void TopologyCheck()
        {
            var          ParameterInitialize = _ParameterInitialize;
            List <CEdge> pAllReadCEdgeLt     = _AllReadCEdgeLt;

            long lngStartTime = System.Environment.TickCount;

            double dblVerySmall = CConstants.dblVerySmallCoord;

            throw new ArgumentException("consider setting of dblverysmall!");
            for (int i = 0; i < 10; i++)
            {
                CConstants.dblVerySmallCoord = dblVerySmall / Math.Pow(10, i - 5);
                var fEdgeGrid      = new CEdgeGrid(pAllReadCEdgeLt);
                var IntersectionLt = fEdgeGrid.DetectIntersectionsOfExistingEdges(true, true, true);

                foreach (var cedge in pAllReadCEdgeLt)
                {
                    cedge.FrCpt.IntersectionLt = new List <CIntersection>();
                    cedge.ToCpt.IntersectionLt = new List <CIntersection>();

                    cedge.FrCpt.isTraversed = false;
                    cedge.ToCpt.isTraversed = false;
                }

                List <CPoint> CrossCptLt = new List <CPoint>();
                //List<CEdge> OverlapEdgeLt = new List<CEdge>();  //to save memory, we don't record overlap edges anymore, instead, we only record an end of the overlap edge
                List <CPoint> OverlapCptLt = new List <CPoint>();
                foreach (CIntersection pIntersection in IntersectionLt)
                {
                    switch (pIntersection.enumIntersectionType)
                    {
                    case CEnumIntersectionType.NoNo:
                        break;

                    case CEnumIntersectionType.FrFr:
                        pIntersection.CEdge1.FrCpt.IntersectionLt.Add(pIntersection);       //End Intersection
                        pIntersection.CEdge2.FrCpt.IntersectionLt.Add(pIntersection);       //End Intersection
                        break;

                    case CEnumIntersectionType.FrIn:
                        //CrossCptLt.AddLast(pIntersection.IntersectCpt);     //Cross
                        //pIntersection.CEdge1.FrCpt.IntersectionLt.Add(pIntersection);   //we don't want to notice this intersection twice, so we add this intersection to the vertice
                        break;

                    case CEnumIntersectionType.FrTo:
                        pIntersection.CEdge1.FrCpt.IntersectionLt.Add(pIntersection);       //End Intersection
                        pIntersection.CEdge2.ToCpt.IntersectionLt.Add(pIntersection);       //End Intersection
                        break;

                    case CEnumIntersectionType.InFr:
                        //CrossCptLt.AddLast(pIntersection.IntersectCpt);     //Cross
                        //pIntersection.CEdge2.FrCpt.IntersectionLt.Add(pIntersection);   //we don't want to notice this intersection twice, so we add this intersection to the vertice
                        break;

                    case CEnumIntersectionType.InIn:
                        CrossCptLt.Add(pIntersection.IntersectCpt);         //Cross
                        break;

                    case CEnumIntersectionType.InTo:
                        //CrossCptLt.AddLast(pIntersection.IntersectCpt);     //Cross
                        //pIntersection.CEdge2.ToCpt.IntersectionLt.Add(pIntersection);   //we don't want to notice this intersection twice, so we add this intersection to the vertice
                        break;

                    case CEnumIntersectionType.ToFr:
                        pIntersection.CEdge1.ToCpt.IntersectionLt.Add(pIntersection);       //End Intersection
                        pIntersection.CEdge2.FrCpt.IntersectionLt.Add(pIntersection);       //End Intersection
                        break;

                    case CEnumIntersectionType.ToIn:
                        //CrossCptLt.AddLast(pIntersection.IntersectCpt);     //Cross
                        //pIntersection.CEdge1.ToCpt.IntersectionLt.Add(pIntersection);   //we don't want to notice this intersection twice, so we add this intersection to the vertice
                        break;

                    case CEnumIntersectionType.ToTo:
                        pIntersection.CEdge1.ToCpt.IntersectionLt.Add(pIntersection);       //End Intersection
                        pIntersection.CEdge2.ToCpt.IntersectionLt.Add(pIntersection);       //End Intersection
                        break;

                    case CEnumIntersectionType.Overlap:
                        //OverlapEdgeLt.Add(pIntersection.OverlapCEdge);
                        OverlapCptLt.Add(pIntersection.IntersectCpt);
                        //pIntersection.OverlapCEdge.FrCpt.IntersectionLt.Add(pIntersection);   //we don't want to notice this intersection twice, so we add this intersection to the vertice
                        //pIntersection.OverlapCEdge.ToCpt.IntersectionLt.Add(pIntersection);   //we don't want to notice this intersection twice, so we add this intersection to the vertice
                        break;

                    default:
                        break;
                    }
                }
                CConstants.dblVerySmallCoord = dblVerySmall;

                List <CPoint> UnLinkedCptLt = new List <CPoint>();
                foreach (var cedge in pAllReadCEdgeLt)
                {
                    if (cedge.FrCpt.isTraversed == false && cedge.FrCpt.IntersectionLt.Count == 0)
                    {
                        UnLinkedCptLt.Add(cedge.FrCpt);
                    }

                    if (cedge.ToCpt.isTraversed == false && cedge.ToCpt.IntersectionLt.Count == 0)
                    {
                        UnLinkedCptLt.Add(cedge.ToCpt);
                    }

                    cedge.FrCpt.IntersectionLt = null;
                    cedge.ToCpt.IntersectionLt = null;

                    cedge.FrCpt.isTraversed = true;
                    cedge.ToCpt.isTraversed = true;
                }

                IntersectionLt = null;

                CSaveFeature.SaveCGeoEb(UnLinkedCptLt, esriGeometryType.esriGeometryPoint,
                                        "UnLinkedCpt_" + i.ToString() + "__" + UnLinkedCptLt.Count, blnVisible: false);
                CHelpFunc.SetAEGeometryNull(UnLinkedCptLt);

                CSaveFeature.SaveCGeoEb(CrossCptLt, esriGeometryType.esriGeometryPoint,
                                        "Crosses_" + i.ToString() + "__" + CrossCptLt.Count, blnVisible: false);
                CHelpFunc.SetAEGeometryNull(CrossCptLt);

                CSaveFeature.SaveCGeoEb(OverlapCptLt, esriGeometryType.esriGeometryPoint,
                                        "OverlapCpt_" + i.ToString() + "__" + OverlapCptLt.Count, blnVisible: false);
                CHelpFunc.SetAEGeometryNull(OverlapCptLt);
            }

            long lngEndTime = System.Environment.TickCount;                                                            //记录结束时间

            ParameterInitialize.tsslTime.Text = "Running Time: " + Convert.ToString(lngEndTime - lngStartTime) + "ms"; //显示运行时
        }