/**
   * This method returns a list of urls for retrieving the individual layers of the map. It will
   * coalesce adjacent layers into a single request, when possible.
   *
   * @param layerList Element parent node to the list of layer Elements within the ViewContext
   * @param layers String[] of layer names
   * @param bbox Envelope spatial extent of the map image
   * @param width x-dimension of the map image
   * @param height y-dimension of the map image
   * @param format String mime-type of the map image
   * @return List of urls for get map requests
   * @ssdd
   */
  private List<String> getLayerRequests(
      Element layerList, String[] layers, Envelope bbox, int width, int height, String format) {

    List<String> requests = new ArrayList<String>();
    String lastServer = null;

    for (Element elem : DOMUtils.getChildren(layerList, "Layer")) {
      // get layer name
      String name = DOMUtils.getChildText(elem, "Name");
      // is layer in list of requested layers?
      if (!contains(layers, name)) continue;
      // is layer visible?
      if (Coerce.toBoolean(elem.getAttribute("hidden"))) continue;
      // get href to layer's service
      Node server = DOMUtils.getChild(elem, "Server");
      Element or = DOMUtils.getChild(server, "OnlineResource");
      String href = or.getAttribute("xlink:href");

      if (href.equals(lastServer)) {
        String layerNames = requests.remove(requests.size() - 1);
        layerNames += "," + name;
        requests.add(layerNames);
      } else {
        lastServer = href;
        requests.add(getMapRequest(href, name, bbox, width, height, format));
      }
    }
    return requests;
  }