1 /*******************************************************************************
\r
4 PURPOSE: Transforms input longitude and latitude to Easting and
\r
5 Northing for the MOllweide projection. The
\r
6 longitude and latitude must be in radians. The Easting
\r
7 and Northing values will be returned in meters.
\r
11 D. Steinwand, EROS May, 1991; Updated Sept, 1992; Updated Feb, 1993
\r
12 S. Nelson, EDC Jun, 2993; Made corrections in precision and
\r
13 number of iterations.
\r
15 ALGORITHM REFERENCES
\r
17 1. Snyder, John P. and Voxland, Philip M., "An Album of Map Projections",
\r
18 U.S. Geological Survey Professional Paper 1453 , United State Government
\r
19 Printing Office, Washington D.C., 1989.
\r
21 2. Snyder, John P., "Map Projections--A Working Manual", U.S. Geological
\r
22 Survey Professional Paper 1395 (Supersedes USGS Bulletin 1532), United
\r
23 State Government Printing Office, Washington D.C., 1987.
\r
24 *******************************************************************************/
\r
27 package com.gradoservice.proj4as.proj
\r
29 import com.gradoservice.proj4as.ProjPoint;
\r
30 import com.gradoservice.proj4as.ProjConstants;
\r
31 import com.gradoservice.proj4as.Datum;
\r
33 public class ProjMoll extends AbstractProjProjection
\r
35 public function ProjMoll(data:ProjParams)
\r
40 override public function init():void
\r
45 /* Mollweide forward equations--mapping lat,long to x,y
\r
46 ----------------------------------------------------*/
\r
47 override public function forward(p:ProjPoint):ProjPoint
\r
49 /* Forward equations
\r
54 var delta_lon:Number = ProjConstants.adjust_lon(lon - this.long0);
\r
55 var theta:Number = lat;
\r
56 var con:Number = ProjConstants.PI * Math.sin(lat);
\r
58 /* Iterate using the Newton-Raphson method to find theta
\r
59 -----------------------------------------------------*/
\r
60 for (var i:int=0;;i++) {
\r
61 var delta_theta:Number = -(theta + Math.sin(theta) - con)/ (1.0 + Math.cos(theta));
\r
62 theta += delta_theta;
\r
63 if (Math.abs(delta_theta) < ProjConstants.EPSLN) break;
\r
65 trace("moll:Fwd:IterationError");
\r
71 /* If the latitude is 90 deg, force the x coordinate to be "0 + false easting"
\r
72 this is done here because of precision problems with "cos(theta)"
\r
73 --------------------------------------------------------------------------*/
\r
74 if (ProjConstants.PI/2 - Math.abs(lat) < ProjConstants.EPSLN) delta_lon =0;
\r
75 var x:Number = 0.900316316158 * this.a * delta_lon * Math.cos(theta) + this.x0;
\r
76 var y:Number = 1.4142135623731 * this.a * Math.sin(theta) + this.y0;
\r
83 override public function inverse(p:ProjPoint):ProjPoint
\r
88 /* Inverse equations
\r
92 arg = p.y / (1.4142135623731 * this.a);
\r
94 /* Because of division by zero problems, 'arg' can not be 1.0. Therefore
\r
95 a number very close to one is used instead.
\r
96 -------------------------------------------------------------------*/
\r
97 if(Math.abs(arg) > 0.999999999999) arg=0.999999999999;
\r
98 theta =Math.asin(arg);
\r
99 var lon:Number = ProjConstants.adjust_lon(this.long0 + (p.x / (0.900316316158 * this.a * Math.cos(theta))));
\r
100 if(lon < (-ProjConstants.PI)) lon= -ProjConstants.PI;
\r
101 if(lon > ProjConstants.PI) lon= ProjConstants.PI;
\r
102 arg = (2.0 * theta + Math.sin(2.0 * theta)) / ProjConstants.PI;
\r
103 if(Math.abs(arg) > 1.0)arg=1.0;
\r
104 var lat:Number = Math.asin(arg);
\r