!
! Test plotting map from OGC WMS Map Server (that is returning WMS 1.1.1 exception format
! but claims to be a WMS 1.3.0 server)
!
! Bug:     2267 PLOT: does not work with World Wind WMS Server
! Author:  Neon Ngo
!
startmacro fn:url["http://nextmidas.com:8800/wms"] cs:layers["bmng200401"]
  switch INTERACTIVE interAct GET DEF=TRUE  SDEF=TRUE
  switch BASELINE    baseline GET DEF=FALSE SDEF=TRUE

  invoke z:jvmHangFix nxm.sys.lib.Shell.getJVMHangWorkaround()
  res z:mytrue true
  invoke ,, nxm.sys.lib.Shell.setJVMHangWorkaround(^mytrue)

  call setDatDir

  if interAct then
    pipe on
      panel/msgid=MAIN/setup/controls=gc
      plot/id=idplot ^{datDir}.world.prm|{LT="WMS",URL="^url",LAYERS="^layers",ConnectTimeout=30,ReadTimeout=120,useTiles=true} view=LatLon

      gcontrol label macro "MACRO"
      gcontrol menu    main "Exit with Status = " "PASS,FAIL" /tleft
      set gc.main.itemColors {PASS=GREEN,FAIL=RED}

      set instructions "World map from WMS Map Server should be displayed in PLOT with Blue Marble (Next Generation) tiles. &
                        There should be two warnings in console: &
                        1. for GetCapabilities specifies invalid href for GetMap requests (without question mark at end) &
                        2. for WMS 1.3.0 server using WMS 1.1.1 exception format"
      gcontrol text    idtext "Instructions" "^instructions" 24 16 /title

    pipe off
  endif

  invoke ,, nxm.sys.lib.Shell.setJVMHangWorkaround(^jvmHangFix)
endmacro

!******************************************************************************!
procedure processMessage m:msg
  if msg.name eqs "MAIN" then
    assert/text="^reg.main.name: Interactive tests" msg.data eqss "PASS"
    pipe stop
  else
    say "Unhandled message name: ^msg.name from fid: ^msg.fid dats: ^msg.data"
  endif
return

!******************************************************************************!
! Set the dat directory
!******************************************************************************!
procedure setDatDir
  invoke nxmMajor env.nmversion.subString(0,1)
  invoke major java.lang.Integer.valueOf(nxmMajor)
  if major GE 4 then
    invoke s:datDir           nxm.sys.test.DatLocator.getDatDirLocation()
    invoke s:datDirSlash      nxm.sys.test.DatLocator.getDatDirSlashLocation()
    invoke z:sysDatFull       nxm.sys.test.DatLocator.sysDatFull()
    invoke z:sysTestDatExists nxm.sys.test.DatLocator.sysTestDatExists()
  else
    set s:datDir           "nxm.sys.dat"
    set s:datDirSlash      "nxm/sys/dat"
    set z:sysDatFull       true
    set z:sysTestDatExists false
  endif
return
