ISINGrid { public static int detectRowCount(String productName) { Pattern p = Pattern.compile(".*_(\\d{4})x(\\d{4})_.*"); Matcher m = p.matcher(productName); if (m.matches() && m.groupCount() == 2) { String binSize1 = m.group(1); String binSize2 = m.group(2); if (binSize1.equals(binSize2)) { int binSize = Integer.parseInt(binSize1); return (int) Math.round(Math.PI * RE * 1000 / binSize); } } return DEFAULT_ROW_COUNT; } ISINGrid(int rowCount); int getRowCount(); double getBinSize(); double getDeltaLat(); int getTotalBinCount(); double getLat(int rowIndex); double getDeltaLon(int rowIndex); int getRowLength(int rowIndex); int getBinOffset(int rowIndex); int getRowIndex(int binIndex); Point getGridPoint(int binIndex, Point gridPoint); int getBinIndex(Point gridPoint); int getColIndex(int rowIndex, double lon); int getBinIndex(int rowIndex, double lon); static int detectRowCount(String productName); static final double RE; static final int DEFAULT_ROW_COUNT; }
@Test public void testDetectRowCount() throws Exception { final String name9277 = "L3_ENV_MER_A443_m__20030301_GLOB_SI_ACR_9277x9277_-90+90+-180+180_0000.nc"; assertEquals(2160, ISINGrid.detectRowCount(name9277)); final String name4320 = "L3_ENV_MER_CHL1_d__20070101_GLOB_SI_ESA_4638x4638_-90+90+-180+180_0000.nc"; assertEquals(4320, ISINGrid.detectRowCount(name4320)); final String nameFoo = "foo"; assertEquals(2160, ISINGrid.detectRowCount(nameFoo)); }