public void setTimeMode(TimeMode timeMode) { this.timeMode = timeMode; this.timeHandler = timeMode.createHandler(); }
public Mosaic(File file) { super(file, false); setTimeMode(TimeMode.NONE); }
public TimeHandler createHandler() { if (this == FILENAME) { return new FilenameTimeHandler(); } return new TimeHandler() { private static final long serialVersionUID = 1L; @Override public Date computeTimestamp(Granule g) { switch (TimeMode.this) { case AUTO: return Dates.matchAndParse(g.getFile().getName()); case MANUAL: return g.getTimestamp(); } return null; } }; } }
@Test public void testFilenameTimeHandler() throws Exception { Mosaic m = new Mosaic(unpack("mosaic/bm_time.zip")); m.setTimeMode(TimeMode.FILENAME); FilenameTimeHandler th = (FilenameTimeHandler) m.getTimeHandler(); th.setFilenameRegex("(\\d){6}"); th.setTimeFormat("yyyyMM"); m.prepare(); List<FileData> files = m.getFiles(); assertEquals(4, files.size()); for (int i = 0; i < files.size(); i++) { FileData fd = files.get(i); assertTrue(fd instanceof Granule); Granule g = (Granule) fd; // TODO: comparison fails on build server assertNotNull(g.getTimestamp()); // assertEquals(date(2004, i), g.getTimestamp()); } }
@Override public void init(Map<String, Object> props) { if (props.containsKey(FILENAME_REGEX)) { setFilenameRegex(props.get(FILENAME_REGEX).toString()); } if (props.containsKey(TIME_FORMAT)) { setTimeFormat(props.get(TIME_FORMAT).toString()); } }
@Override public CoverageStoreInfo createStore(ImportData data, WorkspaceInfo workspace, Catalog catalog) throws IOException { MosaicIndex index = new MosaicIndex((Mosaic) data); index.write(); CoverageStoreInfo store = super.createStore(data, workspace, catalog); store.setURL(DataUtilities.fileToURL(index.getFile()).toString()); return store; }
DataFormat format = format(); if (format == null) { throw new IllegalArgumentException("Unable to determine format for mosaic files"); setFormat(new MosaicFormat());
@Override public Date computeTimestamp(Granule g) { switch(TimeMode.this) { case AUTO: return Dates.matchAndParse(g.getFile().getName()); case MANUAL: return g.getTimestamp(); } return null; } };
@Override public boolean accept(File dir, String name) { if ("sample_image".equalsIgnoreCase(name)) { return true; } if (!mosaic.getName().equalsIgnoreCase(FilenameUtils.getBaseName(name))) { return false; } String ext = FilenameUtils.getExtension(name); ShpFileType shpFileType = null; if (ext != null) { try { shpFileType = ShpFileType.valueOf(ext.toUpperCase()); } catch (IllegalArgumentException iae) { // the extension is not matching } } return "properties".equalsIgnoreCase(ext) || shpFileType != null; } })) {
@Test public void testSimpleMosaic() throws Exception { File dir = unpack("mosaic/bm.zip"); ImportContext context = importer.createContext(new Mosaic(dir)); assertEquals(1, context.getTasks().size()); ImportTask task = context.getTasks().get(0); assertTrue(task.getData() instanceof Mosaic); assertTrue(task.getData().getFormat() instanceof MosaicFormat); importer.run(context); runChecks(dir.getName()); }
@Override public boolean apply(Granule input) { return input.getEnvelope() != null && input.getEnvelope().getCoordinateReferenceSystem() != null; } });
@Override public void init(Map<String, Object> props) { if (props.containsKey(FILENAME_REGEX)) { setFilenameRegex(props.get(FILENAME_REGEX).toString()); } if (props.containsKey(TIME_FORMAT)) { setTimeFormat(props.get(TIME_FORMAT).toString()); } }
@Override public CoverageStoreInfo createStore(ImportData data, WorkspaceInfo workspace, Catalog catalog) throws IOException { MosaicIndex index = new MosaicIndex((Mosaic) data); index.write(); CoverageStoreInfo store = super.createStore(data, workspace, catalog); store.setURL(URLs.fileToUrl(index.getFile()).toString()); return store; }
@Override public Date computeTimestamp(Granule g) { switch (TimeMode.this) { case AUTO: return Dates.matchAndParse(g.getFile().getName()); case MANUAL: return g.getTimestamp(); } return null; } };
public Mosaic(File file) { super(file, false); setTimeMode(TimeMode.NONE); }
public void setTimeMode(TimeMode timeMode) { this.timeMode = timeMode; this.timeHandler = timeMode.createHandler(); }
@Override public boolean apply(Granule input) { return input.getEnvelope() != null && input.getEnvelope().getCoordinateReferenceSystem() != null; } });
public TimeHandler createHandler() { if (this == FILENAME) { return new FilenameTimeHandler(); } return new TimeHandler() { private static final long serialVersionUID = 1L; @Override public Date computeTimestamp(Granule g) { switch(TimeMode.this) { case AUTO: return Dates.matchAndParse(g.getFile().getName()); case MANUAL: return g.getTimestamp(); } return null; } }; } }