Skip to content

Commit 590dd3c

Browse files
authored
Merge pull request #9864 from rldhont/fix-server-wmts-resolutions-release-3_4
[Backport release-3_4] [Server] WMTS - use resolution for bbox calculation
2 parents f5627e1 + 52882f4 commit 590dd3c

File tree

9 files changed

+335
-327
lines changed

9 files changed

+335
-327
lines changed

src/server/services/wmts/qgswmtsutils.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ namespace QgsWmts
137137
double top = ( extent.yMinimum() + ( extent.yMaximum() - extent.yMinimum() ) / 2.0 ) + ( row / 2.0 ) * ( tileSize * res );
138138
tmi.extent = QgsRectangle( left, bottom, right, top );
139139

140+
tmi.resolution = res;
140141
tmi.scaleDenominator = scaleDenominator;
141142

142143
tileMatrixInfoMap[crsStr] = tmi;
@@ -152,8 +153,7 @@ namespace QgsWmts
152153
QgsUnitTypes::DistanceUnit unit = tmi.unit;
153154

154155
// constant
155-
double unit_to_m = QgsUnitTypes::fromUnitToUnitFactor( tmi.unit, QgsUnitTypes::DistanceMeters );
156-
double resolution = points_to_m * scaleDenominator / unit_to_m;
156+
double resolution = tmi.resolution;
157157
int column = std::ceil( ( extent.xMaximum() - extent.xMinimum() ) / ( tileSize * resolution ) );
158158
int row = std::ceil( ( extent.yMaximum() - extent.yMinimum() ) / ( tileSize * resolution ) );
159159

@@ -691,17 +691,23 @@ namespace QgsWmts
691691

692692
// Tile matrix information
693693
// to build tile matrix set like Google Mercator or TMS
694+
// some references for resolution
695+
// https://github.com/mapserver/mapcache/blob/master/lib/configuration.c#L94
694696
tileMatrixInfo tmi3857;
695697
tmi3857.ref = QStringLiteral( "EPSG:3857" );
696698
tmi3857.extent = QgsRectangle( -20037508.3427892480, -20037508.3427892480, 20037508.3427892480, 20037508.3427892480 );
699+
tmi3857.resolution = 156543.0339280410;
697700
tmi3857.scaleDenominator = 559082264.0287179;
698701
tmi3857.unit = QgsUnitTypes::DistanceMeters;
699702
m[tmi3857.ref] = tmi3857;
700703

701-
704+
// To build tile matrix set like mapcache for WGS84
705+
// some references for resolution
706+
// https://github.com/mapserver/mapcache/blob/master/lib/configuration.c#L73
702707
tileMatrixInfo tmi4326;
703708
tmi4326.ref = QStringLiteral( "EPSG:4326" );
704709
tmi4326.extent = QgsRectangle( -180, -90, 180, 90 );
710+
tmi4326.resolution = 0.703125000000000;
705711
tmi4326.scaleDenominator = 279541132.0143588675418869;
706712
tmi4326.unit = QgsUnitTypes::DistanceDegrees;
707713
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

0 commit comments

Comments
 (0)