libosmscout 1.1.1
Loading...
Searching...
No Matches
TileProjection.h
Go to the documentation of this file.
1#ifndef OSMSCOUT_UTIL_TILEPROJECTION_H
2#define OSMSCOUT_UTIL_TILEPROJECTION_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
28
29namespace osmscout {
30
38 {
39 private:
40 bool valid=false;
41
42 double lonOffset=0.0;
43 double latOffset=0.0;
44 double scale=1.0;
45 double scaleGradtorad=0.0;
46
47 double scaledLatDeriv=0.0;
49 bool useLinearInterpolation=false;
50
51#ifdef OSMSCOUT_HAVE_SSE2
52 //some extra vars for special sse needs
53 v2df sse2LonOffset;
54 v2df sse2LatOffset;
55 v2df sse2Scale;
56 v2df sse2ScaleGradtorad;
57 v2df sse2Height;
58#endif
59
60 protected:
61 virtual bool SetInternal(const GeoBox& boundingBox,
62 const Magnification& magnification,
63 double dpi,
64 size_t width,size_t height);
65
66 public:
67 TileProjection() = default;
68 TileProjection(const TileProjection&) = default;
72 ~TileProjection() override = default;
73
74 bool CanBatch() const override
75 {
76 return true;
77 }
78
79 bool IsValid() const override
80 {
81 return valid;
82 }
83
84 bool IsValidFor(const GeoCoord& coord) const override
85 {
86 return coord.GetLat() >= -85.0511 && coord.GetLat() <= +85.0511 &&
87 coord.GetLon() >= -180.0 && coord.GetLon() <= +180.0;
88 }
89
90 bool Set(const OSMTileId& tile,
91 const Magnification& magnification,
92 size_t width, size_t height)
93 {
94 return Set(tile,
96 GetDPI(),
97 width,
98 height);
99 }
100
101 bool Set(const OSMTileId& tile,
102 const Magnification& magnification,
103 double dpi,
104 size_t width, size_t height);
105
106 bool Set(const OSMTileIdBox& tileBox,
107 const Magnification& magnification,
108 double dpi,
109 size_t width, size_t height);
110
111 bool PixelToGeo(double x, double y,
112 GeoCoord& coord) const override;
113
114 bool GeoToPixel(const GeoCoord& coord,
115 Vertex2D& pixel) const override;
116
117 [[nodiscard]] bool IsLinearInterpolationEnabled() const
118 {
119 return useLinearInterpolation;
120 }
121
127 {
128 useLinearInterpolation = b;
129 }
130
131 protected:
132
133 void GeoToPixel(const BatchTransformer& transformData) const override;
134 };
135}
136
137#endif
#define OSMSCOUT_API
Definition CoreImportExport.h:45
size_t width
Width of image.
Definition Projection.h:52
size_t height
Height of image.
Definition Projection.h:53
GeoBox boundingBox
Bounding box of the current projection on the ground.
Definition Projection.h:55
friend class BatchTransformer
Definition Projection.h:341
double GetDPI() const
Definition Projection.h:250
double dpi
Screen DPI.
Definition Projection.h:51
Magnification magnification
Current magnification.
Definition Projection.h:50
virtual bool SetInternal(const GeoBox &boundingBox, const Magnification &magnification, double dpi, size_t width, size_t height)
TileProjection & operator=(TileProjection &&)=default
bool GeoToPixel(const GeoCoord &coord, Vertex2D &pixel) const override
TileProjection(const TileProjection &)=default
bool Set(const OSMTileId &tile, const Magnification &magnification, size_t width, size_t height)
Definition TileProjection.h:90
bool CanBatch() const override
Definition TileProjection.h:74
bool IsLinearInterpolationEnabled() const
Definition TileProjection.h:117
TileProjection(TileProjection &&)=default
bool PixelToGeo(double x, double y, GeoCoord &coord) const override
bool Set(const OSMTileIdBox &tileBox, const Magnification &magnification, double dpi, size_t width, size_t height)
void GeoToPixel(const BatchTransformer &transformData) const override
bool Set(const OSMTileId &tile, const Magnification &magnification, double dpi, size_t width, size_t height)
void SetLinearInterpolationUsage(bool b)
Definition TileProjection.h:126
~TileProjection() override=default
bool IsValid() const override
Definition TileProjection.h:79
TileProjection & operator=(const TileProjection &)=default
bool IsValidFor(const GeoCoord &coord) const override
Definition TileProjection.h:84
Definition Area.h:39