/// <summary> /// Apply the read operation for a geometry. /// </summary> /// <returns>The geometry read from the stream.</returns> protected override IGeometry ApplyReadGeometry() { if (_filePaths.Count == 0) { return(null); } // read imaging data RasterImaging imaging = _metafileReader == null ? null : _metafileReader.ReadImaging(); // read files List <ISpectralPolygon> polygons = new List <ISpectralPolygon>(); Dictionary <GeometryStreamParameter, Object> parameters = new Dictionary <GeometryStreamParameter, Object>(Parameters); parameters[SpectralGeometryStreamParameters.IncludeMetadata] = false; foreach (String filePath in _filePaths) { try { using (GeoTiffReader reader = new GeoTiffReader(filePath, parameters)) { polygons.Add(reader.Read() as ISpectralPolygon); } } catch { } } _filePaths.Clear(); // if no polygons are available if (polygons.Count == 0) { return(null); } // remove rasters with different size for (Int32 index = polygons.Count - 1; index >= 0; index--) { if (polygons[index].Raster.NumberOfRows != polygons[0].Raster.NumberOfRows || polygons[index].Raster.NumberOfColumns != polygons[0].Raster.NumberOfColumns) { polygons.RemoveAt(index); if (imaging != null) { imaging.RemoveBand(index); } } } // merge content return(polygons[0].Factory.CreateSpectralPolygon(polygons, imaging)); }
/// <summary> /// Computes the spectral imaging scene data of the geometry. /// </summary> /// <returns>The spectral imaging scene data of the geometry.</returns> protected override RasterImaging ComputeRasterImaging() { // DEPRECATED AEGIS SOLUTION // the imaging data may be contained within the tags if (_imageFileDirectories[_currentImageIndex].ContainsKey(57410) && _imageFileDirectories[_currentImageIndex].ContainsKey(57411) && _imageFileDirectories[_currentImageIndex].ContainsKey(57412) && _imageFileDirectories[_currentImageIndex].ContainsKey(57413) && _imageFileDirectories[_currentImageIndex].ContainsKey(57417) && _imageFileDirectories[_currentImageIndex].ContainsKey(57418) && _imageFileDirectories[_currentImageIndex].ContainsKey(57419)) { ImagingDevice device = ImagingDevices.FromName(_imageFileDirectories[_currentImageIndex][57410][0].ToString()).FirstOrDefault(); if (device == null) { return(null); } DateTime imagingTime = DateTime.Parse(_imageFileDirectories[_currentImageIndex][57411][0].ToString(), CultureInfo.InvariantCulture.DateTimeFormat); GeoCoordinate deviceLocation = new GeoCoordinate(Convert.ToDouble(_imageFileDirectories[_currentImageIndex][57412][0]), Convert.ToDouble(_imageFileDirectories[_currentImageIndex][57412][1]), Convert.ToDouble(_imageFileDirectories[_currentImageIndex][57412][2])); Double incidenceAngle = Convert.ToDouble(_imageFileDirectories[_currentImageIndex][57413][0]); Double viewingAngle = Convert.ToDouble(_imageFileDirectories[_currentImageIndex][57413][1]); Double sunAzimuth = Convert.ToDouble(_imageFileDirectories[_currentImageIndex][57413][2]); Double sunElevation = Convert.ToDouble(_imageFileDirectories[_currentImageIndex][57413][3]); GeoCoordinate[] imageLocation; if (_imageFileDirectories[_currentImageIndex].ContainsKey(57420) && _imageFileDirectories[_currentImageIndex][57420].Length == 12) { Double[] imageLocationValues = _imageFileDirectories[_currentImageIndex][57420].Select(value => Convert.ToDouble(value)).ToArray(); imageLocation = new GeoCoordinate[] { new GeoCoordinate(imageLocationValues[0], imageLocationValues[1], imageLocationValues[2]), new GeoCoordinate(imageLocationValues[3], imageLocationValues[4], imageLocationValues[5]), new GeoCoordinate(imageLocationValues[6], imageLocationValues[7], imageLocationValues[8]), new GeoCoordinate(imageLocationValues[9], imageLocationValues[10], imageLocationValues[11]) }; } else { imageLocation = Enumerable.Repeat(GeoCoordinate.Undefined, 4).ToArray(); } List <RasterImagingBand> bands = new List <RasterImagingBand>(); for (Int32 bandIndex = 0; bandIndex < device.Bands.Count && bandIndex < _imageFileDirectories[_currentImageIndex][57417].Length && bandIndex < _imageFileDirectories[_currentImageIndex][57418].Length && bandIndex < _imageFileDirectories[_currentImageIndex][57419].Length; bandIndex++) { bands.Add(new RasterImagingBand(device.Bands[bandIndex].Description, Convert.ToDouble(_imageFileDirectories[_currentImageIndex][57417][bandIndex]), Convert.ToDouble(_imageFileDirectories[_currentImageIndex][57418][bandIndex]), Convert.ToDouble(_imageFileDirectories[_currentImageIndex][57419][bandIndex]), device.Bands[bandIndex].SpectralDomain, device.Bands[bandIndex].SpectralRange)); } if (device != null) { return(new RasterImaging(device, imagingTime, deviceLocation, imageLocation, incidenceAngle, viewingAngle, sunAzimuth, sunElevation, bands)); } } // the imaging data may be contained in a metafile if (_metafileReader != null) { try { return(_metafileReader.ReadImaging()); } catch { } } return(null); }