Skip to content

Commit

Permalink
support micaps data file with BOM using Apache commons io library
Browse files Browse the repository at this point in the history
  • Loading branch information
Yaqiang committed Feb 14, 2022
1 parent 46d39b5 commit 5fe37be
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 5 deletions.
1 change: 1 addition & 0 deletions meteoinfo-chart/meteoinfo-chart.iml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
<orderEntry type="module" module-name="meteoinfo-dataframe" />
<orderEntry type="library" name="Maven: edu.ucar:netcdfAll:5.4.1" level="project" />
<orderEntry type="library" name="Maven: com.github.albfernandez:juniversalchardet:2.4.0" level="project" />
<orderEntry type="library" name="Maven: commons-io:commons-io:2.11.0" level="project" />
<orderEntry type="library" name="Maven: com.formdev:flatlaf:2.0.1" level="project" />
<orderEntry type="library" name="Maven: com.formdev:flatlaf-extras:2.0.1" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: com.formdev:svgSalamander:1.1.3" level="project" />
Expand Down
1 change: 1 addition & 0 deletions meteoinfo-data/meteoinfo-data.iml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@
<orderEntry type="module" module-name="meteoinfo-dataframe" />
<orderEntry type="library" name="Maven: edu.ucar:netcdfAll:5.4.1" level="project" />
<orderEntry type="library" name="Maven: com.github.albfernandez:juniversalchardet:2.4.0" level="project" />
<orderEntry type="library" name="Maven: commons-io:commons-io:2.11.0" level="project" />
</component>
</module>
5 changes: 5 additions & 0 deletions meteoinfo-data/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@
<artifactId>juniversalchardet</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.11.0</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,13 @@ private void readXY(Range yRange, Range xRange, IndexIterator ii) {
do {
aLine = sr.readLine();
if (aLine == null) {
while (dataList.size() >= xNum) {
for (i = 0; i < xNum; i++) {
theData[col][i] = Float.parseFloat(dataList.get(i));
}
dataList = dataList.subList(xNum, dataList.size());
col += 1;
}
break;
}
aLine = aLine.trim();
Expand Down Expand Up @@ -374,6 +381,13 @@ public GridData getGridData_LonLat(int timeIdx, String varName, int levelIdx) {
do {
aLine = sr.readLine();
if (aLine == null) {
while (dataList.size() >= xNum) {
for (i = 0; i < xNum; i++) {
theData[col][i] = Float.parseFloat(dataList.get(i));
}
dataList = dataList.subList(xNum, dataList.size());
col += 1;
}
break;
}
aLine = aLine.trim();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/
package org.meteoinfo.data.meteodata.micaps;

import org.apache.commons.io.input.BOMInputStream;
import org.meteoinfo.data.meteodata.MeteoDataType;

import java.io.BufferedReader;
Expand Down Expand Up @@ -45,7 +46,7 @@ public static MeteoDataType getDataType(String fileName) {
MeteoDataType mdType = null;
try {
String dataType;
sr = new BufferedReader(new InputStreamReader(new FileInputStream(fileName), "gbk"));
sr = new BufferedReader(new InputStreamReader(new BOMInputStream(new FileInputStream(fileName)), "gbk"));
String aLine;
String[] dataArray;

Expand Down
1 change: 1 addition & 0 deletions meteoinfo-geo/meteoinfo-geo.iml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
<orderEntry type="module" module-name="meteoinfo-dataframe" />
<orderEntry type="library" name="Maven: edu.ucar:netcdfAll:5.4.1" level="project" />
<orderEntry type="library" name="Maven: com.github.albfernandez:juniversalchardet:2.4.0" level="project" />
<orderEntry type="library" name="Maven: commons-io:commons-io:2.11.0" level="project" />
<orderEntry type="library" name="Maven: org.meteothink:wContour:1.7.1" level="project" />
<orderEntry type="library" name="Maven: com.l2fprod:l2fprod-common-all:0.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.12.0" level="project" />
Expand Down
1 change: 1 addition & 0 deletions meteoinfo-lab/meteoinfo-lab.iml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
<orderEntry type="module" module-name="meteoinfo-dataframe" />
<orderEntry type="library" name="Maven: edu.ucar:netcdfAll:5.4.1" level="project" />
<orderEntry type="library" name="Maven: com.github.albfernandez:juniversalchardet:2.4.0" level="project" />
<orderEntry type="library" name="Maven: commons-io:commons-io:2.11.0" level="project" />
<orderEntry type="library" name="Maven: com.formdev:flatlaf:2.0.1" level="project" />
<orderEntry type="library" name="Maven: com.formdev:flatlaf-extras:2.0.1" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: com.formdev:svgSalamander:1.1.3" level="project" />
Expand Down
10 changes: 7 additions & 3 deletions meteoinfo-lab/milconfig.xml
Original file line number Diff line number Diff line change
@@ -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\meteo\interpolation">
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\mesh"/>
<Path OpenPath="D:\Working\MIScript\Jython\mis\micaps">
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\isosurface"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\particles"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\streamslice"/>
Expand All @@ -11,22 +10,27 @@
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d_earth"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\chart"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\array"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\meteo\calc"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\meteo"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\meteo\interpolation"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\micaps"/>
</Path>
<File>
<OpenedFiles>
<OpenedFile File="D:\Working\MIScript\Jython\mis\meteo\calc\potential_vorticity_baroclinic.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\meteo\calc\isentropic_analysis.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\meteo\interpolation\log_interpolate_1d_1.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\micaps\micaps_4_1.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\micaps\test_read_bom.py"/>
</OpenedFiles>
<RecentFiles>
<RecentFile File="D:\Working\MIScript\Jython\mis\meteo\calc\potential_vorticity_baroclinic.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\meteo\calc\isentropic_analysis.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\meteo\interpolation\log_interpolate_1d_1.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\micaps\micaps_4_1.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\micaps\test_read_bom.py"/>
</RecentFiles>
</File>
<Font>
Expand Down
2 changes: 1 addition & 1 deletion meteoinfo-map/config.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<MeteoInfo File="config.xml" Type="configurefile">
<Path OpenPath="D:\Temp\traj\Sample"/>
<Path OpenPath="D:\Temp\micaps\test"/>
<Font>
<TextFont FontName="YaHei Consolas Hybrid" FontSize="14"/>
<LegendFont FontName="宋体" FontSize="12"/>
Expand Down
1 change: 1 addition & 0 deletions meteoinfo-map/meteoinfo-map.iml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
<orderEntry type="module" module-name="meteoinfo-dataframe" />
<orderEntry type="library" name="Maven: edu.ucar:netcdfAll:5.4.1" level="project" />
<orderEntry type="library" name="Maven: com.github.albfernandez:juniversalchardet:2.4.0" level="project" />
<orderEntry type="library" name="Maven: commons-io:commons-io:2.11.0" level="project" />
<orderEntry type="library" name="Maven: com.formdev:flatlaf:2.0.1" level="project" />
<orderEntry type="library" name="Maven: com.formdev:flatlaf-extras:2.0.1" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: com.formdev:svgSalamander:1.1.3" level="project" />
Expand Down

0 comments on commit 5fe37be

Please sign in to comment.