本文整理汇总了C++中VRTDataset::SetGCPs方法的典型用法代码示例。如果您正苦于以下问题:C++ VRTDataset::SetGCPs方法的具体用法?C++ VRTDataset::SetGCPs怎么用?C++ VRTDataset::SetGCPs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VRTDataset
的用法示例。
在下文中一共展示了VRTDataset::SetGCPs方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CPLAssert
//.........这里部分代码省略.........
{
poVRTDS->SetGeoTransform( adfGeoTransform );
}
/* -------------------------------------------------------------------- */
/* Copy projection */
/* -------------------------------------------------------------------- */
poVRTDS->SetProjection( poSrcDS->GetProjectionRef() );
/* -------------------------------------------------------------------- */
/* Emit dataset level metadata. */
/* -------------------------------------------------------------------- */
poVRTDS->SetMetadata( poSrcDS->GetMetadata() );
/* -------------------------------------------------------------------- */
/* Copy any special domains that should be transportable. */
/* -------------------------------------------------------------------- */
char **papszMD = poSrcDS->GetMetadata( "RPC" );
if( papszMD )
poVRTDS->SetMetadata( papszMD, "RPC" );
papszMD = poSrcDS->GetMetadata( "IMD" );
if( papszMD )
poVRTDS->SetMetadata( papszMD, "IMD" );
papszMD = poSrcDS->GetMetadata( "GEOLOCATION" );
if( papszMD )
poVRTDS->SetMetadata( papszMD, "GEOLOCATION" );
/* -------------------------------------------------------------------- */
/* GCPs */
/* -------------------------------------------------------------------- */
if( poSrcDS->GetGCPCount() > 0 )
{
poVRTDS->SetGCPs( poSrcDS->GetGCPCount(),
poSrcDS->GetGCPs(),
poSrcDS->GetGCPProjection() );
}
/* -------------------------------------------------------------------- */
/* Loop over all the bands. */
/* -------------------------------------------------------------------- */
for( int iBand = 0; iBand < poSrcDS->GetRasterCount(); iBand++ )
{
GDALRasterBand *poSrcBand = poSrcDS->GetRasterBand( iBand+1 );
/* -------------------------------------------------------------------- */
/* Create the band with the appropriate band type. */
/* -------------------------------------------------------------------- */
poVRTDS->AddBand( poSrcBand->GetRasterDataType(), NULL );
VRTSourcedRasterBand *poVRTBand
= reinterpret_cast<VRTSourcedRasterBand *>(
poVRTDS->GetRasterBand( iBand+1 ) );
/* -------------------------------------------------------------------- */
/* Setup source mapping. */
/* -------------------------------------------------------------------- */
poVRTBand->AddSimpleSource( poSrcBand );
/* -------------------------------------------------------------------- */
/* Emit various band level metadata. */
/* -------------------------------------------------------------------- */
poVRTBand->CopyCommonInfoFrom( poSrcBand );
/* -------------------------------------------------------------------- */
/* Add specific mask band. */
/* -------------------------------------------------------------------- */
if( (poSrcBand->GetMaskFlags()
& (GMF_PER_DATASET | GMF_ALL_VALID | GMF_NODATA)) == 0)
{
VRTSourcedRasterBand* poVRTMaskBand = new VRTSourcedRasterBand(
poVRTDS, 0,
poSrcBand->GetMaskBand()->GetRasterDataType(),
poSrcDS->GetRasterXSize(), poSrcDS->GetRasterYSize());
poVRTMaskBand->AddMaskBandSource( poSrcBand );
poVRTBand->SetMaskBand( poVRTMaskBand );
}
}
/* -------------------------------------------------------------------- */
/* Add dataset mask band */
/* -------------------------------------------------------------------- */
if( poSrcDS->GetRasterCount() != 0 &&
poSrcDS->GetRasterBand(1) != NULL &&
poSrcDS->GetRasterBand(1)->GetMaskFlags() == GMF_PER_DATASET )
{
GDALRasterBand *poSrcBand = poSrcDS->GetRasterBand(1);
VRTSourcedRasterBand* poVRTMaskBand = new VRTSourcedRasterBand(
poVRTDS, 0,
poSrcBand->GetMaskBand()->GetRasterDataType(),
poSrcDS->GetRasterXSize(), poSrcDS->GetRasterYSize() );
poVRTMaskBand->AddMaskBandSource( poSrcBand );
poVRTDS->SetMaskBand( poVRTMaskBand );
}
poVRTDS->FlushCache();
return poVRTDS;
}
示例2: ProxyMain
//.........这里部分代码省略.........
adfGeoTransform[3] = adfULLR[1];
adfGeoTransform[4] = 0.0;
adfGeoTransform[5] = (adfULLR[3] - adfULLR[1]) / nOYSize;
poVDS->SetGeoTransform(adfGeoTransform);
}
else if (GDALGetGeoTransform(hDataset, adfGeoTransform) == CE_None
&& nGCPCount == 0)
{
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);
}
if (nGCPCount != 0)
{
const char *pszGCPProjection = pszOutputSRS;
if (pszGCPProjection == NULL)
pszGCPProjection = GDALGetGCPProjection(hDataset);
if (pszGCPProjection == NULL)
pszGCPProjection = "";
poVDS->SetGCPs(nGCPCount, pasGCPs, pszGCPProjection);
GDALDeinitGCPs(nGCPCount, pasGCPs);
CPLFree(pasGCPs);
}
else if (GDALGetGCPCount(hDataset) > 0)
{
GDAL_GCP *pasGCPs;
int nGCPs = GDALGetGCPCount(hDataset);
pasGCPs = GDALDuplicateGCPs(nGCPs, GDALGetGCPs(hDataset));
for (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,
GDALGetGCPProjection(hDataset));
GDALDeinitGCPs(nGCPs, pasGCPs);
CPLFree(pasGCPs);
}
/* -------------------------------------------------------------------- */
/* Transfer generally applicable metadata. */
/* -------------------------------------------------------------------- */
poVDS->SetMetadata(((GDALDataset*)hDataset)->GetMetadata());
AttachMetadata((GDALDatasetH) poVDS, papszMetadataOptions);
示例3: main
//.........这里部分代码省略.........
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++ )
{
VRTSourcedRasterBand *poVRTBand;
GDALRasterBand *poSrcBand;
GDALDataType eBandType;
poSrcBand = ((GDALDataset *) hDataset)->GetRasterBand(iBand+1);
/* -------------------------------------------------------------------- */
/* Select output data type to match source. */
/* -------------------------------------------------------------------- */
if( eOutputType == GDT_Unknown )
eBandType = GDT_Byte;
else
eBandType = eOutputType;
/* -------------------------------------------------------------------- */
/* Create this band. */
/* -------------------------------------------------------------------- */
poVDS->AddBand( eBandType, NULL );
poVRTBand = (VRTSourcedRasterBand *) poVDS->GetRasterBand( iBand+1 );
/* -------------------------------------------------------------------- */
/* Create a function based source with info on how to apply the */
/* enhancement. */
/* -------------------------------------------------------------------- */
示例4: 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() );
//.........这里部分代码省略.........