关于构建RasterPyramids

来源:互联网 发布:淘宝国际版叫什么名字 编辑:程序博客网 时间:2024/04/29 23:55

应该是构建Raster Pyramid的用法,但第一次调试还没有成功。

HRESULT BuildPyramids(CString inputName)

{  

CComBSTR dataPath;  

CComBSTR dataFile;  

HRESULT hr;  

CString temp;

 long idx;  

idx = inputName.ReverseFind('//');

 dataFile = inputName.Mid(idx+1);  

dataPath = inputName.Left(idx);    

if ( dataPath.Length() <= 0)  

{   

MessageBox("Invalid data path.");  

 return E_FAIL;

 }

  if (dataFile.Length() <= 0)  

{   

  MessageBox( "Invalid data file." );  

   return E_FAIL;  

}

 // Get the raster workspace through the workspace factory.  

IWorkspaceFactoryPtr ipRasWkspFac(CLSID_RasterWorkspaceFactory);

 IWorkspacePtr ipWksp;

 hr = ipRasWkspFac->OpenFromFile(dataPath, 0, &ipWksp);  

  if (FAILED(hr) || ipWksp == 0)  

{  

 MessageBox("Could not open workspace.");  

 return hr;  

}

 IRasterDatasetPtr ipRasDataset;

 hr = ((IRasterWorkspacePtr) ipWksp)->OpenRasterDataset(dataFile, &ipRasDataset);  

  if (FAILED(hr) || ipRasDataset == 0)

 {   MessageBox("Couldn't open dataset.");  

 return hr;  

}  

 // If there are not already pyramids, create them  

IRasterPyramidPtr ipRasPyr(ipRasDataset);   

short pyrPresent;  

ipRasPyr->get_Present(&pyrPresent);

 if (!pyrPresent)  

{  

 ipRasPyr->Create();  

 temp.Format("Done creating pyramids on %s",  (BSTR) dataFile);

  MessageBox(temp);

 }  

else

 {  

 temp.Format("Pyramids already exist for %s", (BSTR) dataFile);

  MessageBox(temp);  

}  

return S_OK;

}

原创粉丝点击