/** * Aggregate multipleFeatures related to the same file, on the same {@link FileGroup}. This * is usually needed when the underlying coverage isn't a simple 2D coverage but it has * multiple dimensions (as an instance, time, elevation, custom...) * * <p>The method also look for supportFiles. * * @param file * @paran aggregate, whether aggregation queries should be invoked to extract domains * @param firstFeature, sample feature to be used when no aggregation is needed * @return */ private FileGroup buildFileGroup(File file, boolean aggregate, SimpleFeature firstFeature) { // Looking for supportFiles for the current file // As an instance .prj and .tfw for un-georeferenced tifs String filePath = file.getAbsolutePath(); String ext = FilenameUtils.getExtension(filePath).toUpperCase(); List<File> supportFiles = null; if (COLLECTORS.containsKey(ext)) { supportFiles = COLLECTORS.get(ext).getSupportFiles(filePath); } Map<String, Object> metadataMap = computeGroupMetadata(filePath, aggregate, firstFeature); return new FileGroup(file, supportFiles, metadataMap); }
private List<File> getFilesToRemove(CloseableIterator<FileGroupProvider.FileGroup> it) { List<File> filesToRemove = new ArrayList<>(); while (it.hasNext()) { FileGroupProvider.FileGroup group = it.next(); filesToRemove.add(group.getMainFile()); List<File> supportFiles = group.getSupportFiles(); if (supportFiles != null) { filesToRemove.addAll(supportFiles); } } return filesToRemove; } }
while (files.hasNext()) { FileGroup fileGroup = files.next(); File mainFile = fileGroup.getMainFile(); String hashedName = DownloadLinkHandler.hashFile(mainFile); List<File> supportFile = fileGroup.getSupportFiles(); if (supportFile != null && !supportFile.isEmpty()) { result.addAll(supportFile);
File mainFile = element.getMainFile(); String canonicalPath = null; try { StringBuilder builder = new StringBuilder(baseLink.replace(FILE_TEMPLATE, hashFile)); Map<String, Object> metadata = element.getMetadata(); if (metadata != null && !metadata.isEmpty()) {
/** * Aggregate multipleFeatures related to the same file, on the same {@link FileGroup}. This * is usually needed when the underlying coverage isn't a simple 2D coverage but it has * multiple dimensions (as an instance, time, elevation, custom...) * * <p>The method also look for supportFiles. * * @param file * @paran aggregate, whether aggregation queries should be invoked to extract domains * @param firstFeature, sample feature to be used when no aggregation is needed * @return * @throws IOException */ private FileGroup buildFileGroup(List<CoverageSlice> slices) throws IOException { List<File> supportFiles = null; Map<String, Object> metadataMap = computeSlicesMetadata(slices); // Change this when we start supporting multiple BBOXes within same file metadataMap.put(Utils.BBOX, new ReferencedEnvelope(slices.get(0).getGranuleBBOX())); return new FileGroup(file, supportFiles, metadataMap); } }
/** Collect all files from the fileGroupProvider */ void collectFull(List<File> result) { CloseableIterator<FileGroup> files = null; try { files = fileGroupProvider.getFiles(null); while (files.hasNext()) { FileGroup fileGroup = files.next(); result.add(fileGroup.getMainFile()); List<File> supportFile = fileGroup.getSupportFiles(); if (supportFile != null && !supportFile.isEmpty()) { result.addAll(supportFile); } } } finally { closeIterator(files); } } }
private FileGroup buildFileGroupOnSlices(File file) throws IOException { List<File> supportFiles = null; Map<String, Object> metadataMap = computeSlicesMetadata(slices); metadataMap.put( Utils.BBOX, new ReferencedEnvelope(reader.getOriginalEnvelope(coverageName))); return new FileGroup(file, supportFiles, metadataMap); }
/** * Aggregate multipleFeatures related to the same file, on the same {@link FileGroup}. This * is usually needed when the underlying coverage isn't a simple 2D coverage but it has * multiple dimensions (as an instance, time, elevation, custom...) * * <p>The method also look for supportFiles. * * @param file * @paran aggregate, whether aggregation queries should be invoked to extract domains * @param firstFeature, sample feature to be used when no aggregation is needed * @return * @throws IOException */ private FileGroup buildFileGroup(List<CoverageSlice> slices) throws IOException { List<File> supportFiles = null; Map<String, Object> metadataMap = computeSlicesMetadata(slices); // Change this when we start supporting multiple BBOXes within same file metadataMap.put(Utils.BBOX, new ReferencedEnvelope(slices.get(0).getGranuleBBOX())); return new FileGroup(file, supportFiles, metadataMap); } }
@Override protected List<FileGroup> getFiles() { File file = getSourceAsFile(); if (file == null) { return null; } List<File> files = new ArrayList<>(); // add all common sidecars addAllSiblings(file, files, ".prj", ".tab", ".wld", ".tfw"); if (hasMaskOvrProvider) { DatasetLayout layout = maskOvrProvider.getLayout(); addSiblings( files, layout.getExternalMaskOverviews(), layout.getExternalOverviews(), layout.getExternalMasks()); } return Collections.singletonList(new FileGroup(file, files, null)); } }
@Override protected List<FileGroup> getFiles() { File file = getSourceAsFile(); if (file == null) { return null; } List<File> files = new ArrayList<>(); List<String> extensions = new ArrayList<>(); extensions.add(".prj"); Set<String> worldExtensions = WorldImageFormat.getWorldExtension(getExtension()); extensions.addAll(worldExtensions); String[] siblingExtensions = extensions.toArray(new String[extensions.size()]); addAllSiblings(file, files, siblingExtensions); return Collections.singletonList(new FileGroup(file, files, null)); } }
/** * Returns a list of files making up the source data for this reader (as a whole). The default * implementation returns the source, if it can be made into a File object, or null otherwise. * * @return * @throws IOException */ protected List<FileGroup> getFiles() throws IOException { File file = getSourceAsFile(); if (file == null) { return null; } else { return Collections.singletonList(new FileGroup(file, null, null)); } }
@Override public ServiceInfo getInfo() { IOFileFilter filesFilter = Utils.MOSAIC_SUPPORT_FILES_FILTER; Collection<File> files = FileUtils.listFiles(parentDirectory, filesFilter, null); List<FileGroup> fileGroups = new ArrayList<FileGroup>(); for (File file : files) { fileGroups.add(new FileGroup(file, null, null)); } return new DefaultFileServiceInfo(fileGroups); }
@Override public String toString() { return "FileGroup [mainFile=" + mainFile + ", supportFiles=" + supportFiles + ", metadata=" + printMetadata(metadata) + "]"; }
private FileGroup buildFileGroupOnSlices(File file) throws IOException { List<File> supportFiles = null; Map<String, Object> metadataMap = computeSlicesMetadata(slices); metadataMap.put( Utils.BBOX, new ReferencedEnvelope(reader.getOriginalEnvelope(coverageName))); return new FileGroup(file, supportFiles, metadataMap); }