Header { private EnviProjectionInfo parseProjectionInfo(String line) { EnviProjectionInfo projectionInfo = new EnviProjectionInfo(); final StringTokenizer tokenizer = createTokenizerFromLine(line); projectionInfo.setProjectionNumber(Integer.parseInt(tokenizer.nextToken().trim())); final ArrayList<Double> parameterList = new ArrayList<>(20); String token = null; try { while (tokenizer.hasMoreTokens()) { token = tokenizer.nextToken().trim(); parameterList.add(Double.parseDouble(token)); } } catch (NumberFormatException e) { } final double[] parameters = new double[parameterList.size()]; for (int i = 0; i < parameters.length; i++) { parameters[i] = parameterList.get(i); } projectionInfo.setParameter(parameters); projectionInfo.setDatum(token); projectionInfo.setName(tokenizer.nextToken().trim()); return projectionInfo; } 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 testParseProjectionInfo() throws IOException { final String line = "projection info = {9, 6378137.0, 6356752.3, -17.500000, -63.500000, 0.0, 0.0, -32.500000, -2.500000, WGS-84, SamerAlbers, units=Meters}"; final BufferedReader in = createReader(createMandatoryHeader() + line); final Header header = new Header(in); EnviProjectionInfo projectionInfo = header.getProjectionInfo(); assertEquals(9, projectionInfo.getProjectionNumber()); final double[] parameter = projectionInfo.getParameter(); assertEquals(8, parameter.length); assertEquals(6378137.0, parameter[0], 1e-8); assertEquals(6356752.3, parameter[1], 1e-8); assertEquals(-17.5, parameter[2], 1e-8); assertEquals(-63.5, parameter[3], 1e-8); assertEquals(0.0, parameter[4], 1e-8); assertEquals(0.0, parameter[5], 1e-8); assertEquals(-32.5, parameter[6], 1e-8); assertEquals(-2.5, parameter[7], 1e-8); assertEquals("WGS-84", projectionInfo.getDatum()); assertEquals("SamerAlbers", projectionInfo.getName()); }