Welcome to the Harris Geospatial product documentation center. Here you will find reference guides, help documents, and product libraries.


  >  Docs Center  >  IDL Reference  >  I/O - Network  >  IDLnetJPIP Example

IDLnetJPIP Example

IDLnetJPIP Example

The following example uses the IDLnetJPIP object class to access and display JPEG2000 data from a remote server. Please note that before you compile the code (below) in your IDL Workbench, you must edit two lines in the PRO code for jpip_kakadu_server_test to provide the correct information for the remote JPIP server (the sections that need input are noted in the code comments).

 

;;-------------------------------------------
FUNCTION jpip_progressive_updates, img, data
  compile_opt idl2
  ON_ERROR, 2                    ; Return errors to caller.
   
  ; Catch all errors and display an error dialog.
  CATCH, errorStatus             
  IF (errorStatus ne 0) THEN BEGIN
     CATCH, /CANCEL
     PRINT, !error_state.msg
     r = DIALOG_MESSAGE(!error_state.msg, TITLE='JPIP Error', $
        DIALOG_PARENT=cwBase, /ERROR)
     RETURN, 1
  ENDIF
   
  PRINT, 'progressive update
  ;;HELP, img
   
  IF (data NE 3) THEN BEGIN
     TV, img
  ENDIF
   
  IF (data EQ 3) then begin
     TV, img, TRUE=1
  ENDIF
   
  RETURN, 1
END
 
 
;;------------------------------------------------
FUNCTION jpip_status_msgs, msg, data
  compile_opt idl2
     ON_ERROR, 2                   ; Return errors to caller.
   
             ; Catch all errors and display an error dialog.
  CATCH, errorStatus            
  IF (errorStatus NE 0) THEN BEGIN
    CATCH, /CANCEL
    PRINT, !error_state.msg
    r = Dialog_Message(!error_state.msg, TITLE='JPIP Error', $
       DIALOG_PARENT=cwBase, /ERROR)
    RETURN, 1
  ENDIF
   
  PRINT, msg
  RETURN, 1
end
 
 
 
;;-------------------------------------------------
PRO jpip_img_props, oJpip
   compile_opt idl2
 
  ; Catch all errors and display an error dialog.
  CATCH, errorStatus            
  IF (errorStatus NE 0) THEN BEGIN
  CATCH, /CANCEL
  PRINT, !error_state.msg
  r = DIALOG_MESSAGE(!error_state.msg, TITLE='JPIP Error', $
     DIALOG_PARENT=cwBase, /ERROR)
  RETURN
  ENDIF
   
  PRINT, ''
   
  oJpip->GetProperty, BIT_DEPTH = BIT_DEPTH
  PRINT, 'BIT_DEPTH         =', STRTRIM(STRING(BIT_DEPTH), 2)
   
  oJpip->GetProperty, COLOR_SPACE = COLOR_SPACE
  PRINT, 'COLOR_SPACE       =', COLOR_SPACE
   
  oJpip->GetProperty, DIMENSIONS = DIMENSIONS
  PRINT, 'DIMENSIONS        =', STRTRIM(STRING(DIMENSIONS), 2)
   
  oJpip->GetProperty, N_COMPONENTS = N_COMPONENTS
  PRINT, 'N_COMPONENTS      =', STRTRIM(STRING(N_COMPONENTS), 2)
   
  oJpip->GetProperty, N_LAYERS = N_LAYERS
  PRINT, 'N_LAYERS          =', STRTRIM(STRING(N_LAYERS), 2)
   
  oJpip->GetProperty, N_LEVELS = N_LEVELS
  PRINT, 'N_LEVELS          =', STRTRIM(STRING(N_LEVELS), 2)
   
  oJpip->GetProperty, N_TILES = N_TILES
  PRINT, 'N_TILES           =', STRTRIM(STRING(N_TILES), 2)
   
  oJpip->GetProperty, PROGRESSION = PROGRESSION
  PRINT, 'PROGRESSION       =', PROGRESSION
   
  oJpip->GetProperty, REVERSIBLE = REVERSIBLE
  PRINT, 'REVERSIBLE        =', STRTRIM(STRING(REVERSIBLE), 2)
   
  oJpip->GetProperty, SIGNED = SIGNED
  PRINT, 'SIGNED            =', STRTRIM(STRING(SIGNED), 2)
   
  oJpip->GetProperty, TILE_DIMENSIONS = TILE_DIMENSIONS
  PRINT, 'TILE_DIMENSIONS   =', STRTRIM(STRING(TILE_DIMENSIONS), 2)
   
  oJpip->GetProperty, TILE_RANGE = TILE_RANGE
  PRINT, 'TILE_RANGE        =', STRTRIM(STRING(TILE_RANGE ), 2)
   
  oJpip->GetProperty, YCC = YCC
  PRINT, 'YCC               =', STRTRIM(STRING(YCC), 2)
   
  PRINT, ''
 
end
 
;;----------------------------------------------
PRO jpip_kakadu_server_test
  compile_opt idl2
  ; To make this example work you must provide a
  ; valid JPIP server url and port number;
  ; valid path to an image on the server.
   
             ; Catch all errors and display an error dialog.
  CATCH, errorStatus 
  IF (errorStatus NE 0) THEN BEGIN
    CATCH, /CANCEL
    PRINT, !error_state.msg
    r = DIALOG_MESSAGE(!error_state.msg, TITLE='JPIP Error', $
       DIALOG_PARENT=cwBase, /ERROR)
    RETURN
  ENDIF
   
  oJpip = OBJ_NEW('IdlNetJpip')
   
    ; *********************************************
    ; YOU MUST EDIT THE NEXT TWO LINES
    ; You must provide a valid JPIP server url and port number.
    oJpip->SetProperty, SERVER_NAME = '10.17.2.13'
    oJpip->SetProperty, SERVER_PORT = 82
     
    oJpip->SetProperty, STATUS_CALLBACK_FUNCTION = 'jpip_status_msgs'
    oJpip->SetProperty, STATUS_CALLBACK_DATA = 1001
    oJpip->SetProperty, PROGRESSIVE_CALLBACK_FUNCTION = 'jpip_progressive_updates'
     
    ; Open a dataset on the JPIP server.
    ;**********************************************
    ; YOU MUST EDIT THIS LINE
    ; You must provide a valid path to an image on the server.
    oJpip->Open, 'jp2/utm.jp2
    region = [0, 0, 511, 511]
     
    jpip_img_props, oJpip
    oJpip->GetProperty, N_COMPONENTS = ncomps
    oJpip->GetProperty, N_LAYERS = nlayers
    oJpip->SetProperty, PROGRESSIVE_CALLBACK_DATA = ncomps
     
    img = oJpip->GetData(REGION=region, DISCARD_LEVELS=0, $
       MAX_LAYERS=nlayers, STREAM_DIMENSIONS=strmdims)
     
    IF (ncomps NE 3) THEN BEGIN
       TV, img
    ENDIF
     
    IF (ncomps EQ 3) THEN BEGIN
       TV, img, TRUE=1
    ENDIF
     
    oJpip->GetStatistics, AVAILABLE_BYTES=ab, BIT_RATE=br, BYTES_STREAMED=bs
    msg = 'Stats:        Available Bytes = ' +  STRTRIM(ab, 2) + ', Bit Rate = ' +  STRTRIM(br, 2) + ', Bytes Streamed = ' +  STRTRIM(bs, 2)
    PRINT, msg
     
    OBJ_DESTROY, oJpip
   
  PRINT, 'done'
 

See Also


CATCH, DIALOG_MESSAGE, IDLnetJPIP, OBJ_DESTROY, OBJ_NEW, STRTRIM, TV



© 2018 Harris Geospatial Solutions, Inc. |  Legal
My Account    |    Store    |    Contact Us