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