Commit e6741ca1 authored by Christophe Palmann's avatar Christophe Palmann

ENH: gdal-config (bigtiff)

parent 94807edb
......@@ -2,24 +2,24 @@
#include <stdexcept>
#include <gdal.h>
#include <gdal_priv.h>
#include "cpl_string.h"
int main(int argc, char * argv[])
{
{
const char *pszFormat = argv[1];
GDALDriver *poDriver,*poDriver2;
char **papszMetadata;
char **papszCreateOptions=NULL;
if(argc==5)
{
papszCreateOptions = CSLAddString( papszCreateOptions, argv[4] );
std::cout << "argv[4] = " << argv[4] << std::endl;
}
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;
......@@ -31,7 +31,7 @@ int main(int argc, char * argv[])
//poDriver2 = (GDALDriver *) GDALGetDriver(19);
poDriver2 = (GDALDriver *) GDALGetDriverByName(argv[3]);
poDstDS = poDriver2->CreateCopy( argv[2], poSrcDS, FALSE, NULL, NULL, NULL );
poDstDS = poDriver2->CreateCopy( argv[2], poSrcDS, FALSE, papszCreateOptions, NULL, NULL );
// ------------------- step 2 -------------------
if( poDstDS != NULL )
......@@ -40,3 +40,5 @@ int main(int argc, char * argv[])
return 1; // SUCCESS
}
//GDALDataset * CreateCopy (const char *, GDALDataset *, int, char **, GDALProgressFunc pfnProgress, void *pProgressData) CPL_WARN_UNUSED_RESULT
//GDALCreateCopy (GDALDriverH, const char *, GDALDatasetH, int, char **, GDALProgressFunc, void *)
......@@ -2,10 +2,8 @@
tempFolder=@TEMP@
gdalLibLocation=@GDAL_LIBRARY@
sourceDir=@CMAKE_SOURCE_DIR@
apple=@APPLE@
gdalConfig=@GDAL_CONFIG@
gdalTranslate=`dirname ${gdalConfig}`/gdal_translate
mkdir -p ${tempFolder}
......@@ -17,6 +15,3 @@ nm -D --defined-only ${gdalLibLocation} | grep TIFFClose > ${tempFolder}/testgda
else
nm -U ${gdalLibLocation} | grep TIFFClose > ${tempFolder}/testgdal2.txt # -U : don't display undefined syms (same as --defined-only)
fi
#TEST 3 : Big tiff
${gdalTranslate} -co "BIGTIFF=YES" ${tempFolder}/testImage.gtif ${tempFolder}/testImageBIG.tif > ${tempFolder}/testgdal3.txt
#include <fstream>
#include <iostream>
#include <sstream>
#include <cstdlib>
using namespace std;
//----------------- BIGTIFF -------------------------
int main(int argc, char * argv[])
{
const char * inputFilename = argv[1];
string patternDone("done");
ifstream file(inputFilename, ios::in);
if(file)
{
string line;
bool bigtiff=false;
while(getline(file, line))
if (line.find(patternDone) != string::npos)
bigtiff=true;
if (!bigtiff)
{
cout << "WARNING : No BIGTIFF capatilities" << endl;
return 1;
}
file.close();
}
/*else
{
cout << "WARNING : Can't open file " << inputFilename << endl;
return 2;
}*/
return EXIT_SUCCESS;
}
......@@ -40,11 +40,18 @@ try_run(GDAL_HAS_GTIF COMPILE_RESULT_FORMATS ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE
# Can create geotiff file
try_run(GDAL_CAN_CREATE_GEOTIFF COMPILE_RESULT_CREATE ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/Modules/ThirdParty/GDAL/gdalCreateTest.cxx CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:PATH=${GDAL_INCLUDE_DIR}" "-DLINK_LIBRARIES:STRING=${GDAL_LIBRARY}" ARGS GTiff ${TEMP}/testImage.gtif )
if (GDAL_HAS_GTIF)
try_run(GDAL_CAN_CREATE_GEOTIFF COMPILE_RESULT_CREATE ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/Modules/ThirdParty/GDAL/gdalCreateTest.cxx CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:PATH=${GDAL_INCLUDE_DIR}" "-DLINK_LIBRARIES:STRING=${GDAL_LIBRARY}" ARGS GTiff ${TEMP}/testImage.gtif )
endif()
#Can create other format file
if(COMPILE_RESULT_CREATE AND GDAL_CAN_CREATE_GEOTIFF) #Use the result of the previous try_run
# Can create bigtiff file
if (GDAL_HAS_GTIF)
try_run(GDAL_CAN_CREATE_BIGTIFF COMPILE_RESULT_CREATECOPY ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/Modules/ThirdParty/GDAL/gdalCreateCopyTest.cxx CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:PATH=${GDAL_INCLUDE_DIR}" "-DLINK_LIBRARIES:STRING=${GDAL_LIBRARY}" ARGS ${TEMP}/testImage.gtif ${TEMP}/testImage.bigtif GTiff "BIGTIFF=YES")
endif()
# Can create jpeg file
if (GDAL_HAS_JPEG)
try_run(GDAL_CAN_CREATE_JPEG COMPILE_RESULT_CREATECOPY ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/Modules/ThirdParty/GDAL/gdalCreateCopyTest.cxx CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:PATH=${GDAL_INCLUDE_DIR}" "-DLINK_LIBRARIES:STRING=${GDAL_LIBRARY}" ARGS ${TEMP}/testImage.gtif ${TEMP}/testImage.jpeg JPEG)
......@@ -121,10 +128,16 @@ if (NOT COMPILE_RESULT_CREATECOPY)
else()
if (NOT GDAL_CAN_CREATE_BIGTIFF)
message(WARNING "No BIGTIFF capatilities.")
set(GDAL_QUALIFIES FALSE)
endif()
if (NOT GDAL_CAN_CREATE_JPEG)
message(WARNING "GDAL can't create jpeg files.")
set(GDAL_QUALIFIES FALSE)
endif()
if (NOT GDAL_CAN_CREATE_JPEG2000)
message(WARNING "GDAL can't create jpeg2000 files.")
set(GDAL_QUALIFIES FALSE)
......@@ -153,9 +166,6 @@ if(UNIX)
#------------------- TESTS ---------------------
# test libtiff/libgeotiff and test if symbols are renamed (only for internal libtiff/libgeotiff)
try_run(RUN_RESULT_VAR2 COMPILE_RESULT_VAR2 ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/Modules/ThirdParty/GDAL/gdalTest2.cxx ARGS ${TEMP}/testgdal2.txt)
# bigtiff
try_run(RUN_RESULT_VAR3 COMPILE_RESULT_VAR3 ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/Modules/ThirdParty/GDAL/gdalTest3.cxx ARGS ${TEMP}/testgdal3.txt)
#------------------- TESTS (END)---------------------
......@@ -168,14 +178,6 @@ if(UNIX)
endif()
if (NOT COMPILE_RESULT_VAR3)
message(WARNING "Modules/ThirdParty/GDAL/gdalTest3.cxx did not compile.")
elseif (${RUN_RESULT_VAR3} EQUAL 1)
message(WARNING "No BIGTIFF capatilities.")
set(GDAL_QUALIFIES FALSE)
endif()
endif() #GDAL_QUALIFIES
......
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