Skip to content

Commit

Permalink
[Backport release_3_5] check project scales and replace scale 0 with …
Browse files Browse the repository at this point in the history
…scale 1 (#3820)

* check project scales and replace scale 0 with scale 1

* Apply suggestions from code review

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

---------

Co-authored-by: rmartin <rmartin@3liz.com>
Co-authored-by: nworr <43475951+nworr@users.noreply.github.com>
Co-authored-by: mdouchin <mdouchin@3liz.com>
  • Loading branch information
4 people authored Jul 31, 2023
1 parent 1bdd6cd commit c57647b
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 @@ -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;
}
}

0 comments on commit c57647b

Please sign in to comment.