From c57647b6f76c781da9d0a438e195bc7983e42978 Mon Sep 17 00:00:00 2001 From: 3Liz Bot <63838475+3liz-bot@users.noreply.github.com> Date: Mon, 31 Jul 2023 10:59:35 +0200 Subject: [PATCH] [Backport release_3_5] check project scales and replace scale 0 with scale 1 (#3820) * check project scales and replace scale 0 with scale 1 * Apply suggestions from code review Co-authored-by: mdouchin --------- Co-authored-by: rmartin Co-authored-by: nworr <43475951+nworr@users.noreply.github.com> Co-authored-by: mdouchin --- .../lizmap/classes/lizmapTiler.class.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/lizmap/modules/lizmap/classes/lizmapTiler.class.php b/lizmap/modules/lizmap/classes/lizmapTiler.class.php index 7b0963d54c..7d15d9c7b9 100644 --- a/lizmap/modules/lizmap/classes/lizmapTiler.class.php +++ b/lizmap/modules/lizmap/classes/lizmapTiler.class.php @@ -219,9 +219,7 @@ public static function getTileMatrixSetList($project, $wms_xml) $rootExtent[3] = $geoExtent[3]; } - $scales = array_merge(array(), $project->getOption('mapScales')); - rsort($scales); - + $scales = self::normalizeProjectScales($project); $projection = $project->getOption('projection'); $tileMatrixSetList = array(); @@ -421,8 +419,7 @@ public static function getLayerTileInfo($layerName, $project, $wms_xml, $tileMat $rootExtent[3] = $geoExtent[3]; } - $scales = array_merge(array(), $project->getOption('mapScales')); - rsort($scales); + $scales = self::normalizeProjectScales($project); $layers = $project->getLayers(); $layer = $layers->{$layerName}; @@ -601,4 +598,16 @@ public static function getTileBbox($tileMatrixSet, $tileMatrixId, $tileRow, $til return (string) $minx.','.(string) $miny.','.(string) $maxx.','.(string) $maxy; } + + private static function normalizeProjectScales($project) + { + $scales = array_merge(array(), $project->getOption('mapScales')); + if ($scales[0] == 0) { + $scales[0] = 1; + trigger_error('The minimum scale cannot have a value of 0, redefined as 1.', E_USER_NOTICE); + } + rsort($scales); + + return $scales; + } }