Quantcast

Looking for a "surefire" way to get valid output formats.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Looking for a "surefire" way to get valid output formats.

Vlad
Basically trying to keep users from selecting an invalid -of parameter in translate and warp.

Looking at gdalinfo --formats I see this for PNG..

 PNG -raster- (rwv): Portable Network Graphics

and gdalinfo --format png, I get...

 Supports: Open() - Open existing dataset.
 Supports: CreateCopy() - Create dataset by copying another.
 Supports: Virtual IO - eg. /vsimem/

HOWEVER, the key/value pairs in the PNG driver metadata map give me...
"DCAP_CREATECOPY"=YES

and no "DCAP_CREATE".

For a BMP I get a "DCAP_CREATE" = YES, and there is no "DCAP_CREATECOPY", however I know translate will work with -of png or -of bmp.

What should I be looking at to see if a driver short name is a supported output type?

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Looking for a "surefire" way to get valid output formats.

Even Rouault-2

On mardi 16 mai 2017 11:39:03 CEST Vlad wrote:

> Basically trying to keep users from selecting an invalid -of parameter in

> translate and warp.

>

> Looking at gdalinfo --formats I see this for PNG..

>

> PNG -raster- (rwv): Portable Network Graphics

>

> and gdalinfo --format png, I get...

>

> Supports: Open() - Open existing dataset.

> Supports: CreateCopy() - Create dataset by copying another.

> Supports: Virtual IO - eg. /vsimem/

>

> HOWEVER, the key/value pairs in the PNG driver metadata map give me...

> "DCAP_CREATECOPY"=YES

>

> and no "DCAP_CREATE".

>

> For a BMP I get a "DCAP_CREATE" = YES, and there is no "DCAP_CREATECOPY",

> however I know translate will work with -of png or -of bmp.

>

> What should I be looking at to see if a driver short name is a supported

> output type?

 

I've just improved the doc regarding those aspects.

 

Extract:

 

 

/** Capability set by a driver that implements the Create() API.

*

* If GDAL_DCAP_CREATE is set, but GDAL_DCAP_CREATECOPY not, a generic

* CreateCopy() implementation is available and will use the Create() API of

* the driver.

* So to test if some CreateCopy() implementation is available, generic or

* specialize, test for both GDAL_DCAP_CREATE and GDAL_DCAP_CREATECOPY.

*/

#define GDAL_DCAP_CREATE "DCAP_CREATE"

 

/** Capability set by a driver that implements the CreateCopy() API.

*

* If GDAL_DCAP_CREATECOPY is not defined, but GDAL_DCAP_CREATE is set, a generic

* CreateCopy() implementation is available and will use the Create() API of

* the driver.

* So to test if some CreateCopy() implementation is available, generic or

* specialize, test for both GDAL_DCAP_CREATE and GDAL_DCAP_CREATECOPY.

*/

#define GDAL_DCAP_CREATECOPY "DCAP_CREATECOPY"

 

 

/**

* \brief Create a copy of a dataset.

*

* This method will attempt to create a copy of a raster dataset with the

* indicated filename, and in this drivers format. Band number, size,

* type, projection, geotransform and so forth are all to be copied from

* the provided template dataset.

*

* Note that many sequential write once formats (such as JPEG and PNG) don't

* implement the Create() method but do implement this CreateCopy() method.

* If the driver doesn't implement CreateCopy(), but does implement Create()

* then the default CreateCopy() mechanism built on calling Create() will

* be used.

* So to test if CreateCopy() is available, you can test if GDAL_DCAP_CREATECOPY

* or GDAL_DCAP_CREATE is set in the GDAL metadata.

*

* It is intended that CreateCopy() will often be used with a source dataset

* which is a virtual dataset allowing configuration of band types, and other

* information without actually duplicating raster data (see the VRT driver).

* This is what is done by the gdal_translate utility for example.

*

* That function will try to validate the creation option list passed to the

* driver with the GDALValidateCreationOptions() method. This check can be

* disabled by defining the configuration option

* GDAL_VALIDATE_CREATION_OPTIONS=NO.

*

* After you have finished working with the returned dataset, it is

* <b>required</b> to close it with GDALClose(). This does not only close the

* file handle, but also ensures that all the data and metadata has been written

* to the dataset (GDALFlushCache() is not sufficient for that purpose).

*

* In some situations, the new dataset can be created in another process through

* the \ref gdal_api_proxy mechanism.

*

* @param pszFilename the name for the new dataset. UTF-8 encoded.

* @param poSrcDS the dataset being duplicated.

* @param bStrict TRUE if the copy must be strictly equivalent, or more

* normally FALSE indicating that the copy may adapt as needed for the

* output format.

* @param papszOptions additional format dependent options controlling

* creation of the output file. The APPEND_SUBDATASET=YES option can be

* specified to avoid prior destruction of existing dataset.

* @param pfnProgress a function to be used to report progress of the copy.

* @param pProgressData application data passed into progress function.

*

* @return a pointer to the newly created dataset (may be read-only access).

*/

 

GDALDataset *GDALDriver::CreateCopy( const char * pszFilename,

GDALDataset * poSrcDS,

int bStrict, char ** papszOptions,

GDALProgressFunc pfnProgress,

void * pProgressData );

 

--

Spatialys - Geospatial professional services

http://www.spatialys.com


_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Loading...