本文整理汇总了C++中GDALGetRasterXSize函数的典型用法代码示例。如果您正苦于以下问题:C++ GDALGetRasterXSize函数的具体用法?C++ GDALGetRasterXSize怎么用?C++ GDALGetRasterXSize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GDALGetRasterXSize函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: GDALOpen
QgsAlignRaster::RasterInfo::RasterInfo( const QString& layerpath )
{
mDataset = GDALOpen( layerpath.toLocal8Bit().constData(), GA_ReadOnly );
if ( !mDataset )
return;
mXSize = GDALGetRasterXSize( mDataset );
mYSize = GDALGetRasterYSize( mDataset );
GDALGetGeoTransform( mDataset, mGeoTransform );
// TODO: may be null or empty string
mCrsWkt = QString::fromAscii( GDALGetProjectionRef( mDataset ) );
mBandCnt = GDALGetBandNumber( mDataset );
}
开发者ID:giserfly,项目名称:QGIS,代码行数:16,代码来源:qgsalignraster.cpp
示例2: GDALGetRasterCount
void MDAL::GdalDataset::parseParameters()
{
mNBands = static_cast<unsigned int>( GDALGetRasterCount( mHDataset ) );
if ( mNBands == 0 ) throw MDAL_Status::Err_InvalidData;
GDALGetGeoTransform( mHDataset, mGT ); // in case of error it returns Identid
mXSize = static_cast<unsigned int>( GDALGetRasterXSize( mHDataset ) ); //raster width in pixels
if ( mXSize == 0 ) throw MDAL_Status::Err_InvalidData;
mYSize = static_cast<unsigned int>( GDALGetRasterYSize( mHDataset ) ); //raster height in pixels
if ( mYSize == 0 ) throw MDAL_Status::Err_InvalidData;
mNPoints = mXSize * mYSize;
mNVolumes = ( mXSize - 1 ) * ( mYSize - 1 );
}
开发者ID:AlisterH,项目名称:Quantum-GIS,代码行数:16,代码来源:mdal_gdal.cpp
示例3: WorkerFunc
static void WorkerFunc( void * )
{
GDALDatasetH hDS;
int iIter, iOpenIter;
for( iOpenIter = 0; iOpenIter < nOpenIterations; iOpenIter++ )
{
if( bLockOnOpen )
CPLAcquireMutex( pGlobalMutex, 100.0 );
hDS = GDALOpen( pszFilename, GA_ReadOnly );
if( bLockOnOpen )
CPLReleaseMutex( pGlobalMutex );
for( iIter = 0; iIter < nIterations && hDS != NULL; iIter++ )
{
int nMyChecksum;
nMyChecksum = GDALChecksumImage( GDALGetRasterBand( hDS, 1 ),
0, 0,
GDALGetRasterXSize( hDS ),
GDALGetRasterYSize( hDS ) );
if( nMyChecksum != nChecksum )
{
printf( "Checksum ERROR in worker thread!\n" );
break;
}
}
if( hDS )
{
if( bLockOnOpen )
CPLAcquireMutex( pGlobalMutex, 100.0 );
GDALClose( hDS );
if( bLockOnOpen )
CPLReleaseMutex( pGlobalMutex );
}
}
CPLAcquireMutex( pGlobalMutex, 100.0 );
nPendingThreads--;
CPLReleaseMutex( pGlobalMutex );
}
开发者ID:469447793,项目名称:World-Wind-Java,代码行数:46,代码来源:multireadtest.cpp
示例4: GDALOpen
//duplicated from QgsNineCellFilter. Todo: make common base class
GDALDatasetH QgsRelief::openInputFile( int &nCellsX, int &nCellsY )
{
GDALDatasetH inputDataset = GDALOpen( mInputFile.toUtf8().constData(), GA_ReadOnly );
if ( inputDataset )
{
nCellsX = GDALGetRasterXSize( inputDataset );
nCellsY = GDALGetRasterYSize( inputDataset );
//we need at least one band
if ( GDALGetRasterCount( inputDataset ) < 1 )
{
GDALClose( inputDataset );
return nullptr;
}
}
return inputDataset;
}
开发者ID:GeoCat,项目名称:QGIS,代码行数:18,代码来源:qgsrelief.cpp
示例5: GDALOpen
GDALDatasetH QgsNineCellFilter::openInputFile( int& nCellsX, int& nCellsY )
{
GDALDatasetH inputDataset = GDALOpen( mInputFile.toLocal8Bit().data(), GA_ReadOnly );
if ( inputDataset != NULL )
{
nCellsX = GDALGetRasterXSize( inputDataset );
nCellsY = GDALGetRasterYSize( inputDataset );
//we need at least one band
if ( GDALGetRasterCount( inputDataset ) < 1 )
{
GDALClose( inputDataset );
return NULL;
}
}
return inputDataset;
}
开发者ID:mmubangizi,项目名称:qgis,代码行数:17,代码来源:qgsninecellfilter.cpp
示例6: GDALOpen
//duplicated from QgsNineCellFilter. Todo: make common base class
GDALDatasetH QgsRelief::openInputFile( int& nCellsX, int& nCellsY )
{
GDALDatasetH inputDataset = GDALOpen( TO8F( mInputFile ), GA_ReadOnly );
if ( inputDataset != NULL )
{
nCellsX = GDALGetRasterXSize( inputDataset );
nCellsY = GDALGetRasterYSize( inputDataset );
//we need at least one band
if ( GDALGetRasterCount( inputDataset ) < 1 )
{
GDALClose( inputDataset );
return NULL;
}
}
return inputDataset;
}
开发者ID:ACorradini,项目名称:QGIS,代码行数:18,代码来源:qgsrelief.cpp
示例7: QgsRectangle
void TestQgsGdalUtils::testCreateSingleBandMemoryDataset()
{
gdal::dataset_unique_ptr ds1 = QgsGdalUtils::createSingleBandMemoryDataset( GDT_Float32, QgsRectangle( 1, 1, 21, 11 ), 40, 20, QgsCoordinateReferenceSystem( "EPSG:4326" ) );
QVERIFY( ds1 );
QCOMPARE( GDALGetRasterCount( ds1.get() ), 1 );
QCOMPARE( GDALGetRasterXSize( ds1.get() ), 40 );
QCOMPARE( GDALGetRasterYSize( ds1.get() ), 20 );
QCOMPARE( GDALGetProjectionRef( ds1.get() ), EPSG_4326_WKT );
double geoTransform[6];
double geoTransformExpected[] = { 1, 0.5, 0, 11, 0, -0.5 };
QCOMPARE( GDALGetGeoTransform( ds1.get(), geoTransform ), CE_None );
QVERIFY( memcmp( geoTransform, geoTransformExpected, sizeof( double ) * 6 ) == 0 );
QCOMPARE( GDALGetRasterDataType( GDALGetRasterBand( ds1.get(), 1 ) ), GDT_Float32 );
}
开发者ID:alexbruy,项目名称:QGIS,代码行数:17,代码来源:testqgsgdalutils.cpp
示例8: make_me_a_sandwitch
/* Makes a copy of a dataset, and opens it for writing.. */
GDALDatasetH make_me_a_sandwitch(GDALDatasetH *in_dataset, char *filename)
{
char **papszOptions = NULL;
const char *pszFormat = "GTiff";
GDALDriverH hDriver;
GDALDatasetH out_gdalfile;
hDriver = GDALGetDriverByName( pszFormat );
papszOptions = CSLSetNameValue( papszOptions, "TILED", "YES" );
papszOptions = CSLSetNameValue( papszOptions, "COMPRESS", "DEFLATE" );
/*Create copy..*/
/*return GDALCreateCopy( hDriver, filename, *in_dataset, FALSE, papszOptions, NULL, NULL );*/
return GDALCreate(hDriver, filename,
GDALGetRasterXSize( *in_dataset ),
GDALGetRasterYSize( *in_dataset ),
1,
GDT_Byte, papszOptions );
}
开发者ID:spruceboy,项目名称:Spruceboy-s-Data-Processing-Scripts,代码行数:19,代码来源:saturate.c
示例9: GDALGetRasterXSize
GDALDatasetH QgsNineCellFilter::openOutputFile( GDALDatasetH inputDataset, GDALDriverH outputDriver )
{
if ( inputDataset == NULL )
{
return NULL;
}
int xSize = GDALGetRasterXSize( inputDataset );
int ySize = GDALGetRasterYSize( inputDataset );;
//open output file
char **papszOptions = NULL;
GDALDatasetH outputDataset = GDALCreate( outputDriver, mOutputFile.toLocal8Bit().data(), xSize, ySize, 1, GDT_Float32, papszOptions );
if ( outputDataset == NULL )
{
return outputDataset;
}
//get geotransform from inputDataset
double geotransform[6];
if ( GDALGetGeoTransform( inputDataset, geotransform ) != CE_None )
{
GDALClose( outputDataset );
return NULL;
}
GDALSetGeoTransform( outputDataset, geotransform );
//make sure mCellSizeX and mCellSizeY are always > 0
mCellSizeX = geotransform[1];
if ( mCellSizeX < 0 )
{
mCellSizeX = -mCellSizeX;
}
mCellSizeY = geotransform[5];
if ( mCellSizeY < 0 )
{
mCellSizeY = -mCellSizeY;
}
const char* projection = GDALGetProjectionRef( inputDataset );
GDALSetProjection( outputDataset, projection );
return outputDataset;
}
开发者ID:mmubangizi,项目名称:qgis,代码行数:44,代码来源:qgsninecellfilter.cpp
示例10: JakoFileDataView
static dErr JakoFileDataView(GDALDatasetH filedata,const char *name,PetscViewer viewer)
{
dErr err;
CPLErr cplerr;
double geo[6],data[8*12];
int nx=8,ny=12,snx,sny;
GDALRasterBandH band;
dFunctionBegin;
cplerr = GDALGetGeoTransform(filedata,geo);
err = dRealTableView(2,3,geo,PETSC_VIEWER_STDOUT_WORLD,"%s:geo",name);dCHK(err);
snx = GDALGetRasterXSize(filedata);
sny = GDALGetRasterYSize(filedata);
err = PetscViewerASCIIPrintf(viewer,"%s: nx=%d ny=%d\n",name,snx,sny);dCHK(err);
band = GDALGetRasterBand(filedata,1);
cplerr = GDALRasterIO(band,GF_Read,snx/2,sny/2,nx,ny,data,nx,ny,GDT_Float64,0,0);dCPLCHK(cplerr);
err = dRealTableView(ny,nx,data,PETSC_VIEWER_STDOUT_WORLD,name);dCHK(err);
dFunctionReturn(0);
}
开发者ID:jedbrown,项目名称:dohp,代码行数:19,代码来源:vhtjako.c
示例11: JakoGDALMemAddBand
static dErr JakoGDALMemAddBand(GDALDatasetH dset,GDALDataType dtype,void *memory)
{
char buf[256] = {0},**bandoptions = NULL;
int bytes,nx,ny;
CPLErr cplerr;
dErr err;
dFunctionBegin;
bytes = GDALGetDataTypeSize(dtype);
nx = GDALGetRasterXSize(dset);
ny = GDALGetRasterYSize(dset);
err = dMalloc(nx*ny*bytes,(void**)memory);dCHK(err);
// This is where the API moves from merely cumbersome to outright demeaning, like some twisted hazing ritual.
CPLPrintPointer(buf,*(void**)memory,sizeof(buf));
bandoptions = CSLSetNameValue(bandoptions,"DATAPOINTER",buf);
cplerr = GDALAddBand(dset,dtype,bandoptions);dCPLCHK(cplerr);
CSLDestroy(bandoptions);
dFunctionReturn(0);
}
开发者ID:jedbrown,项目名称:dohp,代码行数:20,代码来源:vhtjako.c
示例12: generic_read
void generic_read(struct FI *f, char *filename)
{
if (filename_corresponds_to_tiffo(filename)) {
#ifdef FANCY_TIFF
f->tiffo = true;
tiff_octaves_init0(f->t, filename, f->megabytes,f->max_octaves);
if (f->option_write) f->t->option_write = true;
f->w = f->t->i->w;
f->h = f->t->i->h;
f->pd = f->t->i->spp;
f->no = f->t->noctaves;
#else
assert(false);
#endif
} else if (!f->option_write && FORCE_GDAL()) {
#ifdef FANCY_GDAL
f->gdal = true;
GDALAllRegister();
char buf[2*FILENAME_MAX];
snprintf(buf, 2*FILENAME_MAX, has_prefix(filename, "http://") ||
has_prefix(filename, "https://") ?
"/vsicurl/%s" : "%s", filename);
f->gdal_img = GDALOpen(buf, GA_ReadOnly);
fprintf(stderr, "gdal_dataset = %p\n", f->gdal_img);
f->pd = GDALGetRasterCount(f->gdal_img);
f->w = GDALGetRasterXSize(f->gdal_img);
f->h = GDALGetRasterYSize(f->gdal_img);
f->no = 1;
for (int i = 0; i < f->pd; i++)
f->gdal_band[i] = GDALGetRasterBand(f->gdal_img, i+1);
#else
assert(false);
#endif
} else {
f->x = iio_read_image_float_vec(filename, &f->w, &f->h, &f->pd);
f->no = build_pyramid(f, f->max_octaves);
snprintf(f->x_filename, FILENAME_MAX, "%s", filename);
f->x_changed = false;
}
}
开发者ID:mnhrdt,项目名称:imscript,代码行数:40,代码来源:fancy_image.c
示例13: GDALGetRasterXSize
// Determines the pixel/line position given an x/y.
// No reprojection is done at this time.
bool Colorization::getPixelAndLinePosition(double x,
double y,
boost::array<double, 6> const& inverse,
boost::int32_t& pixel,
boost::int32_t& line,
void* ds)
{
#ifdef PDAL_HAVE_GDAL
pixel = (boost::int32_t) std::floor(
inverse[0]
+ inverse[1] * x
+ inverse[2] * y);
line = (boost::int32_t) std::floor(
inverse[3]
+ inverse[4] * x
+ inverse[5] * y);
int xs = GDALGetRasterXSize(ds);
int ys = GDALGetRasterYSize(ds);
if (!xs || !ys)
{
throw pdal_error("Unable to get X or Y size from raster!");
}
if (pixel < 0 ||
line < 0 ||
pixel >= xs ||
line >= ys
)
{
// The x, y is not coincident with this raster
return false;
}
#endif
return true;
}
开发者ID:mweisman,项目名称:PDAL,代码行数:40,代码来源:Colorization.cpp
示例14: msUVRASTERLayerGetExtent
int msUVRASTERLayerGetExtent(layerObj *layer, rectObj *extent)
{
char szPath[MS_MAXPATHLEN];
mapObj *map = layer->map;
double adfGeoTransform[6];
int nXSize, nYSize;
GDALDatasetH hDS;
shapefileObj *tileshpfile;
int tilelayerindex = -1;
CPLErr eErr = CE_Failure;
char *decrypted_path;
if( (!layer->data || strlen(layer->data) == 0)
&& layer->tileindex == NULL) {
/* should we be issuing a specific error about not supporting
extents for tileindexed raster layers? */
return MS_FAILURE;
}
if( map == NULL )
return MS_FAILURE;
/* If the layer use a tileindex, return the extent of the tileindex shapefile/referenced layer */
if (layer->tileindex) {
tilelayerindex = msGetLayerIndex(map, layer->tileindex);
if(tilelayerindex != -1) /* does the tileindex reference another layer */
return msLayerGetExtent(GET_LAYER(map, tilelayerindex), extent);
else {
tileshpfile = (shapefileObj *) malloc(sizeof(shapefileObj));
MS_CHECK_ALLOC(tileshpfile, sizeof(shapefileObj), MS_FAILURE);
if(msShapefileOpen(tileshpfile, "rb", msBuildPath3(szPath, map->mappath, map->shapepath, layer->tileindex), MS_TRUE) == -1)
if(msShapefileOpen(tileshpfile, "rb", msBuildPath(szPath, map->mappath, layer->tileindex), MS_TRUE) == -1)
return MS_FAILURE;
*extent = tileshpfile->bounds;
msShapefileClose(tileshpfile);
free(tileshpfile);
return MS_SUCCESS;
}
}
msTryBuildPath3(szPath, map->mappath, map->shapepath, layer->data);
decrypted_path = msDecryptStringTokens( map, szPath );
msAcquireLock( TLOCK_GDAL );
if( decrypted_path ) {
hDS = GDALOpen(decrypted_path, GA_ReadOnly );
msFree( decrypted_path );
} else
hDS = NULL;
if( hDS != NULL ) {
nXSize = GDALGetRasterXSize( hDS );
nYSize = GDALGetRasterYSize( hDS );
eErr = GDALGetGeoTransform( hDS, adfGeoTransform );
GDALClose( hDS );
}
msReleaseLock( TLOCK_GDAL );
if( hDS == NULL || eErr != CE_None ) {
return MS_FAILURE;
}
/* If this appears to be an ungeoreferenced raster than flip it for
mapservers purposes. */
if( adfGeoTransform[5] == 1.0 && adfGeoTransform[3] == 0.0 ) {
adfGeoTransform[5] = -1.0;
adfGeoTransform[3] = nYSize;
}
extent->minx = adfGeoTransform[0];
extent->maxy = adfGeoTransform[3];
extent->maxx = adfGeoTransform[0] + nXSize * adfGeoTransform[1];
extent->miny = adfGeoTransform[3] + nYSize * adfGeoTransform[5];
return MS_SUCCESS;
}
开发者ID:EOX-A,项目名称:mapserver,代码行数:82,代码来源:mapuvraster.c
示例15: main
int main( int argc, char ** argv )
{
GDALDatasetH hSrcDS;
int iY, iX, nOutLevel=0, nXSize, nYSize, iArg, nFillDist=0;
void *pStream;
GInt16 *panData;
const char *pszFilename = NULL;
GDALRasterBandH hSrcBand;
double adfGeoTransform[6];
int bEnableTrim = FALSE;
GInt16 noDataValue = 0;
int bHasNoData;
/* -------------------------------------------------------------------- */
/* Identify arguments. */
/* -------------------------------------------------------------------- */
for( iArg = 1; iArg < argc; iArg++ )
{
if( EQUAL(argv[iArg],"-trim") )
bEnableTrim = TRUE;
else if( EQUAL(argv[iArg],"-fill") )
nFillDist = atoi(argv[++iArg]);
else if( EQUAL(argv[iArg],"-level") )
nOutLevel = atoi(argv[++iArg]);
else
{
if( pszFilename != NULL )
Usage();
pszFilename = argv[iArg];
}
}
if( pszFilename == NULL )
Usage();
/* -------------------------------------------------------------------- */
/* Open input file. */
/* -------------------------------------------------------------------- */
GDALAllRegister();
hSrcDS = GDALOpen( pszFilename, GA_ReadOnly );
if( hSrcDS == NULL )
exit(1);
hSrcBand = GDALGetRasterBand( hSrcDS, 1 );
noDataValue = (GInt16)GDALGetRasterNoDataValue(hSrcBand, &bHasNoData);
nXSize = GDALGetRasterXSize( hSrcDS );
nYSize = GDALGetRasterYSize( hSrcDS );
GDALGetGeoTransform( hSrcDS, adfGeoTransform );
/* -------------------------------------------------------------------- */
/* Create output stream. */
/* -------------------------------------------------------------------- */
pStream = DTEDCreatePtStream( ".", nOutLevel );
if( pStream == NULL )
exit( 1 );
/* -------------------------------------------------------------------- */
/* Process all the profiles. */
/* -------------------------------------------------------------------- */
panData = (GInt16 *) malloc(sizeof(GInt16) * nXSize);
for( iY = 0; iY < nYSize; iY++ )
{
GDALRasterIO( hSrcBand, GF_Read, 0, iY, nXSize, 1,
panData, nXSize, 1, GDT_Int16, 0, 0 );
if (bHasNoData)
{
for( iX = 0; iX < nXSize; iX++ )
{
if (panData[iX] == noDataValue)
panData[iX] = DTED_NODATA_VALUE;
}
}
for( iX = 0; iX < nXSize; iX++ )
{
DTEDWritePt( pStream,
adfGeoTransform[0]
+ adfGeoTransform[1] * (iX + 0.5)
+ adfGeoTransform[2] * (iY + 0.5),
adfGeoTransform[3]
+ adfGeoTransform[4] * (iX + 0.5)
+ adfGeoTransform[5] * (iY + 0.5),
panData[iX] );
}
}
free( panData );
/* -------------------------------------------------------------------- */
/* Cleanup. */
//.........这里部分代码省略.........
开发者ID:StephenHolzman,项目名称:UVAmisc,代码行数:101,代码来源:dted_test.c
示例16: main
//.........这里部分代码省略.........
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++ )
{
VRTSourcedRasterBand *poVRTBand;
GDALRasterBand *poSrcBand;
GDALDataType eBandType;
poSrcBand = ((GDALDataset *) hDataset)->GetRasterBand(iBand+1);
/* -------------------------------------------------------------------- */
开发者ID:brunosimoes,项目名称:WorldWind,代码行数:67,代码来源:gdalenhance.cpp
示例17: main
int main( int argc, char ** argv )
{
GDALDatasetH hDataset;
GDALRasterBandH hBand;
int i, iBand;
double adfGeoTransform[6];
GDALDriverH hDriver;
char **papszMetadata;
int bComputeMinMax = FALSE;
if( !GDALBridgeInitialize( "..", stderr ) )
{
fprintf( stderr, "Unable to intiailize GDAL bridge.\n" );
exit( 10 );
}
if( argc > 1 && strcmp(argv[1],"-mm") == 0 )
{
bComputeMinMax = TRUE;
argv++;
}
GDALAllRegister();
hDataset = GDALOpen( argv[1], GA_ReadOnly );
if( hDataset == NULL )
{
fprintf( stderr,
"GDALOpen failed - %d\n%s\n",
CPLGetLastErrorNo(), CPLGetLastErrorMsg() );
exit( 1 );
}
/* -------------------------------------------------------------------- */
/* Report general info. */
/* -------------------------------------------------------------------- */
hDriver = GDALGetDatasetDriver( hDataset );
printf( "Driver: %s/%s\n",
GDALGetDriverShortName( hDriver ),
GDALGetDriverLongName( hDriver ) );
printf( "Size is %d, %d\n",
GDALGetRasterXSize( hDataset ),
GDALGetRasterYSize( hDataset ) );
/* -------------------------------------------------------------------- */
/* Report projection. */
/* -------------------------------------------------------------------- */
if( GDALGetProjectionRef( hDataset ) != NULL )
{
OGRSpatialReferenceH hSRS;
char *pszProjection;
pszProjection = (char *) GDALGetProjectionRef( hDataset );
hSRS = OSRNewSpatialReference(NULL);
if( OSRImportFromWkt( hSRS, &pszProjection ) == CE_None )
{
char *pszPrettyWkt = NULL;
OSRExportToPrettyWkt( hSRS, &pszPrettyWkt, FALSE );
printf( "Coordinate System is:\n%s\n", pszPrettyWkt );
}
else
printf( "Coordinate System is `%s'\n",
GDALGetProjectionRef( hDataset ) );
OSRDestroySpatialReference( hSRS );
}
/* -------------------------------------------------------------------- */
/* Report Geotransform. */
/* -------------------------------------------------------------------- */
if( GDALGetGeoTransform( hDataset, adfGeoTransform ) == CE_None )
{
printf( "Origin = (%.6f,%.6f)\n",
adfGeoTransform[0], adfGeoTransform[3] );
printf( "Pixel Size = (%.6f,%.6f)\n",
adfGeoTransform[1], adfGeoTransform[5] );
}
/* -------------------------------------------------------------------- */
/* Report GCPs. */
/* -------------------------------------------------------------------- */
if( GDALGetGCPCount( hDataset ) > 0 )
{
printf( "GCP Projection = %s\n", GDALGetGCPProjection(hDataset) );
for( i = 0; i < GDALGetGCPCount(hDataset); i++ )
{
const GDAL_GCP *psGCP;
psGCP = GDALGetGCPs( hDataset ) + i;
printf( "GCP[%3d]: Id=%s, Info=%s\n"
" (%g,%g) -> (%g,%g,%g)\n",
i, psGCP->pszId, psGCP->pszInfo,
psGCP->dfGCPPixel, psGCP->dfGCPLine,
//.........这里部分代码省略.........
开发者ID:drownedout,项目名称:datamap,代码行数:101,代码来源:bridge_test.cpp
示例18: main
//.........这里部分代码省略.........
CSLDestroy( argv );
GDALDumpOpenDatasets( stderr );
GDALDestroyDriverManager();
CPLDumpSharedList( NULL );
exit( 1 );
}
/* -------------------------------------------------------------------- */
/* Report general info. */
/* -------------------------------------------------------------------- */
hDriver = GDALGetDatasetDriver( hDataset );
printf( "Driver: %s/%s\n",
GDALGetDriverShortName( hDriver ),
GDALGetDriverLongName( hDriver ) );
papszFileList = GDALGetFileList( hDataset );
if( CSLCount(papszFileList) == 0 )
{
printf( "Files: none associated\n" );
}
else
{
printf( "Files: %s\n", papszFileList[0] );
for( i = 1; papszFileList[i] != NULL; i++ )
printf( " %s\n", papszFileList[i] );
}
CSLDestroy( papszFileList );
printf( "Size is %d, %d\n",
GDALGetRasterXSize( hDataset ),
GDALGetRasterYSize( hDataset ) );
/* -------------------------------------------------------------------- */
/* Report projection. */
/* -------------------------------------------------------------------- */
if( GDALGetProjectionRef( hDataset ) != NULL )
{
OGRSpatialReferenceH hSRS;
char *pszProjection;
pszProjection = (char *) GDALGetProjectionRef( hDataset );
hSRS = OSRNewSpatialReference(NULL);
if( OSRImportFromWkt( hSRS, &pszProjection ) == CE_None )
{
char *pszPrettyWkt = NULL;
OSRExportToPrettyWkt( hSRS, &pszPrettyWkt, FALSE );
printf( "Coordinate System is:\n%s\n", pszPrettyWkt );
CPLFree( pszPrettyWkt );
}
else
printf( "Coordinate System is `%s'\n",
GDALGetProjectionRef( hDataset ) );
OSRDestroySpatialReference( hSRS );
}
/* -------------------------------------------------------------------- */
/* Report Geotransform. */
/* -------------------------------------------------------------------- */
if( GDALGetGeoTransform( hDataset, adfGeoTransform ) == CE_None )
开发者ID:469447793,项目名称:World-Wind-Java,代码行数:67,代码来源:gdalinfo.c
示例19: gv_symbol_manager_get_symbol
GvSymbolObj *
gv_symbol_manager_get_symbol(GvSymbolManager *manager, const char *symbol_name)
{
gchar *pszOpenEVHome = NULL;
gchar *pszSymbolsDir = NULL;
gchar *pszAbsolutePath = NULL;
gchar *pszPathSeparator = NULL;
GDALDatasetH hDataset;
GvSymbolObj *poSymbol;
CPLXMLNode *xml_shape = NULL;
GByte *rgba_buffer;
/* -------------------------------------------------------------------- */
/* Lookup the symbol in the hash table, and return it if found. */
/* -------------------------------------------------------------------- */
poSymbol = g_hash_table_lookup( manager->symbol_cache, symbol_name );
if( poSymbol != NULL )
return poSymbol;
/* -------------------------------------------------------------------- */
/* We didn't already have it, so try to find a file to load it */
/* from. */
/* -------------------------------------------------------------------- */
#ifndef WIN32
pszPathSeparator = "/";
#else
pszPathSeparator = "\\";
#endif /* WIN32 */
/* validate inputs */
g_return_val_if_fail( manager != NULL, 0 );
g_return_val_if_fail( symbol_name != NULL, 0 );
/* get an absolute path */
if ( !g_path_is_absolute( symbol_name ) )
{
/* check configuration option first */
pszSymbolsDir = g_strdup( gv_manager_get_preference( gv_get_manager(),
"symbols_dir" ) );
/* if not configured check $OPENEV_HOME */
if ( !pszSymbolsDir )
{
pszOpenEVHome = g_getenv( "OPENEV_HOME" );
if( pszOpenEVHome == NULL )
pszOpenEVHome = g_getenv( "OPENEVHOME" );
if ( pszOpenEVHome )
pszSymbolsDir = g_strjoin( pszPathSeparator, pszOpenEVHome,
"symbols", NULL );
}
/* get current directory as last resort */
if ( !pszSymbolsDir )
pszSymbolsDir = g_get_current_dir();
pszAbsolutePath = g_strjoin( pszPathSeparator, pszSymbolsDir,
symbol_name, NULL );
g_free( pszSymbolsDir );
}
else
pszAbsolutePath = g_strdup( symbol_name );
/* -------------------------------------------------------------------- */
/* pszAbsolutePath contains a newly allocated string that is */
/* suitable for using as a key in the hash table. If a texture */
/* is found in the hash table then this string needs to be */
/* freed. If one isn't found then the string is used in the */
/* hash table and should be freed when the associated hash */
/* table entry is released */
/* -------------------------------------------------------------------- */
CPLDebug( "OpenEV",
"gv_symbol_manager_get_symbol(%s) ... need to load.",
pszAbsolutePath );
/*
* validate path by opening with GDAL and looking for an error
* Disable CPL error handler to supress error reporting
*/
CPLErrorReset();
CPLPushErrorHandler( CPLQuietErrorHandler );
hDataset = GDALOpen( pszAbsolutePath, GA_ReadOnly );
CPLPopErrorHandler();
if ( hDataset )
{
rgba_buffer = gdal_to_rgba( hDataset );
if ( rgba_buffer )
{
gv_symbol_manager_inject_raster_symbol(
manager, symbol_name,
GDALGetRasterXSize( hDataset ),
GDALGetRasterYSize( hDataset ),
rgba_buffer );
CPLFree( rgba_buffer );
}
GDALClose( hDataset );
}
//.........这里部分代码省略.........
开发者ID:Onjrew,项目名称:OpenEV,代码行数:101,代码来源:gvsymbolmanager.c
示例20: DumpBand
static void DumpBand( GDALDatasetH hBaseDS, GDALRasterBandH hSrcOver,
const char *pszName )
{
/* -------------------------------------------------------------------- */
/* Get base ds info. */
/* -------------------------------------------------------------------- */
double adfGeoTransform[6];
bool bHaveGT = GDALGetGeoTransform( hBaseDS, adfGeoTransform ) == CE_None;
int nOrigXSize = GDALGetRasterXSize( hBaseDS );
int nOrigYSize = GDALGetRasterYSize( hBaseDS );
/* -------------------------------------------------------------------- */
/* Create matching output file. */
/* -------------------------------------------------------------------- */
int nXSize = GDALGetRasterBandXSize( hSrcOver );
int nYSize = GDALGetRasterBandYSize( hSrcOver );
GDALDataType eDT = GDALGetRasterDataType( hSrcOver );
GDALDriverH hDriver = GDALGetDriverByName( "GTiff" );
GDALDatasetH hDstDS = GDALCreate( hDriver, pszName, nXSize, nYSize,
1, eDT, NULL );
if( hDstDS == NULL )
exit( 1 );
/* -------------------------------------------------------------------- */
/* Apply corresponding georeferencing, scaled to size. */
/* -------------------------------------------------------------------- */
if( bHaveGT )
{
double adfOvGeoTransform[6];
memcpy( adfOvGeoTransform, adfGeoTransform,
sizeof(double) * 6 );
adfOvGeoTransform[1] *= (nOrigXSize / (double) nXSize);
adfOvGeoTransform[2] *= (nOrigXSize / (double) nXSize);
adfOvGeoTransform[4] *= (nOrigYSize / (double) nYSize);
adfOvGeoTransform[5] *= (nOrigYSize / (double) nYSize);
GDALSetGeoTransform( hDstDS, adfOvGeoTransform );
GDALSetProjection( hDstDS, GDALGetProjectionRef( hBaseDS ) );
}
/* -------------------------------------------------------------------- */
/* Copy over all the image data. */
/* -------------------------------------------------------------------- */
void *pData = CPLMalloc(64 * nXSize);
for( int iLine = 0; iLine < nYSize; iLine++ )
{
GDALRasterIO( hSrcOver, GF_Read, 0, iLine, nXSize, 1,
pData, nXSize, 1, eDT, 0, 0 );
GDALRasterIO( GDALGetRasterBand( hDstDS, 1 ), GF_Write,
0, iLine, nXSize, 1,
pData, nXSize, 1, eDT, 0, 0 );
}
CPLFree( pData );
GDALClose( hDstDS );
}
开发者ID:StephenHolzman,项目名称:UVAmisc,代码行数:64,代码来源:dumpoverviews.cpp
注:本文中的GDALGetRasterXSize函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论