Exemplo n.º 1
0
        private List <CEdge> GetCareCEdgeLtCptCoincident(CPoint LSNodeCpt, CEdge SgCEdge, bool blnAllowOverlap = false)
        {
            var SmallerAxisAngleCEdge = CDCEL.FindSmallerAxisAngleCEdgebyCEdge(LSNodeCpt, SgCEdge, blnAllowOverlap);
            var CareCEdgeLt           = new List <CEdge>(1);

            if (SgCEdge.dblAxisAngle != SmallerAxisAngleCEdge.dblAxisAngle)
            {
                CareCEdgeLt.Add(SmallerAxisAngleCEdge.cedgeNext);
            }
            else
            {
                if (blnAllowOverlap == true)
                {
                    //this should be a special case where a single polyline has only one edge (SgCEdge),
                    //at the same time, this edge is used by the combined triangulation
                    CareCEdgeLt.Add(SmallerAxisAngleCEdge);
                }
                else
                {
                    throw new ArgumentException("we did not consider overlap!");
                }
            }

            return(CareCEdgeLt);
        }
Exemplo n.º 2
0
        private List <CPoint> GenerateFieldCpt(CDCEL pDCEL)
        {
            CEnvelope pEnvelope   = pDCEL.pEdgeGrid.pEnvelope;
            double    dblCellSize = pDCEL.pEdgeGrid.dblCellWidth / 3;
            int       intRow      = Convert.ToInt32(Math.Truncate(pEnvelope.Height / dblCellSize)) + 1;
            int       intCol      = Convert.ToInt32(Math.Truncate(pEnvelope.Width / dblCellSize)) + 1;

            List <CPoint> FieldCptLt = new List <CPoint>(intRow * intCol);
            double        dblX       = pEnvelope.XMin;
            double        dblY       = pEnvelope.YMin;
            int           intCount   = 0;

            for (int i = 0; i < intRow; i++)
            {
                dblX = pEnvelope.XMin;
                for (int j = 0; j < intCol; j++)
                {
                    FieldCptLt.Add(new CPoint(intCount, dblX, dblY));
                    dblX += dblCellSize;
                    intCount++;
                }
                dblY += dblCellSize;
            }

            pDCEL.DetectCloestLeftCorrectCEdge(FieldCptLt);

            return(FieldCptLt);
        }
Exemplo n.º 3
0
        private CPolygon DetectFaceForSg(CPolyline SgCpl, CDCEL pInterLSDCEL)
        {
            var identitycpt = CGeoFunc.GetInbetweenCpt(SgCpl.CptLt[0], SgCpl.CptLt[1], 0.5);

            //comparing to the method which traverses along DCEL, this method only needs to detect the face once
            return(pInterLSDCEL.DetectCloestLeftCorrectCEdge(identitycpt).cpgIncidentFace);
        }
        public void GetCptLtUntilIntersection(List <CPoint> CptLt, CEdge cedge)
        {
            //var CptLt = new List<CPoint>();


            var CurrentCEdge = cedge;

            //CurrentCEdge.isTraversed == false is useful when it is a "hole"
            while (CDCEL.IsVertexIntersection(CurrentCEdge.FrCpt) == false && CurrentCEdge.isTraversed == false)
            {
                CptLt.Add(CurrentCEdge.ToCpt);
                CurrentCEdge.isTraversed           = true;
                CurrentCEdge.cedgeTwin.isTraversed = true;

                CurrentCEdge = CurrentCEdge.cedgeNext;
            }


            //do
            //{
            //    CptLt.Add(CurrentCEdge.ToCpt);
            //    CurrentCEdge.isTraversed = true;
            //    CurrentCEdge.cedgeTwin.isTraversed = true;

            //    CurrentCEdge = CurrentCEdge.cedgeNext;
            //} while (CDCEL.IsVertexIntersection(CurrentCEdge.FrCpt) == false);

            //return CptLt;
        }
Exemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <remarks>construct DCEL for InterLSCPlLt, and set the two face numbers for every Cpl.
        /// since InterSSCPlLt are stored with the same order as InterLSCPlLt,
        /// we also set the same faces numbers for every Cpl from InterSSCPlLt for a SgCpl,
        /// we get a point on it and test in which face this point is</remarks>
        public void IdentifyAddFaceNumber()
        {
            CParameterInitialize pParameterInitialize = _ParameterInitialize;

            _intInterLS = 0;
            _intInterSS = 1;
            _intSg      = 2;


            List <CPolyline> pInterLSCPlLt = this.ObjCGeoLtLt[_intInterLS].AsExpectedClassEb <CPolyline, CGeoBase>().ToList();
            List <CPolyline> pSgCPlLt      = this.ObjCGeoLtLt[_intSg].AsExpectedClassEb <CPolyline, CGeoBase>().ToList();

            CDCEL pInterLSDCEL = new CDCEL(pInterLSCPlLt);

            pInterLSDCEL.ConstructDCEL();

            List <object> InterLSobjlt1 = new List <object>(pInterLSCPlLt.Count);
            List <object> InterLSobjlt2 = new List <object>(pInterLSCPlLt.Count);

            for (int i = 0; i < pInterLSCPlLt.Count; i++)
            {
                int indexID1 = pInterLSCPlLt[i].CEdgeLt[0].cpgIncidentFace.indexID;
                int indexID2 = pInterLSCPlLt[i].CEdgeLt[0].cedgeTwin.cpgIncidentFace.indexID;

                //we store the smaller index at "FaceNum_1", and store the larger index at "FaceNum_2"
                int intSmallerindexID;
                int intLargerindexID;
                CHelpFunc.CompareAndOrder(indexID1, indexID2, ID => ID, out intSmallerindexID, out intLargerindexID);

                InterLSobjlt1.Add(intSmallerindexID);
                InterLSobjlt2.Add(intLargerindexID);
            }

            //it should be true that a polyline of pInterSSCPlLt has the same indices of faces
            //as the corresponding polyline of pInterLSCPlLt does
            CSaveFeature.AddFieldandAttribute(pParameterInitialize.pFLayerLt[_intInterLS].FeatureClass,
                                              esriFieldType.esriFieldTypeInteger, "FaceNum1", InterLSobjlt1);
            CSaveFeature.AddFieldandAttribute(pParameterInitialize.pFLayerLt[_intInterLS].FeatureClass,
                                              esriFieldType.esriFieldTypeInteger, "FaceNum2", InterLSobjlt2);
            CSaveFeature.AddFieldandAttribute(pParameterInitialize.pFLayerLt[_intInterSS].FeatureClass,
                                              esriFieldType.esriFieldTypeInteger, "FaceNum1", InterLSobjlt1);
            CSaveFeature.AddFieldandAttribute(pParameterInitialize.pFLayerLt[_intInterSS].FeatureClass,
                                              esriFieldType.esriFieldTypeInteger, "FaceNum2", InterLSobjlt2);


            List <object> Sgobjlt = new List <object>(pSgCPlLt.Count);

            for (int i = 0; i < pSgCPlLt.Count; i++)
            {
                Sgobjlt.Add(DetectFaceForSg(pSgCPlLt[i], pInterLSDCEL).indexID);
            }
            CSaveFeature.AddFieldandAttribute(pParameterInitialize.pFLayerLt[_intSg].FeatureClass,
                                              esriFieldType.esriFieldTypeInteger, "FaceNum", Sgobjlt);
        }
        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";
        }
Exemplo n.º 7
0
        /// <summary>
        /// Transform interior polylines in one province
        /// </summary>
        /// <param name="pParameterInitialize"></param>
        /// <param name="InterLSIplLt"></param>
        /// <param name="InterSSIplLt"></param>
        /// <param name="SgIplLt"></param>
        /// <returns></returns>
        /// <remarks>InterLSIplLt and InterSSIplLt can be clockwise of counterclockwise.
        /// we will construct DCEL, in which the directions will be counterclockwise.
        /// InterLSIplLt and InterSSIplLt should have the same direction and the corresponding start points</remarks>
        private List <CPolyline> CTTransform(List <IPolyline5> InterLSIplLt, List <IPolyline5> InterSSIplLt,
                                             List <IPolyline5> SgIplLt, bool blnMaxCommonChords = true)
        {
            CConstants.dblVerySmallCoord /= 10;  //this assignment should equal to _dblVerySmallDenominator = 10000000


            var InterLSCplLt = CHelpFunc.GenerateCGeoEbAccordingToGeoEb <CPolyline>(InterLSIplLt).ToList();
            var InterSSCplLt = CHelpFunc.GenerateCGeoEbAccordingToGeoEb <CPolyline>(InterSSIplLt).ToList();
            var SgCplEb      = CHelpFunc.GenerateCGeoEbAccordingToGeoEb <CPolyline>(SgIplLt);

            //there are only two faces: the super face and a normal face. Face *.FaceCpgLt[1] is the normal face
            var pInterLSDCEL = new CDCEL(InterLSCplLt);

            pInterLSDCEL.ConstructDCEL();
            pInterLSDCEL.FaceCpgLt[1].SetOuterFaceCptlt(false, true, InterLSCplLt[0].CptLt[0]);

            //there are only two faces: the super face and a normal face. Face *.FaceCpgLt[1] is the normal face
            var pInterSSDCEL = new CDCEL(InterSSCplLt);

            pInterSSDCEL.ConstructDCEL();
            pInterSSDCEL.FaceCpgLt[1].SetOuterFaceCptlt(false, true, InterSSCplLt[0].CptLt[0]);

            //we maintaine this SD so that for a point from single polyline,
            //we can know whether this single point overlaps a point of a larger-scale polyline
            var pInterLSCptSD = pInterLSDCEL.FaceCpgLt[1].CptLt.ToSD(cpt => cpt, new CCmpCptYX_VerySmall());


            var pCptbCtgl = new CCptbCtgl(pInterLSDCEL.FaceCpgLt[1], pInterSSDCEL.FaceCpgLt[1],
                                          blnMaxCommonChords, _blnSave);

            pCptbCtgl.ConstructCcptbCtgl();
            var TransSgCPlLt = new List <CPolyline>(SgIplLt.Count);

            foreach (var SgCpl in SgCplEb)
            {
                TransSgCPlLt.Add(GenerateCorrSgCpl(pCptbCtgl, SgCpl, pInterLSCptSD));
            }

            CConstants.dblVerySmallCoord *= 10;
            return(TransSgCPlLt);
        }