This adds a "compilation" step to the legend rendering where we compile the following information about the MgMap to avoid repeated linear searches for this information:
- The number of visible layers for each group (as a typedef'd std::map<STRING, int> )
- The list of child groups for each group (as a typedef'd std::map<STRING, std::vector<STRING>> )
Then for each child group we find in MgLegendPlotUtil::ProcessLayersForLegend(), we check if that group has any visible child layers using the above compiled information. If there are no visible layers for that group, we skip the recursive call back into MgLegendPlotUtil::ProcessLayersForLegend() for that particular group.
The net result is that visible groups that have no visible child layers are not drawn into the legend, reducing the clutter of empty groups in the rendered legend.