latitudeToWebMercatorFraction.js 1.2 KB

1234567891011121314151617181920212223
  1. //This file is automatically rebuilt by the Cesium build process.
  2. export default "/**\n\
  3. * Computes the fraction of a Web Wercator rectangle at which a given geodetic latitude is located.\n\
  4. *\n\
  5. * @name czm_latitudeToWebMercatorFraction\n\
  6. * @glslFunction\n\
  7. *\n\
  8. * @param {float} latitude The geodetic latitude, in radians.\n\
  9. * @param {float} southMercatorY The Web Mercator coordinate of the southern boundary of the rectangle.\n\
  10. * @param {float} oneOverMercatorHeight The total height of the rectangle in Web Mercator coordinates.\n\
  11. *\n\
  12. * @returns {float} The fraction of the rectangle at which the latitude occurs. If the latitude is the southern\n\
  13. * boundary of the rectangle, the return value will be zero. If it is the northern boundary, the return\n\
  14. * value will be 1.0. Latitudes in between are mapped according to the Web Mercator projection.\n\
  15. */ \n\
  16. float czm_latitudeToWebMercatorFraction(float latitude, float southMercatorY, float oneOverMercatorHeight)\n\
  17. {\n\
  18. float sinLatitude = sin(latitude);\n\
  19. float mercatorY = 0.5 * log((1.0 + sinLatitude) / (1.0 - sinLatitude));\n\
  20. \n\
  21. return (mercatorY - southMercatorY) * oneOverMercatorHeight;\n\
  22. }\n\
  23. ";