/src/gdal/gcore/tilematrixset.hpp
Line | Count | Source (jump to first uncovered line) |
1 | | /****************************************************************************** |
2 | | * |
3 | | * Project: GDAL |
4 | | * Purpose: Class to handle TileMatrixSet |
5 | | * Author: Even Rouault, <even dot rouault at spatialys.com> |
6 | | * |
7 | | ****************************************************************************** |
8 | | * Copyright (c) 2020, Even Rouault <even dot rouault at spatialys.com> |
9 | | * |
10 | | * SPDX-License-Identifier: MIT |
11 | | ****************************************************************************/ |
12 | | |
13 | | #ifndef TILEMATRIXSET_HPP_INCLUDED |
14 | | #define TILEMATRIXSET_HPP_INCLUDED |
15 | | |
16 | | #include "cpl_port.h" |
17 | | |
18 | | #include <memory> |
19 | | #include <limits> |
20 | | #include <set> |
21 | | #include <string> |
22 | | #include <vector> |
23 | | |
24 | | //! @cond Doxygen_Suppress |
25 | | |
26 | | namespace gdal |
27 | | { |
28 | | |
29 | | class CPL_DLL TileMatrixSet |
30 | | { |
31 | | static constexpr double NaN = std::numeric_limits<double>::quiet_NaN(); |
32 | | |
33 | | public: |
34 | | const std::string &identifier() const |
35 | 0 | { |
36 | 0 | return mIdentifier; |
37 | 0 | } |
38 | | |
39 | | const std::string &title() const |
40 | 0 | { |
41 | 0 | return mTitle; |
42 | 0 | } |
43 | | |
44 | | //! "abstract" in TMS v1 / "description" in TMS v2 |
45 | | const std::string &abstract() const |
46 | 0 | { |
47 | 0 | return mAbstract; |
48 | 0 | } |
49 | | |
50 | | struct CPL_DLL BoundingBox |
51 | | { |
52 | | std::string mCrs{}; //! Can be a URL, a URI, a WKT or PROJJSON string. |
53 | | double mLowerCornerX{NaN}; |
54 | | double mLowerCornerY{NaN}; |
55 | | double mUpperCornerX{NaN}; |
56 | | double mUpperCornerY{NaN}; |
57 | | }; |
58 | | |
59 | | const BoundingBox &bbox() const |
60 | 0 | { |
61 | 0 | return mBbox; |
62 | 0 | } |
63 | | |
64 | | //! Can be a URL, a URI, a WKT or PROJJSON string. |
65 | | const std::string &crs() const |
66 | 0 | { |
67 | 0 | return mCrs; |
68 | 0 | } |
69 | | |
70 | | const std::string &wellKnownScaleSet() const |
71 | 0 | { |
72 | 0 | return mWellKnownScaleSet; |
73 | 0 | } |
74 | | |
75 | | struct CPL_DLL TileMatrix |
76 | | { |
77 | | std::string mId{}; |
78 | | double mScaleDenominator{NaN}; |
79 | | double mResX{ |
80 | | NaN}; // computed from mScaleDenominator and CRS definition |
81 | | double mResY{ |
82 | | NaN}; // computed from mScaleDenominator and CRS definition |
83 | | double mTopLeftX{NaN}; |
84 | | double mTopLeftY{NaN}; |
85 | | int mTileWidth{}; |
86 | | int mTileHeight{}; |
87 | | int mMatrixWidth{}; |
88 | | int mMatrixHeight{}; |
89 | | |
90 | | struct CPL_DLL VariableMatrixWidth |
91 | | { |
92 | | int mCoalesce{}; |
93 | | int mMinTileRow{}; |
94 | | int mMaxTileRow{}; |
95 | | }; |
96 | | |
97 | | std::vector<VariableMatrixWidth> mVariableMatrixWidthList{}; |
98 | | }; |
99 | | |
100 | | const std::vector<TileMatrix> &tileMatrixList() const |
101 | 0 | { |
102 | 0 | return mTileMatrixList; |
103 | 0 | } |
104 | | |
105 | | /** Parse a TileMatrixSet definition, passed inline or by filename, |
106 | | * corresponding to the JSON encoding of the OGC Two Dimensional Tile Matrix |
107 | | * Set: http://docs.opengeospatial.org/is/17-083r2/17-083r2.html */ |
108 | | static std::unique_ptr<TileMatrixSet> parse(const char *fileOrDef); |
109 | | |
110 | | /** Create a raster tiling scheme */ |
111 | | static std::unique_ptr<TileMatrixSet> |
112 | | createRaster(int width, int height, int tileSize, int zoomLevelCount, |
113 | | double dfTopLeftX = 0.0, double dfTopLeftY = 0.0, |
114 | | double dfResXFull = 1.0, double dfResYFull = 1.0, |
115 | | const std::string &mCRS = std::string()); |
116 | | |
117 | | /** Return hardcoded tile matrix set names (such as GoogleMapsCompatible), |
118 | | * as well as XXX for each tms_XXXX.json in GDAL data directory */ |
119 | | static std::vector<std::string> listPredefinedTileMatrixSets(); |
120 | | |
121 | | bool haveAllLevelsSameTopLeft() const; |
122 | | |
123 | | bool haveAllLevelsSameTileSize() const; |
124 | | |
125 | | bool hasOnlyPowerOfTwoVaryingScales() const; |
126 | | |
127 | | bool hasVariableMatrixWidth() const; |
128 | | |
129 | | private: |
130 | 0 | TileMatrixSet() = default; |
131 | | |
132 | | std::string mIdentifier{}; |
133 | | std::string mTitle{}; |
134 | | std::string mAbstract{}; |
135 | | BoundingBox mBbox{}; |
136 | | std::string mCrs{}; |
137 | | std::string mWellKnownScaleSet{}; |
138 | | std::vector<TileMatrix> mTileMatrixList{}; |
139 | | }; |
140 | | |
141 | | } // namespace gdal |
142 | | |
143 | | //! @endcond |
144 | | |
145 | | #endif // TILEMATRIXSET_HPP_INCLUDED |