private void addModisTiePointGeoCoding(Product product, NetCDFVariables netCDFVariables) throws IOException { ModisProductDescription prodDesc = prodDb.getProductDescription(product.getProductType()); final String[] geolocationDatasetNames; if (prodDesc.hasExternalGeolocation()) { // @todo 2 tb/tb this relies on the order of the tie point grids in the *.dd file. // better check the metadata for the lat/lon band names - // but for the test products this works fine. geolocationDatasetNames = loadExternalQCFile(product, prodDesc, netCDFVariables); } else { geolocationDatasetNames = prodDesc.getGeolocationDatasetNames(); } if (geolocationDatasetNames != null) { final TiePointGrid latGrid = product.getTiePointGrid(geolocationDatasetNames[0]); final TiePointGrid lonGrid = product.getTiePointGrid(geolocationDatasetNames[1]); if (latGrid != null && lonGrid != null) { // set cyclic behaviour lonGrid.setDiscontinuity(TiePointGrid.DISCONT_AT_180); // and create geo coding GeoCoding coding = new ModisTiePointGeoCoding(latGrid, lonGrid); product.setGeoCoding(coding); } } }
/** * Checks the correct functionality of the geocoding accessors */ @Test public void testGeocodingAccessors() { // intially everything is null and false String[] latlon; latlon = prod.getGeolocationDatasetNames(); assertNull(latlon); assertEquals(false, prod.hasExternalGeolocation()); assertNull(prod.getExternalGeolocationPattern()); // set lat/lon tiepoint geocoding String expLat = "latitude"; String expLon = "lomgitude"; prod.setGeolocationDatasetNames(expLat, expLon); assertEquals(false, prod.hasExternalGeolocation()); latlon = prod.getGeolocationDatasetNames(); assertNotNull(latlon); assertEquals(2, latlon.length); assertEquals(expLat, latlon[0]); assertEquals(expLon, latlon[1]); // set external geocoding String expExter = "external"; prod.setExternalGeolocationPattern(expExter); assertEquals(true, prod.hasExternalGeolocation()); assertEquals(expExter, prod.getExternalGeolocationPattern()); prod.setExternalGeolocationPattern(null); assertEquals(false, prod.hasExternalGeolocation()); assertEquals(null, prod.getExternalGeolocationPattern()); }
@Test public void testDefaultConstruction() { assertEquals(0, prod.getBandNames().length); assertNull(prod.getBandDescription("no_band")); assertEquals(false, prod.mustFlipTopDown()); assertArrayEquals(null, prod.getGeolocationDatasetNames()); assertEquals(null, prod.getExternalGeolocationPattern()); assertEquals(false, prod.hasExternalGeolocation()); assertEquals(0, prod.getTiePointNames().length); }