public List<ImportTask> update(ImportContext context, ImportData data) throws IOException { List<ImportTask> tasks = addTasks(context, data, true); // prep(context); changed(context); return tasks; }
public List<ImportTask> update(ImportContext context, ImportData data) throws IOException { List<ImportTask> tasks = addTasks(context, data, true); //prep(context); changed(context); return tasks; }
@Override protected ImportContext callInternal(ProgressMonitor monitor) throws Exception { try { init(context, prepData); } finally { changed(context); } return context; }
public void changed(ImportTask task) throws IOException { prep(task); changed(task.getContext()); }
public void changed(ImportTask task) { prep(task); changed(task.getContext()); }
@Test public void testImportSpaceInNames() throws Exception { File dir = unpack("shape/spaceInNames.zip"); DataStoreInfo ds = createH2DataStore(null, "spaceInNamesContainer"); ImportContext context = importer.createContext(new SpatialFile(new File(dir, "spaceInNames.shp")), ds); assertEquals(1, context.getTasks().size()); ImportTask task = context.getTasks().get(0); assertEquals(ImportTask.State.NO_CRS, task.getState()); task.getLayer().getResource().setSRS("EPSG:26713"); importer.changed(task); assertEquals(ImportTask.State.READY, task.getState()); assertEquals("spaceInNames", task.getLayer().getResource().getName()); importer.run(context); Catalog cat = getCatalog(); assertNotNull(cat.getLayerByName("spaceInNames")); assertEquals(ImportTask.State.COMPLETE, task.getState()); SimpleFeatureSource fs = (SimpleFeatureSource) cat.getFeatureTypeByName("spaceInNames").getFeatureSource(null, null); SimpleFeature sf = DataUtilities.first(fs.getFeatures()); assertNotNull(sf.getAttribute("WIND_SPEED")); assertNotNull(sf.getAttribute("WIND_DIREC")); }
@Test public void testImportNoCrsLatLonBoundingBox() throws Exception { File dir = unpack("shape/archsites_no_crs.zip"); ImportContext context = importer.createContext(new Directory(dir)); assertEquals(1, context.getTasks().size()); ImportTask task = context.getTasks().get(0); assertEquals(ImportTask.State.NO_CRS, task.getState()); task.getLayer().getResource().setSRS("EPSG:26713"); importer.changed(task); assertEquals(ImportTask.State.READY, task.getState()); ResourceInfo r = task.getLayer().getResource(); assertNotNull(r.getLatLonBoundingBox()); assertNotNull(r.boundingBox()); assertNotNull(r.boundingBox().getCoordinateReferenceSystem()); assertEquals("EPSG:26713", CRS.toSRS(r.boundingBox().getCoordinateReferenceSystem())); // Do the import, verify the changed CRS is preserved when the bounds are calculated importer.doDirectImport(task); assertEquals(ImportTask.State.COMPLETE, task.getState()); r = task.getLayer().getResource(); assertNotNull(r.getLatLonBoundingBox()); assertNotEquals(VectorFormat.EMPTY_BOUNDS, r.getLatLonBoundingBox()); assertNotNull(r.boundingBox()); assertNotEquals(VectorFormat.EMPTY_BOUNDS, r.boundingBox()); assertNotNull(r.boundingBox().getCoordinateReferenceSystem()); assertEquals("EPSG:26713", CRS.toSRS(r.boundingBox().getCoordinateReferenceSystem())); }