Commit 25ad48a8 authored by Julien Michel's avatar Julien Michel
Browse files

BUG: Fixing bug #86 by ensuring the use of gdal internal geotiff. Please note...

BUG: Fixing bug #86 by ensuring the use of gdal internal geotiff. Please note that two additional cmake inputs are required : LIBTIFF_INCLUDE_DIRS and GEOTIFF_INCLUDE_DIRS
parent e32b4e8f
......@@ -327,6 +327,19 @@ ENDIF (NOT GDAL_INCLUDE_DIRS)
INCLUDE_DIRECTORIES(${GDAL_INCLUDE_DIRS})
LINK_DIRECTORIES( ${GDAL_LIBRARY_DIRS} )
FIND_PATH(GEOTIFF_INCLUDE_DIRS geotiff.h $ENV{GDAL_INCLUDE_DIRS} /usr/include/geotiff)
IF (NOT GEOTIFF_INCLUDE_DIRS)
MESSAGE(FATAL_ERROR
"Cannot find geotiff headers. Please set GEOTIFF_INCLUDE_DIRS.")
ENDIF (NOT GEOTIFF_INCLUDE_DIRS)
INCLUDE_DIRECTORIES(${GEOTIFF_INCLUDE_DIRS})
FIND_PATH(LIBTIFF_INCLUDE_DIRS tiffio.h $ENV{GDAL_INCLUDE_DIRS} /usr/include)
IF (NOT LIBTIFF_INCLUDE_DIRS)
MESSAGE(FATAL_ERROR
"Cannot find libtiff headers. Please set LIBTIFF_INCLUDE_DIRS.")
ENDIF (NOT LIBTIFF_INCLUDE_DIRS)
INCLUDE_DIRECTORIES(${LIBTIFF_INCLUDE_DIRS})
#-------------------------------
# End connections whith external libraries
......@@ -497,7 +510,7 @@ ENDIF(OTB_USE_VISU_GUI)
# Use OTB_ALLS_UTILITIES_DEPENDENT_LIBRARIES to LINK Utilities Algo libraries into your executable
# => Create OTB_IO_UTILITIES_DEPENDENT_LIBRARIES
SET(OTB_IO_UTILITIES_DEPENDENT_LIBRARIES "gdal;dxf;tinyXML;otbgeotiff;otbxtiff;otbliblas;otbossim;otbossimplugins" )
SET(OTB_IO_UTILITIES_DEPENDENT_LIBRARIES "gdal;dxf;tinyXML;otbliblas;otbossim;otbossimplugins" )
IF(NOT OTB_USE_EXTERNAL_OPENTHREADS)
SET(OTB_IO_UTILITIES_DEPENDENT_LIBRARIES "${OTB_IO_UTILITIES_DEPENDENT_LIBRARIES};${OPENTHREADS_LIBRARY}")
......
......@@ -27,7 +27,7 @@ ENDIF(OTB_COMPILE_JPEG2000)
ADD_LIBRARY(OTBIO ${OTBIO_SRCS})
TARGET_LINK_LIBRARIES (OTBIO OTBCommon ITKIO ITKCommon gdal otbossim otbossimplugins dxf otbkml otbliblas)
TARGET_LINK_LIBRARIES (OTBIO OTBCommon otbossim otbossimplugins ITKIO ITKCommon dxf otbkml otbliblas)
IF( OTB_COMPILE_JPEG2000 )
TARGET_LINK_LIBRARIES (OTBIO otbopenjpeg)
ENDIF( OTB_COMPILE_JPEG2000 )
......
......@@ -25,9 +25,8 @@ IF(NOT OTB_USE_EXTERNAL_EXPAT)
SUBDIRS( otbexpat )
ENDIF(NOT OTB_USE_EXTERNAL_EXPAT)
#Supress libraries not used by the 2.2.0 version
#SUBDIRS(BGL otbsvm dxflib InsightJournal otbossim otb6S otbgeotiff tinyXMLlib otbgalib otbkml)
SUBDIRS(BGL otbsvm dxflib InsightJournal otbossim otbossimplugins otb6S otbgeotiff tinyXMLlib otbkml otbliblas otbedison otbsiftfast)
SUBDIRS(BGL otbsvm dxflib InsightJournal otbossim otbossimplugins otb6S tinyXMLlib otbkml otbliblas otbedison otbsiftfast)
IF(BUILD_TESTING)
SUBDIRS( Dart )
......
# do not do coverage in this directory
PROJECT(libgeotiff)
FILE(GLOB libgeotiff_SRCS "*.c")
FILE(GLOB libgeotiff_HDRS "*.h")
CONFIGURE_FILE(geo_config.h.in ${OTB_BINARY_DIR}/Utilities/otbgeotiff/geo_config.h)
INCLUDE_DIRECTORIES(${OTB_BINARY_DIR}/Utilities/otbgeotiff/)
# Adjust the compiler flags to avoid problems with geotiff code.
IF(CMAKE_COMPILER_IS_GNUCC)
# Hide warnings in geotiff code.
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w")
# CMake versions before 2.4 did not put the source-file-specific flags
# after the directory-level flags. Remove optimization flags from the
# CMAKE_C_FLAGS* variables so they can be overridden.
IF("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.4)
FOREACH(c "" "_DEBUG" "_RELEASE" "_MINSIZEREL" "_RELWITHDEBINFO")
STRING(REGEX REPLACE
"-O[^ ]*( |$)" "" CMAKE_C_FLAGS${c} "${CMAKE_C_FLAGS${c}}")
ENDFOREACH(c)
ENDIF("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.4)
ENDIF(CMAKE_COMPILER_IS_GNUCC)
ADD_LIBRARY(otbgeotiff ${libgeotiff_SRCS})
TARGET_LINK_LIBRARIES(otbgeotiff itktiff)
INSTALL(TARGETS otbgeotiff
RUNTIME DESTINATION ${OTB_INSTALL_BIN_DIR} COMPONENT RuntimeLibraries
LIBRARY DESTINATION ${OTB_INSTALL_LIB_DIR} COMPONENT RuntimeLibraries
ARCHIVE DESTINATION ${OTB_INSTALL_LIB_DIR} COMPONENT Development)
INSTALL(FILES ${libgeotiff_HDRS_HDRS}
DESTINATION ${OTB_INSTALL_INCLUDE_DIR}/Utilities/otbgeotiff
COMPONENT Development)
INSTALL(FILES ${OTB_BINARY_DIR}/Utilities/otbgeotiff/geo_config.h
DESTINATION ${OTB_INSTALL_INCLUDE_DIR}/Utilities/otbgeotiff
COMPONENT Development)
SUBDIRS(libxtiff)
libgeotiff Licensing
====================
All the source code in this toolkit are either in the public domain, or under
an X style license. In any event it is all considered to be free to use
for any purpose (including commercial software). No credit is required
though some of the code requires that the specific source code modules
retain their existing copyright statements. The CSV files, and other tables
derived from the EPSG coordinate system database are also free to use. In
particular, no part of this code is "copyleft", nor does it imply any
requirement for users to disclose this or their own source code.
All components not carrying their own copyright message, but distributed
with libgeotiff should be considered to be under the same license as
Niles' code.
---------
Code by Frank Warmerdam has this copyright notice (directly copied from
X Consortium licence):
* Copyright (c) 1999, Frank Warmerdam
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
-----------
Code by Niles Ritter is under this licence:
* Written By: Niles D. Ritter.
*
* copyright (c) 1995 Niles D. Ritter
*
* Permission granted to use this software, so long as this copyright
* notice accompanies any products derived therefrom.
-----------
The EPSG Tables (from which the CSV files, and .inc files are derived)
carried this statement on use of the data (from the EPSG web site):
Use of the Data
The user assumes the entire risk as to the accuracy and the use of this
data. The data may be copied and distributed subject to the following
conditions:
1.All data pertinent to a specific coordinate system must be copied
without modification and all related pages must be included;
2.All components of this data set pertinent to any given coordinate
system must be distributed together (complete distribution of all
components of the data set is preferred, but the EPSG recognises
the need for a more limited distribution);
3.The data may not be distributed for profit by any third party; and
4.The original source [EPSG] must be acknowledged.
INFORMATION PROVIDED IN THIS DOCUMENT IS PROVIDED "AS
IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
This diff is collapsed.
/******************************************************************************
* Copyright (c) 1998, Frank Warmerdam
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************
*
* cpl_serv.c: Various Common Portability Library derived convenience functions
*
* $Log: cpl_serv.c,v $
* Revision 1.8 2001/07/09 20:14:37 warmerda
* Another problem freeing pszRLBuffer and not setting to NULL.
*
* Revision 1.7 2001/04/17 13:40:43 warmerda
* fixed freeing of line buffer in CPLReadLine(), init ptr to NULL
*
* Revision 1.6 2001/03/05 04:56:17 warmerda
* make it possible to deallocate CPLReadLine buffer
*
* Revision 1.5 2000/09/30 03:35:05 warmerda
* Fixed CPLReadLine() to use avoid calling VSIRealloc() on a NULL pointer.
*
* Revision 1.4 1999/06/25 04:35:26 warmerda
* Fixed to actually support long lines.
*
* Revision 1.3 1999/03/17 20:43:03 geotiff
* Avoid use of size_t keyword
*
* Revision 1.2 1999/03/10 18:22:39 geotiff
* Added string.h, fixed backslash escaping
*
* Revision 1.1 1999/03/09 15:57:04 geotiff
* New
*
*/
#include "cpl_serv.h"
#include "geo_tiffp.h"
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#if defined(HAVE_STRINGS_H) && !defined(HAVE_STRING_H)
# include <strings.h>
#endif
/************************************************************************/
/* CPLCalloc() */
/************************************************************************/
void *CPLCalloc( int nCount, int nSize )
{
void *pReturn;
if( nSize == 0 )
return NULL;
pReturn = VSICalloc( nCount, nSize );
if( pReturn == NULL )
{
CPLError( CE_Fatal, CPLE_OutOfMemory,
"CPLCalloc(): Out of memory allocating %d bytes.\n",
nSize * nCount );
}
return pReturn;
}
/************************************************************************/
/* CPLMalloc() */
/************************************************************************/
void *CPLMalloc( int nSize )
{
void *pReturn;
if( nSize == 0 )
return NULL;
pReturn = VSIMalloc( nSize );
if( pReturn == NULL )
{
CPLError( CE_Fatal, CPLE_OutOfMemory,
"CPLMalloc(): Out of memory allocating %d bytes.\n",
nSize );
}
return pReturn;
}
/************************************************************************/
/* CPLRealloc() */
/************************************************************************/
void * CPLRealloc( void * pData, int nNewSize )
{
void *pReturn;
if( pData == NULL )
pReturn = VSIMalloc( nNewSize );
else
pReturn = VSIRealloc( pData, nNewSize );
if( pReturn == NULL )
{
CPLError( CE_Fatal, CPLE_OutOfMemory,
"CPLRealloc(): Out of memory allocating %d bytes.\n",
nNewSize );
}
return pReturn;
}
/************************************************************************/
/* CPLStrdup() */
/************************************************************************/
char *CPLStrdup( const char * pszString )
{
char *pszReturn;
if( pszString == NULL )
pszString = "";
pszReturn = VSIMalloc( strlen(pszString)+1 );
if( pszReturn == NULL )
{
CPLError( CE_Fatal, CPLE_OutOfMemory,
"CPLStrdup(): Out of memory allocating %d bytes.\n",
strlen(pszString) );
}
strcpy( pszReturn, pszString );
return( pszReturn );
}
/************************************************************************/
/* CPLReadLine() */
/* */
/* Read a line of text from the given file handle, taking care */
/* to capture CR and/or LF and strip off ... equivelent of */
/* DKReadLine(). Pointer to an internal buffer is returned. */
/* The application shouldn't free it, or depend on it's value */
/* past the next call to CPLReadLine() */
/************************************************************************/
const char *CPLReadLine( FILE * fp )
{
static char *pszRLBuffer = NULL;
static int nRLBufferSize = 0;
int nLength, nReadSoFar = 0;
/* -------------------------------------------------------------------- */
/* Cleanup case. */
/* -------------------------------------------------------------------- */
if( fp == NULL )
{
CPLFree( pszRLBuffer );
pszRLBuffer = NULL;
nRLBufferSize = 0;
return NULL;
}
/* -------------------------------------------------------------------- */
/* Loop reading chunks of the line till we get to the end of */
/* the line. */
/* -------------------------------------------------------------------- */
do {
/* -------------------------------------------------------------------- */
/* Grow the working buffer if we have it nearly full. Fail out */
/* of read line if we can't reallocate it big enough (for */
/* instance for a _very large_ file with no newlines). */
/* -------------------------------------------------------------------- */
if( nRLBufferSize-nReadSoFar < 128 )
{
nRLBufferSize = nRLBufferSize*2 + 128;
if( pszRLBuffer == NULL )
pszRLBuffer = (char *) VSIMalloc(nRLBufferSize);
else
pszRLBuffer = (char *) VSIRealloc(pszRLBuffer, nRLBufferSize);
if( pszRLBuffer == NULL )
{
nRLBufferSize = 0;
return NULL;
}
}
/* -------------------------------------------------------------------- */
/* Do the actual read. */
/* -------------------------------------------------------------------- */
if( VSIFGets( pszRLBuffer+nReadSoFar, nRLBufferSize-nReadSoFar, fp )
== NULL )
{
CPLFree( pszRLBuffer );
pszRLBuffer = NULL;
nRLBufferSize = 0;
return NULL;
}
nReadSoFar = strlen(pszRLBuffer);
} while( nReadSoFar == nRLBufferSize - 1
&& pszRLBuffer[nRLBufferSize-2] != 13
&& pszRLBuffer[nRLBufferSize-2] != 10 );
/* -------------------------------------------------------------------- */
/* Clear CR and LF off the end. */
/* -------------------------------------------------------------------- */
nLength = strlen(pszRLBuffer);
if( nLength > 0
&& (pszRLBuffer[nLength-1] == 10 || pszRLBuffer[nLength-1] == 13) )
{
pszRLBuffer[--nLength] = '\0';
}
if( nLength > 0
&& (pszRLBuffer[nLength-1] == 10 || pszRLBuffer[nLength-1] == 13) )
{
pszRLBuffer[--nLength] = '\0';
}
return( pszRLBuffer );
}
/*=====================================================================
StringList manipulation functions.
=====================================================================*/
/**********************************************************************
* CSLAddString()
*
* Append a string to a StringList and return a pointer to the modified
* StringList.
* If the input StringList is NULL, then a new StringList is created.
**********************************************************************/
char **CSLAddString(char **papszStrList, const char *pszNewString)
{
int nItems=0;
if (pszNewString == NULL)
return papszStrList; /* Nothing to do!*/
/* Allocate room for the new string */
if (papszStrList == NULL)
papszStrList = (char**) CPLCalloc(2,sizeof(char*));
else
{
nItems = CSLCount(papszStrList);
papszStrList = (char**)CPLRealloc(papszStrList,
(nItems+2)*sizeof(char*));
}
/* Copy the string in the list */
papszStrList[nItems] = CPLStrdup(pszNewString);
papszStrList[nItems+1] = NULL;
return papszStrList;
}
/**********************************************************************
* CSLCount()
*
* Return the number of lines in a Stringlist.
**********************************************************************/
int CSLCount(char **papszStrList)
{
int nItems=0;
if (papszStrList)
{
while(*papszStrList != NULL)
{
nItems++;
papszStrList++;
}
}
return nItems;
}
/************************************************************************/
/* CSLGetField() */
/* */
/* Fetches the indicated field, being careful not to crash if */
/* the field doesn't exist within this string list. The */
/* returned pointer should not be freed, and doesn't */
/* necessarily last long. */
/************************************************************************/
const char * CSLGetField( char ** papszStrList, int iField )
{
int i;
if( papszStrList == NULL || iField < 0 )
return( "" );
for( i = 0; i < iField+1; i++ )
{
if( papszStrList[i] == NULL )
return "";
}
return( papszStrList[iField] );
}
/**********************************************************************
* CSLDestroy()
*
* Free all memory used by a StringList.
**********************************************************************/
void CSLDestroy(char **papszStrList)
{
char **papszPtr;
if (papszStrList)
{
papszPtr = papszStrList;
while(*papszPtr != NULL)
{
CPLFree(*papszPtr);
papszPtr++;
}
CPLFree(papszStrList);
}
}
/**********************************************************************
* CSLDuplicate()
*
* Allocate and return a copy of a StringList.
**********************************************************************/
char **CSLDuplicate(char **papszStrList)
{
char **papszNewList, **papszSrc, **papszDst;
int nLines;
nLines = CSLCount(papszStrList);
if (nLines == 0)
return NULL;
papszNewList = (char **)CPLMalloc((nLines+1)*sizeof(char*));
papszSrc = papszStrList;
papszDst = papszNewList;
while(*papszSrc != NULL)
{
*papszDst = CPLStrdup(*papszSrc);
papszSrc++;
papszDst++;
}
*papszDst = NULL;
return papszNewList;
}
/**********************************************************************
* CSLTokenizeString()
*
* Tokenizes a string and returns a StringList with one string for
* each token.
**********************************************************************/
char **CSLTokenizeString( const char *pszString )
{
return CSLTokenizeStringComplex( pszString, " ", TRUE, FALSE );
}
/************************************************************************/
/* CSLTokenizeStringComplex() */
/* */
/* The ultimate tokenizer? */
/************************************************************************/
char ** CSLTokenizeStringComplex( const char * pszString,
const char * pszDelimiters,
int bHonourStrings, int bAllowEmptyTokens )
{
char **papszRetList = NULL;
char *pszToken;
int nTokenMax, nTokenLen;
pszToken = (char *) CPLCalloc(10,1);
nTokenMax = 10;
while( pszString != NULL && *pszString != '\0' )
{
int bInString = FALSE;
nTokenLen = 0;
/* Try to find the next delimeter, marking end of token */
for( ; *pszString != '\0'; pszString++ )
{
/* End if this is a delimeter skip it and break. */
if( !bInString && strchr(pszDelimiters, *pszString) != NULL )
{
pszString++;
break;
}
/* If this is a quote, and we are honouring constant
strings, then process the constant strings, with out delim
but don't copy over the quotes */
if( bHonourStrings && *pszString == '"' )
{
if( bInString )