Skip to content

Commit d816d6b

Browse files
committed
getSize() implemented
1 parent b0730d6 commit d816d6b

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

core/src/main/java/com/bc/fiduceo/reader/smos/SmosL1CDailyGriddedReader.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,10 @@ public List<Variable> getVariables() throws InvalidRangeException, IOException {
138138

139139
@Override
140140
public Dimension getProductSize() throws IOException {
141-
throw new IllegalStateException("not implemented");
141+
final Array longitudes = arrayCache.get("lon");
142+
final Array latitudes = arrayCache.get("lat");
143+
144+
return new Dimension("size", (int) longitudes.getSize(), (int) latitudes.getSize());
142145
}
143146

144147
@Override
@@ -151,7 +154,6 @@ public String getLatitudeVariableName() {
151154
return "lat";
152155
}
153156

154-
155157
private File extractFromTar(File file) throws IOException {
156158
TarArchiveInputStream tarIn = null;
157159
final int oneMb = 1024 * 1024;
@@ -240,7 +242,7 @@ static Polygon createPolygonFromMinMax(double[] geoMinMax, GeometryFactory geome
240242
* package access for testing only tb 2022-09-26
241243
*
242244
* @param longitudes longitude data
243-
* @param latitudes latitude data
245+
* @param latitudes latitude data
244246
* @return array with the extreme values
245247
*/
246248
static double[] extractMinMax(Array longitudes, Array latitudes) {

core/src/test/java/com/bc/fiduceo/reader/smos/SmosL1CDailyGriddedReader_IO_Test.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.bc.fiduceo.IOTestRunner;
44
import com.bc.fiduceo.TestUtil;
5+
import com.bc.fiduceo.core.Dimension;
56
import com.bc.fiduceo.core.NodeType;
67
import com.bc.fiduceo.geometry.*;
78
import com.bc.fiduceo.reader.AcquisitionInfo;
@@ -18,15 +19,15 @@
1819

1920
import static org.junit.Assert.*;
2021

22+
@SuppressWarnings("NewClassNamingConvention")
2123
@RunWith(IOTestRunner.class)
2224
public class SmosL1CDailyGriddedReader_IO_Test {
2325

2426
private SmosL1CDailyGriddedReader reader;
25-
private ReaderContext readerContext;
2627

2728
@Before
2829
public void setUp() throws IOException {
29-
readerContext = new ReaderContext();
30+
final ReaderContext readerContext = new ReaderContext();
3031
readerContext.setGeometryFactory(new GeometryFactory(GeometryFactory.Type.S2));
3132

3233
final File testDir = TestUtil.getTestDir();
@@ -88,8 +89,28 @@ public void testReadAcquisitionInfo_CDF3TA() throws IOException {
8889
}
8990
}
9091

92+
@Test
93+
public void testGetProductSize_CDF3TD() throws IOException {
94+
final File file = getCDF3TDFile();
95+
try {
96+
reader.open(file);
97+
98+
final Dimension productSize = reader.getProductSize();
99+
assertNotNull(productSize);
100+
assertEquals(1388, productSize.getNx());
101+
assertEquals(584, productSize.getNy());
102+
} finally {
103+
reader.close();
104+
}
105+
}
106+
91107
private File getCDF3TAFile() throws IOException {
92108
final String testFilePath = TestUtil.assembleFileSystemPath(new String[]{"miras-smos-CDF3TA", "re07", "2016", "162", "SM_RE07_MIR_CDF3TA_20160610T000000_20160610T235959_330_001_7.tgz"}, false);
93109
return TestUtil.getTestDataFileAsserted(testFilePath);
94110
}
111+
112+
private File getCDF3TDFile() throws IOException {
113+
final String testFilePath = TestUtil.assembleFileSystemPath(new String[]{"miras-smos-CDF3TD", "re07", "2017", "324", "SM_RE07_MIR_CDF3TD_20171120T000000_20171120T235959_330_001_7.tgz"}, false);
114+
return TestUtil.getTestDataFileAsserted(testFilePath);
115+
}
95116
}

0 commit comments

Comments
 (0)