!******************************************************************************!
! This converts the the LAYER section of getCapabilities into the LAYER listing
! needed by layerwms_config.tbl, though it is recommended to have the resulting
! table updated to have comma sepearted entries, rather than one entry per line.
! The layerwms_config.tbl is used by test_plot_layerwms_config, which is designed
! to test against operational URLs
!
! @since    4.1.1
! @author:  Jeanette McCall
!******************************************************************************!
startmacro cs:file_with_capabilities cs:output_file[wms_layers_for_config.tbl]

  TABLE capabilities_tbl LOAD "^{file_with_capabilities}"
  TABLE layers_tbl CREATE

  FOREACH layer INTABLE capabilities_tbl
    TABLE capabilities_tbl GETKEY ^layer layertbl
    TABLE layertbl GETKEY NAME name
    res layers_tbl.^layer "\"^{name}\""
  endfor

  TABLE layers_tbl SAVE output_file
endmacro