/** * Retrieves the geolocation information for the given product type * * @param prodType * @return the geolocation information */ public String[] getGeolocationInformation(final String prodType) { String[] strRet = null; try { final ModisProductDescription prod = getProductDescription(prodType); strRet = prod.getGeolocationDatasetNames(); } catch (IOException e) { logger.severe("Unable to retrieve geolocation information for product type '" + prodType + "'."); } return strRet; }
/** * Tests the correct functionality of the geolocation accessors. */ @Test public void testGeolocationAccess() { // none shall be set initially assertNull(prod.getGeolocationDatasetNames()); // set a tie point geolocation and check String expLat = "latitude"; String expLon = "longitude"; String[] geoLoc; prod.setGeolocationDatasetNames(expLat, expLon); geoLoc = prod.getGeolocationDatasetNames(); assertNotNull(geoLoc); assertEquals(2, geoLoc.length); assertEquals(expLat, geoLoc[0]); assertEquals(expLon, geoLoc[1]); }
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); } } }
@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); }
/** * 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()); }