EEExportGridPointHandler implements GridPointHandler { @Override public void handleGridPoint(int id, CompoundData gridPointData) throws IOException { if (gridPointCount == 0) { init(gridPointData); } if (targetFilter.accept(id, gridPointData)) { trackSensingTime(gridPointData); trackGeometry(gridPointData); targetContext.getData().setLong(SmosConstants.GRID_POINT_COUNTER_NAME, ++gridPointCount); targetContext.getData().flush(); gridPointData.resolveSize(); final long size = gridPointData.getSize(); final byte[] bytes = new byte[(int) size]; get(gridPointData, bytes); put(targetContext, bytes, gridPointDataPosition); gridPointDataPosition += size; } } EEExportGridPointHandler(DataContext targetContext);   EEExportGridPointHandler(DataContext targetContext, GridPointFilter targetFilter); @Override void handleGridPoint(int id, CompoundData gridPointData);  }
@Test public void handleGridPointsForScenario27() throws URISyntaxException, IOException { final ProductFile productFile = SmosProductReader.createProductFile(getResourceAsFile(SCENARIO_27_DBL_NAME)); assertTrue(productFile instanceof SmosFile); final SmosFile sourceFile = (SmosFile) productFile; final GridPointList sourceGridPointList = sourceFile.getGridPointList(); assertEquals(5533, sourceGridPointList.getElementCount()); final DataContext targetContext = sourceFile.getDataFormat().createContext(new ByteArrayIOHandler()); final GridPointHandler handler = new EEExportGridPointHandler(targetContext, new GridPointFilter() { @Override public boolean accept(int id, CompoundData gridPointData) throws IOException { return id == 0 || id == 7; } }); for (int i = 0; i < sourceGridPointList.getElementCount(); i++) { final CompoundData gridPointData = sourceGridPointList.getCompound(i); handler.handleGridPoint(i, gridPointData); } final CompoundData targetData = targetContext.createData(); targetContext.dispose(); final DataPrinter dataPrinter = new DataPrinter(); dataPrinter.print(targetData); final SequenceData targetSnapshotList = targetData.getSequence(SmosConstants.SNAPSHOT_LIST_NAME); assertEquals(2, targetSnapshotList.getElementCount()); assertEquals(60046, targetSnapshotList.getCompound(0).getInt("Snapshot_ID")); assertEquals(60047, targetSnapshotList.getCompound(1).getInt("Snapshot_ID")); final SequenceData targetGridPointList = targetData.getSequence(SmosConstants.GRID_POINT_LIST_NAME); assertEquals(2, targetGridPointList.getElementCount()); assertGridPointData(targetGridPointList.getCompound(0), 233545, 70.169426F, 173.99301F); assertGridPointData(targetGridPointList.getCompound(1), 235084, 62.994823F, 179.01186F); }