Subversion Repositories Projects

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2287 - 1

2
namespace GMap.NET.Projections
3
{
4
#if OLD_PERGO
5
   using System;
6
 
7
   /// <summary>
8
   /// Plate Carrée (literally, “plane square”) projection
9
   /// PROJCS["WGS 84 / World Equidistant Cylindrical",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],UNIT["Meter",1]]
10
   /// </summary>
11
   public class PlateCarreeProjectionPergo : PureProjection
12
   {
13
      public static readonly PlateCarreeProjectionPergo Instance = new PlateCarreeProjectionPergo();
14
 
15
      static readonly double MinLatitude = -85.05112878;
16
      static readonly double MaxLatitude = 85.05112878;
17
      static readonly double MinLongitude = -180;
18
      static readonly double MaxLongitude = 180;
19
 
20
      public override RectLatLng Bounds
21
      {
22
         get
23
         {
24
            return RectLatLng.FromLTRB(MinLongitude, MaxLatitude, MaxLongitude, MinLatitude);
25
         }
26
      }
27
 
28
      GSize tileSize = new GSize(256, 256);
29
      public override GSize TileSize
30
      {
31
         get
32
         {
33
            return tileSize;
34
         }
35
      }
36
 
37
      public override double Axis
38
      {
39
         get
40
         {
41
            return 6378137;
42
         }
43
      }
44
 
45
      public override double Flattening
46
      {
47
         get
48
         {
49
            return (1.0 / 298.257223563);
50
         }
51
      }
52
 
53
      public override GPoint FromLatLngToPixel(double lat, double lng, int zoom)
54
      {
55
         GPoint ret = GPoint.Empty;
56
 
57
         lat = Clip(lat, MinLatitude, MaxLatitude);
58
         lng = Clip(lng, MinLongitude, MaxLongitude);
59
 
60
         GSize s = GetTileMatrixSizePixel(zoom);
61
         double mapSizeX = s.Width;
62
         double mapSizeY = s.Height;
63
 
64
         double scale = 360.0 / mapSizeX;
65
 
66
         ret.Y = (long)((90.0 - lat) / scale);
67
         ret.X = (long)((lng + 180.0) / scale);
68
 
69
         return ret;
70
      }
71
 
72
      public override PointLatLng FromPixelToLatLng(long x, long y, int zoom)
73
      {
74
         PointLatLng ret = PointLatLng.Empty;
75
 
76
         GSize s = GetTileMatrixSizePixel(zoom);
77
         double mapSizeX = s.Width;
78
         double mapSizeY = s.Height;
79
 
80
         double scale = 360.0 / mapSizeX;
81
 
82
         ret.Lat = 90 - (y * scale);
83
         ret.Lng = (x * scale) - 180;
84
 
85
         return ret;
86
      }
87
 
88
      public override GSize GetTileMatrixMaxXY(int zoom)
89
      {
90
         long y = (long)Math.Pow(2, zoom);
91
         return new GSize((2*y) - 1, y - 1);
92
      }
93
 
94
      public override GSize GetTileMatrixMinXY(int zoom)
95
      {
96
         return new GSize(0, 0);
97
      }
98
   }
99
#endif
100
}