mirror of
https://github.com/meteoinfo/MeteoInfo.git
synced 2025-12-08 20:36:05 +00:00
update addfile function to support MICAPS data files
This commit is contained in:
parent
cf29d55b47
commit
c1661201df
@ -480,6 +480,8 @@ public class MeteoDataInfo {
|
||||
di = new ARLDataInfo();
|
||||
} else if (CMARadarBaseDataInfo.class.getDeclaredConstructor().newInstance().canOpen(fileName)) {
|
||||
di = new CMARadarBaseDataInfo();
|
||||
} else {
|
||||
di = MICAPSDataInfo.getDataInfo(raf);
|
||||
}
|
||||
raf.close();
|
||||
} catch (IOException | NoSuchMethodException ex) {
|
||||
|
||||
@ -274,6 +274,7 @@ public class GrADSDataInfo extends DataInfo implements IGridDataInfo, IStationDa
|
||||
|
||||
public boolean isValidFile(RandomAccessFile raf) {
|
||||
try {
|
||||
raf.seek(0);
|
||||
byte[] bytes = new byte[1000];
|
||||
raf.read(bytes);
|
||||
String line = new String(bytes).trim();
|
||||
|
||||
@ -14,13 +14,12 @@
|
||||
package org.meteoinfo.data.meteodata.micaps;
|
||||
|
||||
import org.apache.commons.io.input.BOMInputStream;
|
||||
import org.meteoinfo.data.meteodata.DataInfo;
|
||||
import org.meteoinfo.data.meteodata.MeteoDataType;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.*;
|
||||
import java.util.RandomAccess;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@ -107,6 +106,63 @@ public class MICAPSDataInfo {
|
||||
|
||||
return mdType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get MICAPS data info
|
||||
*
|
||||
* @param raf RandomAccessFile object
|
||||
* @return Data info
|
||||
*/
|
||||
public static DataInfo getDataInfo(RandomAccessFile raf) {
|
||||
DataInfo dataInfo = null;
|
||||
try {
|
||||
raf.seek(0);
|
||||
byte[] bytes = new byte[1000];
|
||||
raf.read(bytes);
|
||||
String line = new String(bytes).trim();
|
||||
if (line.substring(0, 4).equals("mdfs")) {
|
||||
dataInfo = new MDFSDataInfo();
|
||||
} else {
|
||||
StringTokenizer stoker = new StringTokenizer(line);
|
||||
if (stoker.countTokens() >= 2) {
|
||||
String dataType = stoker.nextToken() + " " + stoker.nextToken();
|
||||
if (dataType.contains("diamond 1")) {
|
||||
dataInfo = new MICAPS1DataInfo();
|
||||
}
|
||||
if (dataType.equals("diamond 2")) {
|
||||
dataInfo = new MICAPS2DataInfo();
|
||||
}
|
||||
if (dataType.equals("diamond 3")) {
|
||||
dataInfo = new MICAPS3DataInfo();
|
||||
}
|
||||
if (dataType.equals("diamond 4")) {
|
||||
dataInfo = new MICAPS4DataInfo();
|
||||
}
|
||||
if (dataType.equals("diamond 7")) {
|
||||
dataInfo = new MICAPS7DataInfo();
|
||||
}
|
||||
if (dataType.equals("diamond 11")) {
|
||||
dataInfo = new MICAPS11DataInfo();
|
||||
}
|
||||
if (dataType.equals("diamond 13")) {
|
||||
dataInfo = new MICAPS13DataInfo();
|
||||
}
|
||||
if (dataType.contains("iamond 120")) {
|
||||
dataInfo = new MICAPS120DataInfo();
|
||||
}
|
||||
if (dataType.contains("diamond 131")) {
|
||||
dataInfo = new MICAPS131DataInfo();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (FileNotFoundException ex) {
|
||||
Logger.getLogger(MICAPSDataInfo.class.getName()).log(Level.SEVERE, null, ex);
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(MICAPSDataInfo.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
|
||||
return dataInfo;
|
||||
}
|
||||
// </editor-fold>
|
||||
// <editor-fold desc="Methods">
|
||||
// </editor-fold>
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<MeteoInfo File="milconfig.xml" Type="configurefile">
|
||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\map">
|
||||
<RecentFolder Folder="D:\Run\emips\run_cams"/>
|
||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\io\micaps">
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\interpolate"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\LaSW\airship"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\dataconvert"/>
|
||||
@ -11,11 +10,12 @@
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\plot"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\mesh"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\geotiff"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map\projection"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\micaps"/>
|
||||
</Path>
|
||||
<File>
|
||||
<OpenedFiles>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user