GDAL

- Main Page
- Related Pages
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
GDALPamDataset Class Reference

A subclass of GDALDataset which introduces the ability to save and restore auxiliary information (coordinate system, gcps, metadata, etc) not supported by a file format via an "auxiliary metadata" file with the .aux.xml extension. More...

`#include "gdal_pam.h"`

Inheritance diagram for GDALPamDataset:

## Public Member Functions
virtual void | FlushCache (void)
| Flush all write cached data to disk. More...
virtual const char * | GetProjectionRef (void)
| Fetch the projection definition string for this dataset. More...
virtual CPLErr | SetProjection (const char *)
| Set the projection reference string for this dataset. More...
virtual CPLErr | GetGeoTransform (double *)
| Fetch the affine transformation coefficients. More...
virtual CPLErr | SetGeoTransform (double *)
| Set the affine transformation coefficients. More...
virtual int | GetGCPCount ()
| Get number of GCPs. More...
virtual const char * | GetGCPProjection ()
| Get output projection for GCPs. More...
virtual const GDAL_GCP * | GetGCPs ()
| Fetch GCPs. More...
virtual CPLErr | SetGCPs (int nGCPCount, const GDAL_GCP *pasGCPList, const char *pszGCPProjection)
| Assign GCPs. More...
virtual CPLErr | SetMetadata (char **papszMetadata, const char *pszDomain="")
| Set metadata. More...
virtual CPLErr | SetMetadataItem (const char *pszName, const char *pszValue, const char *pszDomain="")
| Set single metadata item. More...
virtual char ** | GetMetadata (const char *pszDomain="")
| Fetch metadata. More...
virtual const char * | GetMetadataItem (const char *pszName, const char *pszDomain="")
| Fetch single metadata item. More...
virtual char ** | GetFileList (void)
| Fetch files forming dataset. More...
virtual CPLErr | CloneInfo (GDALDataset *poSrcDS, int nCloneInfoFlags)
virtual CPLErr | IBuildOverviews (const char *pszResampling, int nOverviews, int *panOverviewList, int nListBands, int *panBandList, GDALProgressFunc pfnProgress, void *pProgressData)
void | MarkPamDirty ()
GDALDatasetPamInfo * | GetPamInfo ()
int | GetPamFlags ()
void | SetPamFlags (int nValue)
Public Member Functions inherited from GDALDataset
virtual | ~GDALDataset ()
| Destroy an open GDALDataset. More...
int | GetRasterXSize (void)
| Fetch raster width in pixels. More...
int | GetRasterYSize (void)
| Fetch raster height in pixels. More...
int | GetRasterCount (void)
| Fetch the number of raster bands on this dataset. More...
GDALRasterBand * | GetRasterBand (int)
| Fetch a band object for a dataset. More...
virtual CPLErr | AddBand (GDALDataType eType, char **papszOptions=NULL)
| Add a band to a dataset. More...
virtual void * | GetInternalHandle (const char *)
| Fetch a format specific internally meaningful handle. More...
virtual GDALDriver * | GetDriver (void)
| Fetch the driver to which this dataset relates. More...
virtual const char * | GetDriverName ()
virtual CPLErr | AdviseRead (int nXOff, int nYOff, int nXSize, int nYSize, int nBufXSize, int nBufYSize, GDALDataType eDT, int nBandCount, int *panBandList, char **papszOptions)
| Advise driver of upcoming read requests. More...
virtual CPLErr | CreateMaskBand (int nFlagsIn)
| Adds a mask band to the dataset. More...
virtual GDALAsyncReader * | BeginAsyncReader (int nXOff, int nYOff, int nXSize, int nYSize, void *pBuf, int nBufXSize, int nBufYSize, GDALDataType eBufType, int nBandCount, int *panBandMap, int nPixelSpace, int nLineSpace, int nBandSpace, char **papszOptions)
| Sets up an asynchronous data request. More...
virtual void | EndAsyncReader (GDALAsyncReader *)
| End asynchronous request. More...
CPLErr | RasterIO (GDALRWFlag, int, int, int, int, void *, int, int, GDALDataType, int, int *, GSpacing, GSpacing, GSpacing, GDALRasterIOExtraArg *psExtraArg) CPL_WARN_UNUSED_RESULT
| Read/write a region of image data from multiple bands. More...
int | Reference ()
| Add one to dataset reference count. More...
int | Dereference ()
| Subtract one from dataset reference count. More...
GDALAccess | GetAccess () const
int | GetShared ()
| Returns shared flag. More...
void | MarkAsShared ()
| Mark this dataset as available for sharing.
void | MarkSuppressOnClose ()
char ** | GetOpenOptions ()
CPLErr | BuildOverviews (const char *, int, int *, int, int *, GDALProgressFunc, void *)
| Build raster overview(s) More...
void | ReportError (CPLErr eErrClass, CPLErrorNum err_no, const char *fmt,...) CPL_PRINT_FUNC_FORMAT(4
| Emits an error related to a dataset. More...
virtual int | GetLayerCount ()
| Get the number of layers in this dataset. More...
virtual OGRLayer * | GetLayer (int)
| Fetch a layer by index. More...
virtual OGRLayer * | GetLayerByName (const char *)
| Fetch a layer by name. More...
virtual OGRErr | DeleteLayer (int)
| Delete the indicated layer from the datasource. More...
virtual int | TestCapability (const char *)
| Test if capability is available. More...
virtual OGRLayer * | CreateLayer (const char *pszName, OGRSpatialReference *poSpatialRef=NULL, OGRwkbGeometryType eGType=wkbUnknown, char **papszOptions=NULL)
| This method attempts to create a new layer on the dataset with the indicated name, coordinate system, geometry type. More...
virtual OGRLayer * | CopyLayer (OGRLayer *poSrcLayer, const char *pszNewName, char **papszOptions=NULL)
| Duplicate an existing layer. More...
virtual OGRStyleTable * | GetStyleTable ()
| Returns dataset style table. More...
virtual void | SetStyleTableDirectly (OGRStyleTable *poStyleTable)
| Set dataset style table. More...
virtual void | SetStyleTable (OGRStyleTable *poStyleTable)
| Set dataset style table. More...
virtual OGRLayer * | ExecuteSQL (const char *pszStatement, OGRGeometry *poSpatialFilter, const char *pszDialect)
| Execute an SQL statement against the data store. More...
virtual void | ReleaseResultSet (OGRLayer *poResultsSet)
| Release results of ExecuteSQL(). More...
int | GetRefCount () const
| Fetch reference count. More...
int | GetSummaryRefCount () const
| Fetch reference count of datasource and all owned layers. More...
OGRErr | Release ()
| Drop a reference to this dataset, and if the reference count drops to one close (destroy) the dataset. More...
virtual OGRErr | StartTransaction (int bForce=FALSE)
| For datasources which support transactions, StartTransaction creates a `transaction. More...
virtual OGRErr | CommitTransaction ()
| For datasources which support transactions, CommitTransaction commits a transaction. More...
virtual OGRErr | RollbackTransaction ()
| For datasources which support transactions, RollbackTransaction will roll back a datasource to its state before the start of the current transaction. More...
GDALSQLParseInfo * | BuildParseInfo (swq_select *psSelectInfo, swq_select_parse_options *poSelectParseOptions)
void | DestroyParseInfo (GDALSQLParseInfo *psParseInfo)
OGRLayer * | ExecuteSQL (const char *pszStatement, OGRGeometry *poSpatialFilter, const char *pszDialect, swq_select_parse_options *poSelectParseOptions)
Public Member Functions inherited from GDALMajorObject
int | GetMOFlags ()
void | SetMOFlags (int nFlagsIn)
virtual const char * | GetDescription () const
| Fetch object description. More...
virtual void | SetDescription (const char *)
| Set object description. More...
virtual char ** | GetMetadataDomainList ()
| Fetch list of metadata domains. More...

## Protected Member Functions
virtual CPLXMLNode * | SerializeToXML (const char *)
virtual CPLErr | XMLInit (CPLXMLNode *, const char *)
virtual CPLErr | TryLoadXML (char **papszSiblingFiles=NULL)
virtual CPLErr | TrySaveXML ()
CPLErr | TryLoadAux (char **papszSiblingFiles=NULL)
CPLErr | TrySaveAux ()
virtual const char * | BuildPamFilename ()
void | PamInitialize ()
void | PamClear ()
void | SetPhysicalFilename (const char *)
const char * | GetPhysicalFilename ()
void | SetSubdatasetName (const char *)
const char * | GetSubdatasetName ()
Protected Member Functions inherited from GDALDataset
| GDALDataset (int bForceCachedIO)
void | RasterInitialize (int, int)
void | SetBand (int, GDALRasterBand *)
virtual CPLErr | IRasterIO (GDALRWFlag, int, int, int, int, void *, int, int, GDALDataType, int, int *, GSpacing, GSpacing, GSpacing, GDALRasterIOExtraArg *psExtraArg) CPL_WARN_UNUSED_RESULT
CPLErr | BlockBasedRasterIO (GDALRWFlag, int, int, int, int, void *, int, int, GDALDataType, int, int *, GSpacing, GSpacing, GSpacing, GDALRasterIOExtraArg *psExtraArg) CPL_WARN_UNUSED_RESULT
void | BlockBasedFlushCache ()
CPLErr | BandBasedRasterIO (GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize, int nYSize, void *pData, int nBufXSize, int nBufYSize, GDALDataType eBufType, int nBandCount, int *panBandMap, GSpacing nPixelSpace, GSpacing nLineSpace, GSpacing nBandSpace, GDALRasterIOExtraArg *psExtraArg) CPL_WARN_UNUSED_RESULT
CPLErr | RasterIOResampled (GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize, int nYSize, void *pData, int nBufXSize, int nBufYSize, GDALDataType eBufType, int nBandCount, int *panBandMap, GSpacing nPixelSpace, GSpacing nLineSpace, GSpacing nBandSpace, GDALRasterIOExtraArg *psExtraArg) CPL_WARN_UNUSED_RESULT
CPLErr | ValidateRasterIOOrAdviseReadParameters (const char *pszCallingFunc, int *pbStopProcessingOnCENone, int nXOff, int nYOff, int nXSize, int nYSize, int nBufXSize, int nBufYSize, int nBandCount, int *panBandMap)
CPLErr | TryOverviewRasterIO (GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize, int nYSize, void *pData, int nBufXSize, int nBufYSize, GDALDataType eBufType, int nBandCount, int *panBandMap, GSpacing nPixelSpace, GSpacing nLineSpace, GSpacing nBandSpace, GDALRasterIOExtraArg *psExtraArg, int *pbTried)
virtual int | CloseDependentDatasets ()
| Drop references to any other datasets referenced by this dataset. More...
int | ValidateLayerCreationOptions (const char *const *papszLCO)
int | EnterReadWrite (GDALRWFlag eRWFlag)
void | LeaveReadWrite ()
void | TemporarilyDropReadWriteLock ()
void | ReacquireReadWriteLock ()
void | DisableReadWriteMutex ()
int | AcquireMutex ()
void | ReleaseMutex ()
virtual OGRLayer * | ICreateLayer (const char *pszName, OGRSpatialReference *poSpatialRef=NULL, OGRwkbGeometryType eGType=wkbUnknown, char **papszOptions=NULL)
| This method attempts to create a new layer on the dataset with the indicated name, coordinate system, geometry type. More...
OGRErr | ProcessSQLCreateIndex (const char *)
OGRErr | ProcessSQLDropIndex (const char *)
OGRErr | ProcessSQLDropTable (const char *)
OGRErr | ProcessSQLAlterTableAddColumn (const char *)
OGRErr | ProcessSQLAlterTableDropColumn (const char *)
OGRErr | ProcessSQLAlterTableAlterColumn (const char *)
OGRErr | ProcessSQLAlterTableRenameColumn (const char *)
Protected Member Functions inherited from GDALMajorObject
char ** | BuildMetadataDomainList (char **papszList, int bCheckNonEmpty,...) CPL_NULL_TERMINATED
| Helper function for custom implementations of GetMetadataDomainList() More...

## Protected Attributes
int | nPamFlags
GDALDatasetPamInfo * | psPam
Protected Attributes inherited from GDALDataset
GDALDriver * | poDriver
GDALAccess | eAccess
int | nRasterXSize
int | nRasterYSize
int | nBands
GDALRasterBand ** | papoBands
int | nOpenFlags
int | nRefCount
GByte | bForceCachedIO
GByte | bShared
GByte | bIsInternal
GByte | bSuppressOnClose
GDALDefaultOverviews | oOvManager
char ** | papszOpenOptions
OGRStyleTable * | m_poStyleTable
Protected Attributes inherited from GDALMajorObject
int | nFlags
CPLString | sDescription
GDALMultiDomainMetadata | oMDMD

## Friends
class | GDALPamRasterBand

## Additional Inherited Members
Static Public Member Functions inherited from GDALDataset
static GDALDataset ** | GetOpenDatasets (int *pnDatasetCount)
| Fetch all open GDAL dataset handles. More...
static int | IsGenericSQLDialect (const char *pszDialect)

## Detailed Description

A subclass of GDALDataset which introduces the ability to save and restore auxiliary information (coordinate system, gcps, metadata, etc) not supported by a file format via an "auxiliary metadata" file with the .aux.xml extension.

### Enabling PAM

PAM support can be enabled (resp. disabled) in GDAL by setting the GDAL_PAM_ENABLED configuration option (via CPLSetConfigOption(), or the environment) to the value of YES (resp. NO). Note: The default value is build dependent and defaults to YES in Windows and Unix builds.

### PAM Proxy Files

In order to be able to record auxiliary information about files on read-only media such as CDROMs or in directories where the user does not have write permissions, it is possible to enable the "PAM Proxy Database". When enabled the .aux.xml files are kept in a different directory, writable by the user. Overviews will also be stored in the PAM proxy directory.

To enable this, set the GDAL_PAM_PROXY_DIR configuration option to be the name of the directory where the proxies should be kept. The configuration option must be set before the first access to PAM, because its value is cached for later access.

### Adding PAM to Drivers

Drivers for physical file formats that wish to support persistent auxiliary metadata in addition to that for the format itself should derive their dataset class from GDALPamDataset instead of directly from GDALDataset. The raster band classes should also be derived from GDALPamRasterBand.

They should also call something like this near the end of the Open() method:

poDS->SetDescription( poOpenInfo->pszFilename );
poDS->TryLoadXML();

The SetDescription() is necessary so that the dataset will have a valid filename set as the description before TryLoadXML() is called. TryLoadXML() will look for an .aux.xml file with the same basename as the dataset and in the same directory. If found the contents will be loaded and kept track of in the GDALPamDataset and GDALPamRasterBand objects. When a call like GetProjectionRef() is not implemented by the format specific class, it will fall through to the PAM implementation which will return information if it was in the .aux.xml file.

Drivers should also try to call the GDALPamDataset/GDALPamRasterBand methods as a fallback if their implementation does not find information. This allows using the .aux.xml for variations that can't be stored in the format. For instance, the GeoTIFF driver GetProjectionRef() looks like this:

if( EQUAL(pszProjection,"") )
return GDALPamDataset::GetProjectionRef();
else
return( pszProjection );

So if the geotiff header is missing, the .aux.xml file will be consulted.

Similarly, if SetProjection() were called with a coordinate system not supported by GeoTIFF, the SetProjection() method should pass it on to the GDALPamDataset::SetProjection() method after issuing a warning that the information can't be represented within the file itself.

Drivers for subdataset based formats will also need to declare the name of the physical file they are related to, and the name of their subdataset before calling TryLoadXML().

poDS->SetDescription( poOpenInfo->pszFilename );
poDS->SetPhysicalFilename( poDS->pszFilename );
poDS->SetSubdatasetName( osSubdatasetName );
poDS->TryLoadXML();

## Member Function Documentation

void GDALPamDataset::FlushCache | ( | void |  | ) |
| virtual

Flush all write cached data to disk.

Any raster (or other GDAL) data written via GDAL calls, but buffered internally will be written to disk.

The default implementation of this method just calls the FlushCache() method on each of the raster bands and the SyncToDisk() method on each of the layers. Conceptionally, calling FlushCache() on a dataset should include any work that might be accomplished by calling SyncToDisk() on layers in that dataset.

Using this method does not prevent use from calling GDALClose() to properly close a dataset and ensure that important data not addressed by FlushCache() is written in the file.

This method is the same as the C function GDALFlushCache().

Reimplemented from GDALDataset.

char ** GDALPamDataset::GetFileList | ( | void |  | ) |
| virtual

Fetch files forming dataset.

Returns a list of files believed to be part of this dataset. If it returns an empty list of files it means there is believed to be no local file system files associated with the dataset (for instance a virtual dataset). The returned file list is owned by the caller and should be deallocated with CSLDestroy().

The returned filenames will normally be relative or absolute paths depending on the path used to originally open the dataset. The strings will be UTF-8 encoded.

This method is the same as the C GDALGetFileList() function.

Returns
  NULL or a NULL terminated array of file names.

Reimplemented from GDALDataset.

Reimplemented in GDALJP2AbstractDataset.

int GDALPamDataset::GetGCPCount | ( |  | ) |
| virtual

Get number of GCPs.

This method is the same as the C function GDALGetGCPCount().

Returns
  number of GCPs for this dataset. Zero if there are none.

Reimplemented from GDALDataset.

Reimplemented in GDALGeorefPamDataset.

const char * GDALPamDataset::GetGCPProjection | ( |  | ) |
| virtual

Get output projection for GCPs.

This method is the same as the C function GDALGetGCPProjection().

The projection string follows the normal rules from GetProjectionRef().

Returns
  internal projection string or "" if there are no GCPs. It should not be altered, freed or expected to last for long.

Reimplemented from GDALDataset.

Reimplemented in GDALGeorefPamDataset.

const GDAL_GCP * GDALPamDataset::GetGCPs | ( |  | ) |
| virtual

Fetch GCPs.

This method is the same as the C function GDALGetGCPs().

Returns
  pointer to internal GCP structure list. It should not be modified, and may change on the next GDAL call.

Reimplemented from GDALDataset.

Reimplemented in GDALGeorefPamDataset.

CPLErr GDALPamDataset::GetGeoTransform | ( | double * | padfTransform | ) |
| virtual

Fetch the affine transformation coefficients.

Fetches the coefficients for transforming between pixel/line (P,L) raster space, and projection coordinates (Xp,Yp) space.

Xp = padfTransform[0] + P*padfTransform[1] + L*padfTransform[2];
Yp = padfTransform[3] + P*padfTransform[4] + L*padfTransform[5];

In a north up image, padfTransform[1] is the pixel width, and padfTransform[5] is the pixel height. The upper left corner of the upper left pixel is at position (padfTransform[0],padfTransform[3]).

The default transform is (0,1,0,0,0,1) and should be returned even when a CE_Failure error is returned, such as for formats that don't support transformation to projection coordinates.

This method does the same thing as the C GDALGetGeoTransform() function.

Parameters

  padfTransform | an existing six double buffer into which the transformation will be placed.

Returns
  CE_None on success, or CE_Failure if no transform can be fetched.

Reimplemented from GDALDataset.

Reimplemented in GDALGeorefPamDataset.

char ** GDALPamDataset::GetMetadata | ( | const char * | pszDomain = `""` | ) |
| virtual

Fetch metadata.

The returned string list is owned by the object, and may change at any time. It is formatted as a "Name=value" list with the last pointer value being NULL. Use the CPL StringList functions such as CSLFetchNameValue() to manipulate it.

Note that relatively few formats return any metadata at this time.

This method does the same thing as the C function GDALGetMetadata().

Parameters

  pszDomain | the domain of interest. Use "" or NULL for the default domain.

Returns
  NULL or a string list.

Reimplemented from GDALMajorObject.

const char * GDALPamDataset::GetMetadataItem | ( | const char * | pszName,
|  | const char * | pszDomain = `""`
| ) |  |
| virtual

Fetch single metadata item.

The C function GDALGetMetadataItem() does the same thing as this method.

Parameters

  pszName | the key for the metadata item to fetch.
  pszDomain | the domain to fetch for, use NULL for the default domain.

Returns
  NULL on failure to find the key, or a pointer to an internal copy of the value string on success.

Reimplemented from GDALMajorObject.

const char * GDALPamDataset::GetProjectionRef | ( | void |  | ) |
| virtual

Fetch the projection definition string for this dataset.

Same as the C function GDALGetProjectionRef().

The returned string defines the projection coordinate system of the image in OpenGIS WKT format. It should be suitable for use with the OGRSpatialReference class.

When a projection definition is not available an empty (but not NULL) string is returned.

Returns
  a pointer to an internal projection reference string. It should not be altered, freed or expected to last for long.

See also
  http://www.gdal.org/osr_tutorial.html

Reimplemented from GDALDataset.

Reimplemented in GDALGeorefPamDataset.

CPLErr GDALPamDataset::SetGCPs | ( | int | nGCPCount,
|  | const GDAL_GCP * | pasGCPList,
|  | const char * | pszGCPProjection
| ) |  |
| virtual

Assign GCPs.

This method is the same as the C function GDALSetGCPs().

This method assigns the passed set of GCPs to this dataset, as well as setting their coordinate system. Internally copies are made of the coordinate system and list of points, so the caller remains responsible for deallocating these arguments if appropriate.

Most formats do not support setting of GCPs, even formats that can handle GCPs. These formats will return CE_Failure.

Parameters

  nGCPCount | number of GCPs being assigned.
  pasGCPList | array of GCP structures being assign (nGCPCount in array).
  pszGCPProjection | the new OGC WKT coordinate system to assign for the GCP output coordinates. This parameter should be "" if no output coordinate system is known.

Returns
  CE_None on success, CE_Failure on failure (including if action is not supported for this format).

Reimplemented from GDALDataset.

CPLErr GDALPamDataset::SetGeoTransform | ( | double * | padfTransform | ) |
| virtual

Set the affine transformation coefficients.

See GetGeoTransform() for details on the meaning of the padfTransform coefficients.

This method does the same thing as the C GDALSetGeoTransform() function.

Parameters

  padfTransform | a six double buffer containing the transformation coefficients to be written with the dataset.

Returns
  CE_None on success, or CE_Failure if this transform cannot be written.

Reimplemented from GDALDataset.

CPLErr GDALPamDataset::SetMetadata | ( | char ** | papszMetadataIn,
|  | const char * | pszDomain = `""`
| ) |  |
| virtual

Set metadata.

The C function GDALSetMetadata() does the same thing as this method.

Parameters

  papszMetadataIn | the metadata in name=value string list format to apply.
  pszDomain | the domain of interest. Use "" or NULL for the default domain.

Returns
  CE_None on success, CE_Failure on failure and CE_Warning if the metadata has been accepted, but is likely not maintained persistently by the underlying object between sessions.

Reimplemented from GDALMajorObject.

CPLErr GDALPamDataset::SetMetadataItem | ( | const char * | pszName,
|  | const char * | pszValue,
|  | const char * | pszDomain = `""`
| ) |  |
| virtual

Set single metadata item.

The C function GDALSetMetadataItem() does the same thing as this method.

Parameters

  pszName | the key for the metadata item to fetch.
  pszValue | the value to assign to the key.
  pszDomain | the domain to set within, use NULL for the default domain.

Returns
  CE_None on success, or an error code on failure.

Reimplemented from GDALMajorObject.

CPLErr GDALPamDataset::SetProjection | ( | const char * | pszProjection | ) |
| virtual

Set the projection reference string for this dataset.

The string should be in OGC WKT or PROJ.4 format. An error may occur because of incorrectly specified projection strings, because the dataset is not writable, or because the dataset does not support the indicated projection. Many formats do not support writing projections.

This method is the same as the C GDALSetProjection() function.

Parameters

  pszProjection | projection reference string.

Returns
  CE_Failure if an error occurs, otherwise CE_None.

Reimplemented from GDALDataset.

The documentation for this class was generated from the following files:

- gdal_pam.h
- gdalpamdataset.cpp

Generated for GDAL by 1.8.8.