Skip to content

Commit 833fa3d

Browse files
authored
Merge pull request #9856 from rldhont/fix-server-wmts-resolutions
[Server] WMTS - use resolution for bbox calculation
2 parents 4824afa + f8880c6 commit 833fa3d

File tree

11 files changed

+825
-817
lines changed

11 files changed

+825
-817
lines changed

src/server/services/wmts/qgswmtsutils.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ namespace QgsWmts
140140
double top = ( extent.yMinimum() + ( extent.yMaximum() - extent.yMinimum() ) / 2.0 ) + ( row / 2.0 ) * ( tileSize * res );
141141
tmi.extent = QgsRectangle( left, bottom, right, top );
142142

143+
tmi.resolution = res;
143144
tmi.scaleDenominator = scaleDenominator;
144145

145146
calculatedTileMatrixInfoMap[crsStr] = tmi;
@@ -155,8 +156,7 @@ namespace QgsWmts
155156
QgsUnitTypes::DistanceUnit unit = tmi.unit;
156157

157158
// constant
158-
double UNIT_TO_M = QgsUnitTypes::fromUnitToUnitFactor( tmi.unit, QgsUnitTypes::DistanceMeters );
159-
double resolution = POINTS_TO_M * scaleDenominator / UNIT_TO_M;
159+
double resolution = tmi.resolution;
160160
int column = std::ceil( ( extent.xMaximum() - extent.xMinimum() ) / ( tileSize * resolution ) );
161161
int row = std::ceil( ( extent.yMaximum() - extent.yMinimum() ) / ( tileSize * resolution ) );
162162

@@ -263,7 +263,7 @@ namespace QgsWmts
263263
{
264264
tmi = fixedTileMatrixInfoMap[crsStr];
265265
// Calculate resolution based on scale denominator
266-
resolution = POINTS_TO_M * tmi.scaleDenominator / QgsUnitTypes::fromUnitToUnitFactor( tmi.unit, QgsUnitTypes::DistanceMeters );
266+
resolution = tmi.resolution;
267267
// Get fixed corner
268268
QgsRectangle extent = tmi.extent;
269269
fixedTop = extent.yMaximum();
@@ -811,17 +811,23 @@ namespace QgsWmts
811811

812812
// Tile matrix information
813813
// to build tile matrix set like Google Mercator or TMS
814+
// some references for resolution
815+
// https://github.com/mapserver/mapcache/blob/master/lib/configuration.c#L94
814816
tileMatrixInfo tmi3857;
815817
tmi3857.ref = QStringLiteral( "EPSG:3857" );
816818
tmi3857.extent = QgsRectangle( -20037508.3427892480, -20037508.3427892480, 20037508.3427892480, 20037508.3427892480 );
819+
tmi3857.resolution = 156543.0339280410;
817820
tmi3857.scaleDenominator = 559082264.0287179;
818821
tmi3857.unit = QgsUnitTypes::DistanceMeters;
819822
m[tmi3857.ref] = tmi3857;
820823

821-
824+
// To build tile matrix set like mapcache for WGS84
825+
// some references for resolution
826+
// https://github.com/mapserver/mapcache/blob/master/lib/configuration.c#L73
822827
tileMatrixInfo tmi4326;
823828
tmi4326.ref = QStringLiteral( "EPSG:4326" );
824829
tmi4326.extent = QgsRectangle( -180, -90, 180, 90 );
830+
tmi4326.resolution = 0.703125000000000;
825831
tmi4326.scaleDenominator = 279541132.0143588675418869;
826832
tmi4326.unit = QgsUnitTypes::DistanceDegrees;
827833
tmi4326.hasAxisInverted = true;

src/server/services/wmts/qgswmtsutils.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ namespace QgsWmts
4545

4646
bool hasAxisInverted = false;
4747

48+
double resolution = 0.0;
49+
4850
double scaleDenominator = 0.0;
4951

5052
int lastLevel = -1;

0 commit comments

Comments
 (0)