Understand shapefiles in different projections (notably OSGB)
[potlatch2.git] / com / gradoservice / proj4as / proj / ProjEqc.as
1 package com.gradoservice.proj4as.proj\r
2 {\r
3         import com.gradoservice.proj4as.ProjPoint;\r
4         import com.gradoservice.proj4as.ProjConstants;\r
5         import com.gradoservice.proj4as.Datum;\r
6                 \r
7         public class ProjEqc extends AbstractProjProjection\r
8         {\r
9                 public function ProjEqc(data:ProjParams)\r
10                 {\r
11                         super(data);\r
12                 }\r
13                 \r
14                 override public function init():void \r
15                 {\r
16                 if(!this.x0) this.x0=0;\r
17                 if(!this.y0) this.y0=0;\r
18                 if(!this.lat0) this.lat0=0;\r
19                 if(!this.long0) this.long0=0;\r
20                 if(!this.lat_ts) this.lat_ts=0;\r
21                 if (!this.title) this.title = "Equidistant Cylindrical (Plate Carre)";\r
22                 this.rc= Math.cos(this.lat_ts);\r
23         }\r
24 \r
25 \r
26     // forward equations--mapping lat,long to x,y\r
27     // -----------------------------------------------------------------\r
28         override public function forward(p:ProjPoint):ProjPoint \r
29         {\r
30         var lon:Number= p.x;\r
31         var lat:Number= p.y;\r
32         \r
33         var dlon:Number = ProjConstants.adjust_lon(lon - this.long0);\r
34         var dlat:Number = ProjConstants.adjust_lat(lat - this.lat0 );\r
35         p.x= this.x0 + (this.a*dlon*this.rc);\r
36         p.y= this.y0 + (this.a*dlat        );\r
37         return p;\r
38         }\r
39 \r
40   // inverse equations--mapping x,y to lat/long\r
41   // -----------------------------------------------------------------\r
42                 override public function inverse(p:ProjPoint):ProjPoint \r
43                 {\r
44         var x:Number= p.x;\r
45         var y:Number= p.y;\r
46 \r
47         p.x= ProjConstants.adjust_lon(this.long0 + ((x - this.x0)/(this.a*this.rc)));\r
48         p.y= ProjConstants.adjust_lat(this.lat0  + ((y - this.y0)/(this.a        )));\r
49                 return p;\r
50                 }\r
51 \r
52                 \r
53                 \r
54         }\r
55 }