圆柱投影 - 如何从 tangens(纬度)获取 y 图像坐标



我需要实现从具有高数据的地理坐标到图像的转换。

就像 http://mathworld.wolfram.com/CylindricalProjection.html 中所述的那样。

我根本不知道如何创建合适的 y 值......

例如:

   double longitude   = -180; // (λ)   
   double latitude    =  80;  // (φ)   
   int mapHeight   = 360;   
   int mapWidth    = 720;   
   x = (int)((longitude+180.0)*(mapWidth/360.0)); 

如何使用

 Math.tan(Math.toRadians(latitude))  

谢谢!

不能使用圆柱投影表示极点。所以你需要设置一个最大纬度并存储它(比如说double maxlat=3.1415/2.0)。要获得y,首先,测试该点是否不接近极点,然后计算:

  y=(int)(mapHeight/2+mapHeight/2*Math.tan(Math.toRadians(latitude)) /Math.tan(Math.toRadians(maxlat))) ;

如果您正在寻找精美的地图,请考虑使用 墨卡托投影 :

 y=(int)(mapHeight/2+mapHeight/2*Math.log(Math.tan(Math.toRadians(latitude)/2.0+M_PI/4.0)) /Math.log(Math.tan(Math.toRadians(maxlat)/2.0+M_PI/4.0))) ;

如果需要计算多个点,则存储Math.tan(Math.toRadians(maxlat))math.log(Math.tan(Math.toRadians(maxlat)/2.0+M_PI/4.0))

最新更新