Commit 2c5d9613 authored by Christophe Palmann's avatar Christophe Palmann

ENH gdal-config (formats)

parent 7efdae33
#include <iostream>
#include <fstream>
#include <stdexcept>
#include <gdal.h>
#include <gdal_priv.h>
//http://www.gdal.org/formats_list.html
using namespace std;
int main(int argc, char * argv[])
{
cout << " argc = " << argc << endl;
string driverName(argv[1]);
GDALAllRegister();
GDALDriverH drv = NULL;
unsigned int count = GDALGetDriverCount();
// Remember gdal formats
if (argc == 3) // ie. ./exe driverName fileName
{
const char * inputFilename = argv[2];
ofstream file(inputFilename, ios::out | ios::trunc);
if(file)
{
file << "###############################" << std::endl;
file << "# ID / Short name / Long name #" << std::endl;
file << "###############################" << std::endl;
file << std::endl;
file << "# Nb of drivers : " << count << std::endl;
file << std::endl;
for (unsigned int i = 0; i < count; i++)
{
drv = GDALGetDriver(i);
file << "i = " << i << " / " << GDALGetDriverShortName(drv) << " / " << GDALGetDriverLongName(drv) << std::endl;
}
file.close();
}
}
//std::cout << GDALGetDriverShortName(GDALGetDriverByName("GTiff")) << std::endl;
//Driver check
for (unsigned int i = 0; i < count; i++)
{
drv = GDALGetDriver(i);
if (string(GDALGetDriverShortName(drv)).compare(driverName) == 0 )
return 1; // SUCCESS
}
return 0; // FAIL
}
......@@ -20,6 +20,3 @@ fi
#TEST 3 : Big tiff
${gdalTranslate} -co "BIGTIFF=YES" ${tempFolder}/testImage.gtif ${tempFolder}/testImageBIG.tif > ${tempFolder}/testgdal3.txt
#TEST 4 : GDAL formats
${gdalConfig} --formats > ${tempFolder}/testgdal4.txt
#include <fstream>
#include <iostream>
#include <sstream>
#include <cstdlib>
using namespace std;
//----------------- FORMAT -------------------------
int main(int argc, char * argv[])
{
const char * inputFilename = argv[1];
string format(argv[2]);
ifstream file(inputFilename, ios::in);
if(file)
{
string line;
while(getline(file, line))
if (line.find(format) != string::npos)
return 1; //SUCCESS
file.close();
}
/*else
{
cout << "WARNING : Can't open file " << inputFilename << endl;
return 2;
}*/
return 0; //FAIL
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment