ENVI/IDL——Java-IDL Export Bridge

6105 ワード

タスク:
リモートセンシング画像の各画素点に対応する帯域値や緯度などの情報をデータベースに統一して挿入し、クエリー管理を容易にします.
技術の探求:
下一篇博文http://blog.csdn.net/niaokedaoren/article/details/8881620,帯域値と緯度をプローブ的にコードで読み出すだけである.
しかし、複数の画像を処理するには、いくつかのフォルダの間を泳ぐ必要があります.IDLはこの面で力がないようです.同時にIDLはデータベースのリンクをサポートするが、
ODBCのようですが、使いにくい感じです.そこでIDLとJavaの混成形式で、このタスクを完了しようとしました.IDLのhelpドキュメントには確かに
この技術に言及した.
もう一つhelloworld
書く前にIDLのhelpドキュメントを見て、IDL Programmers'Guides->IDL Connectivity Bridgesというセクションで見たほうがいいです.
具体的な任務をする前に、helpドキュメントの例helloworldを試してみました.helloworldはどこにもいないようです.ほほほ.
1.環境の構成
私はwin 7を使って、classpath変数の中でプラスします:ENVI_DIR\ENVI\IDL71\resource\bridges\export\java\javaidlb.jar
2.procedureの作成
小さなクラス
function helloword::init
  return, 1
end

pro helloworld__define
  struct = {helloworld, $
    dummy:0b $
  }
end

3.javaクラスに包装する
IDEのコマンドラインでコマンドを入力:ENVI>IDLEBR_ASSISTANT
Export Bridge Assistantというウィンドウが出てきます
具体的な操作はhelpドキュメントを見てください.詳しいです.
生成されたコード:
// This code has been generated by the code Wizard and should not be
// modified.  The recommended manner of changing the behavior is to
// implement a class that inherits from this generated class.

package helloworld;

import com.idl.javaidl.*;

public class helloworld extends JIDLObject
{
   // Constants set by Wizard
   private static String IDL_CLASS = "helloworld";
   private static String OPS_NAME  = "Default_Process_Name";

   // Constructor
   public helloworld() {
      super(IDL_CLASS, OPS_NAME);
   }

   // properties generated by Wizard

   // class methods generated by Wizard

}

4.javaで呼び出す
テストコード:
package helloworld; 
import com.idl.javaidl.*; 
public class helloworld_example extends helloworld 
implements JIDLOutputListener 
{ 
   private helloworld hwObj; 
 
   // Constructor 
   public helloworld_example() { 
      hwObj = new helloworld(); 
      hwObj.createObject(); 
      hwObj.addIDLOutputListener(this); 
      hwObj.executeString("print, 'Hello World'"); 
   } 
 
   // implement JIDLOutputListener 
   public void IDLoutput(JIDLObjectI obj, String sMessage) { 
      System.out.println("IDL: "+sMessage); 
   } 
 
   public static void main(String[] argv) { 
      helloworld_example example = new helloworld_example(); 
   } 
}

コンパイルして、実行して、直接エラーを報告します:
Exception in thread "main"com.idl.javaidl.JIDLException[iErr=-999 sMsg=Attempt to call undefined procedure/function: 'HELLOWORLD__DEFINE'.]         at com.idl.javaidl.JIDLPAL.nativeThrowJIDLException(Native Method)         at com.idl.javaidl.JIDLPAL.throwSpecificException(JIDLPAL.java:1073)         at com.idl.javaidl.JIDLPAL.throwJIDLException(JIDLPAL.java:1102)         at com.idl.javaidl.JIDLPAL.createObject(JIDLPAL.java:382)         at com.idl.javaidl.JIDLPAL.createObject(JIDLPAL.java:318)         at com.idl.javaidl.JIDLObject.createObject(JIDLObject.java:193)         at com.idl.javaidl.JIDLObject.createObject(JIDLObject.java:103)         at helloworld.helloworld_example.(helloworld_example.java:11)         at helloworld.helloworld_example.main(helloworld_example.java:22)
ソリューション:
問題の原因はIDLのsearch PATHの下で根本的にさっき書いたそのproが探し出せないので、java類に包装された東東は事実をやらないことを知っていて、それはproを呼び出すことを通じてです
で行ないます.>PREF_を使ってみますSET, 'IDL_PATH', 'ADD_DIR;',/COMMIT
プラスしていないので、いっそ簡単に暴力を振るって、直接helloworld_define.proファイルはENVIIDL 71libの下にコピーされます.もちろん、下にlocalなどのフォルダを作成することができます.
自分のproを統一する.
Can't be resolved
いくつかの例の実験をして、心の中で底がついて、本当の任務を完成することに着手しました.
しかし、時には、現実は想像以上に残酷になることが多い.
例えばENVI_FILE_OPEN, ENVI_FILE_QUERY, ENVI_GET_SLICE等ENVI_*形式のroutine報告:Warning...can not be resolved
これは、IDLが提供するAPIではなく、ENVIが提供するため、明らかに正常です.
あなたが私に絶技を強要して、再びgoogleの大法を使って、蒼天は心の人を負わないで、
神作を見てください.http://www.exelisvis.com/Company/PressRoom/TabId/190/ArtMID/786/ArticleID/4302/4302.aspx
すべてがこんなに順調に見えて、O(∩∩)Oはははは~
function DataExtractor::init
  compile_opt STRICTARR
  pathInfo = routine_info('dataextractor__define', /SOURCE)
  sourceCodeDir = file_dirname(pathInfo.path)
  cd, sourceCodeDir
  ; Basic ENVI startup routines
  enviLogFile = filepath('DataExtractor.log', ROOT_DIR=sourceCodeDir)
  call_procedure, "ENVI", /RESTORE_BASE_SAVE_FILES
  call_procedure, "ENVI_BATCH_INIT", LOG_FILE=enviLogFile
  return, 1
end

function DataExtractor::openFile, filename
  if (n_elements(filename) ne 0) then begin
    call_procedure, "ENVI_OPEN_FILE", filename, r_fid=fid, $
      /no_realize, /no_interactive_query
  endif else begin
    call_procedure, "ENVI_BATCH_EXIT"
    return, -1
  endelse
  if (fid eq -1) then begin
    call_procedure, "ENVI_BATCH_EXIT"
    return, -1
  endif
  self.fid = fid
  return, self.fid
end

function DataExtractor::closeFile
  call_procedure, "ENVI_FILE_MNG", id=self.fid, /remove
end

function DataExtractor::getMapInfo
  call_procedure, "ENVI_FILE_QUERY", self.fid, nl=nl, ns=ns, nb=nb
  self.mapInfo[0] = nl
  self.mapInfo[1] = ns
  self.mapInfo[2] = nb
  return, self.mapInfo 
end


function DataExtractor::getBands, x, y
  pos = lindgen(self.mapInfo[2])
  data = call_function("ENVI_GET_SLICE", fid=self.fid, line=y, pos=pos, $
    xs=x, xe=x, /bip)
  return, data
end

function DataExtractor::getLocation, x, y
  iproj = call_function("ENVI_GET_PROJECTION", fid=self.fid)
  oproj = call_function("ENVI_PROJ_CREATE", /geographic)
  call_procedure, "ENVI_CONVERT_FILE_COORDINATES", $
    self.fid, x, y, xmap, ymap, /to_map
  call_procedure, "ENVI_CONVERT_PROJECTION_COORDINATES", $
    xmap, ymap, iproj, oxmap, oymap, oproj
  location = dblarr(2)
  location[0] = oxmap
  location[1] = oymap
  return, location
end

pro DataExtractor__define
  struct = { $
    DataExtractor, $
    mapInfo: intarr(3), $
    fid: 0 $
  }
end

データベースのあの1枚はずっと简単で、あれは熟知しているjavaのする事で、明後日やりましょう、ほほほ、终わらないで続きます.