dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
platecarreeprojection.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 */
27 #include "platecarreeprojection.h"
28 
29 
30 
31 namespace projections {
32 PlateCarreeProjection::PlateCarreeProjection():MinLatitude(-85.05112878), MaxLatitude(85.05112878),MinLongitude(-180),
33 MaxLongitude(180), tileSize(512, 512)
34 {
35 }
36 Point PlateCarreeProjection::FromLatLngToPixel(double lat, double lng, const int &zoom)
37 {
38  Point ret;// = Point.Empty;
39 
40  lat = bound(lat, MinLatitude, MaxLatitude);
41  lng = bound(lng, MinLongitude, MaxLongitude);
42 
43  Size s = GetTileMatrixSizePixel(zoom);
44  double mapSizeX = s.Width();
45  //double mapSizeY = s.Height();
46 
47  double scale = 360.0 / mapSizeX;
48 
49  ret.SetY((qint64) round((90.0 - lat) / scale));
50  ret.SetX((qint64) round((lng + 180.0) / scale));
51 
52  return ret;
53 
54 }
55 internals::PointLatLng PlateCarreeProjection::FromPixelToLatLng(const qint64 &x,const qint64 &y,const int &zoom)
56 {
57  internals::PointLatLng ret;// = internals::PointLatLng.Empty;
58 
59  Size s = GetTileMatrixSizePixel(zoom);
60  double mapSizeX = s.Width();
61  //double mapSizeY = s.Height();
62 
63  double scale = 360.0 / mapSizeX;
64 
65  ret.SetLat(90 - (y * scale));
66  ret.SetLng((x * scale) - 180);
67 
68  return ret;
69 }
70 
72 {
73  return tileSize;
74 }
76 {
77  return 6378137;
78 }
80 {
81  return (1.0 / 298.257223563);
82 }
84 {
85  int y = (int) pow(2, zoom);
86  return Size((2*y) - 1, y - 1);
87 }
88 
90 {
91  Q_UNUSED(zoom);
92  return Size(0, 0);
93 }
94 }
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 internals::PointLatLng FromPixelToLatLng(const qint64 &x, const qint64 &y, const int &zoom)
virtual Size GetTileMatrixMinXY(const int &zoom)
virtual Size GetTileMatrixMaxXY(const int &zoom)
void SetLng(const double &value)
Definition: pointlatlng.h:80
x
Definition: OPPlots.m:100
virtual core::Point FromLatLngToPixel(double lat, double lng, int const &zoom)
virtual Size GetTileMatrixSizePixel(const int &zoom)
y
Definition: OPPlots.m:101