/** * Pre-processes the legend request and returns a style whose rules have been altered to contain * a feature count * * @param legend * @return * @throws Exception */ public Rule[] preProcessRules(LegendRequest legend, Rule[] rules) { if (rules == null || rules.length == 0) { return rules; } // is the code running in match first mode? MatchFirstVisitor matchFirstVisitor = new MatchFirstVisitor(); legend.getStyle().accept(matchFirstVisitor); boolean matchFirst = matchFirstVisitor.matchFirst; try { GetMapRequest getMapRequest = parseAssociatedGetMap(legend, rules); Map<Rule, AtomicInteger> counters = renderAndCountFeatures(rules, getMapRequest, matchFirst); Rule[] result = updateRuleTitles(rules, counters); return result; } catch (ServiceException ex) { throw ex; } catch (Exception ex) { throw new ServiceException(ex); } }