dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
platecarreeprojectionpergo.cpp
Go to the documentation of this file.
1 
13 /*
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 3 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 * for more details.
23 *
24 * You should have received a copy of the GNU General Public License along
25 * with this program; if not, see <http://www.gnu.org/licenses/>
26 */
28 
29 
30 namespace projections {
31 PlateCarreeProjectionPergo::PlateCarreeProjectionPergo():MinLatitude(-85.05112878), MaxLatitude(85.05112878),MinLongitude(-180),
32 MaxLongitude(180), tileSize(256, 256)
33 {
34 }
35 Point PlateCarreeProjectionPergo::FromLatLngToPixel(double lat, double lng, const int &zoom)
36 {
37  Point ret;// = Point.Empty;
38 
39  lat = bound(lat, MinLatitude, MaxLatitude);
40  lng = bound(lng, MinLongitude, MaxLongitude);
41 
42  Size s = GetTileMatrixSizePixel(zoom);
43  double mapSizeX = s.Width();
44  //double mapSizeY = s.Height();
45 
46  double scale = 360.0 / mapSizeX;
47 
48  ret.SetY((qint64) round((90.0 - lat) / scale));
49  ret.SetX((qint64) round((lng + 180.0) / scale));
50 
51  return ret;
52 }
53 internals::PointLatLng PlateCarreeProjectionPergo::FromPixelToLatLng(const qint64 &x,const qint64 &y,const int &zoom)
54 {
55  internals::PointLatLng ret;// = internals::PointLatLng.Empty;
56 
57  Size s = GetTileMatrixSizePixel(zoom);
58  double mapSizeX = s.Width();
59  //double mapSizeY = s.Height();
60 
61  double scale = 360.0 / mapSizeX;
62 
63  ret.SetLat(90 - (y * scale));
64  ret.SetLng((x * scale) - 180);
65 
66  return ret;
67 }
68 
70 {
71  return tileSize;
72 }
74 {
75  return 6378137;
76 }
78 {
79  return (1.0 / 298.257223563);
80 }
82 {
83  int y = (int) pow(2, zoom);
84  return Size((2*y) - 1, y - 1);
85 }
86 
88 {
89  Q_UNUSED(zoom)
90  return Size(0, 0);
91 }
92 }
void SetLat(const double &value)
Definition: pointlatlng.h:69
double bound(double const &n, double const &minValue, double const &maxValue) const
PureProjection::bound Bounds the value at an upper and lower threshold.
virtual core::Point FromLatLngToPixel(double lat, double lng, int const &zoom)
void SetLng(const double &value)
Definition: pointlatlng.h:80
virtual internals::PointLatLng FromPixelToLatLng(const qint64 &x, const qint64 &y, const int &zoom)
x
Definition: OPPlots.m:100
virtual Size GetTileMatrixSizePixel(const int &zoom)
y
Definition: OPPlots.m:101