/// <summary> /// Call the build function of the inner Raster Type and generate a thumbnail from the Builder Item created. /// </summary> /// <param name="pItemURI">URI of the Item to be built</param> /// <returns></returns> public IBuilderItem Build(IItemURI pItemURI) { IBuilderItem pbuilderItem = innerRasterBuilder.Build(pItemURI); // Generate the IBuilderItem Resampling(pbuilderItem); // Generate the Thumbnail from the item. return(pbuilderItem); }
/// <summary> /// Create the function raster dataset from the source images. /// </summary> /// <param name="dimPar">Parser for the dimap file.</param> /// <param name="pItemURI">ItemURi to use.</param> /// <returns>Function raster dataset created.</returns> private IFunctionRasterDataset GetFRD(DiMapParser dimPar, IItemURI pItemURI) { IFunctionRasterDataset opFrd = null; try { Type factoryType = Type.GetTypeFromProgID("esriDataSourcesRaster.RasterWorkspaceFactory"); IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(factoryType); IWorkspace workspace = workspaceFactory.OpenFromFile(System.IO.Path.GetDirectoryName(pItemURI.Key), 0); IRasterWorkspace rasterWorkspace = (IRasterWorkspace)workspace; // Open the tif file associated with the .dim file as a raster dataset. string imagePath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(pItemURI.Key), pItemURI.Group + ".tif"); string rpcPath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(pItemURI.Key), pItemURI.Group + ".rpc"); IRasterDataset inputRasterDataset = null; if (File.Exists(imagePath)) inputRasterDataset = rasterWorkspace.OpenRasterDataset(pItemURI.Group + ".tif"); else return null; IFunctionRasterDataset intermedFrd = null; // If the file opes successfully, add a RasterInfo function on top. if (inputRasterDataset != null) { // Create an Identity function dataset to get the raster info. IRasterFunction identityFunction = new IdentityFunctionClass(); IFunctionRasterDataset idFrd = new FunctionRasterDatasetClass(); idFrd.Init(identityFunction, inputRasterDataset); // Create a raster info function dataset. IRasterFunction rasterInfoFunction = new RasterInfoFunctionClass(); IRasterInfoFunctionArguments rasterInfoFuncArgs = new RasterInfoFunctionArgumentsClass(); rasterInfoFuncArgs.Raster = inputRasterDataset; rasterInfoFuncArgs.RasterInfo = idFrd.RasterInfo; intermedFrd = new FunctionRasterDatasetClass(); intermedFrd.Init(rasterInfoFunction, rasterInfoFuncArgs); } else return null; // Check if there is an RPC file associated with the image. If so // then add a geometric function to apply the rpc xform. if (File.Exists(rpcPath)) opFrd = ApplyRPC(rpcPath, (IRasterDataset)intermedFrd); // If no rpc pars exist or applying rpc fails, use the intermediate // function raster dataset created. if (opFrd == null) opFrd = intermedFrd; //IRasterFunction ebFunction = new ExtractBandFunctionClass(); //IRasterFunctionArguments ebFuncArgs = new ExtractBandFunctionArgumentsClass(); //ILongArray bandIDs = new LongArrayClass(); //bandIDs.Add(2); //bandIDs.Add(1); //bandIDs.Add(0); ////bandIDs.Add(4); //((IExtractBandFunctionArguments)ebFuncArgs).BandIDs = bandIDs; //((IExtractBandFunctionArguments)ebFuncArgs).Raster = inputRasterDataset; //opFrd = new FunctionRasterDatasetClass(); //opFrd.Init(ebFunction, ebFuncArgs); //if (opFrd == null) //{ // IRasterFunction identityFunction = new IdentityFunctionClass(); // opFrd = new FunctionRasterDatasetClass(); // opFrd.Init(identityFunction, inputRasterDataset); //} } catch (Exception exc) { string error = exc.Message; } return opFrd; }
/// <summary> /// Check if the item provided is "stale" or not valid /// </summary> /// <param name="pItemURI">URI for the item to be checked</param> /// <returns>Flag to specify whether the item is stale or not.</returns> public bool IsStale(IItemURI pItemURI) { try { IRasterTypeEnvironment myEnv = new RasterTypeEnvironmentClass(); DateTime currDimTS = myEnv.GetTimeStamp(pItemURI.Key); return pItemURI.SourceTimeStamp != currDimTS; } catch (Exception) { throw; } }
/// <summary> /// Build the Builder Item which includes the function raster dataset and its footprint /// given the ItemURI. /// </summary> /// <param name="pItemURI">ItemURi to use to build the Builder Item.</param> /// <returns>The builder item.</returns> public IBuilderItem Build(IItemURI pItemURI) { try { // Create a new parser object and builder item. DiMapParser myDimParser = new DiMapParser(pItemURI.Key); IBuilderItem currItem = new BuilderItemClass(); // Set Category and URI currItem.Category = esriRasterCatalogItemCategory.esriRasterCatalogItemCategoryPrimary; currItem.URI = pItemURI; // Set FunctionRasterDataset IFunctionRasterDataset inputFrd = GetFRD(myDimParser, pItemURI); currItem.Dataset = inputFrd; // Set band information for the function dataset including names, wavelengths and stats if available. SetBandProperties((IDataset)inputFrd, myDimParser); // Set Footprint IGeoDataset geoDset = (IGeoDataset)inputFrd; // Set it to the current raster extent first. If the raster has no // spatial reference, the extents will be in pixel space. currItem.Footprint = (IGeometry)geoDset.Extent; // The get the footprint from the dim file is it exists. currItem.Footprint = GetFootprint(myDimParser); // Set Properties. These properties are used to fill the Auxiliary Fields // defined earlier and also key properties if the names are correct. IPropertySet propSet = currItem.Dataset.Properties; if (null == propSet) propSet = new PropertySetClass(); double sunAzimuth = Convert.ToDouble(myDimParser.SunAzimuth); double sunElevation = Convert.ToDouble(myDimParser.SunElevation); double sensorAzimuth = Convert.ToDouble(myDimParser.SensorAzimuth); double sensorElevation = 180 - Convert.ToDouble(myDimParser.IncidenceAngle); string acqDate = myDimParser.AcquisitionDate; string acqTime = myDimParser.AcquisitionTime; // Create a time object from the provided date and time. ITime acqDateTimeObj = new TimeClass(); acqDateTimeObj.SetFromTimeString(esriTimeStringFormat.esriTSFYearThruSubSecondWithDash, acqDate + " " + acqTime); // and obtain a DateTime object to set as value of the property. This ensures the // field displays the value correctly. DateTime acqDateTimeFieldVal = acqDateTimeObj.QueryOleTime(); propSet.SetProperty("AcquisitionDate", acqDateTimeFieldVal); propSet.SetProperty("SensorName", myDimParser.MetadataProfile); propSet.SetProperty("SunAzimuth", sunAzimuth); propSet.SetProperty("SunElevation", sunElevation); propSet.SetProperty("SatAzimuth", sensorAzimuth); propSet.SetProperty("SatElevation", sensorElevation); currItem.Dataset.Properties = propSet; return currItem; } catch (Exception exc) { throw exc; } }
/// <summary> /// Check if the item provided is "stale" or not valid /// </summary> /// <param name="pItemURI">URI for the item to be checked</param> /// <returns></returns> public bool IsStale(IItemURI pItemURI) { return(innerRasterBuilder.IsStale(pItemURI)); }
/// <summary> /// Check if the item provided is "stale" or not valid /// </summary> /// <param name="pItemURI">URI for the item to be checked</param> /// <returns></returns> public bool IsStale(IItemURI pItemURI) { return innerRasterBuilder.IsStale(pItemURI); }
/// <summary> /// Call the build function of the inner Raster Type and generate a thumbnail from the Builder Item created. /// </summary> /// <param name="pItemURI">URI of the Item to be built</param> /// <returns></returns> public IBuilderItem Build(IItemURI pItemURI) { IBuilderItem pbuilderItem = innerRasterBuilder.Build(pItemURI); // Generate the IBuilderItem Resampling(pbuilderItem); // Generate the Thumbnail from the item. return pbuilderItem; }