PixExOp extends Operator { static List<Coordinate> extractMatchupCoordinates(File matchupFile) { final List<Coordinate> result = new ArrayList<>(); List<SimpleFeature> simpleFeatures; try { simpleFeatures = PixExOpUtils.extractFeatures(matchupFile); } catch (IOException e) { BeamLogManager.getSystemLogger().warning( String.format("Unable to read matchups from file '%s'. Reason: %s", matchupFile.getAbsolutePath(), e.getMessage())); return result; } for (SimpleFeature extendedFeature : simpleFeatures) { try { final Coordinate.OriginalValue[] originalValues = getOriginalValues(extendedFeature); final GeoPos geoPos; geoPos = PixExOpUtils.getGeoPos(extendedFeature); final Date dateTime = (Date) extendedFeature.getAttribute(Placemark.PROPERTY_NAME_DATETIME); result.add(new Coordinate(extendedFeature.getID(), geoPos.lat, geoPos.lon, dateTime, originalValues)); } catch (IOException e) { BeamLogManager.getSystemLogger().warning(e.getMessage()); } } return result; }  @SuppressWarnings({"unchecked", "ConstantConditions"}) static Coordinate.OriginalValue[] getOriginalValues(SimpleFeature feature); @Override void initialize(); static Set<File> getSourceProductFileSet(String[] sourceProductPaths, Logger logger); @Override void dispose(); static final String RECURSIVE_INDICATOR; static final String NO_AGGREGATION; static final String MEAN_AGGREGATION; static final String MIN_AGGREGATION; static final String MAX_AGGREGATION; static final String MEDIAN_AGGREGATION; }
@Test public void testExtractMatchupCoordinates() throws Exception { final File testFile = new File(getClass().getResource("test.csv").getFile()); final List<Coordinate> coordinates = PixExOp.extractMatchupCoordinates(testFile); assertEquals(2, coordinates.size()); assertEquals("0", coordinates.get(0).getName()); assertEquals(56.0123, (double) coordinates.get(0).getLat(), 0.0001); assertEquals(6.2345, (double) coordinates.get(0).getLon(), 0.0001); final Coordinate.OriginalValue[] originalValues = coordinates.get(0).getOriginalValues(); assertEquals(4, originalValues.length); assertEquals("test1.1", originalValues[1].value); assertEquals(0.2F, Float.parseFloat(originalValues[2].value), 0.001); assertEquals(0.3F, Float.parseFloat(originalValues[3].value), 0.001); assertEquals("1", coordinates.get(1).getName()); assertEquals(56.0124, (double) coordinates.get(1).getLat(), 0.0001); assertEquals(6.2346, (double) coordinates.get(1).getLon(), 0.0001); final Coordinate.OriginalValue[] originalValues1 = coordinates.get(1).getOriginalValues(); assertEquals(4, originalValues.length); assertEquals("test1.2", originalValues1[1].value); assertEquals(0.21F, Float.parseFloat(originalValues1[2].value), 0.001); assertEquals(0.31F, Float.parseFloat(originalValues1[3].value), 0.001); }