Opened 15 years ago

Closed 14 years ago

#283 closed enhancement (fixed)

Make Use of MapServer CLASS TITLE in Legend

Reported by: tnolte Owned by: tnolte
Priority: P2 Milestone: 2.0
Component: MapServer Version: 2.0 - beta
Severity: Minor Keywords: mapserver, layer, class, title
Cc: Browser: All
External ID: Operating System: All
state: Committed

Description

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)

comment:1 by tnolte, 14 years ago

Owner: changed from madair to tnolte
Status: newassigned

comment:2 by tnolte, 14 years ago

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.

comment:3 by tnolte, 14 years ago

state: NewPending Approval

comment:4 by pagameba, 14 years ago

state: Pending ApprovalApproved

please go ahead and commit, no need to ask for approval ;)

comment:5 by tnolte, 14 years ago

state: ApprovedCommitted

comment:6 by tnolte, 14 years ago

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.