Skip to content

Instantly share code, notes, and snippets.

@AndrewTheTM
Created October 8, 2012 13:31
Show Gist options
  • Save AndrewTheTM/3852559 to your computer and use it in GitHub Desktop.
Save AndrewTheTM/3852559 to your computer and use it in GitHub Desktop.
Path Reader DLL Program
public static void main(String[] args) {
try{
voyagerDLL vdll=voyagerDLL.INSTANCE;
String err="";
int errB=256;
Pointer pathState=vdll.PathReaderOpen("C:\\Modelrun\\FieldsErtel\\05e05i05i05aV76FE\\AMPATHS.PTH", err, errB);
int nTables=vdll.PathReaderGetNumTables(pathState);
String[] tNames=new String[nTables];
int tnr=vdll.PathReaderGetTableNames(pathState, tNames);
int prZones=vdll.PathReaderGetNumZones(pathState);
int prIter=vdll.PathReaderGetNumIterations(pathState);
int prVol=vdll.PathReaderGetHighestVol(pathState);
int prMaxPathLen=vdll.PathReaderGetMaxPathLen(pathState);
int prNumPaths=vdll.PathReaderGetNumPaths(pathState);
vdll.PathReaderRewind(pathState);
PathRead_Data prd=new PathRead_Data();
for(int p=0;p<=10;p++){
int prrn=vdll.PathReaderReadNext(pathState,prd);
System.out.println(prrn);
int[] node=new int[prrn];
node=prd.nodes.getPointer().getIntArray(0, prrn);
int[] cost=new int[prrn];
cost=prd.costs.getPointer().getIntArray(0, prrn);
/*
* BIG IMPORTANT NOTE
* The Cost value here does not match what you'd get from C++. I'm not sure that either works
* properly, since the cost value I was expecting was for an array, and I'm seeing one value.
*/
float[] volume=new float[prrn];
volume=prd.vols.getPointer().getFloatArray(0, prrn);
/*
* BIG IMPORTANT NOTE
* I'm not sure if this value is correct in C++ or Java. Use caution when using it.
*/
}
vdll.PathReaderClose(pathState);
System.out.println("Complete!");
}catch (Exception e){
e.printStackTrace();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment