本文整理汇总了C++中VRTDataset类的典型用法代码示例。如果您正苦于以下问题:C++ VRTDataset类的具体用法?C++ VRTDataset怎么用?C++ VRTDataset使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VRTDataset类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: CreateMaskBand
CPLErr VRTRasterBand::CreateMaskBand( int nFlags )
{
VRTDataset* poGDS = (VRTDataset *)poDS;
if (poGDS->poMaskBand)
{
CPLError( CE_Failure, CPLE_AppDefined,
"Cannot create mask band at raster band level when a dataset mask band already exists." );
return CE_Failure;
}
if (poMaskBand != NULL)
{
CPLError(CE_Failure, CPLE_AppDefined,
"This VRT band has already a mask band");
return CE_Failure;
}
if ((nFlags & GMF_PER_DATASET) != 0)
return poGDS->CreateMaskBand(nFlags);
SetMaskBand(new VRTSourcedRasterBand( poGDS, 0 ));
return CE_None;
}
开发者ID:Joe-xXx,项目名称:gdal,代码行数:25,代码来源:vrtrasterband.cpp
示例2: GDALOpenShared
GDALRasterBand *VRTRasterBand::GetOverview( int iOverview )
{
// First: overviews declared in <Overview> element
if( !m_apoOverviews.empty() )
{
if( iOverview < 0
|| iOverview >= static_cast<int>( m_apoOverviews.size() ) )
return NULL;
if( m_apoOverviews[iOverview].poBand == NULL
&& !m_apoOverviews[iOverview].bTriedToOpen )
{
m_apoOverviews[iOverview].bTriedToOpen = TRUE;
GDALDataset *poSrcDS = reinterpret_cast<GDALDataset *>(
GDALOpenShared( m_apoOverviews[iOverview].osFilename,
GA_ReadOnly ) );
if( poSrcDS == NULL )
return NULL;
m_apoOverviews[iOverview].poBand = poSrcDS->GetRasterBand(
m_apoOverviews[iOverview].nBand );
if (m_apoOverviews[iOverview].poBand == NULL)
{
GDALClose( (GDALDatasetH)poSrcDS );
}
}
return m_apoOverviews[iOverview].poBand;
}
// If not found, external .ovr overviews
GDALRasterBand* poRet = GDALRasterBand::GetOverview( iOverview );
if( poRet )
return poRet;
// If not found, implicit virtual overviews
VRTDataset* poVRTDS = reinterpret_cast<VRTDataset *>( poDS );
poVRTDS->BuildVirtualOverviews();
if( !poVRTDS->m_apoOverviews.empty() && poVRTDS->m_apoOverviews[0] )
{
if( iOverview < 0
|| iOverview >= static_cast<int>( poVRTDS->m_apoOverviews.size() ) )
return NULL;
return poVRTDS->m_apoOverviews[iOverview]->GetRasterBand(nBand);
}
return NULL;
}
开发者ID:Mavrx-inc,项目名称:gdal,代码行数:53,代码来源:vrtrasterband.cpp
示例3: OpenXML
GDALDataset *
VRTDataset::Create( const char * pszName,
int nXSize, int nYSize, int nBands,
GDALDataType eType, char ** papszOptions )
{
VRTDataset *poDS = NULL;
int iBand = 0;
(void) papszOptions;
if( EQUALN(pszName,"<VRTDataset",11) )
{
GDALDataset *poDS = OpenXML( pszName, NULL, GA_Update );
if (poDS)
poDS->SetDescription( "<FromXML>" );
return poDS;
}
else
{
const char *pszSubclass = CSLFetchNameValue( papszOptions,
"SUBCLASS" );
if( pszSubclass == NULL || EQUAL(pszSubclass,"VRTDataset") )
poDS = new VRTDataset( nXSize, nYSize );
else if( EQUAL(pszSubclass,"VRTWarpedDataset") )
{
poDS = new VRTWarpedDataset( nXSize, nYSize );
}
else
{
CPLError( CE_Failure, CPLE_AppDefined,
"SUBCLASS=%s not recognised.",
pszSubclass );
return NULL;
}
poDS->eAccess = GA_Update;
poDS->SetDescription( pszName );
for( iBand = 0; iBand < nBands; iBand++ )
poDS->AddBand( eType, NULL );
poDS->bNeedsFlush = 1;
poDS->oOvManager.Initialize( poDS, pszName );
return poDS;
}
}
开发者ID:Joe-xXx,项目名称:gdal,代码行数:50,代码来源:vrtdataset.cpp
示例4: GDALOpenShared
GDALRasterBand *VRTRasterBand::GetOverview( int iOverview )
{
// First: overviews declared in <Overview> element
if( apoOverviews.size() > 0 )
{
if( iOverview < 0 || iOverview >= (int) apoOverviews.size() )
return NULL;
if( apoOverviews[iOverview].poBand == NULL
&& !apoOverviews[iOverview].bTriedToOpen )
{
apoOverviews[iOverview].bTriedToOpen = TRUE;
GDALDataset *poSrcDS = (GDALDataset *)
GDALOpenShared( apoOverviews[iOverview].osFilename, GA_ReadOnly );
if( poSrcDS == NULL )
return NULL;
apoOverviews[iOverview].poBand = poSrcDS->GetRasterBand(
apoOverviews[iOverview].nBand );
if (apoOverviews[iOverview].poBand == NULL)
{
GDALClose( (GDALDatasetH)poSrcDS );
}
}
return apoOverviews[iOverview].poBand;
}
// If not found, external .ovr overviews
GDALRasterBand* poRet = GDALRasterBand::GetOverview( iOverview );
if( poRet )
return poRet;
// If not found, implicit virtual overviews
VRTDataset* poVRTDS = ((VRTDataset *)poDS);
poVRTDS->BuildVirtualOverviews();
if( poVRTDS->apoOverviews.size() && poVRTDS->apoOverviews[0] )
{
if( iOverview < 0 || iOverview >= (int) poVRTDS->apoOverviews.size() )
return NULL;
return poVRTDS->apoOverviews[iOverview]->GetRasterBand(nBand);
}
return NULL;
}
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:49,代码来源:vrtrasterband.cpp
示例5: GetOverviewCount
int VRTRasterBand::GetOverviewCount()
{
// First: overviews declared in <Overview> element
if( !m_apoOverviews.empty() )
return static_cast<int>(m_apoOverviews.size());
// If not found, external .ovr overviews
const int nOverviewCount = GDALRasterBand::GetOverviewCount();
if( nOverviewCount )
return nOverviewCount;
// If not found, implicit virtual overviews
VRTDataset* poVRTDS = reinterpret_cast<VRTDataset *>( poDS );
poVRTDS->BuildVirtualOverviews();
if( !poVRTDS->m_apoOverviews.empty() && poVRTDS->m_apoOverviews[0] )
return static_cast<int>( poVRTDS->m_apoOverviews.size() );
return 0;
}
开发者ID:Mavrx-inc,项目名称:gdal,代码行数:20,代码来源:vrtrasterband.cpp
示例6: GetOverviewCount
int VRTRasterBand::GetOverviewCount()
{
// First: overviews declared in <Overview> element
if( apoOverviews.size() > 0 )
return apoOverviews.size();
// If not found, external .ovr overviews
int nOverviewCount = GDALRasterBand::GetOverviewCount();
if( nOverviewCount )
return nOverviewCount;
// If not found, implicit virtual overviews
VRTDataset* poVRTDS = ((VRTDataset *)poDS);
poVRTDS->BuildVirtualOverviews();
if( poVRTDS->apoOverviews.size() && poVRTDS->apoOverviews[0] )
return (int)poVRTDS->apoOverviews.size();
return 0;
}
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:20,代码来源:vrtrasterband.cpp
示例7: VRTCreateCopy
static GDALDataset *
VRTCreateCopy( const char * pszFilename,
GDALDataset *poSrcDS,
int /* bStrict */,
char ** /* papszOptions */,
GDALProgressFunc /* pfnProgress */,
void * /* pProgressData */ )
{
CPLAssert( NULL != poSrcDS );
/* -------------------------------------------------------------------- */
/* If the source dataset is a virtual dataset then just write */
/* it to disk as a special case to avoid extra layers of */
/* indirection. */
/* -------------------------------------------------------------------- */
if( poSrcDS->GetDriver() != NULL &&
EQUAL(poSrcDS->GetDriver()->GetDescription(),"VRT") )
{
/* -------------------------------------------------------------------- */
/* Convert tree to a single block of XML text. */
/* -------------------------------------------------------------------- */
char *pszVRTPath = CPLStrdup(CPLGetPath(pszFilename));
reinterpret_cast<VRTDataset *>(
poSrcDS )->UnsetPreservedRelativeFilenames();
CPLXMLNode *psDSTree = reinterpret_cast<VRTDataset *>(
poSrcDS )->SerializeToXML( pszVRTPath );
char *pszXML = CPLSerializeXMLTree( psDSTree );
CPLDestroyXMLNode( psDSTree );
CPLFree( pszVRTPath );
/* -------------------------------------------------------------------- */
/* Write to disk. */
/* -------------------------------------------------------------------- */
GDALDataset* pCopyDS = NULL;
if( 0 != strlen( pszFilename ) )
{
VSILFILE *fpVRT = VSIFOpenL( pszFilename, "wb" );
if( fpVRT == NULL )
{
CPLError(CE_Failure, CPLE_AppDefined,
"Cannot create %s", pszFilename);
CPLFree( pszXML );
return NULL;
}
bool bRet = VSIFWriteL( pszXML, strlen(pszXML), 1, fpVRT ) > 0;
if( VSIFCloseL( fpVRT ) != 0 )
bRet = false;
if( bRet )
pCopyDS = reinterpret_cast<GDALDataset *>(
GDALOpen( pszFilename, GA_Update ) );
}
else
{
/* No destination file is given, so pass serialized XML directly. */
pCopyDS = reinterpret_cast<GDALDataset *>(
GDALOpen( pszXML, GA_Update ) );
}
CPLFree( pszXML );
return pCopyDS;
}
/* -------------------------------------------------------------------- */
/* Create the virtual dataset. */
/* -------------------------------------------------------------------- */
VRTDataset *poVRTDS = reinterpret_cast<VRTDataset *>(
VRTDataset::Create( pszFilename,
poSrcDS->GetRasterXSize(),
poSrcDS->GetRasterYSize(),
0, GDT_Byte, NULL ) );
if( poVRTDS == NULL )
return NULL;
/* -------------------------------------------------------------------- */
/* Do we have a geotransform? */
/* -------------------------------------------------------------------- */
double adfGeoTransform[6] = { 0.0 };
if( poSrcDS->GetGeoTransform( adfGeoTransform ) == CE_None )
{
poVRTDS->SetGeoTransform( adfGeoTransform );
}
/* -------------------------------------------------------------------- */
/* Copy projection */
/* -------------------------------------------------------------------- */
poVRTDS->SetProjection( poSrcDS->GetProjectionRef() );
/* -------------------------------------------------------------------- */
/* Emit dataset level metadata. */
/* -------------------------------------------------------------------- */
poVRTDS->SetMetadata( poSrcDS->GetMetadata() );
//.........这里部分代码省略.........
开发者ID:bbradbury,项目名称:lib_gdal,代码行数:101,代码来源:vrtdriver.cpp
示例8: main
//.........这里部分代码省略.........
for( iBand = 0; iBand < nBandCount; iBand++ )
{
fprintf( fpConfig, "%d:Band ", iBand+1 );
if( padfScaleMin != NULL )
fprintf( fpConfig, "%g:ScaleMin %g:ScaleMax ",
padfScaleMin[iBand], padfScaleMax[iBand] );
if( papanLUTs )
{
int iLUT;
for( iLUT = 0; iLUT < nLUTBins; iLUT++ )
fprintf( fpConfig, "%d ", papanLUTs[iBand][iLUT] );
}
fprintf( fpConfig, "\n" );
}
if( pszConfigFile )
fclose( fpConfig );
exit( 0 );
}
if (padfScaleMin == NULL || padfScaleMax == NULL)
{
fprintf( stderr, "-equalize or -config filename command line options must be specified.\n");
exit(1);
}
/* ==================================================================== */
/* Create a virtual dataset. */
/* ==================================================================== */
VRTDataset *poVDS;
EnhanceCBInfo *pasEInfo = (EnhanceCBInfo *)
CPLCalloc(nBandCount, sizeof(EnhanceCBInfo));
/* -------------------------------------------------------------------- */
/* Make a virtual clone. */
/* -------------------------------------------------------------------- */
poVDS = new VRTDataset( GDALGetRasterXSize(hDataset),
GDALGetRasterYSize(hDataset) );
if( GDALGetGCPCount(hDataset) == 0 )
{
const char *pszProjection;
double adfGeoTransform[6];
pszProjection = GDALGetProjectionRef( hDataset );
if( pszProjection != NULL && strlen(pszProjection) > 0 )
poVDS->SetProjection( pszProjection );
if( GDALGetGeoTransform( hDataset, adfGeoTransform ) == CE_None )
poVDS->SetGeoTransform( adfGeoTransform );
}
else
{
poVDS->SetGCPs( GDALGetGCPCount(hDataset),
GDALGetGCPs(hDataset),
GDALGetGCPProjection( hDataset ) );
}
poVDS->SetMetadata( ((GDALDataset*)hDataset)->GetMetadata() );
for( iBand = 0; iBand < nBandCount; iBand++ )
{
开发者ID:brunosimoes,项目名称:WorldWind,代码行数:67,代码来源:gdalenhance.cpp
示例9: notify
bool gstIconManager::CopyIcon(const std::string& src_path,
const std::string& dst_path) {
// file must not exist already
if (khExists(dst_path)) {
notify(NFY_WARN, "Icon \"%s\" already exists", dst_path.c_str());
return false;
}
GDALDataset* srcDataset = static_cast<GDALDataset*>(
GDALOpen(src_path.c_str(), GA_ReadOnly));
if (!srcDataset) {
notify(NFY_WARN, "Unable to open icon %s", src_path.c_str());
return false;
}
// determine the image type
// is it rgb or palette_index type
bool palette_type = false;
if (srcDataset->GetRasterCount() == 1 &&
srcDataset->GetRasterBand(1)->GetColorInterpretation() ==
GCI_PaletteIndex) {
palette_type = true;
} else if (srcDataset->GetRasterCount() != 4) {
notify(NFY_WARN, "%s: Image type not supported", src_path.c_str());
return false;
}
GDALDataset* oldSrcDataset = 0;
int target_size = 0;
bool need_scaling = false;
int srcXSize = srcDataset->GetRasterXSize();
int srcYSize = srcDataset->GetRasterYSize();
if ((srcXSize == 32) || (srcXSize == 64)) {
target_size = srcXSize;
if ((srcYSize != srcXSize) &&
(srcYSize != srcXSize*2) &&
(srcYSize != srcXSize*3)) {
need_scaling = true;
}
} else if (srcXSize < 32) {
target_size = 32;
need_scaling = true;
} else {
target_size = 64;
need_scaling = true;
}
if (need_scaling) {
// create a temp output dataset to scale the src
// icon to a square target_size*target_size. Later we'll make a stack.
VRTDataset* tempDataset = new VRTDataset(target_size, target_size);
int numBands = palette_type ? 1 : 4;
for (int b = 1; b <= numBands; ++b) {
tempDataset->AddBand(GDT_Byte, NULL);
VRTSourcedRasterBand* tempBand =
static_cast<VRTSourcedRasterBand*>(tempDataset->GetRasterBand(b));
GDALRasterBand* srcBand = srcDataset->GetRasterBand(b);
tempBand->AddSimpleSource(srcBand,
0, 0, srcXSize, srcYSize,
0, 0, target_size, target_size);
if (palette_type) {
tempBand->SetColorInterpretation(srcBand->GetColorInterpretation());
tempBand->SetColorTable(srcBand->GetColorTable());
}
}
oldSrcDataset = srcDataset;
srcDataset = tempDataset;
srcXSize = srcYSize = target_size;
}
assert(srcXSize == target_size);
// From here on we assume that we have a square, a stack of 2, or a stack of
// 3. It will be either 32 or 64 wide. The actual size is stored in srcXSize
// and srcYSize
bool simpleCopy = false;
if (srcYSize == srcXSize * 3)
simpleCopy = true;
// create a virtual dataset to represent the desired output image
VRTDataset* vds = new VRTDataset(target_size, target_size * 3);
// copy all the bands from the source
int numBands = palette_type ? 1 : 4;
for (int b = 1; b <= numBands; ++b) {
vds->AddBand(GDT_Byte, NULL);
VRTSourcedRasterBand* vrtBand =
static_cast<VRTSourcedRasterBand*>(vds->GetRasterBand(b));
GDALRasterBand* srcBand = srcDataset->GetRasterBand(b);
if (!simpleCopy) {
// extract the normal icon (on bottom of input image)
// and put it on the bottom of new image
// NOTE: srcYSize calculation lets us hand single, square images
// as well as two squares stacked on top of each other
vrtBand->AddSimpleSource(
srcBand,
0, srcYSize-target_size, target_size, target_size,
0, target_size*2, target_size, target_size);
//.........这里部分代码省略.........
开发者ID:zhanghaoit445,项目名称:earthenterprise,代码行数:101,代码来源:gstIconManager.cpp
示例10: CPLParseXMLString
GDALDataset *VRTDataset::OpenXML( const char *pszXML, const char *pszVRTPath,
GDALAccess eAccess)
{
/* -------------------------------------------------------------------- */
/* Parse the XML. */
/* -------------------------------------------------------------------- */
CPLXMLNode *psTree;
psTree = CPLParseXMLString( pszXML );
if( psTree == NULL )
return NULL;
CPLXMLNode *psRoot = CPLGetXMLNode( psTree, "=VRTDataset" );
if (psRoot == NULL)
{
CPLError( CE_Failure, CPLE_AppDefined,
"Missing VRTDataset element." );
CPLDestroyXMLNode( psTree );
return NULL;
}
if( CPLGetXMLNode( psRoot, "rasterXSize" ) == NULL
|| CPLGetXMLNode( psRoot, "rasterYSize" ) == NULL
|| CPLGetXMLNode( psRoot, "VRTRasterBand" ) == NULL )
{
CPLError( CE_Failure, CPLE_AppDefined,
"Missing one of rasterXSize, rasterYSize or bands on"
" VRTDataset." );
CPLDestroyXMLNode( psTree );
return NULL;
}
/* -------------------------------------------------------------------- */
/* Create the new virtual dataset object. */
/* -------------------------------------------------------------------- */
VRTDataset *poDS;
int nXSize = atoi(CPLGetXMLValue(psRoot,"rasterXSize","0"));
int nYSize = atoi(CPLGetXMLValue(psRoot,"rasterYSize","0"));
if ( !GDALCheckDatasetDimensions(nXSize, nYSize) )
{
CPLDestroyXMLNode( psTree );
return NULL;
}
if( strstr(pszXML,"VRTWarpedDataset") != NULL )
poDS = new VRTWarpedDataset( nXSize, nYSize );
else
{
poDS = new VRTDataset( nXSize, nYSize );
poDS->eAccess = eAccess;
}
if( poDS->XMLInit( psRoot, pszVRTPath ) != CE_None )
{
delete poDS;
poDS = NULL;
}
/* -------------------------------------------------------------------- */
/* Try to return a regular handle on the file. */
/* -------------------------------------------------------------------- */
CPLDestroyXMLNode( psTree );
return poDS;
}
开发者ID:Joe-xXx,项目名称:gdal,代码行数:68,代码来源:vrtdataset.cpp
示例11: ProxyMain
//.........这里部分代码省略.........
CPLFree(panBandList);
if (!bSubCall)
{
GDALDumpOpenDatasets(stderr);
GDALDestroyDriverManager();
}
CSLDestroy(argv);
CSLDestroy(papszCreateOptions);
return hOutDS == NULL;
}
/* -------------------------------------------------------------------- */
/* Establish some parameters. */
/* -------------------------------------------------------------------- */
if (pszOXSize == NULL)
{
nOXSize = anSrcWin[2];
nOYSize = anSrcWin[3];
}
else
{
nOXSize = (int) ((pszOXSize[strlen(pszOXSize) - 1] == '%'
? CPLAtofM(pszOXSize) / 100 * anSrcWin[2] : atoi(pszOXSize)));
nOYSize = (int) ((pszOYSize[strlen(pszOYSize) - 1] == '%'
? CPLAtofM(pszOYSize) / 100 * anSrcWin[3] : atoi(pszOYSize)));
}
/* ==================================================================== */
/* Create a virtual dataset. */
/* ==================================================================== */
VRTDataset *poVDS;
/* -------------------------------------------------------------------- */
/* Make a virtual clone. */
/* -------------------------------------------------------------------- */
poVDS = (VRTDataset*) VRTCreate(nOXSize, nOYSize);
if (nGCPCount == 0)
{
if (pszOutputSRS != NULL)
{
poVDS->SetProjection(pszOutputSRS);
}
else
{
pszProjection = GDALGetProjectionRef(hDataset);
if (pszProjection != NULL && strlen(pszProjection) > 0)
poVDS->SetProjection(pszProjection);
}
}
if (bGotBounds)
{
adfGeoTransform[0] = adfULLR[0];
adfGeoTransform[1] = (adfULLR[2] - adfULLR[0]) / nOXSize;
adfGeoTransform[2] = 0.0;
adfGeoTransform[3] = adfULLR[1];
adfGeoTransform[4] = 0.0;
adfGeoTransform[5] = (adfULLR[3] - adfULLR[1]) / nOYSize;
poVDS->SetGeoTransform(adfGeoTransform);
}
开发者ID:hyyh619,项目名称:OpenSceneGraph-3.4.0,代码行数:66,代码来源:gdal_translate.cpp
示例12: CreateSubRaster
bool CreateSubRaster( wxGISRasterDatasetSPtr pSrcRasterDataSet, OGREnvelope &Env, const OGRGeometry *pGeom, GDALDriver* pDriver, CPLString &szDstPath, GDALDataType eOutputType, int nBandCount, int *panBandList, double dfOutResX, double dfOutResY, bool bCopyNodata, bool bSkipSourceMetadata, char** papszOptions, ITrackCancel* pTrackCancel )
{
GDALDataset* pDset = pSrcRasterDataSet->GetRaster();
if(!pDset)
{
if(pTrackCancel)
pTrackCancel->PutMessage(_("Get raster failed"), -1, enumGISMessageErr);
return false;
}
double adfGeoTransform[6] = { 0, 0, 0, 0, 0, 0 };
CPLErr err = pDset->GetGeoTransform(adfGeoTransform);
if(err == CE_Fatal)
{
if(pTrackCancel)
pTrackCancel->PutMessage(_("Get raster failed"), -1, enumGISMessageErr);
return false;
}
if( adfGeoTransform[2] != 0.0 || adfGeoTransform[4] != 0.0 )
{
if(pTrackCancel)
pTrackCancel->PutMessage(_("The geotransform is rotated. This configuration is not supported."), -1, enumGISMessageErr);
return false;
}
int anSrcWin[4] = {0, 0, 0, 0};
anSrcWin[0] = floor ((Env.MinX - adfGeoTransform[0]) / adfGeoTransform[1] + 0.001);
anSrcWin[1] = floor ((Env.MaxY - adfGeoTransform[3]) / adfGeoTransform[5] + 0.001);
anSrcWin[2] = ceil ((Env.MaxX - Env.MinX) / adfGeoTransform[1]);
anSrcWin[3] = ceil ((Env.MinY - Env.MaxY) / adfGeoTransform[5]);
if(pTrackCancel)
pTrackCancel->PutMessage(wxString::Format(_("Computed source pixel window %d %d %d %d from geographic window."), anSrcWin[0], anSrcWin[1], anSrcWin[2], anSrcWin[3] ), -1, enumGISMessageInfo);
if( anSrcWin[0] < 0 || anSrcWin[1] < 0 || anSrcWin[0] + anSrcWin[2] > pSrcRasterDataSet->GetWidth() || anSrcWin[1] + anSrcWin[3] > pSrcRasterDataSet->GetHeight() )
{
if(pTrackCancel)
pTrackCancel->PutMessage(wxString::Format(_("Computed source pixel window falls outside raster size of %dx%d."), pSrcRasterDataSet->GetWidth(), pSrcRasterDataSet->GetHeight()), -1, enumGISMessageErr);
return false;
}
int nOXSize = 0, nOYSize = 0;
if(IsDoubleEquil(dfOutResX, -1) && IsDoubleEquil(dfOutResY, -1))
{
nOXSize = anSrcWin[2];
nOYSize = anSrcWin[3];
}
else
{
nOXSize = ceil ((Env.MaxX - Env.MinX) / dfOutResX);
nOYSize = ceil ((Env.MinY - Env.MaxY) / (adfGeoTransform[5] < 0 ? dfOutResY * -1 : dfOutResY));
}
/* ==================================================================== */
/* Create a virtual dataset. */
/* ==================================================================== */
VRTDataset *poVDS;
/* -------------------------------------------------------------------- */
/* Make a virtual clone. */
/* -------------------------------------------------------------------- */
poVDS = (VRTDataset *) VRTCreate( nOXSize, nOYSize );
if( pSrcRasterDataSet->GetSpatialReference() != NULL )
{
poVDS->SetProjection( pDset->GetProjectionRef() );
}
adfGeoTransform[0] += anSrcWin[0] * adfGeoTransform[1] + anSrcWin[1] * adfGeoTransform[2];
adfGeoTransform[3] += anSrcWin[0] * adfGeoTransform[4] + anSrcWin[1] * adfGeoTransform[5];
adfGeoTransform[1] *= anSrcWin[2] / (double) nOXSize;
adfGeoTransform[2] *= anSrcWin[3] / (double) nOYSize;
adfGeoTransform[4] *= anSrcWin[2] / (double) nOXSize;
adfGeoTransform[5] *= anSrcWin[3] / (double) nOYSize;
poVDS->SetGeoTransform( adfGeoTransform );
int nGCPs = pDset->GetGCPCount();
if( nGCPs > 0 )
{
GDAL_GCP *pasGCPs = GDALDuplicateGCPs( nGCPs, pDset->GetGCPs() );
for(size_t i = 0; i < nGCPs; ++i )
{
pasGCPs[i].dfGCPPixel -= anSrcWin[0];
pasGCPs[i].dfGCPLine -= anSrcWin[1];
pasGCPs[i].dfGCPPixel *= (nOXSize / (double) anSrcWin[2] );
pasGCPs[i].dfGCPLine *= (nOYSize / (double) anSrcWin[3] );
}
poVDS->SetGCPs( nGCPs, pasGCPs, pDset->GetGCPProjection() );
GDALDeinitGCPs( nGCPs, pasGCPs );
CPLFree( pasGCPs );
}
/* -------------------------------------------------------------------- */
/* Transfer generally applicable metadata. */
/* -------------------------------------------------------------------- */
if(!bSkipSourceMetadata)
poVDS->SetMetadata( pDset->GetMetadata() );
//.........这里部分代码省略.........
开发者ID:Mileslee,项目名称:wxgis,代码行数:101,代码来源:gpraster.cpp
注:本文中的VRTDataset类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论