public List <CCorrSegment> UnifyIndices(ref List <CPolyline> pLSCPlLt, ref List <CPolyline> pSSCPlLt, ref List <CPolyline> LSAttentionCPlLt, ref List <CPolyline> SSAttentionCPlLt) { foreach (var lscpl in pLSCPlLt) { if (lscpl.CorrCGeoLt.Count != 1) { LSAttentionCPlLt.Add(lscpl); } } foreach (var sscpl in pSSCPlLt) { if (sscpl.CorrCGeoLt.Count != 1) { SSAttentionCPlLt.Add(sscpl); } } List <CCorrSegment> pCorrCplLt = new List <CCorrSegment>(pSSCPlLt.Count); foreach (var sscpl in pSSCPlLt) { if (sscpl.CorrCGeoLt.Count == 1 && sscpl.CorrCGeoLt[0].CorrCGeoLt.Count == 1) { CCorrSegment pCorrCpl = new CCorrSegment(sscpl.CorrCGeoLt[0] as CPolyline, sscpl); pCorrCplLt.Add(pCorrCpl); } } return(pCorrCplLt); }
public List <CCorrSegment> UnionLSCPl(ref List <CPolyline> pSSCPlLt, ref List <CPolyline> LSAttentionCPlLt, ref List <CPolyline> SSAttentionCPlLt) { for (int i = 0; i < pSSCPlLt.Count; i++) { pSSCPlLt[i].SetBaseLine(true); if (pSSCPlLt[i].CorrCGeoLt.Count == 0) //if a Smaller-scale polyline doesn't have any correspondecnes, we have to care about it { SSAttentionCPlLt.Add(pSSCPlLt[i]); } else //the codes here can be improved, using a SortedSet { //merge larger-scale polylines according to smaller-scale polylines List <CPolyline> CorrCPlLt = new List <CPolyline>(); CorrCPlLt.AddRange(pSSCPlLt[i].CorrCGeoLt as IEnumerable <CPolyline>); CPolyline pUnionPolyline = CorrCPlLt[0].CopyCpl(); CorrCPlLt.RemoveAt(0); bool isSuccessful = true; while (CorrCPlLt.Count > 0) { bool isUnioned = false; for (int j = 0; j < CorrCPlLt.Count; j++) { pUnionPolyline.UnionCpl(CorrCPlLt[j], ref isUnioned); if (isUnioned == true) { CorrCPlLt.RemoveAt(j); break; } } if (isUnioned == false) { isSuccessful = false; break; } } pUnionPolyline.SetBaseLine(true); var LSFrX = pUnionPolyline.FrCpt.X; var LSFrY = pUnionPolyline.FrCpt.Y; var LSToX = pUnionPolyline.ToCpt.X; var LSToY = pUnionPolyline.ToCpt.Y; var SSFrX = pSSCPlLt[i].FrCpt.X; var SSFrY = pSSCPlLt[i].FrCpt.Y; var SSToX = pSSCPlLt[i].ToCpt.X; var SSToY = pSSCPlLt[i].ToCpt.Y; //judge whether the two polylines are really corresponding polylines double dblRatio = pUnionPolyline.pBaseLine.dblLength / pSSCPlLt[i].pBaseLine.dblLength; if (dblRatio < CConstants.dblLowerBoundLoose || dblRatio > CConstants.dblUpperBoundLoose) { isSuccessful = false; } if (isSuccessful == false) { LSAttentionCPlLt.AddRange(pSSCPlLt[i].CorrCGeoLt as IEnumerable <CPolyline>); SSAttentionCPlLt.Add(pSSCPlLt[i]); } else { pSSCPlLt[i].CorrCGeo = pUnionPolyline; } } } //ReverseCpl //double dblFrDiffX = LSCPlLt[i].pBaseLine.ToCpt.X - LSCPlLt[i].pBaseLine.FrCpt.X; //double dblFrDiffY = LSCPlLt[i].pBaseLine.ToCpt.Y - LSCPlLt[i].pBaseLine.FrCpt.Y; //double dblToDiffX = SSCPlLt[i].pBaseLine.ToCpt.X - SSCPlLt[i].pBaseLine.FrCpt.X; //double dblToDiffY = SSCPlLt[i].pBaseLine.ToCpt.Y - SSCPlLt[i].pBaseLine.FrCpt.Y; //double dblAngleDiff = CGeoFunc.CalAngle_Counterclockwise(dblFrDiffX, dblFrDiffY, dblToDiffX, dblToDiffY); //if ((Math.Abs(dblAngleDiff) > (Math.PI / 2) && Math.Abs(dblAngleDiff) < (3 * Math.PI / 2))) //{ // SSCPlLt[i].ReverseCpl(); // SSCPlLt[i].SetBaseLine(); //} List <CCorrSegment> pCorrCplLt = new List <CCorrSegment>(pSSCPlLt.Count); for (int i = 0; i < pSSCPlLt.Count; i++) { if (pSSCPlLt[i].CorrCGeo != null && pSSCPlLt[i] != null) { CCorrSegment pCorrCpl = new CCorrSegment(pSSCPlLt[i].CorrCGeo as CPolyline, pSSCPlLt[i]); pCorrCplLt.Add(pCorrCpl); } } return(pCorrCplLt); }