Commit 0d80c670 authored by Christophe Palmann's avatar Christophe Palmann

ENH: gdal config test (removed images in src dir, made some tests available for windows)

parent 8e40b0af
#include <iostream>
#include <stdexcept>
#include <gdal.h>
#include <gdal_priv.h>
int main(int argc, char * argv[])
{
const char *pszFormat = argv[1];
GDALDriver *poDriver,*poDriver2;
char **papszMetadata;
GDALAllRegister();
GDALDriverH drv = NULL;
unsigned int count = GDALGetDriverCount();
std::cout << "Nb of drivers : " << count << std::endl;
for (unsigned int i = 0; i < count; i++)
{
drv = GDALGetDriver(i);
std::cout << "i = " << i << " " << GDALGetDriverShortName(drv) << std::endl;
}
std::cout << GDALGetDriverShortName(GDALGetDriverByName("GTiff")) << std::endl;
std::cout << GDALVersionInfo("RELEASE_NAME") << std::endl;
// ------------------- step 1 -------------------
GDALDataset *poSrcDS =
(GDALDataset *) GDALOpen( argv[1], GA_ReadOnly );
GDALDataset *poDstDS;
//poDriver2 = (GDALDriver *) GDALGetDriver(19);
poDriver2 = (GDALDriver *) GDALGetDriverByName(argv[3]);
poDstDS = poDriver2->CreateCopy( argv[2], poSrcDS, FALSE, NULL, NULL, NULL );
// ------------------- step 2 -------------------
if( poDstDS != NULL )
GDALClose( (GDALDatasetH) poDstDS );
return 1; // SUCCESS
}
#include <iostream>
#include <stdexcept>
#include <gdal.h>
#include <gdal_priv.h>
#include <ogr_spatialref.h>
int main(int argc, char * argv[])
{
const char *pszFormat = argv[1];
GDALDriver *poDriver;
char **papszMetadata;
GDALAllRegister();
// ------------------- step 1 -------------------
poDriver = GetGDALDriverManager()->GetDriverByName(pszFormat);
if( poDriver == NULL )
{
std::cout << "poDriver NULL" << std::endl;
return 0; //FAIL
}
papszMetadata = poDriver->GetMetadata();
if( CSLFetchBoolean( papszMetadata, GDAL_DCAP_CREATE, FALSE ) )
printf( "Driver %s supports Create() method.\n", pszFormat );
if( CSLFetchBoolean( papszMetadata, GDAL_DCAP_CREATECOPY, FALSE ) )
printf( "Driver %s supports CreateCopy() method.\n", pszFormat );
// ------------------- step 2 -------------------
GDALDataset *poDstDS;
char **papszOptions = NULL;
poDstDS = poDriver->Create( argv[2], 512, 512, 1, GDT_Byte,
papszOptions );
// ------------------- step 3 -------------------
double adfGeoTransform[6] = { 444720, 30, 0, 3751320, 0, -30 };
OGRSpatialReference oSRS;
char *pszSRS_WKT = NULL;
GDALRasterBand *poBand;
GByte abyRaster[512*512];
poDstDS->SetGeoTransform( adfGeoTransform );
oSRS.SetUTM( 11, TRUE );
oSRS.SetWellKnownGeogCS( "NAD27" );
oSRS.exportToWkt( &pszSRS_WKT );
poDstDS->SetProjection( pszSRS_WKT );
CPLFree( pszSRS_WKT );
poBand = poDstDS->GetRasterBand(1);
poBand->RasterIO( GF_Write, 0, 0, 512, 512,
abyRaster, 512, 512, GDT_Byte, 0, 0 );
// ------------------- step 4 -------------------
GDALClose( (GDALDatasetH) poDstDS );
return 1; // SUCCESS
}
#include <iostream>
#include <stdexcept>
#include <gdal.h>
int main(int argc, char * argv[])
{
if (argc != 2)
{
std::cerr << "Usage : " << argv[0] << "filename" << std::endl;
return 0;//FAIL
}
GDALAllRegister();
GDALOpen(argv[1], GA_ReadOnly );
return 1;//SUCCESS
}
......@@ -9,8 +9,6 @@ gdalTranslate=`dirname ${gdalConfig}`/gdal_translate
mkdir -p ${tempFolder}
#TEST 1 : GDAL version
${gdalConfig} --version > ${tempFolder}/testgdal1.txt
#TEST 2 : dyn. symbols
if [ -z "${apple}" ]
......@@ -21,7 +19,7 @@ nm -U ${gdalLibLocation} | grep TIFFClose > ${tempFolder}/testgdal2.txt # -U : d
fi
#TEST 3 : Big tiff
${gdalTranslate} -co "BIGTIFF=YES" ${sourceDir}/Modules/ThirdParty/GDAL/logoVectoriel.png ${tempFolder}/logoVectoriel.tif > ${tempFolder}/testgdal3.txt
${gdalTranslate} -co "BIGTIFF=YES" ${tempFolder}/testImage.gtif ${tempFolder}/testImageBIG.tif > ${tempFolder}/testgdal3.txt
#TEST 4 : GDAL formats
${gdalConfig} --formats > ${tempFolder}/testgdal4.txt
......@@ -28,7 +28,7 @@ int main(int argc, char * argv[])
}
}
file.close();
}
/*else
{
......
......@@ -27,6 +27,8 @@ int main(int argc, char * argv[])
cout << "WARNING : No BIGTIFF capatilities" << endl;
return 1;
}
file.close();
}
/*else
......
......@@ -20,6 +20,8 @@ int main(int argc, char * argv[])
while(getline(file, line))
if (line.find(format) != string::npos)
return 1; //SUCCESS
file.close();
}
/*else
......
......@@ -2,62 +2,63 @@
#include <iostream>
#include <sstream>
#include <cstdlib>
#include <string>
#include <vector>
#include <gdal.h>
using namespace std;
//----------------- gdal >= 1.10 -------------------------
//----------------- FORMAT -------------------------
int main(int argc, char * argv[])
{
const char * inputFilename = argv[1];
string version(GDALVersionInfo("RELEASE_NAME"));
ifstream file(inputFilename, ios::in);
// Remember gdal version
const char * inputFilename = argv[1];
ofstream file(inputFilename, ios::out | ios::trunc);
if(file)
{
string line;
vector<unsigned int> UIntVect;
getline(file, line);
//Parsing
istringstream iss(line);
unsigned int pos=0;
string sub;
unsigned int someUIntVal;
while ( std::getline( iss, sub, '.' ) )
{
istringstream convert(sub);
convert >> someUIntVal;
//cout << someUIntVal << '\n';
if (pos==0) //Major
UIntVect.push_back(someUIntVal);
if (pos==1) //Minor
UIntVect.push_back(someUIntVal);
pos++;
}
file << version;
file.close();
if ( (UIntVect[0]<1) || (UIntVect[1]<10) )
{
cout << "WARNING : Version of GDAL must be >= 1.10 (" << UIntVect[0] << "." << UIntVect[1] << " detected)." << endl;
return 1;
}
}
}
/*else
{
cout << "WARNING : Can't open file " << inputFilename << endl;
return 2;
}*/
//Version check
istringstream iss(version);
unsigned int pos=0;
string sub;
unsigned int someUIntVal;
vector<unsigned int> UIntVect;
while ( std::getline( iss, sub, '.' ) )
{
istringstream convert(sub);
convert >> someUIntVal;
//cout << someUIntVal << '\n';
if (pos==0) //Major
UIntVect.push_back(someUIntVal);
if (pos==1) //Minor
UIntVect.push_back(someUIntVal);
pos++;
}
if ( (UIntVect[0]<1) || (UIntVect[1]<10) )
{
cout << "WARNING : Version of GDAL must be >= 1.10 (" << UIntVect[0] << "." << UIntVect[1] << " detected)." << endl;
return 1;
}
return EXIT_SUCCESS;
return EXIT_SUCCESS;
}
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