[MetaCRS] Re: Adding Projection Classes to Proj4js
Richard Marsden
winwaed at gmail.com
Sat Jul 25 12:25:03 EDT 2009
Further to last night's email, I now have an implementation of the cea
"Cylindrical Equal Area" projection working. However it currently assumes a
sphere.
I believe I have the forward transform working for an ellipsoid (see below).
Does this look correct? I try to calculate the Earth's radius at the
coord's latitude and use this for calculating the y ordinate. This is not
applied to the x ordinate because this would break the "cylindrical" nature
of the projection.
(I notice that many of the projections marked as untested, assume a
spherical Earth)
Personally I don't need the inverse transform, but I'm also not sure how to
apply the ellipsoid correction to the inverse transform.
I know the efficiency of the following code can be improved - eg.
cos(lat_ts) could be cached in the initialisation function.
Richard
-------------------------------
/* Cylindrical Equal Area forward equations--mapping lat,long to x,y
------------------------------------------------------------*/
forward: function(p) {
var lon=p.x;
var lat=p.y;
/* Forward equations
-----------------*/
dlon = Proj4js.common.adjust_lon(lon - this.long0);
var x,y;
if (this.sphere)
{
x = this.x0 + this.a * dlon * Math.cos(this.lat_ts);
y = this.y0 + this.a * Math.sin(lat) / Math.cos(this.lat_ts);
}
else
{ // Radius at this latitude
var Sin_Lat = Math.sin(lat);
var Rn = this.a * (Math.sqrt(1.0e0 - this.es * Sin_Lat*Sin_Lat));
x = this.x0 + this.a * dlon * Math.cos(this.lat_ts);
y = this.y0 + Rn * Math.sin(lat) / Math.cos(this.lat_ts);
}
p.x=x;
p.y=y;
return p;
},//ceaFwd()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/metacrs/attachments/20090725/d8c5eae2/attachment.html
More information about the MetaCRS
mailing list