缩放下的坐标转换注意

     如前所述,屏幕坐标系中点的坐标与我自定义的坐标的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;

转载于:https://www.cnblogs.com/gisbingxin/archive/2008/12/31/1365895.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值