/**
   * Get the four coordinates that represent the bounding box which includes all the layers
   * indicated for a WMTS Server
   *
   * @param urlServer Url of the WMTS server to connect and get the data
   * @param crs CRS of the bounding box
   * @param layers List of layers to include in the bounding box calculated
   * @return A list of coordinates that represents the bounding box calculated (minX, minY, maxX,
   *     maxY). null if haven't valid bounding box
   */
  private List<String> getWMTSLayersBoundingBox(String urlServer, String crs, String layerId) {
    List<String> boundingBox = new ArrayList<String>();
    WMTSBoundingBox bBox = null;
    String[] crsSplit = crs.split(":");
    String regExpCrs =
        "(.*)(:?)"
            .concat(crsSplit[0])
            .concat("((:)(.*)(:)")
            .concat(crsSplit[1])
            .concat("|(:)")
            .concat(crsSplit[1])
            .concat(")");
    try {
      // get WMTS manager
      WMTSOGCManager wmtsMan = WMTSOGCLocator.getManager();
      WMTSClient wmtsClient = wmtsMan.createWMTSClient(urlServer);
      wmtsClient.connect(true, null);
      if (StringUtils.isNotEmpty(layerId)) {
        WMTSLayer layer = getLayerWMTSById(wmtsClient, layerId);
        if (layer != null) {
          // TODO
          // Need a list of bounding box of the layer
          // to calculate which is the most appropiate
          // WMTSBoundingBox bBox = layer.getBBox();
          List<WMTSTileMatrixSetLink> tileMatrixSetLink = layer.getTileMatrixSetLink();
          Iterator<WMTSTileMatrixSetLink> itTileMatrix = tileMatrixSetLink.iterator();
          while (itTileMatrix.hasNext()) {
            WMTSTileMatrixSetLink wmtsTileMatrixSetLink = itTileMatrix.next();
            WMTSTileMatrixSet tileMatrixSet = wmtsTileMatrixSetLink.getTileMatrixSet();
            String supportedCRS = tileMatrixSet.getSupportedCRS();
            if (supportedCRS.equals(crs) || supportedCRS.matches(regExpCrs)) {
              bBox = tileMatrixSet.getBoundingBox();
              break;
            }
          }
          if (bBox != null) {
            double[] lowerCorner = bBox.getLowerCorner();
            double[] upperCorner = bBox.getUpperCorner();

            boundingBox.add(String.valueOf(lowerCorner[0]));
            boundingBox.add(String.valueOf(lowerCorner[1]));
            boundingBox.add(String.valueOf(upperCorner[0]));
            boundingBox.add(String.valueOf(upperCorner[1]));
          }
        }
      }
    } catch (Exception exc) {
      logger.error("Exception on getWMTSLayersBoundingBox", exc);
      throw new ServerGeoException();
    }
    return boundingBox;
  }