Exemple #1
0
        private void btnStatistic_Click(object sender, EventArgs e)
        {
            double        dblProp     = 0;
            List <double> dbllt       = new List <double>();
            List <CPoint> CResultPtLt = _DataRecords.ParameterResult.CResultPtLt;

            for (int i = 0; i <= 100; i++)
            {
                CPolyline cpl = CGeoFunc.GetTargetcpl(CResultPtLt, dblProp);
                dbllt.Add(cpl.pPolyline.Length);
                dblProp = dblProp + 0.01;
            }

            CHelpFuncExcel.ExportDataltToExcel(dbllt, "Length", _DataRecords.ParameterInitialize.strSavePath);
            //if (dblProp < 0 || dblProp > 1)
            //{
            //    MessageBox.Show("请输入正确参数!");
            //    return null;
            //}
            //List<CPoint> CResultPtLt = pDataRecords.ParameterResult.CResultPtLt;
            //CPolyline cpl = this.CGeoFunc.GetTargetcpl(CResultPtLt, dblProp);

            //// 清除绘画痕迹
            //IMapControl4 m_mapControl = pDataRecords.ParameterInitialize.m_mapControl;
            //IGraphicsContainer pGra = m_mapControl.Map as IGraphicsContainer;
            //pGra.DeleteAllElements();
            //m_mapControl.ActiveView.Refresh();
            //this.ViewPolyline(m_mapControl, cpl);  //显示生成的线段
            //return cpl;
        }
Exemple #2
0
        private void btnstatisticEX_Click(object sender, EventArgs e)
        {
            double        dblProp     = -1;
            List <double> dbllt       = new List <double>();
            List <CPoint> CResultPtLt = _DataRecords.ParameterResult.CResultPtLt;

            for (int i = 0; i <= 300; i++)
            {
                CPolyline cpl = CGeoFunc.GetTargetcpl(CResultPtLt, dblProp);
                dbllt.Add(cpl.pPolyline.Length);
                dblProp = dblProp + 0.01;
            }

            CHelpFuncExcel.ExportDataltToExcel(dbllt, "Length", _DataRecords.ParameterInitialize.strSavePath);
        }
        /// <summary>多个结果的Morphing方法</summary>
        /// <remarks>对于指定的回溯参数K,不断计算增大的结果,直到Translation值稳定</remarks>
        public CParameterResult OptCorMorphing()
        {
            var pParameterInitialize = _ParameterInitialize;

            var pFrCptLtLt      = this.FrCptLtLt;
            var pToCptLtLt      = this.ToCptLtLt;
            var pObjValueLtLtLt = this.ObjValueLtLtLt;

            //var intFieldIndex = pParameterInitialize.pFLayerLt[0].FeatureClass.FindField(pParameterInitialize.txtAttributeOfKnown.Text);
            //try to add an attribute, if this attribute is already existed, then do nothing, otherwise, add this attribute and set value to -1
            //if (intFieldIndex == -1)
            //{
            //    intFieldIndex = CSaveFeature.AddField(pParameterInitialize.pFLayerLt[0].FeatureClass,
            //      esriFieldType.esriFieldTypeDouble, pParameterInitialize.txtAttributeOfKnown.Text);
            //    //CSaveFeature.SetFieldValue(pParameterInitialize.pFLayerLt[0].FeatureClass, intFieldIndex, -1);

            //    this.strFieldNameLtLt[0].Add(pParameterInitialize.txtAttributeOfKnown.Text);
            //    this.esriFieldTypeLtLt[0].Add(esriFieldType.esriFieldTypeDouble);

            //    for (int i = 0; i < pFrCptLtLt.Count; i++)
            //    {
            //        pObjValueLtLtLt[0][i].Add(0);
            //    }
            //}


            int intMaxBackKforI = Convert.ToInt32(pParameterInitialize.txtMaxBackK.Text);
            int intMaxBackKforJ = SetintMaxBackKforJ(pParameterInitialize.cboIntMaxBackKforJ.SelectedIndex, intMaxBackKforI);
            int intMulti        = Convert.ToInt32(pParameterInitialize.txtMulti.Text);
            int intIncrease     = Convert.ToInt32(pParameterInitialize.txtIncrease.Text);

            CConstants.strMethod = pParameterInitialize.cboMorphingMethod.Text;

            //delegation of morphing method
            DlgCreateTable dlgCreateTable = SetDlgCreateTable(pParameterInitialize.cboMorphingMethod.Text);

            _pEvaluation = new CEvaluation(pParameterInitialize.cboEvaluationMethod.SelectedIndex);
            var StandardVectorCpt = SetStandardVectorCpt(pParameterInitialize.cboStandardVector.SelectedIndex,
                                                         pFrCptLtLt[0].First(), pToCptLtLt[0].First());

            long lngStartTime1 = System.Environment.TickCount;  //lngTime1

            Stopwatch pStopwatch1 = Stopwatch.StartNew();

            foreach (var cptlt in pFrCptLtLt)
            {
                CGeoFunc.SetEdgeLengthOnToCpt(cptlt);
            }
            foreach (var cptlt in pToCptLtLt)
            {
                CGeoFunc.SetEdgeLengthOnToCpt(cptlt);
            }
            CGeoFunc.IntegrateStandardVectorCpt(pFrCptLtLt, StandardVectorCpt);

            //generate cptltltlt
            var frcptltltlt = new List <List <List <CPoint> > >(pFrCptLtLt.Count);
            var tocptltltlt = new List <List <List <CPoint> > >(pToCptLtLt.Count);

            SetCptLtLtLt(pParameterInitialize.chkCoincidentPoints.Checked, pFrCptLtLt, pToCptLtLt, ref frcptltltlt, ref tocptltltlt);
            pStopwatch1.Stop();


            long lngTimeSetLength = System.Environment.TickCount - lngStartTime1;  //lngTime1

            var dblDistanceLt = new List <double>(intMulti);
            var dblTimeLt     = new List <double>(intMulti);

            var pCorrCptsLtLt = new List <List <CCorrCpts> >(pFrCptLtLt.Count);  //we only record the last one, when i = intMulti -1
            var pCtrlCptsLtLt = new List <List <CCorrCpts> >(pToCptLtLt.Count);  //we only record the last one, when i = intMulti -1


            for (int i = 0; i < intMulti; i++)
            {
                //Stopwatch pStopwatch2 = Stopwatch.StartNew();
                double dblTotalDistance   = 0;
                long   lngTotalOptCorTime = 0;

                IFeatureCursor pFeatureCursor = pParameterInitialize.pFLayerLt[0].FeatureClass.Search(null, false);
                for (int j = 0; j < pFrCptLtLt.Count; j++)   //for every polyline
                //for (int j = 0; j < 100; j++)
                {
                    Stopwatch pStopwatch2 = Stopwatch.StartNew();
                    double    dblDistance = 0;
                    //double dblComputedDis = Convert.ToDouble(pObjValueLtLtLt[0][j][intFieldIndex]);
                    double dblComputedDis = 0;
                    if (dblComputedDis > 0 && intMaxBackKforI >= (pFrCptLtLt[j].Count - 1) && intMaxBackKforJ >= (pToCptLtLt[j].Count - 1))
                    {
                        dblDistance = dblComputedDis;
                    }
                    else
                    {
                        var frcptltlt = frcptltltlt[j];   //cptltlt are all the points of a polyline
                        var tocptltlt = tocptltltlt[j];

                        var TableLt = new List <CTable>(frcptltlt.Count);

                        Console.WriteLine("intMulti= " + i + ",  Line ID:" + j);

                        for (int k = 0; k < frcptltlt.Count; k++)
                        {
                            //Console.WriteLine("intMulti= " + i + ",  Line ID:" + j + ",  Segment ID:" + k);
                            var Table = dlgCreateTable(frcptltlt[k], tocptltlt[k], intMaxBackKforI, intMaxBackKforJ);
                            dblDistance += Table.dblCost;

                            //Console.WriteLine("cost:  " + dblDistance);
                            TableLt.Add(Table);
                        }
                        dblDistance /= _pEvaluation.dblCorrection;

                        pStopwatch2.Stop();
                        lngTotalOptCorTime += pStopwatch2.ElapsedMilliseconds;

                        CGeoFunc.RemoveStandardVectorCpt(pFrCptLtLt [j], StandardVectorCpt);
                        List <CCorrCpts> CtrlCptsLt;
                        var pCorrCptsLt = GetCorrespondences(TableLt, frcptltlt,
                                                             tocptltlt, pFrCptLtLt[j].Count, pToCptLtLt[j].Count, out CtrlCptsLt);
                        pCorrCptsLtLt.Add(pCorrCptsLt);
                        pCtrlCptsLtLt.Add(CtrlCptsLt);

                        //this will also set MoveVector for CtrlCptsLt
                        //CsfInter0.SaveIGeoEbToLayer(CHelpFunc.MakeEb(1, GenerateInterpolatedIPl(pCorrCptsLt, 0)));
                        //CsfInter1.SaveIGeoEbToLayer(CHelpFunc.MakeEb(1, GenerateInterpolatedIPl(pCorrCptsLt, 1)));
                        //CsfCtrlpl.SaveIGeoEbToLayer(GenerateCorrIPlEb(CtrlCptsLt));
                        //CsfCorrpl.SaveIGeoEbToLayer(GenerateCorrIPlEb(pCorrCptsLt));
                        CHelpFunc.SetMoveVectorForCorrCptsLt(pCorrCptsLt);

                        //if the look-back parameter is larger than the points number of a pair of polylines,
                        //than we don't need to try a larger look-back parameter
                        //Therefore, we record the distance for the two polylines
                        //if (intMaxBackKforI >= (pFrCptLtLt[j].Count - 1) && intMaxBackKforJ >= (pToCptLtLt[j].Count - 1))
                        //{
                        //    pObjValueLtLtLt[0][j][intFieldIndex] = dblDistance;
                        //    for (int l = intFeatureNum; l < pFrCptLtLt.Count; l++)  //find the feature and record it
                        //    {
                        //        IFeature pFeature = pFeatureCursor.NextFeature();
                        //        if (j == l)
                        //        {
                        //            pFeature.set_Value(intFieldIndex, dblDistance);
                        //            pFeature.Store();
                        //            intFeatureNum = j + 1;  //we record the index, so that next time we can start from this index
                        //            break;
                        //        }
                        //    }
                        //}
                        //pExcelSaver.WriteLine(CHelpFunc.MakeEb<object>(5, j,
                        //pLSCPlLt[j].CptLt.Count, pSSCPlLt[j].CptLt.Count, dblDistance, pStopwatch2.ElapsedMilliseconds));
                    }
                    dblTotalDistance += dblDistance;
                }

                dblTimeLt.Add(pStopwatch1.ElapsedMilliseconds + lngTotalOptCorTime);
                dblDistanceLt.Add(dblTotalDistance);
                //pExcelSaver.Close ();
                //CHelpFuncExcel.ExportDataltltToExcel(tablevalueltlt, intMaxBackKforI + "Tableltlt0", pParameterInitialize.strSavePath);
                //保存对应线
                CHelpFuncExcel.ExportDataltToExcel(dblTimeLt, intMaxBackKforI + "Timelt0", pParameterInitialize.strSavePath);
                CHelpFuncExcel.ExportDataltToExcel(dblDistanceLt, intMaxBackKforI + "Distancelt0", pParameterInitialize.strSavePath);

                CHelpFunc.Displaytspb(i + 1, intMulti);
                pParameterInitialize.txtEvaluation.Text = dblDistanceLt.Last().ToString();
                pParameterInitialize.tsslTime.Text      = "Running Time: " + dblTimeLt.Last().ToString();

                intMaxBackKforI = intMaxBackKforI + intIncrease;
                _CorrCptsLtLt   = pCorrCptsLtLt;
            }


            double dblStandardLength = CGeoFunc.CalDis(0, 0, StandardVectorCpt.X, StandardVectorCpt.Y);

            intMaxBackKforI--;
            CHelpFunc.SaveCtrlLine(pCtrlCptsLtLt, intMaxBackKforI + "_" + CConstants.strMethod + "CtrlLine",
                                   dblStandardLength, pParameterInitialize.pWorkspace, pParameterInitialize.m_mapControl);
            CHelpFunc.SaveCorrLine(pCorrCptsLtLt, intMaxBackKforI + "_" + CConstants.strMethod + "CorrLine",
                                   pParameterInitialize.pWorkspace, pParameterInitialize.m_mapControl);

            CHelpFunc.SetMoveVectorForCorrCptsLtLt(_CorrCptsLtLt);

            //the results will be recorded in _ParameterResult
            CParameterResult ParameterResult = new CParameterResult();

            ParameterResult.pMorphingBaseCpl = this as CMorphingBaseCpl;
            ParameterResult.pMorphingBase    = this as CMorphingBase;
            _ParameterResult = ParameterResult;
            return(ParameterResult);
        }