Make Use of MapServer CLASS TITLE in Legend
Currently Fusion only uses the CLASS->NAME when setting the legend label for classes. It is desirable to have the same level of control that is available via METADATA layer naming in the legend. The most appropriate, and seemingly standard way to do this is to check for a CLASS->TITLE and use that in the legend and default back to the CLASS->NAME if not defined. The following small change to the MapServer LoadMap.php, starting around line 360, would be needed:
//create classes and slot them into the scale breaks
for ($j=0; $j<$layer->numclasses; $j++) {
$oClass = $layer->getClass($j);
$classObj = NULL;
// Use formatted legend label as defined by CLASS->TITLE, fallback on CLASS->NAME
$classObj->legendLabel = $oClass->title != '' ? $oClass->title : $oClass->name;
$classObj->filter = $oClass->getExpression();
$classMin = $oClass->minscale == -1 ? $layerMin : max($oClass->minscale, $layerMin);
$classMax = $oClass->maxscale == -1 ? $layerMax : min($oClass->maxscale, $layerMax);
$classObj->minScale = $classMin;
$classObj->maxScale = $classMax;
$classObj->index = $j;
for ($k=0; $k<count($aScaleRanges); $k++) {
if ($classMin < $aScaleRanges[$k]->maxScale && $classMax > $aScaleRanges[$k]->minScale) {
array_push($aScaleRanges[$k]->styles, $classObj);
}
}
}
Change History
(6)
Owner: |
changed from madair to tnolte
|
Status: |
new → assigned
|
state: |
New → Pending Approval
|
state: |
Pending Approval → Approved
|
state: |
Approved → Committed
|
Resolution: |
→ fixed
|
Status: |
assigned → closed
|
I have these changes made and ready to submit. Basically a simple fix that will use the TITLE if defined/available otherwise fallback on the CLASS NAME.