mill.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. var adjust_lon = require('../common/adjust_lon');
  2. /*
  3. reference
  4. "New Equal-Area Map Projections for Noncircular Regions", John P. Snyder,
  5. The American Cartographer, Vol 15, No. 4, October 1988, pp. 341-355.
  6. */
  7. /* Initialize the Miller Cylindrical projection
  8. -------------------------------------------*/
  9. exports.init = function() {
  10. //no-op
  11. };
  12. /* Miller Cylindrical forward equations--mapping lat,long to x,y
  13. ------------------------------------------------------------*/
  14. exports.forward = function(p) {
  15. var lon = p.x;
  16. var lat = p.y;
  17. /* Forward equations
  18. -----------------*/
  19. var dlon = adjust_lon(lon - this.long0);
  20. var x = this.x0 + this.a * dlon;
  21. var y = this.y0 + this.a * Math.log(Math.tan((Math.PI / 4) + (lat / 2.5))) * 1.25;
  22. p.x = x;
  23. p.y = y;
  24. return p;
  25. };
  26. /* Miller Cylindrical inverse equations--mapping x,y to lat/long
  27. ------------------------------------------------------------*/
  28. exports.inverse = function(p) {
  29. p.x -= this.x0;
  30. p.y -= this.y0;
  31. var lon = adjust_lon(this.long0 + p.x / this.a);
  32. var lat = 2.5 * (Math.atan(Math.exp(0.8 * p.y / this.a)) - Math.PI / 4);
  33. p.x = lon;
  34. p.y = lat;
  35. return p;
  36. };
  37. exports.names = ["Miller_Cylindrical", "mill"];