eqc.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. var adjust_lon = require('../common/adjust_lon');
  2. var adjust_lat = require('../common/adjust_lat');
  3. exports.init = function() {
  4. this.x0 = this.x0 || 0;
  5. this.y0 = this.y0 || 0;
  6. this.lat0 = this.lat0 || 0;
  7. this.long0 = this.long0 || 0;
  8. this.lat_ts = this.lat_ts || 0;
  9. this.title = this.title || "Equidistant Cylindrical (Plate Carre)";
  10. this.rc = Math.cos(this.lat_ts);
  11. };
  12. // 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. var dlon = adjust_lon(lon - this.long0);
  18. var dlat = adjust_lat(lat - this.lat0);
  19. p.x = this.x0 + (this.a * dlon * this.rc);
  20. p.y = this.y0 + (this.a * dlat);
  21. return p;
  22. };
  23. // inverse equations--mapping x,y to lat/long
  24. // -----------------------------------------------------------------
  25. exports.inverse = function(p) {
  26. var x = p.x;
  27. var y = p.y;
  28. p.x = adjust_lon(this.long0 + ((x - this.x0) / (this.a * this.rc)));
  29. p.y = adjust_lat(this.lat0 + ((y - this.y0) / (this.a)));
  30. return p;
  31. };
  32. exports.names = ["Equirectangular", "Equidistant_Cylindrical", "eqc"];