/// <summary> /// Initializes a new instance of the <see cref="GeoTiffGroupReader" /> class. /// </summary> /// <param name="basePath">The base path.</param> /// <param name="parameters">The parameters of the reader for the specific stream.</param> /// <exception cref="System.ArgumentNullException">The collection of file paths is null.</exception> public GeoTiffGroupReader(IEnumerable <String> filePaths, IDictionary <GeometryStreamParameter, Object> parameters) : base(SpectralGeometryStreamFormats.GeoTiff, parameters) { if (filePaths == null) { throw new ArgumentNullException("basePath", "The collection of file paths is null."); } _filePaths = filePaths.Where(filePath => filePath.ToLower().EndsWith(".tif")).ToList(); Boolean includeMetadata = ResolveParameter <Boolean>(SpectralGeometryStreamParameters.IncludeMetadata); if (includeMetadata) { foreach (String path in filePaths.Where(filePath => !filePath.ToLower().EndsWith(".tif"))) { _metafileReader = GeoTiffMetafileReaderFactory.CreateReader(path, GeoTiffMetafilePathOption.IsMetafilePath); if (_metafileReader != null) { break; } } } }
/// <summary> /// Initializes a new instance of the <see cref="GeoTiffReader" /> class. /// </summary> /// <param name="path">The file path to be read.</param> /// <param name="parameters">The parameters of the reader for the specific stream.</param> /// <exception cref="System.ArgumentException"> /// The path is empty. /// or /// The path is invalid. /// or /// The type of a parameter value does not match the type specified by the format. /// or /// The parameter value does not satisfy the conditions of the parameter. /// </exception> /// <exception cref="System.IO.IOException"> /// Exception occurred during stream opening. /// or /// Exception occurred during stream reading. /// </exception> public GeoTiffReader(Uri path, IDictionary <GeometryStreamParameter, Object> parameters) : base(path, SpectralGeometryStreamFormats.GeoTiff, parameters) { Boolean includeMetadata = ResolveParameter <Boolean>(SpectralGeometryStreamParameters.IncludeMetadata); if (includeMetadata) { _metafileReader = GeoTiffMetafileReaderFactory.CreateReader(path, GeoTiffMetafilePathOption.IsGeoTiffFilePath); } }
/// <summary> /// Initializes a new instance of the <see cref="GeoTiffReader" /> class. /// </summary> /// <param name="path">The file path to be read.</param> /// <exception cref="System.ArgumentException"> /// The path is empty. /// or /// The path is invalid. /// or /// The type of a parameter value does not match the type specified by the format. /// or /// The parameter value does not satisfy the conditions of the parameter. /// </exception> /// <exception cref="System.IO.IOException"> /// Exception occurred during stream opening. /// or /// Exception occurred during stream reading. /// </exception> public GeoTiffReader(String path) : base(path, SpectralGeometryStreamFormats.GeoTiff, null) { Boolean includeMetadata = ResolveParameter <Boolean>(SpectralGeometryStreamParameters.IncludeMetadata); if (includeMetadata) { _metafileReader = GeoTiffMetafileReaderFactory.CreateReader(path, GeoTiffMetafilePathOption.IsGeoTiffFilePath); } }
/// <summary> /// Initializes a new instance of the <see cref="GeoTiffGroupReader" /> class. /// </summary> /// <param name="basePath">The base path.</param> /// <param name="parameters">The parameters of the reader for the specific stream.</param> /// <exception cref="System.ArgumentNullException">The base path is null.</exception> public GeoTiffGroupReader(String basePath, IDictionary <GeometryStreamParameter, Object> parameters) : base(SpectralGeometryStreamFormats.GeoTiff, parameters) { if (basePath == null) { throw new ArgumentNullException("basePath", "The base path is null."); } Boolean includeMetadata = ResolveParameter <Boolean>(SpectralGeometryStreamParameters.IncludeMetadata); FileSystem fileSystem = FileSystem.GetFileSystemForPath(basePath); _filePaths = new List <String>(); // the base path is a directory if (fileSystem.IsDirectory(basePath)) { if (includeMetadata) { _metafileReader = GeoTiffMetafileReaderFactory.CreateReader(basePath, GeoTiffMetafilePathOption.IsDirectoryPath); } if (_metafileReader != null) { // load files from the path specified by the metafile List <String> filePaths = _metafileReader.ReadFilePaths().Select(path => fileSystem.Combine(basePath, path)).ToList(); // check whether the specified files exist foreach (String filePath in filePaths) { if (fileSystem.Exists(filePath)) { _filePaths.Add(filePath); } } } if (_filePaths.Count == 0) { _filePaths = fileSystem.GetFiles(basePath, "*.tif", false).Union(fileSystem.GetFiles(basePath, "*.TIF", false)).ToList(); } } else { String directoryPath = fileSystem.GetDirectory(basePath); String fileNameBase = fileSystem.GetFileNameWithoutExtension(basePath); String extension = fileSystem.GetExtension(basePath); if (includeMetadata) { _metafileReader = GeoTiffMetafileReaderFactory.CreateReader(fileSystem.Combine(directoryPath, fileNameBase + "*"), GeoTiffMetafilePathOption.IsSearchPattern); } if (_metafileReader != null) { _filePaths = _metafileReader.ReadFilePaths().Select(path => fileSystem.Combine(directoryPath, path)).ToList(); } else { _filePaths = fileSystem.GetFiles(directoryPath, fileNameBase + "*" + extension, false).ToList(); } } }