Skip to content

Commit

Permalink
check project scales and replace scale 0 with scale 1 (#3813)
Browse files Browse the repository at this point in the history
* check project scales and replace scale 0 with scale 1


Co-authored-by: mdouchin <mdouchin@3liz.com>

---------

Co-authored-by: mdouchin <mdouchin@3liz.com>
  • Loading branch information
nworr and mdouchin authored Jul 31, 2023
1 parent 3666d49 commit 58df6be
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions lizmap/modules/lizmap/classes/lizmapTiler.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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};
Expand Down Expand Up @@ -602,4 +599,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;
}
}

0 comments on commit 58df6be

Please sign in to comment.