缩放下的坐标转换注意

     如前所述,屏幕坐标系中点的坐标与我自定义的坐标的Y值相加为显示窗口的大小,即poin.y+sy=nViewsizeY--->sy=nViewsizeY-point.y;其中sy是待求的自定义坐标值。如果加上缩放及漫游的因素,应该是先将缩放后坐标系中的点进行“反漫游”“反缩放”,所以sy=(nviewsizey-point.y-Ymove)/scalefactor;

       double sx=(point.x*1.0-Xmove)/scalefactor; //首先确定点击位置在最原始图像中的的坐标
       double sy=nViewY-point.y-Ymove)/scalefactor;//(point.y*1.0-Ymove)/scalefactor;
       double tempX=sx*nBufferX/nViewX*XResolution+X0;
       double tempY=-1.0*sy*YResolution/(nViewY/nBufferY)+Y0+YResolution*nBufferY;

为了能看懂上面的转换,特将实现从地理坐标(平面)到平面自定义坐标系中坐标地方法贴在下面了:

      for(int array_point=0;array_point<ipoints;array_point++)  //依次取出线上各点的坐标
      {
       double temx;
       temx=Arrayx[array_point];//poLine->getX(line_point_id);
       double temy;
       temy=Arrayy[array_point];//poLine->getY(line_point_id);

       double lower_left_y=Y0+YResolution*nBufferSizeY;
       (*(lpoint+array_point)).X=(temx-X0)/XResolution*(nViewsizeX/nBufferSizeX);//(temx-X0)/XResolution*(rcwidth/PWidth);
                   //遥感影像垂直分辨率为负值
       (*(lpoint+array_point)).Y=-1.0*(temy-lower_left_y)/YResolution*(nViewsizeY/nBufferSizeY);

      }
      linepath.AddLines(lpoint,ipoints);
      delete [] lpoint;
      delete [] Arrayx;
      delete [] Arrayy;

posted @ 2008-12-31 10:26  gisbingxin  阅读(1275)  评论(0编辑  收藏  举报