mill.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import adjust_lon from '../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. export function init() {
  10. //no-op
  11. }
  12. /* Miller Cylindrical forward equations--mapping lat,long to x,y
  13. ------------------------------------------------------------*/
  14. export function forward(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. export function inverse(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. export var names = ["Miller_Cylindrical", "mill"];
  38. export default {
  39. init: init,
  40. forward: forward,
  41. inverse: inverse,
  42. names: names
  43. };