4
#include "ProjectionRectangular.h"
7
ProjectionRectangular::ProjectionRectangular(const int f, const int w,
9
: ProjectionBase (f, w, h),
14
startLon_ = -M_PI + centerLon_;
17
delLat_ = M_PI/height_;
18
delLon_ = TWO_PI/width_;
21
ProjectionRectangular::ProjectionRectangular(const int f, const int w,
23
const double startLat,
24
const double startLon,
25
const double mapHeight,
26
const double mapWidth)
27
: ProjectionBase (f, w, h), mapBounds_(true)
29
startLon_ = startLon * f;
32
delLat_ = mapHeight/height_;
33
delLon_ = mapWidth/width_ * f;
37
ProjectionRectangular::pixelToSpherical(const double x, const double y,
38
double &lon, double &lat)
40
lon = (x + 0.5) * delLon_ + startLon_;
41
lat = startLat_ - (y + 0.5) * delLat_;
46
ProjectionRectangular::sphericalToPixel(double lon, double lat,
47
double &x, double &y) const
49
if (lon > M_PI) lon -= TWO_PI;
50
else if (lon < -M_PI) lon += TWO_PI;
52
x = (lon - startLon_)/delLon_;
62
y = (startLat_ - lat)/delLat_;
64
if (!mapBounds_ && y >= height_) y = height_ - 1;