libosmscout 1.1.1
Loading...
Searching...
No Matches
MercatorProjection.h
Go to the documentation of this file.
1#ifndef OSMSCOUT_UTIL_MERCATORPROJECTION_H
2#define OSMSCOUT_UTIL_MERCATORPROJECTION_H
3
4/*
5 This source is part of the libosmscout library
6 Copyright (C) 2010 Tim Teulings
7
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21*/
22
24
26
27namespace osmscout {
28
40 {
41 protected: // Because the OpenGLProjection inherits from this projection
42 bool valid=false;
43
44 double latOffset=0.0;
45 double angleSin=0.0;
46 double angleCos=0.0;
47 double angleNegSin=0.0;
48 double angleNegCos=0.0;
49
50 double scale=1.0;
51 double scaleGradtorad=0.0 ;
52
53 double scaledLatDeriv=0.0;
56
57 public:
58 static const double MaxLat;
59 static const double MinLat;
60 static const double MaxLon;
61 static const double MinLon;
62
63 MercatorProjection() = default;
68 ~MercatorProjection() override = default;
69
70 bool CanBatch() const override
71 {
72 return false;
73 }
74
75 bool IsValid() const override
76 {
77 return valid;
78 }
79
80 bool IsValidFor(const GeoCoord& coord) const override
81 {
82 return coord.GetLat() >= MinLat && coord.GetLat() <= MaxLat &&
83 coord.GetLon() >= MinLon && coord.GetLon() <= MaxLon;
84 }
85
86 bool Set(const GeoCoord& coord,
87 const Magnification& magnification,
88 size_t width,size_t height)
89 {
90 return Set(coord,0.0,magnification,GetDPI(),width,height);
91 }
92
93 bool Set(const GeoCoord& coord,
94 double angle,
95 const Magnification& magnification,
96 size_t width, size_t height)
97 {
98 return Set(coord,angle,magnification,GetDPI(),width,height);
99 }
100
101 bool Set(const GeoCoord& coord,
102 const Magnification& magnification,
103 double dpi,
104 size_t width, size_t height)
105 {
106 return Set(coord,0.0,magnification,dpi,width,height);
107 }
108
131 bool Set(const GeoCoord& coord,
132 double angle,
133 const Magnification& magnification,
134 double dpi,
135 size_t width, size_t height);
136
137 bool PixelToGeo(double x, double y,
138 GeoCoord& coord) const override;
139
140 bool GeoToPixel(const GeoCoord& coord,
141 Vertex2D& pixel) const override;
142
143 bool Move(double horizPixel,
144 double vertPixel);
145
146 bool MoveUp(double pixel)
147 {
148 return Move(0,pixel);
149 }
150
151 bool MoveDown(double pixel)
152 {
153 return Move(0,-pixel);
154 }
155
156 bool MoveLeft(double pixel)
157 {
158 return Move(-pixel,0);
159 }
160
161 bool MoveRight(double pixel)
162 {
163 return Move(pixel,0);
164 }
165
166 [[nodiscard]] bool IsLinearInterpolationEnabled() const
167 {
169 }
170
176 {
177 this->useLinearInterpolation=useLinearInterpolation;
178 }
179
180 protected:
181 void GeoToPixel(const BatchTransformer& transformData) const override;
182 };
183}
184
185#endif
#define OSMSCOUT_API
Definition CoreImportExport.h:45
static const double MaxLon
Definition MercatorProjection.h:60
bool MoveLeft(double pixel)
Definition MercatorProjection.h:156
bool IsLinearInterpolationEnabled() const
Definition MercatorProjection.h:166
MercatorProjection(const MercatorProjection &)=default
bool CanBatch() const override
Definition MercatorProjection.h:70
double scaledLatDeriv
center scaled by gradtorad * scale
Definition MercatorProjection.h:53
bool Set(const GeoCoord &coord, double angle, const Magnification &magnification, double dpi, size_t width, size_t height)
void GeoToPixel(const BatchTransformer &transformData) const override
double scale
Definition MercatorProjection.h:50
double angleCos
Definition MercatorProjection.h:46
bool GeoToPixel(const GeoCoord &coord, Vertex2D &pixel) const override
bool useLinearInterpolation
switch to enable linear interpolation of latitude to pixel computation
Definition MercatorProjection.h:55
double angleNegCos
Definition MercatorProjection.h:48
bool PixelToGeo(double x, double y, GeoCoord &coord) const override
bool MoveUp(double pixel)
Definition MercatorProjection.h:146
bool Move(double horizPixel, double vertPixel)
bool MoveDown(double pixel)
Definition MercatorProjection.h:151
double latOffset
Absolute and untransformed screen position of lat coordinate.
Definition MercatorProjection.h:44
double scaleGradtorad
Precalculated scale*Gradtorad.
Definition MercatorProjection.h:51
double angleSin
Definition MercatorProjection.h:45
~MercatorProjection() override=default
static const double MaxLat
Definition MercatorProjection.h:58
double angleNegSin
Definition MercatorProjection.h:47
bool valid
projection is valid
Definition MercatorProjection.h:42
MercatorProjection & operator=(MercatorProjection &&)=default
bool IsValidFor(const GeoCoord &coord) const override
Definition MercatorProjection.h:80
void SetLinearInterpolationUsage(bool useLinearInterpolation)
Definition MercatorProjection.h:175
bool Set(const GeoCoord &coord, const Magnification &magnification, double dpi, size_t width, size_t height)
Definition MercatorProjection.h:101
static const double MinLon
Definition MercatorProjection.h:61
MercatorProjection(MercatorProjection &&)=default
bool IsValid() const override
Definition MercatorProjection.h:75
static const double MinLat
Definition MercatorProjection.h:59
MercatorProjection & operator=(const MercatorProjection &)=default
bool Set(const GeoCoord &coord, double angle, const Magnification &magnification, size_t width, size_t height)
Definition MercatorProjection.h:93
bool MoveRight(double pixel)
Definition MercatorProjection.h:161
bool Set(const GeoCoord &coord, const Magnification &magnification, size_t width, size_t height)
Definition MercatorProjection.h:86
size_t width
Width of image.
Definition Projection.h:52
size_t height
Height of image.
Definition Projection.h:53
friend class BatchTransformer
Definition Projection.h:341
double GetDPI() const
Definition Projection.h:250
double angle
Display rotation angle in radians, canvas clockwise.
Definition Projection.h:49
double dpi
Screen DPI.
Definition Projection.h:51
Magnification magnification
Current magnification.
Definition Projection.h:50
Definition Area.h:39