Ticket #283 (closed enhancement: fixed)

Opened 3 years ago

Last modified 3 years ago

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: External ID:
state: Committed Browser: All
Operating System: All

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

Changed 3 years ago by tnolte

  • owner changed from madair to tnolte
  • status changed from new to assigned

Changed 3 years ago by tnolte

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.

Changed 3 years ago by tnolte

  • state changed from New to Pending Approval

Changed 3 years ago by pagameba

  • state changed from Pending Approval to Approved

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

Changed 3 years ago by tnolte

  • state changed from Approved to Committed

Changed 3 years ago by tnolte

  • status changed from assigned to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.