df.getName(), file.getPath()), e);
Level.FINER, String.format( "Error checking if format %s can read file %s, " + df.getName(), file.getPath()), e);
@Test public void testLookupShapefile() throws Exception { DataFormat format = DataFormat.lookup(new File(tmpDir(), "foo.shp")); assertNotNull("No format found for shape files", format); String name = format.getName(); assertEquals("Shapefile format not found", "Shapefile", name); }
@Test public void testLookupTiff() throws Exception { File dir = unpack("geotiff/EmissiveCampania.tif.bz2"); File tif = new File(dir, "EmissiveCampania.tif"); DataFormat format = DataFormat.lookup(tif); assertNotNull("No format found for tif", format); String name = format.getName(); assertEquals("Tif format not found", "GeoTIFF", name); }
@Test public void testLookupCSV() throws Exception { DataFormat format = DataFormat.lookup(new File(tmpDir(), "foo.csv")); assertNotNull("No format found for csv files", format); String name = format.getName(); assertEquals("CSV format not found", "CSV", name); }
@Test public void testLookupKML() throws Exception { File kmlFile = new File(tmpDir(), "foo.kml"); FileUtils.touch(kmlFile); DataFormat format = DataFormat.lookup(kmlFile); assertNotNull("No format found for kml files", format); String name = format.getName(); assertEquals("KML format not found", "KML", name); } }
public void testMosaicAuxillaryFiles() throws Exception { File unpack = ImporterTestUtils.unpack("mosaic/bm.zip"); // all types of junk! String[] aux = new String[] {"aux", "rrd", "xml", "tif.aux.xml", "tfw"}; File[] tifs = unpack.listFiles(); for (int i = 0; i < tifs.length; i++) { File file = tifs[i]; for (int j = 0; j < aux.length; j++) { new File(unpack, file.getName().replace("tif", aux[j])).createNewFile(); } } Mosaic m = new Mosaic(unpack); m.prepare(); assertEquals(4, m.getFiles().size()); for (int i = 0; i < m.getFiles().size(); i++) { assertEquals("GeoTIFF", m.getFiles().get(1).getFormat().getName()); } // make sure the junk was actually picked up for (FileData f : m.getFiles()) { assertEquals(aux.length, ((SpatialFile) f).getSuppFiles().size()); } }
assertEquals(ImportTask.State.READY, task.getState()); assertTrue(task.getData() instanceof SpatialFile); assertEquals("Shapefile", task.getData().getFormat().getName()); assertEquals("Shapefile", task.getData().getFormat().getName()); assertEquals(ImportTask.State.BAD_FORMAT, task.getState()); assertTrue(task.getData() instanceof SpatialFile); assertEquals("GeoTIFF", task.getData().getFormat().getName());
@Test public void testImportDirectoryWithRasterDirect() throws Exception { File dir = tmpDir(); unpack("shape/archsites_epsg_prj.zip", dir); unpack("shape/bugsites_esri_prj.tar.gz", dir); unpack("geotiff/EmissiveCampania.tif.bz2", dir); ImportContext context = importer.createContext(new Directory(dir)); assertEquals(3, context.getTasks().size()); assertTrue(context.getData() instanceof Directory); ImportTask task = context.getTasks().get(0); assertEquals(ImportTask.State.READY, task.getState()); assertEquals("archsites", task.getLayer().getResource().getName()); assertTrue(task.getData() instanceof SpatialFile); assertEquals("Shapefile", task.getData().getFormat().getName()); task = context.getTasks().get(1); assertEquals(ImportTask.State.READY, task.getState()); assertEquals("bugsites", task.getLayer().getResource().getName()); assertTrue(task.getData() instanceof SpatialFile); assertEquals("Shapefile", task.getData().getFormat().getName()); task = context.getTasks().get(2); assertEquals(ImportTask.State.READY, task.getState()); assertEquals("EmissiveCampania", task.getLayer().getResource().getName()); assertTrue(task.getData() instanceof SpatialFile); assertEquals("GeoTIFF", task.getData().getFormat().getName()); }