Header { private EnviMapInfo parseMapInfo(String line) { try { EnviMapInfo mapInfo = new EnviMapInfo(); final StringTokenizer tokenizer = createTokenizerFromLine(line); mapInfo.setProjectionName(tokenizer.nextToken().trim()); mapInfo.setReferencePixelX(Double.parseDouble(tokenizer.nextToken())); mapInfo.setReferencePixelY(Double.parseDouble(tokenizer.nextToken())); mapInfo.setEasting(Double.parseDouble(tokenizer.nextToken())); mapInfo.setNorthing(Double.parseDouble(tokenizer.nextToken())); mapInfo.setPixelSizeX(Double.parseDouble(tokenizer.nextToken())); mapInfo.setPixelSizeY(Double.parseDouble(tokenizer.nextToken())); if (mapInfo.getProjectionName().equalsIgnoreCase("UTM")) { mapInfo.setUtmZone(Integer.parseInt(tokenizer.nextToken().trim())); mapInfo.setUtmHemisphere(tokenizer.nextToken().trim()); } mapInfo.setDatum(tokenizer.nextToken().trim()); while(tokenizer.hasMoreTokens()) { String token = tokenizer.nextToken().trim(); if (token.startsWith("units=")) { mapInfo.setUnit(token.substring("units=".length())); } else if (token.startsWith("rotation=")) { String rotation = token.substring("rotation=".length()); mapInfo.setOrientation(Double.parseDouble(rotation)); } } return mapInfo; } catch (NoSuchElementException e) { } return null; } Header(final BufferedReader reader); ByteOrder getJavaByteOrder(); String getFileType(); int getNumSamples(); int getNumLines(); int getNumBands(); int getHeaderOffset(); int getDataType(); String getInterleave(); String getSensorType(); int getByteOrder(); EnviMapInfo getMapInfo(); EnviProjectionInfo getProjectionInfo(); String[] getBandNames(); String getDescription(); BeamProperties getBeamProperties(); String[] getWavelengths(); String[] getFWHM(); String getWavelengthsUnit(); double[] getDataOffsetValues(); double[] getDataGainValues(); Double getDataIgnoreValue(); int getNumClasses(); String[] getClassNmaes(); int[] getClassColorRGB(); static Properties loadProperties(String text); MetadataElement getAsMetadata();  }
@Test public void testParseMapInfo() throws IOException { final String mapInfoLine = "map info = {testName, 1.0000, 2.0000, 3.0, 4.0, 5.0, 6.0, WGS-62, units=micrometer}"; final BufferedReader in = createReader(createMandatoryHeader() + mapInfoLine); final Header header = new Header(in); final EnviMapInfo mapInfo = header.getMapInfo(); assertEquals("testName", mapInfo.getProjectionName()); assertEquals(1.0, mapInfo.getReferencePixelX(), 1e-8); assertEquals(2.0, mapInfo.getReferencePixelY(), 1e-8); assertEquals(3.0, mapInfo.getEasting(), 1e-8); assertEquals(4.0, mapInfo.getNorthing(), 1e-8); assertEquals(5.0, mapInfo.getPixelSizeX(), 1e-8); assertEquals(6.0, mapInfo.getPixelSizeY(), 1e-8); assertEquals("WGS-62", mapInfo.getDatum()); assertEquals("micrometer", mapInfo.getUnit()); assertEquals(0, mapInfo.getOrientation(), 1E-5); }