@Test public void testCreate_8() throws Exception { File testFile = getTestFile("test_L8_MTL.txt"); LandsatMetadata landsatMetadata = LandsatMetadataFactory.create(testFile); assertTrue(landsatMetadata instanceof Landsat8Metadata); }
static LandsatMetadata create(File mtlFile) throws IOException { LandsatLegacyMetadata landsatMetadata = new LandsatLegacyMetadata(new FileReader(mtlFile)); if (landsatMetadata.isLegacyFormat()) { if (landsatMetadata.isLandsatTM() || landsatMetadata.isLandsatETM_Plus()) { return landsatMetadata; } else { throw new ProductIOException("Product is of a legacy landsat format, not a legacy Landsat5 or Landsat7 ETM+ product."); } } else { BufferedReader reader = null; try { FileReader fileReader = new FileReader(mtlFile); reader = new BufferedReader(fileReader); String line = reader.readLine(); while (line != null) { if (line.contains("SPACECRAFT_ID")) { if (line.contains("LANDSAT_8")) { return new Landsat8Metadata(new FileReader(mtlFile)); } else { return new LandsatReprocessedMetadata(new FileReader(mtlFile)); } } line = reader.readLine(); } } finally { if (reader != null) { reader.close(); } } throw new IllegalStateException( "File '" + mtlFile + "' does not contain spacecraft information. (Field 'SPACECRAFT_ID' missing)"); } }
LandsatMetadataFactory { static LandsatMetadata create(File mtlFile) throws IOException { LandsatLegacyMetadata landsatMetadata = new LandsatLegacyMetadata(new FileReader(mtlFile)); if (landsatMetadata.isLegacyFormat()) { if (landsatMetadata.isLandsatTM() || landsatMetadata.isLandsatETM_Plus()) { return landsatMetadata; } else { throw new ProductIOException("Product is of a legacy landsat format, not a legacy Landsat5 or Landsat7 ETM+ product."); } } else { BufferedReader reader = null; try { FileReader fileReader = new FileReader(mtlFile); reader = new BufferedReader(fileReader); String line = reader.readLine(); while (line != null) { if (line.contains("SPACECRAFT_ID")) { if (line.contains("LANDSAT_8")) { return new Landsat8Metadata(new FileReader(mtlFile)); } else { return new LandsatReprocessedMetadata(new FileReader(mtlFile)); } } line = reader.readLine(); } } finally { if (reader != null) { reader.close(); } } throw new IllegalStateException( "File '" + mtlFile + "' does not contain spacecraft information. (Field 'SPACECRAFT_ID' missing)"); } } }
LandsatMetadataFactory { static LandsatMetadata create(File mtlFile) throws IOException { LandsatLegacyMetadata landsatMetadata = new LandsatLegacyMetadata(new FileReader(mtlFile)); if (landsatMetadata.isLegacyFormat()) { if (landsatMetadata.isLandsatTM() || landsatMetadata.isLandsatETM_Plus()) { return landsatMetadata; } else { throw new ProductIOException("Product is of a legacy landsat format, not a legacy Landsat5 or Landsat7 ETM+ product."); } } else { BufferedReader reader = null; try { FileReader fileReader = new FileReader(mtlFile); reader = new BufferedReader(fileReader); String line = reader.readLine(); while (line != null) { if (line.contains("SPACECRAFT_ID")) { if (line.contains("LANDSAT_8")) { return new Landsat8Metadata(new FileReader(mtlFile)); } else { return new LandsatReprocessedMetadata(new FileReader(mtlFile)); } } line = reader.readLine(); } } finally { if (reader != null) { reader.close(); } } throw new IllegalStateException( "File '" + mtlFile + "' does not contain spacecraft information. (Field 'SPACECRAFT_ID' missing)"); } }  }
LandsatMetadataFactory { static LandsatMetadata create(File mtlFile) throws IOException { LandsatLegacyMetadata landsatMetadata = new LandsatLegacyMetadata(new FileReader(mtlFile)); if (landsatMetadata.isLegacyFormat()) { if (landsatMetadata.isLandsatTM() || landsatMetadata.isLandsatETM_Plus()) { return landsatMetadata; } else { throw new ProductIOException("Product is of a legacy landsat format, not a legacy Landsat5 or Landsat7 ETM+ product."); } } else { BufferedReader reader = null; try { FileReader fileReader = new FileReader(mtlFile); reader = new BufferedReader(fileReader); String line = reader.readLine(); while (line != null) { if (line.contains("SPACECRAFT_ID")) { if (line.contains("LANDSAT_8")) { return new Landsat8Metadata(new FileReader(mtlFile)); } else { return new LandsatReprocessedMetadata(new FileReader(mtlFile)); } } line = reader.readLine(); } } finally { if (reader != null) { reader.close(); } } throw new IllegalStateException( "File '" + mtlFile + "' does not contain spacecraft information. (Field 'SPACECRAFT_ID' missing)"); } }   }
LandsatMetadataFactory { static LandsatMetadata create(File mtlFile) throws IOException { LandsatLegacyMetadata landsatMetadata = new LandsatLegacyMetadata(new FileReader(mtlFile)); if (landsatMetadata.isLegacyFormat()) { if (landsatMetadata.isLandsatTM() || landsatMetadata.isLandsatETM_Plus()) { return landsatMetadata; } else { throw new ProductIOException("Product is of a legacy landsat format, not a legacy Landsat5 or Landsat7 ETM+ product."); } } else { BufferedReader reader = null; try { FileReader fileReader = new FileReader(mtlFile); reader = new BufferedReader(fileReader); String line = reader.readLine(); while (line != null) { if (line.contains("SPACECRAFT_ID")) { if (line.contains("LANDSAT_8")) { return new Landsat8Metadata(new FileReader(mtlFile)); } else { return new LandsatReprocessedMetadata(new FileReader(mtlFile)); } } line = reader.readLine(); } } finally { if (reader != null) { reader.close(); } } throw new IllegalStateException( "File '" + mtlFile + "' does not contain spacecraft information. (Field 'SPACECRAFT_ID' missing)"); } }    }