Understand shapefiles in different projections (notably OSGB)
[potlatch2.git] / com / gradoservice / proj4as / proj / ProjMill.as
1 /*******************************************************************************\r
2 NAME                    MILLER CYLINDRICAL \r
3 \r
4 PURPOSE:        Transforms input longitude and latitude to Easting and\r
5                 Northing for the Miller Cylindrical projection.  The\r
6                 longitude and latitude must be in radians.  The Easting\r
7                 and Northing values will be returned in meters.\r
8 \r
9 PROGRAMMER              DATE            \r
10 ----------              ----           \r
11 T. Mittan               March, 1993\r
12 \r
13 This function was adapted from the Lambert Azimuthal Equal Area projection\r
14 code (FORTRAN) in the General Cartographic Transformation Package software\r
15 which is available from the U.S. Geological Survey National Mapping Division.\r
16  \r
17 ALGORITHM REFERENCES\r
18 \r
19 1.  "New Equal-Area Map Projections for Noncircular Regions", John P. Snyder,\r
20     The American Cartographer, Vol 15, No. 4, October 1988, pp. 341-355.\r
21 \r
22 2.  Snyder, John P., "Map Projections--A Working Manual", U.S. Geological\r
23     Survey Professional Paper 1395 (Supersedes USGS Bulletin 1532), United\r
24     State Government Printing Office, Washington D.C., 1987.\r
25 \r
26 3.  "Software Documentation for GCTP General Cartographic Transformation\r
27     Package", U.S. Geological Survey National Mapping Division, May 1982.\r
28 *******************************************************************************/\r
29 \r
30 \r
31 package com.gradoservice.proj4as.proj\r
32 {\r
33         import com.gradoservice.proj4as.ProjPoint;\r
34         import com.gradoservice.proj4as.ProjConstants;\r
35         import com.gradoservice.proj4as.Datum;\r
36                 \r
37         public class ProjMill extends AbstractProjProjection\r
38         {\r
39                 public function ProjMill(data:ProjParams)\r
40                 {\r
41                         super(data);\r
42                 }\r
43                 \r
44                   override public function init():void\r
45                   {\r
46                 //no-op\r
47                   }\r
48 \r
49 \r
50                   /* Miller Cylindrical forward equations--mapping lat,long to x,y\r
51                     ------------------------------------------------------------*/\r
52                   override public function forward(p:ProjPoint):ProjPoint\r
53                   {\r
54                     var lon:Number=p.x;\r
55                     var lat:Number=p.y;\r
56                     /* Forward equations\r
57                       -----------------*/\r
58                     var dlon:Number = ProjConstants.adjust_lon(lon -this.long0);\r
59                     var x:Number = this.x0 + this.a * dlon;\r
60                     var y:Number = this.y0 + this.a * Math.log(Math.tan((ProjConstants.PI / 4.0) + (lat / 2.5))) * 1.25;\r
61                 \r
62                     p.x=x;\r
63                     p.y=y;\r
64                     return p;\r
65                   }//millFwd()\r
66                 \r
67                   /* Miller Cylindrical inverse equations--mapping x,y to lat/long\r
68                     ------------------------------------------------------------*/\r
69                  override public function inverse(p:ProjPoint):ProjPoint\r
70                  {\r
71                     p.x -= this.x0;\r
72                     p.y -= this.y0;\r
73                 \r
74                     var lon:Number = ProjConstants.adjust_lon(this.long0 + p.x /this.a);\r
75                     var lat:Number = 2.5 * (Math.atan(Math.exp(0.8*p.y/this.a)) - ProjConstants.PI / 4.0);\r
76                 \r
77                     p.x=lon;\r
78                     p.y=lat;\r
79                     return p;\r
80                   }//millInv()          \r
81                 \r
82         }\r
83 }