public void WarpLayer() { IGeoReference pGR = pRasterLayer as IGeoReference; if (pGR != null) { pGR.Reset(); if (OriginPoints == null || TargetPoints == null || OriginPoints.PointCount < 1 || TargetPoints.PointCount < 1) { return; } if (OriginPoints.PointCount == 1) { IPoint pt1, pt2; pt1 = OriginPoints.get_Point(0); pt2 = TargetPoints.get_Point(0); pGR.Shift(pt2.X - pt1.X, pt2.Y - pt1.Y); } else { if (OriginPoints.PointCount == 2) { pGR.TwoPointsAdjust(OriginPoints, TargetPoints); } else { pGR.Warp(OriginPoints, TargetPoints, WarpType); } TransformedOriginPoints = pGR.PointsTransform(OriginPoints, true); //RefreshWarpType(); } } }
private void button1_Click(object sender, EventArgs e) { if (FromPoint.PointCount == 0) { MessageBox.Show("请选择控制点对!"); return; } ((IGraphicsContainer)m_map).DeleteAllElements(); m_geoRef.Warp(FromPoint, ToPoint, 0); //m_geoRef.Register(); m_activeView.Refresh(); MessageBox.Show("配准完成!"); FolderBrowserDialog dlg = new FolderBrowserDialog(); if (dlg.ShowDialog() == DialogResult.OK) { m_selectPath = dlg.SelectedPath; frmW.Show(); Thread myThread; myThread = new Thread(new ThreadStart(Save)); myThread.IsBackground = true; myThread.Start(); } }
//配准但不Register private void Register() { geoReference.Reset(); if (toPoint.PointCount > 0) { if (toPoint.PointCount == 1) { geoReference.Shift(toPoint.Point[0].X - fromPoint.Point[0].X, toPoint.Point[0].Y - fromPoint.Point[0].Y); } if (toPoint.PointCount == 2) { geoReference.TwoPointsAdjust(fromPoint, toPoint); } if (toPoint.PointCount >= 3) { geoReference.Warp(fromPoint, toPoint, 1); } } axMapControl1.Refresh(); }