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