!******************************************************************************!
! Tests range calculations on LayerGeoJSON.
!
! @issue:  NXM-3679 GeoJSON support
! @since:  NeXtMidas 4.1.4
! @author: Zachary Matthews
!******************************************************************************!
startmacro/auto
  switch INTERACTIVE interAct GET DEF=TRUE  SDEF=TRUE  ! for normal interactive test(s)
  switch BASELINE    baseline GET DEF=FALSE SDEF=TRUE  ! for defects or more obscure test case(s)

  if interAct then
    call setDatDir

    set defaultInstructions "&
       Top Left Plot:\n&
         - Puerto Rico GeoJSON zoomed to fit\n&
         - Plot bounds should be approximately longitude -68 to -65 and latitude 17 to 19\n\n&
       Top Right Plot:\n&
         - Multiple GeoJSON Objects zoomed to fit\n&
         - Plot bounds should be approximately longitude -150 to 150 and latitude -71 to 70\n\n&
       Bottom Plot:\n&
         - Puerto Rico GeoJSON (zoomed out) on top of world\n&
         - Plot bounds should be longitude -180 to 180 and latitude -90 to 90\n&
       _________________________________________________________\n&
       Note: \n&
       Puerto Rico was modified to have an additional inner polygon added to it."

    pipe init
      panel/msgid=MAIN/setup/controls=gc

      gcontrol label mainLabel "Main"
      gcontrol menu main "Exit with Status = " "PASS,FAIL" /tleft
      set gc.main.itemColors {PASS=GREEN,FAIL=RED}
      plot/id=idplotPuertoRico/msgid=main/READOUT="+OnAxis"                             nxm.sys.test.puerto_rico_mod.geojson{Layer={LT="GeoJSON"}}
      plot/id=idplotGeoDataJson/msgid=main/READOUT="+OnAxis"                            nxm.sys.test.geo_data_json.geojson{Layer={LT="GeoJSON"}}
      plot/id=idplotWorldAndPuertoRico/msgid=main/READOUT="+OnAxis" ^{datDir}.world.prm|nxm.sys.test.puerto_rico_mod.geojson{Layer={LT="GeoJSON"}}

      gcontrol text idtext "Instructions" "^defaultInstructions" 24 16 /title
    pipe off
  endif
endmacro

!******************************************************************************!
! Main process message for this macro. Should be right after the ENDMACRO.
!******************************************************************************!
procedure processMessage m:msg
  if msg.name eqs "MAIN" then
    assert/text="^reg.main.name user indicated" msg.data eqss "PASS"
    pipe stop
  else
    say "Unhandled message name: ^msg.name from fid: ^msg.fid data: ^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
