diff --git a/modules/globebrowsing/ext/gdal/include/cpl_atomic_ops.h b/modules/globebrowsing/ext/gdal/include/cpl_atomic_ops.h new file mode 100644 index 0000000000..ed3eadaec9 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/cpl_atomic_ops.h @@ -0,0 +1,106 @@ +/********************************************************************** + * $Id$ + * + * Name: cpl_atomic_ops.h + * Project: CPL - Common Portability Library + * Purpose: Atomic operation functions. + * Author: Even Rouault, + * + ********************************************************************** + * Copyright (c) 2009-2010, Even Rouault + * + * 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. + ****************************************************************************/ + +#ifndef CPL_ATOMIC_OPS_INCLUDED +#define CPL_ATOMIC_OPS_INCLUDED + +#include "cpl_port.h" + +CPL_C_START + +/** Add a value to a pointed integer in a thread and SMP-safe way + * and return the resulting value of the operation. + * + * This function, which in most cases is implemented by a few + * efficient machine instructions, guarantees that the value pointed + * by ptr will be incremented in a thread and SMP-safe way. + * The variables for this function must be aligned on a 32-bit boundary. + * + * Depending on the platforms, this function can also act as a + * memory barrier, but this should not be assumed. + * + * Current platforms/architectures where an efficient implementation + * exists are MacOSX, MS Windows, i386/x86_64 with GCC and platforms + * supported by GCC 4.1 or higher. For other platforms supporting + * the pthread library, and when GDAL is configured with thread-support, + * the atomicity will be done with a mutex, but with + * reduced efficiently. For the remaining platforms, a simple addition + * with no locking will be done... + * + * @param ptr a pointer to an integer to increment + * @param increment the amount to add to the pointed integer + * @return the pointed value AFTER the result of the addition + */ +int CPL_DLL CPLAtomicAdd(volatile int* ptr, int increment); + +/** Increment of 1 the pointed integer in a thread and SMP-safe way + * and return the resulting value of the operation. + * + * @see CPLAtomicAdd for the details and guarantees of this atomic + * operation + * + * @param ptr a pointer to an integer to increment + * @return the pointed value AFTER the operation: *ptr + 1 + */ +#define CPLAtomicInc(ptr) CPLAtomicAdd(ptr, 1) + +/** Decrement of 1 the pointed integer in a thread and SMP-safe way + * and return the resulting value of the operation. + * + * @see CPLAtomicAdd for the details and guarantees of this atomic + * operation + * + * @param ptr a pointer to an integer to decrement + * @return the pointed value AFTER the operation: *ptr - 1 + */ +#define CPLAtomicDec(ptr) CPLAtomicAdd(ptr, -1) + + +/** Compares *ptr with oldval. If *ptr == oldval, then *ptr is assigned + * newval and TRUE is returned. Otherwise nothing is done, and FALSE is returned. + * + * Current platforms/architectures where an efficient implementation + * exists are MacOSX, MS Windows, i386/x86_64 with GCC and platforms + * supported by GCC 4.1 or higher. For other platforms supporting + * the pthread library, and when GDAL is configured with thread-support, + * the atomicity will be done with a mutex, but with + * reduced efficiently. For the remaining platforms, a simple addition + * with no locking will be done... + * + * @param ptr a pointer to an integer (aligned on 32bit boundary). + * @param oldval old value + * @param newval new value + * @return TRUE if the exchange has been done + */ +int CPLAtomicCompareAndExchange(volatile int* ptr, int oldval, int newval); + +CPL_C_END + +#endif /* CPL_ATOMIC_OPS_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/cpl_aws.h b/modules/globebrowsing/ext/gdal/include/cpl_aws.h new file mode 100644 index 0000000000..3d968ba750 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/cpl_aws.h @@ -0,0 +1,136 @@ +/********************************************************************** + * $Id$ + * + * Name: cpl_aws.h + * Project: CPL - Common Portability Library + * Purpose: Amazon Web Services routines + * Author: Even Rouault + * + ********************************************************************** + * Copyright (c) 2015, Even Rouault + * + * 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. + ****************************************************************************/ + +#ifndef CPL_AWS_INCLUDED_H +#define CPL_AWS_INCLUDED_H + +#include "cpl_string.h" + +CPLString CPLGetAWS_SIGN4_Authorization(const CPLString& osSecretAccessKey, + const CPLString& osAccessKeyId, + const CPLString& osAccessToken, + const CPLString& osAWSRegion, + const CPLString& osService, + const CPLString& osVerb, + const CPLString& osHost, + const CPLString& osCanonicalURI, + const CPLString& osCanonicalQueryString, + const CPLString& osXAMZContentSHA256, + const CPLString& osTimestamp); + +CPLString CPLGetLowerCaseHexSHA256( const void *pabyData, size_t nBytes ); +CPLString CPLGetLowerCaseHexSHA256( const CPLString& osStr ); + +CPLString CPLGetAWS_SIGN4_Timestamp(); + +CPLString CPLAWSURLEncode(const CPLString& osURL, bool bEncodeSlash = true); + +#ifdef HAVE_CURL + +#include +#include + +class VSIS3HandleHelper +{ + CPLString m_osURL; + CPLString m_osSecretAccessKey; + CPLString m_osAccessKeyId; + CPLString m_osSessionToken; + CPLString m_osAWSS3Endpoint; + CPLString m_osAWSRegion; + CPLString m_osBucket; + CPLString m_osObjectKey; + bool m_bUseHTTPS; + bool m_bUseVirtualHosting; + std::map m_oMapQueryParameters; + + static bool GetBucketAndObjectKey(const char* pszURI, const char* pszFSPrefix, + bool bAllowNoObject, + CPLString &osBucketOut, CPLString &osObjectKeyOut); + void RebuildURL(); + + protected: + + public: + VSIS3HandleHelper(const CPLString& osSecretAccessKey, + const CPLString& osAccessKeyId, + const CPLString& osSessionToken, + const CPLString& osAWSS3Endpoint, + const CPLString& osAWSRegion, + const CPLString& osBucket, + const CPLString& osObjectKey, + bool bUseHTTPS, bool bUseVirtualHosting); + ~VSIS3HandleHelper(); + + static VSIS3HandleHelper* BuildFromURI(const char* pszURI, const char* pszFSPrefix, + bool bAllowNoObject); + static CPLString BuildURL(const CPLString& osAWSS3Endpoint, + const CPLString& osBucket, + const CPLString& osObjectKey, + bool bUseHTTPS, bool bUseVirtualHosting); + + void ResetQueryParameters(); + void AddQueryParameter(const CPLString& osKey, const CPLString& osValue); + struct curl_slist* GetCurlHeaders(const CPLString& osVerb, + const void *pabyDataContent = NULL, + size_t nBytesContent = 0); + bool CanRestartOnError(const char* pszErrorMsg) { return CanRestartOnError(pszErrorMsg, false); } + bool CanRestartOnError(const char*, bool bSetError); + + const CPLString& GetURL() const { return m_osURL; } + const CPLString& GetBucket() const { return m_osBucket; } + const CPLString& GetObjectKey() const { return m_osObjectKey; } + const CPLString& GetAWSS3Endpoint()const { return m_osAWSS3Endpoint; } + const CPLString& GetAWSRegion() const { return m_osAWSRegion; } + bool GetVirtualHosting() const { return m_bUseVirtualHosting; } + void SetAWSS3Endpoint(const CPLString &osStr); + void SetAWSRegion(const CPLString &osStr); + void SetVirtualHosting(bool b); + void SetObjectKey(const CPLString &osStr); +}; + +class VSIS3UpdateParams +{ + public: + CPLString m_osAWSRegion; + CPLString m_osAWSS3Endpoint; + bool m_bUseVirtualHosting; + + VSIS3UpdateParams(const CPLString& osAWSRegion = "", + const CPLString& osAWSS3Endpoint = "", + bool bUseVirtualHosting = false) : + m_osAWSRegion(osAWSRegion), + m_osAWSS3Endpoint(osAWSS3Endpoint), + m_bUseVirtualHosting(bUseVirtualHosting) {} +}; + +#endif /* HAVE_CURL */ + +#endif /* CPL_AWS_INCLUDED_H */ diff --git a/modules/globebrowsing/ext/gdal/include/cpl_config.h b/modules/globebrowsing/ext/gdal/include/cpl_config.h new file mode 100644 index 0000000000..fe7b82a8a2 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/cpl_config.h @@ -0,0 +1,121 @@ + +/* We define this here in general so that a VC++ build will publicly + declare STDCALL interfaces even if an application is built against it + using MinGW */ + +#ifndef CPL_DISABLE_STDCALL +# define CPL_STDCALL __stdcall +#endif + +/* Define if you don't have vprintf but do have _doprnt. */ +#undef HAVE_DOPRNT + +/* Define if you have the vprintf function. */ +#define HAVE_VPRINTF 1 +#define HAVE_VSNPRINTF 1 +#define HAVE_SNPRINTF 1 +#if defined(_MSC_VER) && (_MSC_VER < 1500) +# define vsnprintf _vsnprintf +#endif +#if defined(_MSC_VER) && (_MSC_VER < 1900) +# define snprintf _snprintf +#endif + +#define HAVE_GETCWD 1 +/* gmt_notunix.h from GMT project also redefines getcwd. See #3138 */ +#ifndef getcwd +#define getcwd _getcwd +#endif + +/* Define if you have the ANSI C header files. */ +#ifndef STDC_HEADERS +# define STDC_HEADERS 1 +#endif + +/* Define to 1 if you have the header file. */ +#define HAVE_ASSERT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +#undef HAVE_LIBDL + +/* Define to 1 if you have the header file. */ +#define HAVE_LOCALE_H 1 + +#define HAVE_FLOAT_H 1 + +#define HAVE_ERRNO_H 1 + +#define HAVE_SEARCH_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_DIRECT_H + +/* Define to 1 if you have the `localtime_r' function. */ +#undef HAVE_LOCALTIME_R + +#undef HAVE_DLFCN_H +#undef HAVE_DBMALLOC_H +#undef HAVE_LIBDBMALLOC +#undef WORDS_BIGENDIAN + +/* The size of a `int', as computed by sizeof. */ +#define SIZEOF_INT 4 + +/* The size of a `long', as computed by sizeof. */ +#define SIZEOF_LONG 4 + +/* The size of a `unsigned long', as computed by sizeof. */ +#define SIZEOF_UNSIGNED_LONG 4 + +/* The size of `void*', as computed by sizeof. */ +#ifdef _WIN64 +# define SIZEOF_VOIDP 8 +#else +# define SIZEOF_VOIDP 4 +#endif + +/* Set the native cpu bit order */ +#define HOST_FILLORDER FILLORDER_LSB2MSB + +/* Define as 0 or 1 according to the floating point format supported by the + machine */ +#define HAVE_IEEEFP 1 + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +# ifndef inline +# define inline __inline +# endif +#endif + +#define lfind _lfind + +#if defined(_MSC_VER) && (_MSC_VER < 1310) +# define VSI_STAT64 _stat +# define VSI_STAT64_T _stat +#else +# define VSI_STAT64 _stat64 +# define VSI_STAT64_T __stat64 +#endif + +/* VC6 doesn't known intptr_t */ +#if defined(_MSC_VER) && (_MSC_VER <= 1200) + typedef int intptr_t; +#endif + +#pragma warning(disable: 4786) + +/* #define CPL_DISABLE_DLL */ + diff --git a/modules/globebrowsing/ext/gdal/include/cpl_config_extras.h b/modules/globebrowsing/ext/gdal/include/cpl_config_extras.h new file mode 100644 index 0000000000..654f2fcad6 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/cpl_config_extras.h @@ -0,0 +1,40 @@ + +#ifndef INCLUDED_CPL_CONFIG_EXTRAS +#define INCLUDED_CPL_CONFIG_EXTRAS + +#if defined(__APPLE__) + +#ifdef __BIG_ENDIAN__ + #define HOST_FILLORDER FILLORDER_MSB2LSB +#else + #define HOST_FILLORDER FILLORDER_LSB2MSB +#endif + + +#ifdef __LP64__ + #define SIZEOF_UNSIGNED_LONG 8 +#else + #define SIZEOF_UNSIGNED_LONG 4 +#endif + +#ifdef __LP64__ + #define SIZEOF_VOIDP 8 +#else + #define SIZEOF_VOIDP 4 +#endif + +#ifdef __BIG_ENDIAN__ + #define WORDS_BIGENDIAN 1 +#else + #undef WORDS_BIGENDIAN +#endif + +#undef VSI_STAT64 +#undef VSI_STAT64_T + +#define VSI_STAT64 stat +#define VSI_STAT64_T stat + +#endif // APPLE + +#endif //INCLUDED_CPL_CONFIG_EXTRAS diff --git a/modules/globebrowsing/ext/gdal/include/cpl_conv.h b/modules/globebrowsing/ext/gdal/include/cpl_conv.h new file mode 100644 index 0000000000..ace573f8e6 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/cpl_conv.h @@ -0,0 +1,307 @@ +/****************************************************************************** + * $Id$ + * + * Project: CPL - Common Portability Library + * Purpose: Convenience functions declarations. + * This is intended to remain light weight. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1998, Frank Warmerdam + * Copyright (c) 2007-2013, Even Rouault + * + * 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. + ****************************************************************************/ + +#ifndef CPL_CONV_H_INCLUDED +#define CPL_CONV_H_INCLUDED + +#include "cpl_port.h" +#include "cpl_vsi.h" +#include "cpl_error.h" + +/** + * \file cpl_conv.h + * + * Various convenience functions for CPL. + * + */ + +/* -------------------------------------------------------------------- */ +/* Runtime check of various configuration items. */ +/* -------------------------------------------------------------------- */ +CPL_C_START + +void CPL_DLL CPLVerifyConfiguration(void); + +const char CPL_DLL * CPL_STDCALL +CPLGetConfigOption( const char *, const char * ) CPL_WARN_UNUSED_RESULT; +const char CPL_DLL * CPL_STDCALL +CPLGetThreadLocalConfigOption( const char *, const char * ) CPL_WARN_UNUSED_RESULT; +void CPL_DLL CPL_STDCALL CPLSetConfigOption( const char *, const char * ); +void CPL_DLL CPL_STDCALL CPLSetThreadLocalConfigOption( const char *pszKey, + const char *pszValue ); +void CPL_DLL CPL_STDCALL CPLFreeConfig(void); + +/* -------------------------------------------------------------------- */ +/* Safe malloc() API. Thin cover over VSI functions with fatal */ +/* error reporting if memory allocation fails. */ +/* -------------------------------------------------------------------- */ +void CPL_DLL *CPLMalloc( size_t ) CPL_WARN_UNUSED_RESULT; +void CPL_DLL *CPLCalloc( size_t, size_t ) CPL_WARN_UNUSED_RESULT; +void CPL_DLL *CPLRealloc( void *, size_t ) CPL_WARN_UNUSED_RESULT; +char CPL_DLL *CPLStrdup( const char * ) CPL_WARN_UNUSED_RESULT CPL_RETURNS_NONNULL; +char CPL_DLL *CPLStrlwr( char *); + +#define CPLFree VSIFree + +/* -------------------------------------------------------------------- */ +/* Read a line from a text file, and strip of CR/LF. */ +/* -------------------------------------------------------------------- */ +char CPL_DLL *CPLFGets( char *, int, FILE *); +const char CPL_DLL *CPLReadLine( FILE * ); +const char CPL_DLL *CPLReadLineL( VSILFILE * ); +const char CPL_DLL *CPLReadLine2L( VSILFILE * , int nMaxCols, char** papszOptions); + +/* -------------------------------------------------------------------- */ +/* Convert ASCII string to floating point number */ +/* (THESE FUNCTIONS ARE NOT LOCALE AWARE!). */ +/* -------------------------------------------------------------------- */ +double CPL_DLL CPLAtof(const char *); +double CPL_DLL CPLAtofDelim(const char *, char); +double CPL_DLL CPLStrtod(const char *, char **); +double CPL_DLL CPLStrtodDelim(const char *, char **, char); +float CPL_DLL CPLStrtof(const char *, char **); +float CPL_DLL CPLStrtofDelim(const char *, char **, char); + +/* -------------------------------------------------------------------- */ +/* Convert number to string. This function is locale agnostic */ +/* (i.e. it will support "," or "." regardless of current locale) */ +/* -------------------------------------------------------------------- */ +double CPL_DLL CPLAtofM(const char *); + +/* -------------------------------------------------------------------- */ +/* Read a numeric value from an ASCII character string. */ +/* -------------------------------------------------------------------- */ +char CPL_DLL *CPLScanString( const char *, int, int, int ); +double CPL_DLL CPLScanDouble( const char *, int ); +long CPL_DLL CPLScanLong( const char *, int ); +unsigned long CPL_DLL CPLScanULong( const char *, int ); +GUIntBig CPL_DLL CPLScanUIntBig( const char *, int ); +GIntBig CPL_DLL CPLAtoGIntBig( const char* pszString ); +GIntBig CPL_DLL CPLAtoGIntBigEx( const char* pszString, int bWarn, int *pbOverflow ); +void CPL_DLL *CPLScanPointer( const char *, int ); + +/* -------------------------------------------------------------------- */ +/* Print a value to an ASCII character string. */ +/* -------------------------------------------------------------------- */ +int CPL_DLL CPLPrintString( char *, const char *, int ); +int CPL_DLL CPLPrintStringFill( char *, const char *, int ); +int CPL_DLL CPLPrintInt32( char *, GInt32 , int ); +int CPL_DLL CPLPrintUIntBig( char *, GUIntBig , int ); +int CPL_DLL CPLPrintDouble( char *, const char *, double, const char * ); +int CPL_DLL CPLPrintTime( char *, int , const char *, const struct tm *, + const char * ); +int CPL_DLL CPLPrintPointer( char *, void *, int ); + +/* -------------------------------------------------------------------- */ +/* Fetch a function from DLL / so. */ +/* -------------------------------------------------------------------- */ + +void CPL_DLL *CPLGetSymbol( const char *, const char * ); + +/* -------------------------------------------------------------------- */ +/* Fetch executable path. */ +/* -------------------------------------------------------------------- */ +int CPL_DLL CPLGetExecPath( char *pszPathBuf, int nMaxLength ); + +/* -------------------------------------------------------------------- */ +/* Filename handling functions. */ +/* -------------------------------------------------------------------- */ +const char CPL_DLL *CPLGetPath( const char * ) CPL_WARN_UNUSED_RESULT CPL_RETURNS_NONNULL; +const char CPL_DLL *CPLGetDirname( const char * ) CPL_WARN_UNUSED_RESULT CPL_RETURNS_NONNULL; +const char CPL_DLL *CPLGetFilename( const char * ) CPL_WARN_UNUSED_RESULT CPL_RETURNS_NONNULL; +const char CPL_DLL *CPLGetBasename( const char * ) CPL_WARN_UNUSED_RESULT CPL_RETURNS_NONNULL; +const char CPL_DLL *CPLGetExtension( const char * ) CPL_WARN_UNUSED_RESULT CPL_RETURNS_NONNULL; +char CPL_DLL *CPLGetCurrentDir(void); +const char CPL_DLL *CPLFormFilename( const char *pszPath, + const char *pszBasename, + const char *pszExtension ) CPL_WARN_UNUSED_RESULT CPL_RETURNS_NONNULL; +const char CPL_DLL *CPLFormCIFilename( const char *pszPath, + const char *pszBasename, + const char *pszExtension ) CPL_WARN_UNUSED_RESULT CPL_RETURNS_NONNULL; +const char CPL_DLL *CPLResetExtension( const char *, const char * ) CPL_WARN_UNUSED_RESULT CPL_RETURNS_NONNULL; +const char CPL_DLL *CPLProjectRelativeFilename( const char *pszProjectDir, + const char *pszSecondaryFilename ) CPL_WARN_UNUSED_RESULT CPL_RETURNS_NONNULL; +int CPL_DLL CPLIsFilenameRelative( const char *pszFilename ); +const char CPL_DLL *CPLExtractRelativePath(const char *, const char *, int *) CPL_WARN_UNUSED_RESULT CPL_RETURNS_NONNULL; +const char CPL_DLL *CPLCleanTrailingSlash( const char * ) CPL_WARN_UNUSED_RESULT CPL_RETURNS_NONNULL; +char CPL_DLL **CPLCorrespondingPaths( const char *pszOldFilename, + const char *pszNewFilename, + char **papszFileList ) CPL_WARN_UNUSED_RESULT; +int CPL_DLL CPLCheckForFile( char *pszFilename, char **papszSiblingList ); + +const char CPL_DLL *CPLGenerateTempFilename( const char *pszStem ) CPL_WARN_UNUSED_RESULT CPL_RETURNS_NONNULL; + +/* -------------------------------------------------------------------- */ +/* Find File Function */ +/* -------------------------------------------------------------------- */ +typedef const char *(*CPLFileFinder)(const char *, const char *); + +const char CPL_DLL *CPLFindFile(const char *pszClass, + const char *pszBasename); +const char CPL_DLL *CPLDefaultFindFile(const char *pszClass, + const char *pszBasename); +void CPL_DLL CPLPushFileFinder( CPLFileFinder pfnFinder ); +CPLFileFinder CPL_DLL CPLPopFileFinder(void); +void CPL_DLL CPLPushFinderLocation( const char * ); +void CPL_DLL CPLPopFinderLocation(void); +void CPL_DLL CPLFinderClean(void); + +/* -------------------------------------------------------------------- */ +/* Safe version of stat() that works properly on stuff like "C:". */ +/* -------------------------------------------------------------------- */ +int CPL_DLL CPLStat( const char *, VSIStatBuf * ) CPL_WARN_UNUSED_RESULT; + +/* -------------------------------------------------------------------- */ +/* Reference counted file handle manager. Makes sharing file */ +/* handles more practical. */ +/* -------------------------------------------------------------------- */ +typedef struct { + FILE *fp; + int nRefCount; + int bLarge; + char *pszFilename; + char *pszAccess; +} CPLSharedFileInfo; + +FILE CPL_DLL *CPLOpenShared( const char *, const char *, int ); +void CPL_DLL CPLCloseShared( FILE * ); +CPLSharedFileInfo CPL_DLL *CPLGetSharedList( int * ); +void CPL_DLL CPLDumpSharedList( FILE * ); +void CPL_DLL CPLCleanupSharedFileMutex( void ); + +/* -------------------------------------------------------------------- */ +/* DMS to Dec to DMS conversion. */ +/* -------------------------------------------------------------------- */ +double CPL_DLL CPLDMSToDec( const char *is ); +const char CPL_DLL *CPLDecToDMS( double dfAngle, const char * pszAxis, + int nPrecision ); +double CPL_DLL CPLPackedDMSToDec( double ); +double CPL_DLL CPLDecToPackedDMS( double dfDec ); + +void CPL_DLL CPLStringToComplex( const char *pszString, + double *pdfReal, double *pdfImag ); + +/* -------------------------------------------------------------------- */ +/* Misc other functions. */ +/* -------------------------------------------------------------------- */ +int CPL_DLL CPLUnlinkTree( const char * ); +int CPL_DLL CPLCopyFile( const char *pszNewPath, const char *pszOldPath ); +int CPL_DLL CPLCopyTree( const char *pszNewPath, const char *pszOldPath ); +int CPL_DLL CPLMoveFile( const char *pszNewPath, const char *pszOldPath ); +int CPL_DLL CPLSymlink( const char* pszOldPath, const char* pszNewPath, char** papszOptions ); + +/* -------------------------------------------------------------------- */ +/* ZIP Creation. */ +/* -------------------------------------------------------------------- */ +#define CPL_ZIP_API_OFFERED +void CPL_DLL *CPLCreateZip( const char *pszZipFilename, char **papszOptions ); +CPLErr CPL_DLL CPLCreateFileInZip( void *hZip, const char *pszFilename, + char **papszOptions ); +CPLErr CPL_DLL CPLWriteFileInZip( void *hZip, const void *pBuffer, int nBufferSize ); +CPLErr CPL_DLL CPLCloseFileInZip( void *hZip ); +CPLErr CPL_DLL CPLCloseZip( void *hZip ); + +/* -------------------------------------------------------------------- */ +/* ZLib compression */ +/* -------------------------------------------------------------------- */ + +void CPL_DLL *CPLZLibDeflate( const void* ptr, size_t nBytes, int nLevel, + void* outptr, size_t nOutAvailableBytes, + size_t* pnOutBytes ); +void CPL_DLL *CPLZLibInflate( const void* ptr, size_t nBytes, + void* outptr, size_t nOutAvailableBytes, + size_t* pnOutBytes ); + +/* -------------------------------------------------------------------- */ +/* XML validation. */ +/* -------------------------------------------------------------------- */ +int CPL_DLL CPLValidateXML(const char* pszXMLFilename, + const char* pszXSDFilename, + char** papszOptions); + +/* -------------------------------------------------------------------- */ +/* Locale handling. Prevents parallel executions of setlocale(). */ +/* -------------------------------------------------------------------- */ +char* CPLsetlocale (int category, const char* locale); +void CPLCleanupSetlocaleMutex(void); + +CPL_C_END + +/* -------------------------------------------------------------------- */ +/* C++ object for temporarily forcing a LC_NUMERIC locale to "C". */ +/* -------------------------------------------------------------------- */ + +#if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS) + +class CPL_DLL CPLLocaleC +{ +public: + CPLLocaleC(); + ~CPLLocaleC(); + +private: + char *pszOldLocale; + + /* Make it non-copyable */ + CPLLocaleC(const CPLLocaleC&); + CPLLocaleC& operator=(const CPLLocaleC&); +}; + +// Does the same as CPLLocaleC except that, when available, it tries to +// only affect the current thread. But code that would be dependent of +// setlocale(LC_NUMERIC, NULL) returning "C", such as current proj.4 versions, +// will not work depending on the actual implementation +class CPL_DLL CPLThreadLocaleC +{ +public: + CPLThreadLocaleC(); + ~CPLThreadLocaleC(); + +private: +#ifdef HAVE_USELOCALE + locale_t nNewLocale; + locale_t nOldLocale; +#else +#if defined(_MSC_VER) + int nOldValConfigThreadLocale; +#endif + char *pszOldLocale; +#endif + + /* Make it non-copyable */ + CPLThreadLocaleC(const CPLThreadLocaleC&); + CPLThreadLocaleC& operator=(const CPLThreadLocaleC&); +}; + +#endif /* def __cplusplus */ + + +#endif /* ndef CPL_CONV_H_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/cpl_csv.h b/modules/globebrowsing/ext/gdal/include/cpl_csv.h new file mode 100644 index 0000000000..b1d2ebb903 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/cpl_csv.h @@ -0,0 +1,76 @@ +/****************************************************************************** + * $Id$ + * + * Project: Common Portability Library + * Purpose: Functions for reading and scanning CSV (comma separated, + * variable length text files holding tables) files. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * 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. + ****************************************************************************/ + +#ifndef CPL_CSV_H_INCLUDED +#define CPL_CSV_H_INCLUDED + +#include "cpl_conv.h" +#include "cpl_string.h" +#include "cpl_vsi.h" + +CPL_C_START + +typedef enum { + CC_ExactString, + CC_ApproxString, + CC_Integer +} CSVCompareCriteria; + +const char CPL_DLL *CSVFilename( const char * ); + +char CPL_DLL CSVDetectSeperator( const char *pszLine ); + +char CPL_DLL **CSVReadParseLine( FILE *fp); +char CPL_DLL **CSVReadParseLine2( FILE *fp, char chDelimiter ); + +char CPL_DLL **CSVReadParseLineL( VSILFILE *fp); +char CPL_DLL **CSVReadParseLine2L( VSILFILE *fp, char chDelimiter ); + +char CPL_DLL **CSVScanLines( FILE *, int, const char *, CSVCompareCriteria ); +char CPL_DLL **CSVScanLinesL( VSILFILE *, int, const char *, CSVCompareCriteria ); +char CPL_DLL **CSVScanFile( const char *, int, const char *, + CSVCompareCriteria ); +char CPL_DLL **CSVScanFileByName( const char *, const char *, const char *, + CSVCompareCriteria ); +char CPL_DLL **CSVGetNextLine( const char * ); +int CPL_DLL CSVGetFieldId( FILE *, const char * ); +int CPL_DLL CSVGetFieldIdL( VSILFILE *, const char * ); +int CPL_DLL CSVGetFileFieldId( const char *, const char * ); + +void CPL_DLL CSVDeaccess( const char * ); + +const char CPL_DLL *CSVGetField( const char *, const char *, const char *, + CSVCompareCriteria, const char * ); + +void CPL_DLL SetCSVFilenameHook( const char *(*)(const char *) ); + +CPL_C_END + +#endif /* ndef CPL_CSV_H_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/cpl_error.h b/modules/globebrowsing/ext/gdal/include/cpl_error.h new file mode 100644 index 0000000000..a43f1a32e2 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/cpl_error.h @@ -0,0 +1,179 @@ +/********************************************************************** + * $Id$ + * + * Name: cpl_error.h + * Project: CPL - Common Portability Library + * Purpose: CPL Error handling + * Author: Daniel Morissette, danmo@videotron.ca + * + ********************************************************************** + * Copyright (c) 1998, Daniel Morissette + * + * 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. + ****************************************************************************/ + +#ifndef CPL_ERROR_H_INCLUDED +#define CPL_ERROR_H_INCLUDED + +#include "cpl_port.h" + +/*===================================================================== + Error handling functions (cpl_error.c) + =====================================================================*/ + +/** + * \file cpl_error.h + * + * CPL error handling services. + */ + +CPL_C_START + +typedef enum +{ + CE_None = 0, + CE_Debug = 1, + CE_Warning = 2, + CE_Failure = 3, + CE_Fatal = 4 +} CPLErr; + +/* ==================================================================== */ +/* Well known error codes. */ +/* ==================================================================== */ + +#ifdef STRICT_CPLERRORNUM_TYPE + +/* This is not appropriate for the general case, as there are parts */ +/* of GDAL which use custom error codes, but this can help diagnose confusions */ +/* between CPLErr and CPLErrorNum */ +typedef enum +{ + CPLE_None, + CPLE_AppDefined, + CPLE_OutOfMemory, + CPLE_FileIO, + CPLE_OpenFailed, + CPLE_IllegalArg, + CPLE_NotSupported, + CPLE_AssertionFailed, + CPLE_NoWriteAccess, + CPLE_UserInterrupt, + CPLE_ObjectNull, + CPLE_HttpResponse, + CPLE_HttpResponse, + CPLE_AWSBucketNotFound, + CPLE_AWSObjectNotFound, + CPLE_AWSAccessDenied, + CPLE_AWSInvalidCredentials, + CPLE_AWSSignatureDoesNotMatch, +} CPLErrorNum; + +#else + +typedef int CPLErrorNum; + +#define CPLE_None 0 +#define CPLE_AppDefined 1 +#define CPLE_OutOfMemory 2 +#define CPLE_FileIO 3 +#define CPLE_OpenFailed 4 +#define CPLE_IllegalArg 5 +#define CPLE_NotSupported 6 +#define CPLE_AssertionFailed 7 +#define CPLE_NoWriteAccess 8 +#define CPLE_UserInterrupt 9 +#define CPLE_ObjectNull 10 + +/* + * Filesystem-specific errors + */ +#define CPLE_HttpResponse 11 +#define CPLE_AWSBucketNotFound 12 +#define CPLE_AWSObjectNotFound 13 +#define CPLE_AWSAccessDenied 14 +#define CPLE_AWSInvalidCredentials 15 +#define CPLE_AWSSignatureDoesNotMatch 16 + +/* 100 - 299 reserved for GDAL */ + +#endif + +void CPL_DLL CPLError(CPLErr eErrClass, CPLErrorNum err_no, const char *fmt, ...) CPL_PRINT_FUNC_FORMAT (3, 4); +void CPL_DLL CPLErrorV(CPLErr, CPLErrorNum, const char *, va_list ); +void CPL_DLL CPLEmergencyError( const char * ) CPL_NO_RETURN; +void CPL_DLL CPL_STDCALL CPLErrorReset( void ); +CPLErrorNum CPL_DLL CPL_STDCALL CPLGetLastErrorNo( void ); +CPLErr CPL_DLL CPL_STDCALL CPLGetLastErrorType( void ); +const char CPL_DLL * CPL_STDCALL CPLGetLastErrorMsg( void ); +void CPL_DLL * CPL_STDCALL CPLGetErrorHandlerUserData(void); +void CPL_DLL CPLErrorSetState( CPLErr eErrClass, CPLErrorNum err_no, const char* pszMsg ); +void CPL_DLL CPLCleanupErrorMutex( void ); + +typedef void (CPL_STDCALL *CPLErrorHandler)(CPLErr, CPLErrorNum, const char*); + +void CPL_DLL CPL_STDCALL CPLLoggingErrorHandler( CPLErr, CPLErrorNum, const char * ); +void CPL_DLL CPL_STDCALL CPLDefaultErrorHandler( CPLErr, CPLErrorNum, const char * ); +void CPL_DLL CPL_STDCALL CPLQuietErrorHandler( CPLErr, CPLErrorNum, const char * ); +void CPLTurnFailureIntoWarning(int bOn ); + +CPLErrorHandler CPL_DLL CPL_STDCALL CPLSetErrorHandler(CPLErrorHandler); +CPLErrorHandler CPL_DLL CPL_STDCALL CPLSetErrorHandlerEx(CPLErrorHandler, void*); +void CPL_DLL CPL_STDCALL CPLPushErrorHandler( CPLErrorHandler ); +void CPL_DLL CPL_STDCALL CPLPushErrorHandlerEx( CPLErrorHandler, void* ); +void CPL_DLL CPL_STDCALL CPLSetCurrentErrorHandlerCatchDebug( int bCatchDebug ); +void CPL_DLL CPL_STDCALL CPLPopErrorHandler(void); + +void CPL_DLL CPL_STDCALL CPLDebug( const char *, const char *, ... ) CPL_PRINT_FUNC_FORMAT (2, 3); +void CPL_DLL CPL_STDCALL _CPLAssert( const char *, const char *, int ) CPL_NO_RETURN; + +#ifdef DEBUG +# define CPLAssert(expr) ((expr) ? (void)(0) : _CPLAssert(#expr,__FILE__,__LINE__)) +#else +# define CPLAssert(expr) +#endif + +CPL_C_END + +/* + * Helper macros used for input parameters validation. + */ +#ifdef DEBUG +# define VALIDATE_POINTER_ERR CE_Fatal +#else +# define VALIDATE_POINTER_ERR CE_Failure +#endif + +#define VALIDATE_POINTER0(ptr, func) \ + do { if( NULL == ptr ) \ + { \ + CPLErr const ret = VALIDATE_POINTER_ERR; \ + CPLError( ret, CPLE_ObjectNull, \ + "Pointer \'%s\' is NULL in \'%s\'.\n", #ptr, (func)); \ + return; }} while(0) + +#define VALIDATE_POINTER1(ptr, func, rc) \ + do { if( NULL == ptr ) \ + { \ + CPLErr const ret = VALIDATE_POINTER_ERR; \ + CPLError( ret, CPLE_ObjectNull, \ + "Pointer \'%s\' is NULL in \'%s\'.\n", #ptr, (func)); \ + return (rc); }} while(0) + +#endif /* CPL_ERROR_H_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/cpl_hash_set.h b/modules/globebrowsing/ext/gdal/include/cpl_hash_set.h new file mode 100644 index 0000000000..a0d8e296e2 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/cpl_hash_set.h @@ -0,0 +1,94 @@ +/********************************************************************** + * $Id$ + * + * Name: cpl_hash_set.h + * Project: CPL - Common Portability Library + * Purpose: Hash set functions. + * Author: Even Rouault, + * + ********************************************************************** + * Copyright (c) 2008-2009, Even Rouault + * + * 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. + ****************************************************************************/ + +#ifndef CPL_HASH_SET_H_INCLUDED +#define CPL_HASH_SET_H_INCLUDED + +#include "cpl_port.h" + +/** + * \file cpl_hash_set.h + * + * Hash set implementation. + * + * An hash set is a data structure that holds elements that are unique + * according to a comparison function. Operations on the hash set, such as + * insertion, removal or lookup, are supposed to be fast if an efficient + * "hash" function is provided. + */ + +CPL_C_START + +/* Types */ + +typedef struct _CPLHashSet CPLHashSet; + +typedef unsigned long (*CPLHashSetHashFunc)(const void* elt); + +typedef int (*CPLHashSetEqualFunc)(const void* elt1, const void* elt2); + +typedef void (*CPLHashSetFreeEltFunc)(void* elt); + +typedef int (*CPLHashSetIterEltFunc)(void* elt, void* user_data); + +/* Functions */ + +CPLHashSet CPL_DLL * CPLHashSetNew(CPLHashSetHashFunc fnHashFunc, + CPLHashSetEqualFunc fnEqualFunc, + CPLHashSetFreeEltFunc fnFreeEltFunc); + +void CPL_DLL CPLHashSetDestroy(CPLHashSet* set); + +void CPL_DLL CPLHashSetClear(CPLHashSet* set); + +int CPL_DLL CPLHashSetSize(const CPLHashSet* set); + +void CPL_DLL CPLHashSetForeach(CPLHashSet* set, + CPLHashSetIterEltFunc fnIterFunc, + void* user_data); + +int CPL_DLL CPLHashSetInsert(CPLHashSet* set, void* elt); + +void CPL_DLL * CPLHashSetLookup(CPLHashSet* set, const void* elt); + +int CPL_DLL CPLHashSetRemove(CPLHashSet* set, const void* elt); +int CPL_DLL CPLHashSetRemoveDeferRehash(CPLHashSet* set, const void* elt); + +unsigned long CPL_DLL CPLHashSetHashPointer(const void* elt); + +int CPL_DLL CPLHashSetEqualPointer(const void* elt1, const void* elt2); + +unsigned long CPL_DLL CPLHashSetHashStr(const void * pszStr); + +int CPL_DLL CPLHashSetEqualStr(const void* pszStr1, const void* pszStr2); + +CPL_C_END + +#endif /* CPL_HASH_SET_H_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/cpl_http.h b/modules/globebrowsing/ext/gdal/include/cpl_http.h new file mode 100644 index 0000000000..44500d1a55 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/cpl_http.h @@ -0,0 +1,105 @@ +/****************************************************************************** + * $Id$ + * + * Project: Common Portability Library + * Purpose: Function wrapper for libcurl HTTP access. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2006, Frank Warmerdam + * Copyright (c) 2009, Even Rouault + * + * 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. + ****************************************************************************/ + +#ifndef CPL_HTTP_H_INCLUDED +#define CPL_HTTP_H_INCLUDED + +#include "cpl_conv.h" +#include "cpl_string.h" +#include "cpl_vsi.h" + +/** + * \file cpl_http.h + * + * Interface for downloading HTTP, FTP documents + */ + +CPL_C_START + +/*! Describe a part of a multipart message */ +typedef struct { + /*! NULL terminated array of headers */ char **papszHeaders; + + /*! Buffer with data of the part */ GByte *pabyData; + /*! Buffer length */ int nDataLen; +} CPLMimePart; + +/*! Describe the result of a CPLHTTPFetch() call */ +typedef struct { + /*! cURL error code : 0=success, non-zero if request failed */ + int nStatus; + + /*! Content-Type of the response */ + char *pszContentType; + + /*! Error message from curl, or NULL */ + char *pszErrBuf; + + /*! Length of the pabyData buffer */ + int nDataLen; + int nDataAlloc; + + /*! Buffer with downloaded data */ + GByte *pabyData; + + /*! Headers returned */ + char **papszHeaders; + + /*! Number of parts in a multipart message */ + int nMimePartCount; + + /*! Array of parts (resolved by CPLHTTPParseMultipartMime()) */ + CPLMimePart *pasMimePart; + +} CPLHTTPResult; + +int CPL_DLL CPLHTTPEnabled( void ); +CPLHTTPResult CPL_DLL *CPLHTTPFetch( const char *pszURL, char **papszOptions); +void CPL_DLL CPLHTTPCleanup( void ); +void CPL_DLL CPLHTTPDestroyResult( CPLHTTPResult *psResult ); +int CPL_DLL CPLHTTPParseMultipartMime( CPLHTTPResult *psResult ); + +/* -------------------------------------------------------------------- */ +/* The following is related to OAuth2 authorization around */ +/* google services like fusion tables, and potentially others */ +/* in the future. Code in cpl_google_oauth2.cpp. */ +/* */ +/* These services are built on CPL HTTP services. */ +/* -------------------------------------------------------------------- */ + +char CPL_DLL *GOA2GetAuthorizationURL( const char *pszScope ); +char CPL_DLL *GOA2GetRefreshToken( const char *pszAuthToken, + const char *pszScope ); +char CPL_DLL *GOA2GetAccessToken( const char *pszRefreshToken, + const char *pszScope ); + +CPL_C_END + +#endif /* ndef CPL_HTTP_H_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/cpl_list.h b/modules/globebrowsing/ext/gdal/include/cpl_list.h new file mode 100644 index 0000000000..a8a433458f --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/cpl_list.h @@ -0,0 +1,72 @@ +/********************************************************************** + * $Id$ + * + * Name: cpl_list.h + * Project: CPL - Common Portability Library + * Purpose: List functions. + * Author: Andrey Kiselev, dron@remotesensing.org + * + ********************************************************************** + * Copyright (c) 2003, Andrey Kiselev + * + * 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. + ****************************************************************************/ + +#ifndef CPL_LIST_H_INCLUDED +#define CPL_LIST_H_INCLUDED + +#include "cpl_port.h" + +/** + * \file cpl_list.h + * + * Simplest list implementation. List contains only pointers to stored + * objects, not objects itself. All operations regarding allocation and + * freeing memory for objects should be performed by the caller. + * + */ + +CPL_C_START + +/** List element structure. */ +typedef struct _CPLList +{ + /*! Pointer to the data object. Should be allocated and freed by the + * caller. + * */ + void *pData; + /*! Pointer to the next element in list. NULL, if current element is the + * last one. + */ + struct _CPLList *psNext; +} CPLList; + +CPLList CPL_DLL *CPLListAppend( CPLList *psList, void * pData ); +CPLList CPL_DLL *CPLListInsert( CPLList *psList, void * pData, int nPosition ); +CPLList CPL_DLL *CPLListGetLast( CPLList *psList ); +CPLList CPL_DLL *CPLListGet( CPLList * const psList, int nPosition ); +int CPL_DLL CPLListCount( const CPLList *psList ); +CPLList CPL_DLL *CPLListRemove( CPLList *psList, int nPosition ); +void CPL_DLL CPLListDestroy( CPLList *psList ); +CPLList CPL_DLL *CPLListGetNext( const CPLList *psElement ); +void CPL_DLL *CPLListGetData( const CPLList *psElement ); + +CPL_C_END + +#endif /* CPL_LIST_H_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/cpl_minixml.h b/modules/globebrowsing/ext/gdal/include/cpl_minixml.h new file mode 100644 index 0000000000..fe199034e3 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/cpl_minixml.h @@ -0,0 +1,181 @@ +/********************************************************************** + * $Id$ + * + * Project: CPL - Common Portability Library + * Purpose: Declarations for MiniXML Handler. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ********************************************************************** + * Copyright (c) 2001, 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. + ****************************************************************************/ + +#ifndef CPL_MINIXML_H_INCLUDED +#define CPL_MINIXML_H_INCLUDED + +#include "cpl_port.h" + +/** + * \file cpl_minixml.h + * + * Definitions for CPL mini XML Parser/Serializer. + */ + +CPL_C_START + +typedef enum +{ + /*! Node is an element */ CXT_Element = 0, + /*! Node is a raw text value */ CXT_Text = 1, + /*! Node is attribute */ CXT_Attribute = 2, + /*! Node is an XML comment. */ CXT_Comment = 3, + /*! Node is a special literal */ CXT_Literal = 4 +} CPLXMLNodeType; + +/** + * Document node structure. + * + * This C structure is used to hold a single text fragment representing a + * component of the document when parsed. It should be allocated with the + * appropriate CPL function, and freed with CPLDestroyXMLNode(). The structure + * contents should not normally be altered by application code, but may be + * freely examined by application code. + * + * Using the psChild and psNext pointers, a hierarchical tree structure + * for a document can be represented as a tree of CPLXMLNode structures. + */ + +typedef struct CPLXMLNode +{ + /** + * \brief Node type + * + * One of CXT_Element, CXT_Text, CXT_Attribute, CXT_Comment, + * or CXT_Literal. + */ + CPLXMLNodeType eType; + + /** + * \brief Node value + * + * For CXT_Element this is the name of the element, without the angle + * brackets. Note there is a single CXT_Element even when the document + * contains a start and end element tag. The node represents the pair. + * All text or other elements between the start and end tag will appear + * as children nodes of this CXT_Element node. + * + * For CXT_Attribute the pszValue is the attribute name. The value of + * the attribute will be a CXT_Text child. + * + * For CXT_Text this is the text itself (value of an attribute, or a + * text fragment between an element start and end tags. + * + * For CXT_Literal it is all the literal text. Currently this is just + * used for !DOCTYPE lines, and the value would be the entire line. + * + * For CXT_Comment the value is all the literal text within the comment, + * but not including the comment start/end indicators ("<--" and "-->"). + */ + char *pszValue; + + /** + * \brief Next sibling. + * + * Pointer to next sibling, that is the next node appearing after this + * one that has the same parent as this node. NULL if this node is the + * last child of the parent element. + */ + struct CPLXMLNode *psNext; + + /** + * \brief Child node. + * + * Pointer to first child node, if any. Only CXT_Element and CXT_Attribute + * nodes should have children. For CXT_Attribute it should be a single + * CXT_Text value node, while CXT_Element can have any kind of child. + * The full list of children for a node are identified by walking the + * psNext's starting with the psChild node. + */ + + struct CPLXMLNode *psChild; +} CPLXMLNode; + + +CPLXMLNode CPL_DLL *CPLParseXMLString( const char * ); +void CPL_DLL CPLDestroyXMLNode( CPLXMLNode * ); +CPLXMLNode CPL_DLL *CPLGetXMLNode( CPLXMLNode *poRoot, + const char *pszPath ); +CPLXMLNode CPL_DLL *CPLSearchXMLNode( CPLXMLNode *poRoot, + const char *pszTarget ); +const char CPL_DLL *CPLGetXMLValue( CPLXMLNode *poRoot, + const char *pszPath, + const char *pszDefault ); +CPLXMLNode CPL_DLL *CPLCreateXMLNode( CPLXMLNode *poParent, + CPLXMLNodeType eType, + const char *pszText ); +char CPL_DLL *CPLSerializeXMLTree( const CPLXMLNode *psNode ); +void CPL_DLL CPLAddXMLChild( CPLXMLNode *psParent, + CPLXMLNode *psChild ); +int CPL_DLL CPLRemoveXMLChild( CPLXMLNode *psParent, + CPLXMLNode *psChild ); +void CPL_DLL CPLAddXMLSibling( CPLXMLNode *psOlderSibling, + CPLXMLNode *psNewSibling ); +CPLXMLNode CPL_DLL *CPLCreateXMLElementAndValue( CPLXMLNode *psParent, + const char *pszName, + const char *pszValue ); +void CPL_DLL CPLAddXMLAttributeAndValue( CPLXMLNode *psParent, + const char *pszName, + const char *pszValue ); +CPLXMLNode CPL_DLL *CPLCloneXMLTree( CPLXMLNode *psTree ); +int CPL_DLL CPLSetXMLValue( CPLXMLNode *psRoot, const char *pszPath, + const char *pszValue ); +void CPL_DLL CPLStripXMLNamespace( CPLXMLNode *psRoot, + const char *pszNameSpace, + int bRecurse ); +void CPL_DLL CPLCleanXMLElementName( char * ); + +CPLXMLNode CPL_DLL *CPLParseXMLFile( const char *pszFilename ); +int CPL_DLL CPLSerializeXMLTreeToFile( const CPLXMLNode *psTree, + const char *pszFilename ); + +CPL_C_END + +#ifdef __cplusplus +// Manage a tree of XML nodes so that all nodes are freed when the instance goes +// out of scope. Only the top level node should be in a CPLXMLTreeCloser. +class CPLXMLTreeCloser { + public: + explicit CPLXMLTreeCloser(CPLXMLNode* data) { the_data_ = data; } + + ~CPLXMLTreeCloser() { + if (the_data_) CPLDestroyXMLNode(the_data_); + } + + // Modifying the contents pointed to by the return is allowed. + CPLXMLNode* get() const { return the_data_; } + + CPLXMLNode* operator->() const { return get(); } + + private: + CPLXMLNode* the_data_; +}; +#endif /* __cplusplus */ + +#endif /* CPL_MINIXML_H_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/cpl_minizip_ioapi.h b/modules/globebrowsing/ext/gdal/include/cpl_minizip_ioapi.h new file mode 100644 index 0000000000..15f188d5a5 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/cpl_minizip_ioapi.h @@ -0,0 +1,82 @@ +/* Modified version by Even Rouault. : + - change fill_fopen_filefunc to cpl_fill_fopen_filefunc + - Add support for ZIP64 + + * Copyright (c) 2008-2012, Even Rouault + + Original licence available in port/LICENCE_minizip +*/ + +/* ioapi.h -- IO base function header for compress/uncompress .zip + files using zlib + zip or unzip API + + Version 1.01e, February 12th, 2005 + + Copyright (C) 1998-2005 Gilles Vollant +*/ + +#ifndef CPL_MINIZIP_IOAPI_H_INCLUDED +#define CPL_MINIZIP_IOAPI_H_INCLUDED + +#include "cpl_vsi.h" +#define uLong64 vsi_l_offset + +#define ZLIB_FILEFUNC_SEEK_CUR (1) +#define ZLIB_FILEFUNC_SEEK_END (2) +#define ZLIB_FILEFUNC_SEEK_SET (0) + +#define ZLIB_FILEFUNC_MODE_READ (1) +#define ZLIB_FILEFUNC_MODE_WRITE (2) +#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3) + +#define ZLIB_FILEFUNC_MODE_EXISTING (4) +#define ZLIB_FILEFUNC_MODE_CREATE (8) + +#ifndef ZCALLBACK + +#if (defined(WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK) +#define ZCALLBACK CALLBACK +#else +#define ZCALLBACK +#endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef voidpf (ZCALLBACK *open_file_func) (voidpf opaque, const char* filename, int mode); +typedef uLong (ZCALLBACK *read_file_func) (voidpf opaque, voidpf stream, void* buf, uLong size); +typedef uLong (ZCALLBACK *write_file_func) (voidpf opaque, voidpf stream, const void* buf, uLong size); +typedef uLong64 (ZCALLBACK *tell_file_func) (voidpf opaque, voidpf stream); +typedef long (ZCALLBACK *seek_file_func) (voidpf opaque, voidpf stream, uLong64 offset, int origin); +typedef int (ZCALLBACK *close_file_func) (voidpf opaque, voidpf stream); +typedef int (ZCALLBACK *testerror_file_func) (voidpf opaque, voidpf stream); + +typedef struct zlib_filefunc_def_s +{ + open_file_func zopen_file; + read_file_func zread_file; + write_file_func zwrite_file; + tell_file_func ztell_file; + seek_file_func zseek_file; + close_file_func zclose_file; + testerror_file_func zerror_file; + voidpf opaque; +} zlib_filefunc_def; + +void cpl_fill_fopen_filefunc (zlib_filefunc_def* pzlib_filefunc_def); + +#define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((filefunc).opaque,filestream,buf,size)) +#define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))((filefunc).opaque,filestream,buf,size)) +#define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque,filestream)) +#define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque,filestream,pos,mode)) +#define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc).opaque,filestream)) +#define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaque,filestream)) + + +#ifdef __cplusplus +} +#endif + +#endif /* CPL_MINIZIP_IOAPI_H_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/cpl_minizip_unzip.h b/modules/globebrowsing/ext/gdal/include/cpl_minizip_unzip.h new file mode 100644 index 0000000000..b02d830a03 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/cpl_minizip_unzip.h @@ -0,0 +1,381 @@ +/* Modified version by Even Rouault. : + - Addition of cpl_unzGetCurrentFileZStreamPos + - Decoration of symbol names unz* -> cpl_unz* + - Undef EXPORT so that we are sure the symbols are not exported + - Add support for ZIP64 + + * Copyright (c) 2008, Even Rouault + + Original licence available in port/LICENCE_minizip +*/ + +/* unzip.h -- IO for uncompress .zip files using zlib + Version 1.01e, February 12th, 2005 + + Copyright (C) 1998-2005 Gilles Vollant + + This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g + WinZip, InfoZip tools and compatible. + + Multi volume ZipFile (span) are not supported. + Encryption compatible with pkzip 2.04g only supported + Old compressions used by old PKZip 1.x are not supported + + + I WAIT FEEDBACK at mail info@winimage.com + Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution + + Condition of use and distribution are the same than zlib : + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + +*/ + +/* for more info about .ZIP format, see + http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip + http://www.info-zip.org/pub/infozip/doc/ + PkWare has also a specification at : + ftp://ftp.pkware.com/probdesc.zip +*/ + +#ifndef CPL_MINIZIP_UNZIP_H_INCLUDED +#define CPL_MINIZIP_UNZIP_H_INCLUDED + +#include "cpl_vsi.h" +#define uLong64 vsi_l_offset + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _ZLIB_H +#include +#endif + +#ifndef CPL_MINIZIP_IOAPI_H_INCLUDED +#include "cpl_minizip_ioapi.h" +#endif + +/* GDAL addition */ +#define NOUNCRYPT +#undef ZEXPORT +#define ZEXPORT + +#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP) +/* like the STRICT of WIN32, we define a pointer that cannot be converted + from (void*) without cast */ +typedef struct TagunzFile__ { int unused; } unzFile__; +typedef unzFile__ *unzFile; +#else +typedef voidp unzFile; +#endif + + +#define UNZ_OK (0) +#define UNZ_END_OF_LIST_OF_FILE (-100) +#define UNZ_ERRNO (Z_ERRNO) +#define UNZ_EOF (0) +#define UNZ_PARAMERROR (-102) +#define UNZ_BADZIPFILE (-103) +#define UNZ_INTERNALERROR (-104) +#define UNZ_CRCERROR (-105) + +/* tm_unz contain date/time info */ +typedef struct tm_unz_s +{ + uInt tm_sec; /* seconds after the minute - [0,59] */ + uInt tm_min; /* minutes after the hour - [0,59] */ + uInt tm_hour; /* hours since midnight - [0,23] */ + uInt tm_mday; /* day of the month - [1,31] */ + uInt tm_mon; /* months since January - [0,11] */ + uInt tm_year; /* years - [1980..2044] */ +} tm_unz; + +/* unz_global_info structure contain global data about the ZIPfile + These data comes from the end of central dir */ +typedef struct unz_global_info_s +{ + uLong64 number_entry; /* total number of entries in + the central dir on this disk */ + uLong size_comment; /* size of the global comment of the zipfile */ +} unz_global_info; + + +/* unz_file_info contain information about a file in the zipfile */ +typedef struct unz_file_info_s +{ + uLong version; /* version made by 2 bytes */ + uLong version_needed; /* version needed to extract 2 bytes */ + uLong flag; /* general purpose bit flag 2 bytes */ + uLong compression_method; /* compression method 2 bytes */ + uLong dosDate; /* last mod file date in Dos fmt 4 bytes */ + uLong crc; /* crc-32 4 bytes */ + uLong64 compressed_size; /* compressed size 4 bytes */ + uLong64 uncompressed_size; /* uncompressed size 4 bytes */ + uLong size_filename; /* filename length 2 bytes */ + uLong size_file_extra; /* extra field length 2 bytes */ + uLong size_file_comment; /* file comment length 2 bytes */ + + uLong disk_num_start; /* disk number start 2 bytes */ + uLong internal_fa; /* internal file attributes 2 bytes */ + uLong external_fa; /* external file attributes 4 bytes */ + + tm_unz tmu_date; +} unz_file_info; + +extern int ZEXPORT cpl_unzStringFileNameCompare (const char* fileName1, + const char* fileName2, + int iCaseSensitivity); +/* + Compare two filename (fileName1,fileName2). + If iCaseSenisivity = 1, comparison is case sensitivity (like strcmp) + If iCaseSenisivity = 2, comparison is not case sensitivity (like strcmpi + or strcasecmp) + If iCaseSenisivity = 0, case sensitivity is default of your operating system + (like 1 on Unix, 2 on Windows) +*/ + + +extern unzFile ZEXPORT cpl_unzOpen (const char *path); +/* + Open a Zip file. path contain the full pathname (by example, + on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer + "zlib/zlib113.zip". + If the zipfile cannot be opened (file don't exist or in not valid), the + return value is NULL. + Else, the return value is a unzFile Handle, usable with other function + of this unzip package. +*/ + +extern unzFile ZEXPORT cpl_unzOpen2 (const char *path, + zlib_filefunc_def* pzlib_filefunc_def); +/* + Open a Zip file, like unzOpen, but provide a set of file low level API + for read/write the zip file (see ioapi.h) +*/ + +extern int ZEXPORT cpl_unzClose (unzFile file); +/* + Close a ZipFile opened with unzipOpen. + If there is files inside the .Zip opened with unzOpenCurrentFile (see later), + these files MUST be closed with unzipCloseCurrentFile before call unzipClose. + return UNZ_OK if there is no problem. */ + +extern int ZEXPORT cpl_unzGetGlobalInfo (unzFile file, + unz_global_info *pglobal_info); +/* + Write info about the ZipFile in the *pglobal_info structure. + No preparation of the structure is needed + return UNZ_OK if there is no problem. */ + + +extern int ZEXPORT cpl_unzGetGlobalComment (unzFile file, + char *szComment, + uLong uSizeBuf); +/* + Get the global comment string of the ZipFile, in the szComment buffer. + uSizeBuf is the size of the szComment buffer. + return the number of byte copied or an error code <0 +*/ + + +/***************************************************************************/ +/* Unzip package allow you browse the directory of the zipfile */ + +extern int ZEXPORT cpl_unzGoToFirstFile (unzFile file); +/* + Set the current file of the zipfile to the first file. + return UNZ_OK if there is no problem +*/ + +extern int ZEXPORT cpl_unzGoToNextFile (unzFile file); +/* + Set the current file of the zipfile to the next file. + return UNZ_OK if there is no problem + return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. +*/ + +extern int ZEXPORT cpl_unzLocateFile (unzFile file, + const char *szFileName, + int iCaseSensitivity); +/* + Try locate the file szFileName in the zipfile. + For the iCaseSensitivity signification, see unzStringFileNameCompare + + return value : + UNZ_OK if the file is found. It becomes the current file. + UNZ_END_OF_LIST_OF_FILE if the file is not found +*/ + + +/* ****************************************** */ +/* Ryan supplied functions */ +/* unz_file_info contain information about a file in the zipfile */ +typedef struct unz_file_pos_s +{ + uLong64 pos_in_zip_directory; /* offset in zip file directory */ + uLong64 num_of_file; /* # of file */ +} unz_file_pos; + +extern int ZEXPORT cpl_unzGetFilePos( + unzFile file, + unz_file_pos* file_pos); + +extern int ZEXPORT cpl_unzGoToFilePos( + unzFile file, + unz_file_pos* file_pos); + +/* ****************************************** */ + +extern int ZEXPORT cpl_unzGetCurrentFileInfo (unzFile file, + unz_file_info *pfile_info, + char *szFileName, + uLong fileNameBufferSize, + void *extraField, + uLong extraFieldBufferSize, + char *szComment, + uLong commentBufferSize); +/* + Get Info about the current file + if pfile_info!=NULL, the *pfile_info structure will contain some info about + the current file + if szFileName!=NULL, the filename string will be copied in szFileName + (fileNameBufferSize is the size of the buffer) + if extraField!=NULL, the extra field information will be copied in extraField + (extraFieldBufferSize is the size of the buffer). + This is the Central-header version of the extra field + if szComment!=NULL, the comment string of the file will be copied in szComment + (commentBufferSize is the size of the buffer) +*/ + + +/** Addition for GDAL : START */ + +extern uLong64 ZEXPORT cpl_unzGetCurrentFileZStreamPos (unzFile file); + +/** Addition for GDAL : END */ + + +/***************************************************************************/ +/* for reading the content of the current zipfile, you can open it, read data + from it, and close it (you can close it before reading all the file) + */ + +extern int ZEXPORT cpl_unzOpenCurrentFile (unzFile file); +/* + Open for reading data the current file in the zipfile. + If there is no error, the return value is UNZ_OK. +*/ + +extern int ZEXPORT cpl_unzOpenCurrentFilePassword (unzFile file, + const char* password); +/* + Open for reading data the current file in the zipfile. + password is a crypting password + If there is no error, the return value is UNZ_OK. +*/ + +extern int ZEXPORT cpl_unzOpenCurrentFile2 (unzFile file, + int* method, + int* level, + int raw); +/* + Same than unzOpenCurrentFile, but open for read raw the file (not uncompress) + if raw==1 + *method will receive method of compression, *level will receive level of + compression + note : you can set level parameter as NULL (if you did not want known level, + but you CANNOT set method parameter as NULL +*/ + +extern int ZEXPORT cpl_unzOpenCurrentFile3 (unzFile file, + int* method, + int* level, + int raw, + const char* password); +/* + Same than unzOpenCurrentFile, but open for read raw the file (not uncompress) + if raw==1 + *method will receive method of compression, *level will receive level of + compression + note : you can set level parameter as NULL (if you did not want known level, + but you CANNOT set method parameter as NULL +*/ + + +extern int ZEXPORT cpl_unzCloseCurrentFile (unzFile file); +/* + Close the file in zip opened with unzOpenCurrentFile + Return UNZ_CRCERROR if all the file was read but the CRC is not good +*/ + +extern int ZEXPORT cpl_unzReadCurrentFile (unzFile file, + voidp buf, + unsigned len); +/* + Read bytes from the current file (opened by unzOpenCurrentFile) + buf contain buffer where data must be copied + len the size of buf. + + return the number of byte copied if some bytes are copied + return 0 if the end of file was reached + return <0 with error code if there is an error + (UNZ_ERRNO for IO error, or zLib error for uncompress error) +*/ + +extern z_off_t ZEXPORT cpl_unztell (unzFile file); +/* + Give the current position in uncompressed data +*/ + +extern int ZEXPORT cpl_unzeof (unzFile file); +/* + return 1 if the end of file was reached, 0 elsewhere +*/ + +extern int ZEXPORT cpl_unzGetLocalExtrafield (unzFile file, + voidp buf, + unsigned len); +/* + Read extra field from the current file (opened by unzOpenCurrentFile) + This is the local-header version of the extra field (sometimes, there is + more info in the local-header version than in the central-header) + + if buf==NULL, it return the size of the local extra field + + if buf!=NULL, len is the size of the buffer, the extra header is copied in + buf. + the return value is the number of bytes copied in buf, or (if <0) + the error code +*/ + +/***************************************************************************/ + +/* Get the current file offset */ +extern uLong64 ZEXPORT cpl_unzGetOffset (unzFile file); + +/* Set the current file offset */ +extern int ZEXPORT cpl_unzSetOffset (unzFile file, uLong64 pos); + + + +#ifdef __cplusplus +} +#endif + +#endif /* CPL_MINIZIP_UNZIP_H_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/cpl_minizip_zip.h b/modules/globebrowsing/ext/gdal/include/cpl_minizip_zip.h new file mode 100644 index 0000000000..93a652e2cf --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/cpl_minizip_zip.h @@ -0,0 +1,259 @@ +/****************************************************************************** + * $Id$ + * + * Project: CPL - Common Portability Library + * Author: Frank Warmerdam, warmerdam@pobox.com + * Purpose: Adjusted minizip "zip.h" include file for zip services. + * + * Modified version by Even Rouault. : + * - Decoration of symbol names unz* -> cpl_unz* + * - Undef EXPORT so that we are sure the symbols are not exported + * - Remove old C style function prototypes + * - Added CPL* simplified API at bottom. + * + * Original licence available in port/LICENCE_minizip + * + *****************************************************************************/ + +/* zip.h -- IO for compress .zip files using zlib + Version 1.01e, February 12th, 2005 + + Copyright (C) 1998-2005 Gilles Vollant + + This unzip package allow creates .ZIP file, compatible with PKZip 2.04g + WinZip, InfoZip tools and compatible. + Multi volume ZipFile (span) are not supported. + Encryption compatible with pkzip 2.04g only supported + Old compressions used by old PKZip 1.x are not supported + + For uncompress .zip file, look at unzip.h + + + I WAIT FEEDBACK at mail info@winimage.com + Visit also http://www.winimage.com/zLibDll/unzip.html for evolution + + Condition of use and distribution are the same than zlib : + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + +*/ + +/* for more info about .ZIP format, see + http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip + http://www.info-zip.org/pub/infozip/doc/ + PkWare has also a specification at : + ftp://ftp.pkware.com/probdesc.zip +*/ + +#ifndef CPL_MINIZIP_ZIP_H_INCLUDED +#define CPL_MINIZIP_ZIP_H_INCLUDED + +#include "cpl_vsi.h" +#define uLong64 vsi_l_offset + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _ZLIB_H +#include "zlib.h" +#endif + +#ifndef CPL_MINIZIP_IOAPI_H_INCLUDED +#include "cpl_minizip_ioapi.h" +#endif + +#define NOCRYPT +#undef ZEXPORT +#define ZEXPORT + +#if defined(STRICTZIP) || defined(STRICTZIPUNZIP) +/* like the STRICT of WIN32, we define a pointer that cannot be converted + from (void*) without cast */ +typedef struct TagzipFile__ { int unused; } zipFile__; +typedef zipFile__ *zipFile; +#else +typedef voidp zipFile; +#endif + +#define ZIP_OK (0) +#define ZIP_EOF (0) +#define ZIP_ERRNO (Z_ERRNO) +#define ZIP_PARAMERROR (-102) +#define ZIP_BADZIPFILE (-103) +#define ZIP_INTERNALERROR (-104) + +#ifndef DEF_MEM_LEVEL +# if MAX_MEM_LEVEL >= 8 +# define DEF_MEM_LEVEL 8 +# else +# define DEF_MEM_LEVEL MAX_MEM_LEVEL +# endif +#endif +/* default memLevel */ + +/* tm_zip contain date/time info */ +typedef struct tm_zip_s +{ + uInt tm_sec; /* seconds after the minute - [0,59] */ + uInt tm_min; /* minutes after the hour - [0,59] */ + uInt tm_hour; /* hours since midnight - [0,23] */ + uInt tm_mday; /* day of the month - [1,31] */ + uInt tm_mon; /* months since January - [0,11] */ + uInt tm_year; /* years - [1980..2044] */ +} tm_zip; + +typedef struct +{ + tm_zip tmz_date; /* date in understandable format */ + uLong dosDate; /* if dos_date == 0, tmu_date is used */ +/* uLong flag; */ /* general purpose bit flag 2 bytes */ + + uLong internal_fa; /* internal file attributes 2 bytes */ + uLong external_fa; /* external file attributes 4 bytes */ +} zip_fileinfo; + +typedef const char* zipcharpc; + + +#define APPEND_STATUS_CREATE (0) +#define APPEND_STATUS_CREATEAFTER (1) +#define APPEND_STATUS_ADDINZIP (2) + +extern zipFile ZEXPORT cpl_zipOpen (const char *pathname, int append); +/* + Create a zipfile. + pathname contain on Windows XP a filename like "c:\\zlib\\zlib113.zip" or on + an Unix computer "zlib/zlib113.zip". + if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip + will be created at the end of the file. + (useful if the file contain a self extractor code) + if the file pathname exist and append==APPEND_STATUS_ADDINZIP, we will + add files in existing zip (be sure you don't add file that doesn't exist) + If the zipfile cannot be opened, the return value is NULL. + Else, the return value is a zipFile Handle, usable with other function + of this zip package. +*/ + +/* Note : there is no delete function for a zipfile. + If you want delete file in a zipfile, you must open a zipfile, and create another. + Of course, you can use RAW reading and writing to copy the file you did not want delete. +*/ + +extern zipFile ZEXPORT cpl_zipOpen2 (const char *pathname, + int append, + zipcharpc* globalcomment, + zlib_filefunc_def* pzlib_filefunc_def); + +extern int ZEXPORT cpl_zipOpenNewFileInZip (zipFile file, + const char* filename, + const zip_fileinfo* zipfi, + const void* extrafield_local, + uInt size_extrafield_local, + const void* extrafield_global, + uInt size_extrafield_global, + const char* comment, + int method, + int level); +/* + Open a file in the ZIP for writing. + filename : the filename in zip (if NULL, '-' without quote will be used + *zipfi contain supplemental information + if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local + contains the extrafield data the local header + if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global + contains the extrafield data the local header + if comment != NULL, comment contain the comment string + method contain the compression method (0 for store, Z_DEFLATED for deflate) + level contain the level of compression (can be Z_DEFAULT_COMPRESSION) +*/ + + +extern int ZEXPORT cpl_zipOpenNewFileInZip2 (zipFile file, + const char* filename, + const zip_fileinfo* zipfi, + const void* extrafield_local, + uInt size_extrafield_local, + const void* extrafield_global, + uInt size_extrafield_global, + const char* comment, + int method, + int level, + int raw); + +/* + Same than zipOpenNewFileInZip, except if raw=1, we write raw file + */ + +extern int ZEXPORT cpl_zipOpenNewFileInZip3 (zipFile file, + const char* filename, + const zip_fileinfo* zipfi, + const void* extrafield_local, + uInt size_extrafield_local, + const void* extrafield_global, + uInt size_extrafield_global, + const char* comment, + int method, + int level, + int raw, + int windowBits, + int memLevel, + int strategy, + const char* password, + uLong crcForCtypting); + +/* + Same than zipOpenNewFileInZip2, except + windowBits,memLevel,,strategy : see parameter strategy in deflateInit2 + password : crypting password (NULL for no crypting) + crcForCtypting : crc of file to compress (needed for crypting) + */ + + +extern int ZEXPORT cpl_zipWriteInFileInZip (zipFile file, + const void* buf, + unsigned len); +/* + Write data in the zipfile +*/ + +extern int ZEXPORT cpl_zipCloseFileInZip (zipFile file); +/* + Close the current file in the zipfile +*/ + +extern int ZEXPORT cpl_zipCloseFileInZipRaw (zipFile file, + uLong uncompressed_size, + uLong crc32); +/* + Close the current file in the zipfile, for file opened with + parameter raw=1 in zipOpenNewFileInZip2 + uncompressed_size and crc32 are value for the uncompressed size +*/ + +extern int ZEXPORT cpl_zipClose (zipFile file, + const char* global_comment); +/* + Close the zipfile +*/ + +#ifdef __cplusplus +} +#endif + +#endif /* _zip_H */ diff --git a/modules/globebrowsing/ext/gdal/include/cpl_multiproc.h b/modules/globebrowsing/ext/gdal/include/cpl_multiproc.h new file mode 100644 index 0000000000..d07841dd49 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/cpl_multiproc.h @@ -0,0 +1,234 @@ +/********************************************************************** + * $Id$ + * + * Project: CPL - Common Portability Library + * Purpose: CPL Multi-Threading, and process handling portability functions. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ********************************************************************** + * Copyright (c) 2002, Frank Warmerdam + * Copyright (c) 2008-2013, Even Rouault + * + * 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. + ****************************************************************************/ + +#ifndef CPL_MULTIPROC_H_INCLUDED_ +#define CPL_MULTIPROC_H_INCLUDED_ + +#include "cpl_port.h" + +/* +** There are three primary implementations of the multi-process support +** controlled by one of CPL_MULTIPROC_WIN32, CPL_MULTIPROC_PTHREAD or +** CPL_MULTIPROC_STUB being defined. If none are defined, the stub +** implementation will be used. +*/ + +#if defined(WIN32) && !defined(CPL_MULTIPROC_STUB) +# define CPL_MULTIPROC_WIN32 +/* MinGW can have pthread support, so disable it to avoid issues */ +/* in cpl_multiproc.cpp */ +# undef CPL_MULTIPROC_PTHREAD +#endif + +#if !defined(CPL_MULTIPROC_WIN32) && !defined(CPL_MULTIPROC_PTHREAD) \ + && !defined(CPL_MULTIPROC_STUB) && !defined(CPL_MULTIPROC_NONE) +# define CPL_MULTIPROC_STUB +#endif + +CPL_C_START + +typedef void (*CPLThreadFunc)(void *); + +void CPL_DLL *CPLLockFile( const char *pszPath, double dfWaitInSeconds ); +void CPL_DLL CPLUnlockFile( void *hLock ); + +#ifdef DEBUG +typedef struct _CPLMutex CPLMutex; +typedef struct _CPLCond CPLCond; +typedef struct _CPLJoinableThread CPLJoinableThread; +#else +#define CPLMutex void +#define CPLCond void +#define CPLJoinableThread void +#endif + +/* Options for CPLCreateMutexEx() and CPLCreateOrAcquireMutexEx() */ +#define CPL_MUTEX_RECURSIVE 0 +#define CPL_MUTEX_ADAPTIVE 1 +#define CPL_MUTEX_REGULAR 2 + +CPLMutex CPL_DLL *CPLCreateMutex( void ); /* returned acquired */ +CPLMutex CPL_DLL *CPLCreateMutexEx( int nOptions ); /* returned acquired */ +int CPL_DLL CPLCreateOrAcquireMutex( CPLMutex **, double dfWaitInSeconds ); +int CPL_DLL CPLCreateOrAcquireMutexEx( CPLMutex **, double dfWaitInSeconds, int nOptions ); +int CPL_DLL CPLAcquireMutex( CPLMutex *hMutex, double dfWaitInSeconds ); +void CPL_DLL CPLReleaseMutex( CPLMutex *hMutex ); +void CPL_DLL CPLDestroyMutex( CPLMutex *hMutex ); +void CPL_DLL CPLCleanupMasterMutex( void ); + +CPLCond CPL_DLL *CPLCreateCond( void ); +void CPL_DLL CPLCondWait( CPLCond *hCond, CPLMutex* hMutex ); +void CPL_DLL CPLCondSignal( CPLCond *hCond ); +void CPL_DLL CPLCondBroadcast( CPLCond *hCond ); +void CPL_DLL CPLDestroyCond( CPLCond *hCond ); + +/** Contrary to what its name suggests, CPLGetPID() actually returns the thread id */ +GIntBig CPL_DLL CPLGetPID( void ); +int CPL_DLL CPLGetCurrentProcessID( void ); +int CPL_DLL CPLCreateThread( CPLThreadFunc pfnMain, void *pArg ); +CPLJoinableThread CPL_DLL* CPLCreateJoinableThread( CPLThreadFunc pfnMain, void *pArg ); +void CPL_DLL CPLJoinThread(CPLJoinableThread* hJoinableThread); +void CPL_DLL CPLSleep( double dfWaitInSeconds ); + +const char CPL_DLL *CPLGetThreadingModel( void ); + +int CPL_DLL CPLGetNumCPUs( void ); + + +typedef struct _CPLLock CPLLock; + +/* Currently LOCK_ADAPTIVE_MUTEX is Linux-only and LOCK_SPIN only available */ +/* on systems with pthread_spinlock API (so not MacOsX). If a requested type */ +/* isn't available, it fallbacks to LOCK_RECURSIVE_MUTEX */ +typedef enum +{ + LOCK_RECURSIVE_MUTEX, + LOCK_ADAPTIVE_MUTEX, + LOCK_SPIN +} CPLLockType; + +CPLLock CPL_DLL *CPLCreateLock( CPLLockType eType ); /* returned NON acquired */ +int CPL_DLL CPLCreateOrAcquireLock( CPLLock**, CPLLockType eType ); +int CPL_DLL CPLAcquireLock( CPLLock* ); +void CPL_DLL CPLReleaseLock( CPLLock* ); +void CPL_DLL CPLDestroyLock( CPLLock* ); +void CPL_DLL CPLLockSetDebugPerf( CPLLock*, int bEnableIn ); /* only available on x86/x86_64 with GCC for now */ + + +CPL_C_END + +#ifdef __cplusplus + +/* Instantiates the mutex if not already done. The parameter x should be a (void**). */ +#define CPLMutexHolderD(x) CPLMutexHolder oHolder(x,1000.0,__FILE__,__LINE__); + +/* Instantiates the mutex with options if not already done. */ +/* The parameter x should be a (void**). */ +#define CPLMutexHolderExD(x, nOptions) CPLMutexHolder oHolder(x,1000.0,__FILE__,__LINE__,nOptions); + +/* This variant assumes the mutex has already been created. If not, it will */ +/* be a no-op. The parameter x should be a (void*) */ +#define CPLMutexHolderOptionalLockD(x) CPLMutexHolder oHolder(x,1000.0,__FILE__,__LINE__); + +class CPL_DLL CPLMutexHolder +{ + private: + CPLMutex *hMutex; + const char *pszFile; + int nLine; + + public: + + /* Instantiates the mutex if not already done. */ + CPLMutexHolder( CPLMutex **phMutex, double dfWaitInSeconds = 1000.0, + const char *pszFile = __FILE__, + int nLine = __LINE__, + int nOptions = CPL_MUTEX_RECURSIVE); + + /* This variant assumes the mutex has already been created. If not, it will */ + /* be a no-op */ + CPLMutexHolder( CPLMutex* hMutex, double dfWaitInSeconds = 1000.0, + const char *pszFile = __FILE__, + int nLine = __LINE__ ); + + ~CPLMutexHolder(); +}; + +/* Instantiates the lock if not already done. The parameter x should be a (CPLLock**). */ +#define CPLLockHolderD(x, eType) CPLLockHolder oHolder(x,eType,__FILE__,__LINE__); + +/* This variant assumes the lock has already been created. If not, it will */ +/* be a no-op. The parameter should be (CPLLock*) */ +#define CPLLockHolderOptionalLockD(x) CPLLockHolder oHolder(x,__FILE__,__LINE__); + +class CPL_DLL CPLLockHolder +{ + private: + CPLLock *hLock; + const char *pszFile; + int nLine; + + public: + + /* Instantiates the lock if not already done. */ + CPLLockHolder( CPLLock **phSpin, CPLLockType eType, + const char *pszFile = __FILE__, + int nLine = __LINE__); + + /* This variant assumes the lock has already been created. If not, it will */ + /* be a no-op */ + CPLLockHolder( CPLLock* hSpin, + const char *pszFile = __FILE__, + int nLine = __LINE__ ); + + ~CPLLockHolder(); +}; + + +#endif /* def __cplusplus */ + +/* -------------------------------------------------------------------- */ +/* Thread local storage. */ +/* -------------------------------------------------------------------- */ + +#define CTLS_RLBUFFERINFO 1 /* cpl_conv.cpp */ +#define CTLS_WIN32_COND 2 /* cpl_multiproc.cpp */ +#define CTLS_CSVTABLEPTR 3 /* cpl_csv.cpp */ +#define CTLS_CSVDEFAULTFILENAME 4 /* cpl_csv.cpp */ +#define CTLS_ERRORCONTEXT 5 /* cpl_error.cpp */ +#define CTLS_GDALDATASET_REC_PROTECT_MAP 6 /* gdaldataset.cpp */ +#define CTLS_PATHBUF 7 /* cpl_path.cpp */ +#define CTLS_UNUSED3 8 +#define CTLS_UNUSED4 9 +#define CTLS_CPLSPRINTF 10 /* cpl_string.h */ +#define CTLS_RESPONSIBLEPID 11 /* gdaldataset.cpp */ +#define CTLS_VERSIONINFO 12 /* gdal_misc.cpp */ +#define CTLS_VERSIONINFO_LICENCE 13 /* gdal_misc.cpp */ +#define CTLS_CONFIGOPTIONS 14 /* cpl_conv.cpp */ +#define CTLS_FINDFILE 15 /* cpl_findfile.cpp */ +#define CTLS_VSIERRORCONTEXT 16 /* cpl_vsi_error.cpp */ + +#define CTLS_MAX 32 + +CPL_C_START +void CPL_DLL * CPLGetTLS( int nIndex ); +void CPL_DLL * CPLGetTLSEx( int nIndex, int* pbMemoryErrorOccurred ); +void CPL_DLL CPLSetTLS( int nIndex, void *pData, int bFreeOnExit ); + +/* Warning : the CPLTLSFreeFunc must not in any case directly or indirectly */ +/* use or fetch any TLS data, or a terminating thread will hang ! */ +typedef void (*CPLTLSFreeFunc)( void* pData ); +void CPL_DLL CPLSetTLSWithFreeFunc( int nIndex, void *pData, CPLTLSFreeFunc pfnFree ); +void CPL_DLL CPLSetTLSWithFreeFuncEx( int nIndex, void *pData, CPLTLSFreeFunc pfnFree, int* pbMemoryErrorOccurred ); + +void CPL_DLL CPLCleanupTLS( void ); +CPL_C_END + +#endif /* CPL_MULTIPROC_H_INCLUDED_ */ diff --git a/modules/globebrowsing/ext/gdal/include/cpl_odbc.h b/modules/globebrowsing/ext/gdal/include/cpl_odbc.h new file mode 100644 index 0000000000..cf47b8687c --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/cpl_odbc.h @@ -0,0 +1,281 @@ +/****************************************************************************** + * $Id$ + * + * Project: OGR ODBC Driver + * Purpose: Declarations for ODBC Access Cover API. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2003, 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. + ****************************************************************************/ + +#ifndef CPL_ODBC_H_INCLUDED +#define CPL_ODBC_H_INCLUDED + +#include "cpl_port.h" + +#ifdef WIN32 +# include +#endif + +#include +#include +#include +#include "cpl_string.h" + +#ifdef PATH_MAX +# define ODBC_FILENAME_MAX PATH_MAX +#else +# define ODBC_FILENAME_MAX (255 + 1) /* Max path length */ +#endif + + +/** + * \file cpl_odbc.h + * + * ODBC Abstraction Layer (C++). + */ + +/** + * A class providing functions to install or remove ODBC driver. + */ +class CPL_DLL CPLODBCDriverInstaller +{ + char m_szPathOut[ODBC_FILENAME_MAX]; + char m_szError[SQL_MAX_MESSAGE_LENGTH]; + DWORD m_nErrorCode; + DWORD m_nUsageCount; + + public: + + // Default constructor. + CPLODBCDriverInstaller(); + + + /** + * Installs ODBC driver or updates definition of already installed driver. + * Interanally, it calls ODBC's SQLInstallDriverEx function. + * + * @param pszDriver - The driver definition as a list of keyword-value + * pairs describing the driver (See ODBC API Reference). + * + * @param pszPathIn - Full path of the target directory of the installation, + * or a null pointer (for unixODBC, NULL is passed). + * + * @param fRequest - The fRequest argument must contain one of + * the following values: + * ODBC_INSTALL_COMPLETE - (default) complete the installation request + * ODBC_INSTALL_INQUIRY - inquire about where a driver can be installed + * + * @return TRUE indicates success, FALSE if it fails. + */ + int InstallDriver( const char* pszDriver, const char* pszPathIn, + WORD fRequest = ODBC_INSTALL_COMPLETE ); + + /** + * Removes or changes information about the driver from + * the Odbcinst.ini entry in the system information. + * + * @param pszDriverName - The name of the driver as registered in + * the Odbcinst.ini key of the system information. + * + * @param fRemoveDSN - TRUE: Remove DSNs associated with the driver + * specified in lpszDriver. FALSE: Do not remove DSNs associated + * with the driver specified in lpszDriver. + * + * @return The function returns TRUE if it is successful, + * FALSE if it fails. If no entry exists in the system information + * when this function is called, the function returns FALSE. + * In order to obtain usage count value, call GetUsageCount(). + */ + int RemoveDriver( const char* pszDriverName, int fRemoveDSN = FALSE ); + + + // The usage count of the driver after this function has been called + int GetUsageCount() const { return m_nUsageCount; } + + + // Path of the target directory where the driver should be installed. + // For details, see ODBC API Reference and lpszPathOut + // parameter of SQLInstallDriverEx + const char* GetPathOut() const { return m_szPathOut; } + + + // If InstallDriver returns FALSE, then GetLastError then + // error message can be obtained by calling this function. + // Internally, it calls ODBC's SQLInstallerError function. + const char* GetLastError() const { return m_szError; } + + // If InstallDriver returns FALSE, then GetLastErrorCode then + // error code can be obtained by calling this function. + // Internally, it calls ODBC's SQLInstallerError function. + // See ODBC API Reference for possible error flags. + DWORD GetLastErrorCode() const { return m_nErrorCode; } +}; + +class CPLODBCStatement; + +/* On MSVC SQLULEN is missing in some cases (i.e. VC6) +** but it is always a #define so test this way. On Unix +** it is a typedef so we can't always do this. +*/ +#if defined(_MSC_VER) && !defined(SQLULEN) && !defined(_WIN64) +# define MISSING_SQLULEN +#endif + +#if !defined(MISSING_SQLULEN) +/* ODBC types to support 64 bit compilation */ +# define CPL_SQLULEN SQLULEN +# define CPL_SQLLEN SQLLEN +#else +# define CPL_SQLULEN SQLUINTEGER +# define CPL_SQLLEN SQLINTEGER +#endif /* ifdef SQLULEN */ + + +/** + * A class representing an ODBC database session. + * + * Includes error collection services. + */ + +class CPL_DLL CPLODBCSession { + char m_szLastError[SQL_MAX_MESSAGE_LENGTH + 1]; + HENV m_hEnv; + HDBC m_hDBC; + int m_bInTransaction; + int m_bAutoCommit; + + public: + CPLODBCSession(); + ~CPLODBCSession(); + + int EstablishSession( const char *pszDSN, + const char *pszUserid, + const char *pszPassword ); + const char *GetLastError(); + + // Transaction handling + + int ClearTransaction(); + int BeginTransaction(); + int CommitTransaction(); + int RollbackTransaction(); + int IsInTransaction() { return m_bInTransaction; } + + // Essentially internal. + + int CloseSession(); + + int Failed( int, HSTMT = NULL ); + HDBC GetConnection() { return m_hDBC; } + HENV GetEnvironment() { return m_hEnv; } +}; + +/** + * Abstraction for statement, and resultset. + * + * Includes methods for executing an SQL statement, and for accessing the + * resultset from that statement. Also provides for executing other ODBC + * requests that produce results sets such as SQLColumns() and SQLTables() + * requests. + */ + +class CPL_DLL CPLODBCStatement { + + CPLODBCSession *m_poSession; + HSTMT m_hStmt; + + SQLSMALLINT m_nColCount; + char **m_papszColNames; + SQLSMALLINT *m_panColType; + char **m_papszColTypeNames; + CPL_SQLULEN *m_panColSize; + SQLSMALLINT *m_panColPrecision; + SQLSMALLINT *m_panColNullable; + char **m_papszColColumnDef; + + char **m_papszColValues; + CPL_SQLLEN *m_panColValueLengths; + + int Failed( int ); + + char *m_pszStatement; + size_t m_nStatementMax; + size_t m_nStatementLen; + + public: + CPLODBCStatement( CPLODBCSession * ); + ~CPLODBCStatement(); + + HSTMT GetStatement() { return m_hStmt; } + + // Command buffer related. + void Clear(); + void AppendEscaped( const char * ); + void Append( const char * ); + void Append( int ); + void Append( double ); + int Appendf( const char *, ... ) CPL_PRINT_FUNC_FORMAT (2, 3); + const char *GetCommand() { return m_pszStatement; } + + int ExecuteSQL( const char * = NULL ); + + // Results fetching + int Fetch( int nOrientation = SQL_FETCH_NEXT, + int nOffset = 0 ); + void ClearColumnData(); + + int GetColCount(); + const char *GetColName( int ); + short GetColType( int ); + const char *GetColTypeName( int ); + short GetColSize( int ); + short GetColPrecision( int ); + short GetColNullable( int ); + const char *GetColColumnDef( int ); + + int GetColId( const char * ); + const char *GetColData( int, const char * = NULL ); + const char *GetColData( const char *, const char * = NULL ); + int GetColDataLength( int ); + int GetRowCountAffected(); + + // Fetch special metadata. + int GetColumns( const char *pszTable, + const char *pszCatalog = NULL, + const char *pszSchema = NULL ); + int GetPrimaryKeys( const char *pszTable, + const char *pszCatalog = NULL, + const char *pszSchema = NULL ); + + int GetTables( const char *pszCatalog = NULL, + const char *pszSchema = NULL ); + + void DumpResult( FILE *fp, int bShowSchema = FALSE ); + + static CPLString GetTypeName( int ); + static SQLSMALLINT GetTypeMapping( SQLSMALLINT ); + + int CollectResultsInfo(); +}; + +#endif diff --git a/modules/globebrowsing/ext/gdal/include/cpl_port.h b/modules/globebrowsing/ext/gdal/include/cpl_port.h new file mode 100644 index 0000000000..221a0f6de6 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/cpl_port.h @@ -0,0 +1,974 @@ +/****************************************************************************** + * $Id$ + * + * Project: CPL - Common Portability Library + * Author: Frank Warmerdam, warmerdam@pobox.com + * Purpose: Include file providing low level portability services for CPL. + * This should be the first include file for any CPL based code. + * + ****************************************************************************** + * Copyright (c) 1998, 2005, Frank Warmerdam + * Copyright (c) 2008-2013, Even Rouault + * + * 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. + ****************************************************************************/ + +#ifndef CPL_BASE_H_INCLUDED +#define CPL_BASE_H_INCLUDED + +/** + * \file cpl_port.h + * + * Core portability definitions for CPL. + * + */ + +/* ==================================================================== */ +/* We will use WIN32 as a standard windows define. */ +/* ==================================================================== */ +#if defined(_WIN32) && !defined(WIN32) +# define WIN32 +#endif + +#if defined(_WINDOWS) && !defined(WIN32) +# define WIN32 +#endif + +/* -------------------------------------------------------------------- */ +/* The following apparently allow you to use strcpy() and other */ +/* functions judged "unsafe" by microsoft in VS 8 (2005). */ +/* -------------------------------------------------------------------- */ +#ifdef _MSC_VER +# ifndef _CRT_SECURE_NO_DEPRECATE +# define _CRT_SECURE_NO_DEPRECATE +# endif +# ifndef _CRT_NONSTDC_NO_DEPRECATE +# define _CRT_NONSTDC_NO_DEPRECATE +# endif +#endif + +#include "cpl_config.h" + +/* ==================================================================== */ +/* A few sanity checks, mainly to detect problems that sometimes */ +/* arise with bad configured cross-compilation. */ +/* ==================================================================== */ + +#if !defined(SIZEOF_INT) || SIZEOF_INT != 4 +#error "Unexpected value for SIZEOF_INT" +#endif + +#if !defined(SIZEOF_UNSIGNED_LONG) || (SIZEOF_UNSIGNED_LONG != 4 && SIZEOF_UNSIGNED_LONG != 8) +#error "Unexpected value for SIZEOF_UNSIGNED_LONG" +#endif + +#if !defined(SIZEOF_VOIDP) || (SIZEOF_VOIDP != 4 && SIZEOF_VOIDP != 8) +#error "Unexpected value for SIZEOF_VOIDP" +#endif + + +/* ==================================================================== */ +/* This will disable most WIN32 stuff in a Cygnus build which */ +/* defines unix to 1. */ +/* ==================================================================== */ + +#ifdef unix +# undef WIN32 +#endif + +#if defined(VSI_NEED_LARGEFILE64_SOURCE) && !defined(_LARGEFILE64_SOURCE) +# define _LARGEFILE64_SOURCE 1 +#endif + +/* ==================================================================== */ +/* If iconv() is available use extended recoding module. */ +/* Stub implementation is always compiled in, because it works */ +/* faster than iconv() for encodings it supports. */ +/* ==================================================================== */ + +#if defined(HAVE_ICONV) +# define CPL_RECODE_ICONV +#endif + +#define CPL_RECODE_STUB + +/* ==================================================================== */ +/* MinGW stuff */ +/* ==================================================================== */ + +/* We need __MSVCRT_VERSION__ >= 0x0601 to have "struct __stat64" */ +/* Latest versions of mingw32 define it, but with older ones, */ +/* we need to define it manually */ +#if defined(__MINGW32__) +#ifndef __MSVCRT_VERSION__ +#define __MSVCRT_VERSION__ 0x0601 +#endif +#endif + +/* ==================================================================== */ +/* Standard include files. */ +/* ==================================================================== */ + +#include +#include +#include +#include +#include +#include +#include + +#include + +#if defined(HAVE_ERRNO_H) +# include +#endif + +#ifdef HAVE_LOCALE_H +# include +#endif + +#ifdef HAVE_DIRECT_H +# include +#endif + +#if !defined(WIN32) +# include +#endif + +#if defined(HAVE_LIBDBMALLOC) && defined(HAVE_DBMALLOC_H) && defined(DEBUG) +# define DBMALLOC +# include +#endif + +#if !defined(DBMALLOC) && defined(HAVE_DMALLOC_H) +# define USE_DMALLOC +# include +#endif + +/* ==================================================================== */ +/* Base portability stuff ... this stuff may need to be */ +/* modified for new platforms. */ +/* ==================================================================== */ + +/* -------------------------------------------------------------------- */ +/* Which versions of C++ are available. */ +/* -------------------------------------------------------------------- */ + +#ifdef __cplusplus +# if __cplusplus >= 201103L +# define HAVE_CXX11 1 +# endif +/* TODO(schwehr): What are the correct tests for C++ 14 and 17? */ +#endif /* __cpluscplus */ + +/*--------------------------------------------------------------------- + * types for 16 and 32 bits integers, etc... + *--------------------------------------------------------------------*/ +#if UINT_MAX == 65535 +typedef long GInt32; +typedef unsigned long GUInt32; +#else +typedef int GInt32; +typedef unsigned int GUInt32; +#endif + +typedef short GInt16; +typedef unsigned short GUInt16; +typedef unsigned char GByte; +/* hack for PDF driver and poppler >= 0.15.0 that defines incompatible "typedef bool GBool" */ +/* in include/poppler/goo/gtypes.h */ +#ifndef CPL_GBOOL_DEFINED +#define CPL_GBOOL_DEFINED +typedef int GBool; +#endif + +/* -------------------------------------------------------------------- */ +/* 64bit support */ +/* -------------------------------------------------------------------- */ + +#if defined(WIN32) && defined(_MSC_VER) + +#define VSI_LARGE_API_SUPPORTED +typedef __int64 GIntBig; +typedef unsigned __int64 GUIntBig; + +#define GINTBIG_MIN ((GIntBig)(0x80000000) << 32) +#define GINTBIG_MAX (((GIntBig)(0x7FFFFFFF) << 32) | 0xFFFFFFFFU) +#define GUINTBIG_MAX (((GUIntBig)(0xFFFFFFFFU) << 32) | 0xFFFFFFFFU) + +#elif HAVE_LONG_LONG + +typedef long long GIntBig; +typedef unsigned long long GUIntBig; + +#define GINTBIG_MIN ((GIntBig)(0x80000000) << 32) +#define GINTBIG_MAX (((GIntBig)(0x7FFFFFFF) << 32) | 0xFFFFFFFFU) +#define GUINTBIG_MAX (((GUIntBig)(0xFFFFFFFFU) << 32) | 0xFFFFFFFFU) + +#else + +typedef long GIntBig; +typedef unsigned long GUIntBig; + +#define GINTBIG_MIN INT_MIN +#define GINTBIG_MAX INT_MAX +#define GUINTBIG_MAX UINT_MAX +#endif + +#if SIZEOF_VOIDP == 8 +typedef GIntBig GPtrDiff_t; +#else +typedef int GPtrDiff_t; +#endif + +#if defined(__MSVCRT__) || (defined(WIN32) && defined(_MSC_VER)) + #define CPL_FRMT_GB_WITHOUT_PREFIX "I64" +#elif HAVE_LONG_LONG + #define CPL_FRMT_GB_WITHOUT_PREFIX "ll" +#else + #define CPL_FRMT_GB_WITHOUT_PREFIX "l" +#endif + +#define CPL_FRMT_GIB "%" CPL_FRMT_GB_WITHOUT_PREFIX "d" +#define CPL_FRMT_GUIB "%" CPL_FRMT_GB_WITHOUT_PREFIX "u" + +/* Workaround VC6 bug */ +#if defined(_MSC_VER) && (_MSC_VER <= 1200) +#define GUINTBIG_TO_DOUBLE(x) (double)(GIntBig)(x) +#else +#define GUINTBIG_TO_DOUBLE(x) (double)(x) +#endif + +#ifdef COMPAT_WITH_ICC_CONVERSION_CHECK +#define CPL_INT64_FITS_ON_INT32(x) ((x) >= INT_MIN && (x) <= INT_MAX) +#else +#define CPL_INT64_FITS_ON_INT32(x) (((GIntBig)(int)(x)) == (x)) +#endif + +/* ==================================================================== */ +/* Other standard services. */ +/* ==================================================================== */ +#ifdef __cplusplus +# define CPL_C_START extern "C" { +# define CPL_C_END } +#else +# define CPL_C_START +# define CPL_C_END +#endif + +#ifndef CPL_DLL +#if defined(_MSC_VER) && !defined(CPL_DISABLE_DLL) +# define CPL_DLL __declspec(dllexport) +#else +# if defined(USE_GCC_VISIBILITY_FLAG) +# define CPL_DLL __attribute__ ((visibility("default"))) +# else +# define CPL_DLL +# endif +#endif +#endif + +/* Should optional (normally private) interfaces be exported? */ +#ifdef CPL_OPTIONAL_APIS +# define CPL_ODLL CPL_DLL +#else +# define CPL_ODLL +#endif + +#ifndef CPL_STDCALL +#if defined(_MSC_VER) && !defined(CPL_DISABLE_STDCALL) +# define CPL_STDCALL __stdcall +#else +# define CPL_STDCALL +#endif +#endif + +#ifdef _MSC_VER +# define FORCE_CDECL __cdecl +#else +# define FORCE_CDECL +#endif + +/* TODO : support for other compilers needed */ +#if (defined(__GNUC__) && !defined(__NO_INLINE__)) || defined(_MSC_VER) +#define HAS_CPL_INLINE 1 +#define CPL_INLINE __inline +#elif defined(__SUNPRO_CC) +#define HAS_CPL_INLINE 1 +#define CPL_INLINE inline +#else +#define CPL_INLINE +#endif + +// Define NULL_AS_NULLPTR together with -std=c++11 -Wzero-as-null-pointer-constant with GCC +// to detect misuses of NULL +#if defined(NULL_AS_NULLPTR) && HAVE_CXX11 + +#ifdef __GNUC__ +// We need to include all that bunch of system headers, otherwise +// as they include with __need_NULL, this overrides our #define NULL nullptr +// with #define NULL __null +#include +#include +#include +#ifdef HAVE_ICONV +#include +#endif +#ifdef HAVE_MMAP +#include +#endif +#include +#ifndef _WIN32 +#include +#include +#include +#endif + +extern "C++" { +#include +#include +#include +#include +#include +#include +#include +#include +} +#endif /* __GNUC__ */ + +#undef NULL +#define NULL nullptr +#else /* defined(NULL_AS_NULLPTR) && HAVE_CXX11 */ +#ifndef NULL +# define NULL 0 +#endif +#endif /* defined(NULL_AS_NULLPTR) && HAVE_CXX11 */ + + +#ifndef MAX +# define MIN(a,b) ((ab) ? a : b) +#endif + +#ifndef ABS +# define ABS(x) ((x<0) ? (-1*(x)) : x) +#endif + +#ifndef M_PI +# define M_PI 3.14159265358979323846 +/* 3.1415926535897932384626433832795 */ +#endif + +/* -------------------------------------------------------------------- */ +/* Macro to test equality of two floating point values. */ +/* We use fabs() function instead of ABS() macro to avoid side */ +/* effects. */ +/* -------------------------------------------------------------------- */ +#ifndef CPLIsEqual +# define CPLIsEqual(x,y) (fabs((x) - (y)) < 0.0000000000001) +#endif + +/* -------------------------------------------------------------------- */ +/* Provide macros for case insensitive string comparisons. */ +/* -------------------------------------------------------------------- */ +#ifndef EQUAL + +#if defined(AFL_FRIENDLY) && defined(__GNUC__) + +static inline int CPL_afl_friendly_memcmp(const void* ptr1, const void* ptr2, size_t len) + __attribute__((always_inline)); + +static inline int CPL_afl_friendly_memcmp(const void* ptr1, const void* ptr2, size_t len) +{ + const unsigned char* bptr1 = (const unsigned char*)ptr1; + const unsigned char* bptr2 = (const unsigned char*)ptr2; + while( len-- ) + { + unsigned char b1 = *(bptr1++); + unsigned char b2 = *(bptr2++); + if( b1 != b2 ) return b1 - b2; + } + return 0; +} + +static inline int CPL_afl_friendly_strcmp(const char* ptr1, const char* ptr2) + __attribute__((always_inline)); + +static inline int CPL_afl_friendly_strcmp(const char* ptr1, const char* ptr2) +{ + const unsigned char* usptr1 = (const unsigned char*)ptr1; + const unsigned char* usptr2 = (const unsigned char*)ptr2; + while( 1 ) + { + unsigned char ch1 = *(usptr1++); + unsigned char ch2 = *(usptr2++); + if( ch1 == 0 || ch1 != ch2 ) return ch1 - ch2; + } +} + +static inline int CPL_afl_friendly_strncmp(const char* ptr1, const char* ptr2, size_t len) + __attribute__((always_inline)); + +static inline int CPL_afl_friendly_strncmp(const char* ptr1, const char* ptr2, size_t len) +{ + const unsigned char* usptr1 = (const unsigned char*)ptr1; + const unsigned char* usptr2 = (const unsigned char*)ptr2; + while( len -- ) + { + unsigned char ch1 = *(usptr1++); + unsigned char ch2 = *(usptr2++); + if( ch1 == 0 || ch1 != ch2 ) return ch1 - ch2; + } + return 0; +} + +static inline int CPL_afl_friendly_strcasecmp(const char* ptr1, const char* ptr2) + __attribute__((always_inline)); + +static inline int CPL_afl_friendly_strcasecmp(const char* ptr1, const char* ptr2) +{ + const unsigned char* usptr1 = (const unsigned char*)ptr1; + const unsigned char* usptr2 = (const unsigned char*)ptr2; + while( 1 ) + { + unsigned char ch1 = *(usptr1++); + unsigned char ch2 = *(usptr2++); + ch1 = (unsigned char)toupper(ch1); + ch2 = (unsigned char)toupper(ch2); + if( ch1 == 0 || ch1 != ch2 ) return ch1 - ch2; + } +} + +static inline int CPL_afl_friendly_strncasecmp(const char* ptr1, const char* ptr2, size_t len) + __attribute__((always_inline)); + +static inline int CPL_afl_friendly_strncasecmp(const char* ptr1, const char* ptr2, size_t len) +{ + const unsigned char* usptr1 = (const unsigned char*)ptr1; + const unsigned char* usptr2 = (const unsigned char*)ptr2; + while( len-- ) + { + unsigned char ch1 = *(usptr1++); + unsigned char ch2 = *(usptr2++); + ch1 = (unsigned char)toupper(ch1); + ch2 = (unsigned char)toupper(ch2); + if( ch1 == 0 || ch1 != ch2 ) return ch1 - ch2; + } + return 0; +} + +static inline char* CPL_afl_friendly_strstr(const char* haystack, const char* needle) + __attribute__((always_inline)); + +static inline char* CPL_afl_friendly_strstr(const char* haystack, const char* needle) +{ + const char* ptr_haystack = haystack; + while( 1 ) + { + const char* ptr_haystack2 = ptr_haystack; + const char* ptr_needle = needle; + while( 1 ) + { + char ch1 = *(ptr_haystack2++); + char ch2 = *(ptr_needle++); + if( ch2 == 0 ) + return (char*)ptr_haystack; + if( ch1 != ch2 ) + break; + } + if( *ptr_haystack == 0 ) + return NULL; + ptr_haystack ++; + } +} + +#undef strcmp +#undef strncmp +#define memcmp CPL_afl_friendly_memcmp +#define strcmp CPL_afl_friendly_strcmp +#define strncmp CPL_afl_friendly_strncmp +#define strcasecmp CPL_afl_friendly_strcasecmp +#define strncasecmp CPL_afl_friendly_strncasecmp +#define strstr CPL_afl_friendly_strstr + +#endif /* defined(AFL_FRIENDLY) && defined(__GNUC__) */ + +# if defined(WIN32) +# define STRCASECMP(a,b) (stricmp(a,b)) +# define STRNCASECMP(a,b,n) (strnicmp(a,b,n)) +# else +# define STRCASECMP(a,b) (strcasecmp(a,b)) +# define STRNCASECMP(a,b,n) (strncasecmp(a,b,n)) +# endif +# define EQUALN(a,b,n) (STRNCASECMP(a,b,n)==0) +# define EQUAL(a,b) (STRCASECMP(a,b)==0) +#endif + +/*--------------------------------------------------------------------- + * Does a string "a" start with string "b". Search is case-sensitive or, + * with CI, it is a case-insensitive comparison. + *--------------------------------------------------------------------- */ +#ifndef STARTS_WITH_CI +#define STARTS_WITH(a,b) (strncmp(a,b,strlen(b)) == 0) +#define STARTS_WITH_CI(a,b) EQUALN(a,b,strlen(b)) +#endif + +#ifndef CPL_THREADLOCAL +# define CPL_THREADLOCAL +#endif + +/* -------------------------------------------------------------------- */ +/* Handle isnan() and isinf(). Note that isinf() and isnan() */ +/* are supposed to be macros according to C99, defined in math.h */ +/* Some systems (i.e. Tru64) don't have isinf() at all, so if */ +/* the macro is not defined we just assume nothing is infinite. */ +/* This may mean we have no real CPLIsInf() on systems with isinf()*/ +/* function but no corresponding macro, but I can live with */ +/* that since it isn't that important a test. */ +/* -------------------------------------------------------------------- */ +#ifdef _MSC_VER +# include +# define CPLIsNan(x) _isnan(x) +# define CPLIsInf(x) (!_isnan(x) && !_finite(x)) +# define CPLIsFinite(x) _finite(x) +#else +# define CPLIsNan(x) isnan(x) +# ifdef isinf +# define CPLIsInf(x) isinf(x) +# define CPLIsFinite(x) (!isnan(x) && !isinf(x)) +# elif defined(__sun__) +# include +# define CPLIsInf(x) (!finite(x) && !isnan(x)) +# define CPLIsFinite(x) finite(x) +# else +# define CPLIsInf(x) (0) +# define CPLIsFinite(x) (!isnan(x)) +# endif +#endif + +/*--------------------------------------------------------------------- + * CPL_LSB and CPL_MSB + * Only one of these 2 macros should be defined and specifies the byte + * ordering for the current platform. + * This should be defined in the Makefile, but if it is not then + * the default is CPL_LSB (Intel ordering, LSB first). + *--------------------------------------------------------------------*/ +#if defined(WORDS_BIGENDIAN) && !defined(CPL_MSB) && !defined(CPL_LSB) +# define CPL_MSB +#endif + +#if ! ( defined(CPL_LSB) || defined(CPL_MSB) ) +#define CPL_LSB +#endif + +#if defined(CPL_LSB) +# define CPL_IS_LSB 1 +#else +# define CPL_IS_LSB 0 +#endif + +#ifdef __cplusplus + +extern "C++" { + +template struct CPLStaticAssert {}; +template<> struct CPLStaticAssert +{ + static void my_function() {} +}; + +} /* extern "C++" */ + +#define CPL_STATIC_ASSERT(x) CPLStaticAssert::my_function() +#define CPL_STATIC_ASSERT_IF_AVAILABLE(x) CPL_STATIC_ASSERT(x) + +#else /* __cplusplus */ + +#define CPL_STATIC_ASSERT_IF_AVAILABLE(x) + +#endif /* __cplusplus */ + +/*--------------------------------------------------------------------- + * Little endian <==> big endian byte swap macros. + *--------------------------------------------------------------------*/ + +#define CPL_SWAP16(x) \ + ((GUInt16)( \ + (((GUInt16)(x) & 0x00ffU) << 8) | \ + (((GUInt16)(x) & 0xff00U) >> 8) )) + +#define CPL_SWAP16PTR(x) \ +{ \ + GByte byTemp, *_pabyDataT = (GByte *) (x); \ + CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 2); \ + \ + byTemp = _pabyDataT[0]; \ + _pabyDataT[0] = _pabyDataT[1]; \ + _pabyDataT[1] = byTemp; \ +} + +#define CPL_SWAP32(x) \ + ((GUInt32)( \ + (((GUInt32)(x) & (GUInt32)0x000000ffUL) << 24) | \ + (((GUInt32)(x) & (GUInt32)0x0000ff00UL) << 8) | \ + (((GUInt32)(x) & (GUInt32)0x00ff0000UL) >> 8) | \ + (((GUInt32)(x) & (GUInt32)0xff000000UL) >> 24) )) + +#define CPL_SWAP32PTR(x) \ +{ \ + GByte byTemp, *_pabyDataT = (GByte *) (x); \ + CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 4); \ + \ + byTemp = _pabyDataT[0]; \ + _pabyDataT[0] = _pabyDataT[3]; \ + _pabyDataT[3] = byTemp; \ + byTemp = _pabyDataT[1]; \ + _pabyDataT[1] = _pabyDataT[2]; \ + _pabyDataT[2] = byTemp; \ +} + +#define CPL_SWAP64PTR(x) \ +{ \ + GByte byTemp, *_pabyDataT = (GByte *) (x); \ + CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 8); \ + \ + byTemp = _pabyDataT[0]; \ + _pabyDataT[0] = _pabyDataT[7]; \ + _pabyDataT[7] = byTemp; \ + byTemp = _pabyDataT[1]; \ + _pabyDataT[1] = _pabyDataT[6]; \ + _pabyDataT[6] = byTemp; \ + byTemp = _pabyDataT[2]; \ + _pabyDataT[2] = _pabyDataT[5]; \ + _pabyDataT[5] = byTemp; \ + byTemp = _pabyDataT[3]; \ + _pabyDataT[3] = _pabyDataT[4]; \ + _pabyDataT[4] = byTemp; \ +} + + +/* Until we have a safe 64 bits integer data type defined, we'll replace + * this version of the CPL_SWAP64() macro with a less efficient one. + */ +/* +#define CPL_SWAP64(x) \ + ((uint64)( \ + (uint64)(((uint64)(x) & (uint64)0x00000000000000ffULL) << 56) | \ + (uint64)(((uint64)(x) & (uint64)0x000000000000ff00ULL) << 40) | \ + (uint64)(((uint64)(x) & (uint64)0x0000000000ff0000ULL) << 24) | \ + (uint64)(((uint64)(x) & (uint64)0x00000000ff000000ULL) << 8) | \ + (uint64)(((uint64)(x) & (uint64)0x000000ff00000000ULL) >> 8) | \ + (uint64)(((uint64)(x) & (uint64)0x0000ff0000000000ULL) >> 24) | \ + (uint64)(((uint64)(x) & (uint64)0x00ff000000000000ULL) >> 40) | \ + (uint64)(((uint64)(x) & (uint64)0xff00000000000000ULL) >> 56) )) +*/ + +#define CPL_SWAPDOUBLE(p) CPL_SWAP64PTR(p) + +#ifdef CPL_MSB +# define CPL_MSBWORD16(x) (x) +# define CPL_LSBWORD16(x) CPL_SWAP16(x) +# define CPL_MSBWORD32(x) (x) +# define CPL_LSBWORD32(x) CPL_SWAP32(x) +# define CPL_MSBPTR16(x) CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 2) +# define CPL_LSBPTR16(x) CPL_SWAP16PTR(x) +# define CPL_MSBPTR32(x) CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 4) +# define CPL_LSBPTR32(x) CPL_SWAP32PTR(x) +# define CPL_MSBPTR64(x) CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 8) +# define CPL_LSBPTR64(x) CPL_SWAP64PTR(x) +#else +# define CPL_LSBWORD16(x) (x) +# define CPL_MSBWORD16(x) CPL_SWAP16(x) +# define CPL_LSBWORD32(x) (x) +# define CPL_MSBWORD32(x) CPL_SWAP32(x) +# define CPL_LSBPTR16(x) CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 2) +# define CPL_MSBPTR16(x) CPL_SWAP16PTR(x) +# define CPL_LSBPTR32(x) CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 4) +# define CPL_MSBPTR32(x) CPL_SWAP32PTR(x) +# define CPL_LSBPTR64(x) CPL_STATIC_ASSERT_IF_AVAILABLE(sizeof(*(x)) == 1 || sizeof(*(x)) == 8) +# define CPL_MSBPTR64(x) CPL_SWAP64PTR(x) +#endif + +/** Return a Int16 from the 2 bytes ordered in LSB order at address x */ +#define CPL_LSBINT16PTR(x) ((*(GByte*)(x)) | (*(((GByte*)(x))+1) << 8)) + +/** Return a Int32 from the 4 bytes ordered in LSB order at address x */ +#define CPL_LSBINT32PTR(x) ((*(GByte*)(x)) | (*(((GByte*)(x))+1) << 8) | \ + (*(((GByte*)(x))+2) << 16) | (*(((GByte*)(x))+3) << 24)) + +/** Return a signed Int16 from the 2 bytes ordered in LSB order at address x */ +#define CPL_LSBSINT16PTR(x) ((GInt16) CPL_LSBINT16PTR(x)) + +/** Return a unsigned Int16 from the 2 bytes ordered in LSB order at address x */ +#define CPL_LSBUINT16PTR(x) ((GUInt16)CPL_LSBINT16PTR(x)) + +/** Return a signed Int32 from the 4 bytes ordered in LSB order at address x */ +#define CPL_LSBSINT32PTR(x) ((GInt32) CPL_LSBINT32PTR(x)) + +/** Return a unsigned Int32 from the 4 bytes ordered in LSB order at address x */ +#define CPL_LSBUINT32PTR(x) ((GUInt32)CPL_LSBINT32PTR(x)) + + +/* Utility macro to explicitly mark intentionally unreferenced parameters. */ +#ifndef UNREFERENCED_PARAM +# ifdef UNREFERENCED_PARAMETER /* May be defined by Windows API */ +# define UNREFERENCED_PARAM(param) UNREFERENCED_PARAMETER(param) +# else +# define UNREFERENCED_PARAM(param) ((void)param) +# endif /* UNREFERENCED_PARAMETER */ +#endif /* UNREFERENCED_PARAM */ + +/*********************************************************************** + * Define CPL_CVSID() macro. It can be disabled during a build by + * defining DISABLE_CVSID in the compiler options. + * + * The cvsid_aw() function is just there to prevent reports of cpl_cvsid() + * being unused. + */ + +#ifndef DISABLE_CVSID +#if defined(__GNUC__) && __GNUC__ >= 4 +# define CPL_CVSID(string) static const char cpl_cvsid[] __attribute__((used)) = string; +#else +# define CPL_CVSID(string) static const char cpl_cvsid[] = string; \ +static const char *cvsid_aw() { return( cvsid_aw() ? NULL : cpl_cvsid ); } +#endif +#else +# define CPL_CVSID(string) +#endif + +/* Null terminated variadic */ +/* We exclude mingw64 4.6 which seems to be broken regarding this */ +#if defined(__GNUC__) && __GNUC__ >= 4 && !defined(DOXYGEN_SKIP) && !(defined(__MINGW64__) && __GNUC__ == 4 && __GNUC_MINOR__ == 6) +# define CPL_NULL_TERMINATED __attribute__((__sentinel__)) +#else +# define CPL_NULL_TERMINATED +#endif + +#if defined(__GNUC__) && __GNUC__ >= 3 && !defined(DOXYGEN_SKIP) +#define CPL_PRINT_FUNC_FORMAT( format_idx, arg_idx ) __attribute__((__format__ (__printf__, format_idx, arg_idx))) +#define CPL_SCAN_FUNC_FORMAT( format_idx, arg_idx ) __attribute__((__format__ (__scanf__, format_idx, arg_idx))) +#else +#define CPL_PRINT_FUNC_FORMAT( format_idx, arg_idx ) +#define CPL_SCAN_FUNC_FORMAT( format_idx, arg_idx ) +#endif + +#if defined(__GNUC__) && __GNUC__ >= 4 && !defined(DOXYGEN_SKIP) +#define CPL_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) +#else +#define CPL_WARN_UNUSED_RESULT +#endif + +#if defined(__GNUC__) && __GNUC__ >= 4 +# define CPL_UNUSED __attribute((__unused__)) +#else +/* TODO: add cases for other compilers */ +# define CPL_UNUSED +#endif + +#if defined(__GNUC__) && __GNUC__ >= 3 && !defined(DOXYGEN_SKIP) +#define CPL_NO_RETURN __attribute__((noreturn)) +#else +#define CPL_NO_RETURN +#endif + +/* Clang __has_attribute */ +#ifndef __has_attribute + #define __has_attribute(x) 0 // Compatibility with non-clang compilers. +#endif + +#if ((defined(__GNUC__) && (__GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9))) || __has_attribute(returns_nonnull)) && !defined(DOXYGEN_SKIP) +# define CPL_RETURNS_NONNULL __attribute__((returns_nonnull)) +#else +# define CPL_RETURNS_NONNULL +#endif + + +#if defined(__GNUC__) && __GNUC__ >= 4 && !defined(DOXYGEN_SKIP) +#define CPL_RESTRICT __restrict__ +#else +#define CPL_RESTRICT +#endif + +/* Helper to remove the copy and assignment constructors so that the compiler + will not generate the default versions. + + Must be placed in the private section of a class and should be at the end. +*/ +#ifdef __cplusplus + +#if HAVE_CXX11 +# define CPL_FINAL final +# define CPL_DISALLOW_COPY_ASSIGN(ClassName) \ + ClassName( const ClassName & ) = delete; \ + ClassName &operator=( const ClassName & ) = delete; +#else +# define CPL_FINAL +# define CPL_DISALLOW_COPY_ASSIGN(ClassName) \ + ClassName( const ClassName & ); \ + ClassName &operator=( const ClassName & ); +#endif /* HAVE_CXX11 */ + +#endif /* __cplusplus */ + +#if !defined(DOXYGEN_SKIP) +#if defined(__has_extension) + #if __has_extension(attribute_deprecated_with_message) + /* Clang extension */ + #define CPL_WARN_DEPRECATED(x) __attribute__ ((deprecated(x))) + #else + #define CPL_WARN_DEPRECATED(x) + #endif +#elif defined(__GNUC__) + #define CPL_WARN_DEPRECATED(x) __attribute__ ((deprecated)) +#else + #define CPL_WARN_DEPRECATED(x) +#endif +#endif + +#if !defined(_MSC_VER) && !defined(__APPLE__) +CPL_C_START +#ifdef WARN_STANDARD_PRINTF +int vsnprintf(char *str, size_t size, const char* fmt, va_list args) CPL_WARN_DEPRECATED("Use CPLvsnprintf() instead"); +int snprintf(char *str, size_t size, const char* fmt, ...) CPL_PRINT_FUNC_FORMAT(3,4) CPL_WARN_DEPRECATED("Use CPLsnprintf() instead"); +int sprintf(char *str, const char* fmt, ...) CPL_PRINT_FUNC_FORMAT(2, 3) CPL_WARN_DEPRECATED("Use CPLsnprintf() instead"); +#elif defined(GDAL_COMPILATION) && !defined(DONT_DEPRECATE_SPRINTF) +int sprintf(char *str, const char* fmt, ...) CPL_PRINT_FUNC_FORMAT(2, 3) CPL_WARN_DEPRECATED("Use snprintf() or CPLsnprintf() instead"); +#endif +CPL_C_END +#endif /* !defined(_MSC_VER) && !defined(__APPLE__) */ + +#if defined(MAKE_SANITIZE_HAPPY) || !(defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64)) +#define CPL_CPU_REQUIRES_ALIGNED_ACCESS +#define CPL_IS_DOUBLE_A_INT(d) ( (d) >= INT_MIN && (d) <= INT_MAX && (double)(int)(d) == (d) ) +#else +/* This is technically unspecified behaviour if the double is out of range, but works OK on x86 */ +#define CPL_IS_DOUBLE_A_INT(d) ( (double)(int)(d) == (d) ) +#endif + +#ifdef __cplusplus +/* The size of C style arrays. */ +#define CPL_ARRAYSIZE(array) \ + ((sizeof(array) / sizeof(*(array))) / \ + static_cast(!(sizeof(array) % sizeof(*(array))))) + +extern "C++" { +template static void CPL_IGNORE_RET_VAL(T) {} +inline static bool CPL_TO_BOOL(int x) { return x != 0; } +} /* extern "C++" */ + +#endif /* __cplusplus */ + +#if (((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) || (defined(__clang__) && __clang_major__ >= 3)) && !defined(_MSC_VER)) +#define HAVE_GCC_DIAGNOSTIC_PUSH +#endif + +#if ((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)) && !defined(_MSC_VER)) +#define HAVE_GCC_SYSTEM_HEADER +#endif + +#if defined(__clang__) +# define CPL_FALLTHROUGH [[clang::fallthrough]]; +#else +# define CPL_FALLTHROUGH +#endif + +// Define DEBUG_BOOL to compile in "MSVC mode", ie error out when +// a integer is assigned to a bool +// WARNING: use only at compilation time, since it is know to not work +// at runtime for unknown reasons (crash in MongoDB driver for example) +#if defined(__cplusplus) && defined(DEBUG_BOOL) && !defined(DO_NOT_USE_DEBUG_BOOL) +extern "C++" { +class MSVCPedanticBool +{ + + friend bool operator== (const bool& one, const MSVCPedanticBool& other); + friend bool operator!= (const bool& one, const MSVCPedanticBool& other); + + bool b; + MSVCPedanticBool(int bIn); + + public: + /* b not initialized on purpose in default ctor to flag use. */ + /* cppcheck-suppress uninitMemberVar */ + MSVCPedanticBool() {} + MSVCPedanticBool(bool bIn) : b(bIn) {} + MSVCPedanticBool(const MSVCPedanticBool& other) : b(other.b) {} + + MSVCPedanticBool& operator= (const MSVCPedanticBool& other) { b = other.b; return *this; } + MSVCPedanticBool& operator&= (const MSVCPedanticBool& other) { b &= other.b; return *this; } + MSVCPedanticBool& operator|= (const MSVCPedanticBool& other) { b |= other.b; return *this; } + + bool operator== (const bool& other) const { return b == other; } + bool operator!= (const bool& other) const { return b != other; } + bool operator== (const MSVCPedanticBool& other) const { return b == other.b; } + bool operator!= (const MSVCPedanticBool& other) const { return b != other.b; } + + bool operator! () const { return !b; } + operator bool() const { return b; } + operator int() const { return b; } +}; + +inline bool operator== (const bool& one, const MSVCPedanticBool& other) { return one == other.b; } +inline bool operator!= (const bool& one, const MSVCPedanticBool& other) { return one != other.b; } + +/* We must include all C++ stuff before to avoid issues with templates that use bool */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +} /* extern C++ */ + +#undef FALSE +#define FALSE false +#undef TRUE +#define TRUE true + +/* In the very few cases we really need a "simple" type, fallback to bool */ +#define EMULATED_BOOL int + +/* Use our class instead of bool */ +#define bool MSVCPedanticBool + +/* "volatile bool" with the below substitution doesn't really work. */ +/* Just for the sake of the debug, we don't really need volatile */ +#define VOLATILE_BOOL bool + +#else /* defined(__cplusplus) && defined(DEBUG_BOOL) */ + +#ifndef FALSE +# define FALSE 0 +#endif + +#ifndef TRUE +# define TRUE 1 +#endif + +#define EMULATED_BOOL bool +#define VOLATILE_BOOL volatile bool + +#endif /* defined(__cplusplus) && defined(DEBUG_BOOL) */ + +#endif /* ndef CPL_BASE_H_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/cpl_progress.h b/modules/globebrowsing/ext/gdal/include/cpl_progress.h new file mode 100644 index 0000000000..aa5fe523cc --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/cpl_progress.h @@ -0,0 +1,47 @@ +/****************************************************************************** + * $Id$ + * + * Project: CPL - Common Portability Library + * Author: Frank Warmerdam, warmerdam@pobox.com + * Purpose: Prototypes and definitions for progress functions. + * + ****************************************************************************** + * Copyright (c) 2013, 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. + ****************************************************************************/ + +#ifndef CPL_PROGRESS_H_INCLUDED +#define CPL_PROGRESS_H_INCLUDED + +#include "cpl_port.h" + +CPL_C_START + +typedef int (CPL_STDCALL *GDALProgressFunc)(double dfComplete, const char *pszMessage, void *pProgressArg); + +int CPL_DLL CPL_STDCALL GDALDummyProgress( double, const char *, void *); +int CPL_DLL CPL_STDCALL GDALTermProgress( double, const char *, void *); +int CPL_DLL CPL_STDCALL GDALScaledProgress( double, const char *, void *); +void CPL_DLL * CPL_STDCALL GDALCreateScaledProgress( double, double, + GDALProgressFunc, void * ); +void CPL_DLL CPL_STDCALL GDALDestroyScaledProgress( void * ); +CPL_C_END + +#endif /* ndef CPL_PROGRESS_H_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/cpl_quad_tree.h b/modules/globebrowsing/ext/gdal/include/cpl_quad_tree.h new file mode 100644 index 0000000000..3d95f4f085 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/cpl_quad_tree.h @@ -0,0 +1,100 @@ +/********************************************************************** + * $Id$ + * + * Project: CPL - Common Portability Library + * Purpose: Implementation of quadtree building and searching functions. + * Derived from shapelib and mapserver implementations + * Author: Frank Warmerdam, warmerdam@pobox.com + * Even Rouault, + * + ****************************************************************************** + * Copyright (c) 1999-2008, Frank Warmerdam + * Copyright (c) 2008-2014, Even Rouault + * + * 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. + ****************************************************************************/ + +#ifndef CPL_QUAD_TREE_H_INCLUDED +#define CPL_QUAD_TREE_H_INCLUDED + +#include "cpl_port.h" + +/** + * \file cpl_quad_tree.h + * + * Quad tree implementation. + * + * A quadtree is a tree data structure in which each internal node + * has up to four children. Quadtrees are most often used to partition + * a two dimensional space by recursively subdividing it into four + * quadrants or regions + */ + +CPL_C_START + +/* Types */ + +typedef struct { + double minx, miny, maxx, maxy; +} CPLRectObj; + +typedef struct _CPLQuadTree CPLQuadTree; + +typedef void (*CPLQuadTreeGetBoundsFunc)(const void* hFeature, CPLRectObj* pBounds); +typedef int (*CPLQuadTreeForeachFunc)(void* pElt, void* pUserData); +typedef void (*CPLQuadTreeDumpFeatureFunc)(const void* hFeature, int nIndentLevel, void* pUserData); + +/* Functions */ + +CPLQuadTree CPL_DLL *CPLQuadTreeCreate(const CPLRectObj* pGlobalBounds, + CPLQuadTreeGetBoundsFunc pfnGetBounds); +void CPL_DLL CPLQuadTreeDestroy(CPLQuadTree *hQuadtree); + +void CPL_DLL CPLQuadTreeSetBucketCapacity(CPLQuadTree *hQuadtree, + int nBucketCapacity); +int CPL_DLL CPLQuadTreeGetAdvisedMaxDepth(int nExpectedFeatures); +void CPL_DLL CPLQuadTreeSetMaxDepth(CPLQuadTree *hQuadtree, + int nMaxDepth); + +void CPL_DLL CPLQuadTreeInsert(CPLQuadTree *hQuadtree, + void* hFeature); +void CPL_DLL CPLQuadTreeInsertWithBounds(CPLQuadTree *hQuadtree, + void* hFeature, + const CPLRectObj* psBounds); + +void CPL_DLL **CPLQuadTreeSearch(const CPLQuadTree *hQuadtree, + const CPLRectObj* pAoi, + int* pnFeatureCount); + +void CPL_DLL CPLQuadTreeForeach(const CPLQuadTree *hQuadtree, + CPLQuadTreeForeachFunc pfnForeach, + void* pUserData); + +void CPL_DLL CPLQuadTreeDump(const CPLQuadTree *hQuadtree, + CPLQuadTreeDumpFeatureFunc pfnDumpFeatureFunc, + void* pUserData); +void CPL_DLL CPLQuadTreeGetStats(const CPLQuadTree *hQuadtree, + int* pnFeatureCount, + int* pnNodeCount, + int* pnMaxDepth, + int* pnMaxBucketCapacity); + +CPL_C_END + +#endif diff --git a/modules/globebrowsing/ext/gdal/include/cpl_sha256.h b/modules/globebrowsing/ext/gdal/include/cpl_sha256.h new file mode 100644 index 0000000000..a2f3989b7a --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/cpl_sha256.h @@ -0,0 +1,68 @@ +/* $Id$ */ + +/* The MIT License + + Copyright (C) 2011 Zilong Tan (tzlloch@gmail.com) + Copyright (C) 2015 Even Rouault + + 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. +*/ + +#ifndef CPL_SHA256_INCLUDED_H +#define CPL_SHA256_INCLUDED_H + +#include "cpl_port.h" + +#define CPL_SHA256_HASH_SIZE 32 /* 256 bit */ +#define CPL_SHA256_HASH_WORDS 8 + +#ifndef GUInt64 +#define GUInt64 GUIntBig +#endif + +CPL_C_START + +struct _CPL_SHA256Context { + GUInt64 totalLength; + GUInt32 hash[CPL_SHA256_HASH_WORDS]; + GUInt32 bufferLength; + union { + GUInt32 words[16]; + GByte bytes[64]; + } buffer; +}; +typedef struct _CPL_SHA256Context CPL_SHA256Context; + +void CPL_DLL CPL_SHA256Init(CPL_SHA256Context * sc); + +void CPL_DLL CPL_SHA256Update(CPL_SHA256Context * sc, const void *data, size_t len); + +void CPL_DLL CPL_SHA256Final(CPL_SHA256Context * sc, GByte hash[CPL_SHA256_HASH_SIZE]); + +void CPL_DLL CPL_SHA256(const void *data, size_t len, GByte hash[CPL_SHA256_HASH_SIZE]); + +void CPL_DLL CPL_HMAC_SHA256(const void *pKey, size_t nKeyLen, + const void *pabyMessage, size_t nMessageLen, + GByte abyDigest[CPL_SHA256_HASH_SIZE]); + +CPL_C_END + +#endif /* CPL_SHA256_INCLUDED_H */ diff --git a/modules/globebrowsing/ext/gdal/include/cpl_spawn.h b/modules/globebrowsing/ext/gdal/include/cpl_spawn.h new file mode 100644 index 0000000000..84c28112fc --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/cpl_spawn.h @@ -0,0 +1,78 @@ +/********************************************************************** + * $Id$ + * + * Project: CPL - Common Portability Library + * Purpose: Implement CPLSystem(). + * Author: Even Rouault, + * + ********************************************************************** + * Copyright (c) 2013, Even Rouault + * + * 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. + ****************************************************************************/ + +#ifndef CPL_SPAWN_H_INCLUDED +#define CPL_SPAWN_H_INCLUDED + +#include "cpl_vsi.h" + +CPL_C_START + +/* -------------------------------------------------------------------- */ +/* Spawn a process. */ +/* -------------------------------------------------------------------- */ + +int CPL_DLL CPLSpawn( const char * const papszArgv[], VSILFILE* fin, VSILFILE* fout, + int bDisplayErr ); + +#ifdef WIN32 +#include +typedef HANDLE CPL_FILE_HANDLE; +#define CPL_FILE_INVALID_HANDLE NULL +typedef DWORD CPL_PID; +#else +#include +typedef int CPL_FILE_HANDLE; +#define CPL_FILE_INVALID_HANDLE -1 +typedef pid_t CPL_PID; +#endif + +typedef struct _CPLSpawnedProcess CPLSpawnedProcess; + +CPLSpawnedProcess CPL_DLL* CPLSpawnAsync( int (*pfnMain)(CPL_FILE_HANDLE, CPL_FILE_HANDLE), + const char * const papszArgv[], + int bCreateInputPipe, + int bCreateOutputPipe, + int bCreateErrorPipe, + char** papszOptions ); +CPL_PID CPL_DLL CPLSpawnAsyncGetChildProcessId(CPLSpawnedProcess* p); +int CPL_DLL CPLSpawnAsyncFinish(CPLSpawnedProcess* p, int bWait, int bKill); +CPL_FILE_HANDLE CPL_DLL CPLSpawnAsyncGetInputFileHandle(CPLSpawnedProcess* p); +CPL_FILE_HANDLE CPL_DLL CPLSpawnAsyncGetOutputFileHandle(CPLSpawnedProcess* p); +CPL_FILE_HANDLE CPL_DLL CPLSpawnAsyncGetErrorFileHandle(CPLSpawnedProcess* p); +void CPL_DLL CPLSpawnAsyncCloseInputFileHandle(CPLSpawnedProcess* p); +void CPL_DLL CPLSpawnAsyncCloseOutputFileHandle(CPLSpawnedProcess* p); +void CPL_DLL CPLSpawnAsyncCloseErrorFileHandle(CPLSpawnedProcess* p); + +int CPL_DLL CPLPipeRead(CPL_FILE_HANDLE fin, void* data, int length); +int CPL_DLL CPLPipeWrite(CPL_FILE_HANDLE fout, const void* data, int length); + +CPL_C_END + +#endif // CPL_SPAWN_H_INCLUDED diff --git a/modules/globebrowsing/ext/gdal/include/cpl_string.h b/modules/globebrowsing/ext/gdal/include/cpl_string.h new file mode 100644 index 0000000000..161a6204bd --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/cpl_string.h @@ -0,0 +1,433 @@ +/********************************************************************** + * $Id$ + * + * Name: cpl_string.h + * Project: CPL - Common Portability Library + * Purpose: String and StringList functions. + * Author: Daniel Morissette, dmorissette@mapgears.com + * + ********************************************************************** + * Copyright (c) 1998, Daniel Morissette + * Copyright (c) 2008-2014, Even Rouault + * + * 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. + ****************************************************************************/ + +#ifndef CPL_STRING_H_INCLUDED +#define CPL_STRING_H_INCLUDED + +#include "cpl_error.h" +#include "cpl_conv.h" +#include "cpl_vsi.h" + +/** + * \file cpl_string.h + * + * Various convenience functions for working with strings and string lists. + * + * A StringList is just an array of strings with the last pointer being + * NULL. An empty StringList may be either a NULL pointer, or a pointer to + * a pointer memory location with a NULL value. + * + * A common convention for StringLists is to use them to store name/value + * lists. In this case the contents are treated like a dictionary of + * name/value pairs. The actual data is formatted with each string having + * the format ":" (though "=" is also an acceptable separator). + * A number of the functions in the file operate on name/value style + * string lists (such as CSLSetNameValue(), and CSLFetchNameValue()). + * + * To some extent the CPLStringList C++ class can be used to abstract + * managing string lists a bit but still be able to return them from C + * functions. + * + */ + +CPL_C_START + +char CPL_DLL **CSLAddString(char **papszStrList, + const char *pszNewString) CPL_WARN_UNUSED_RESULT; +char CPL_DLL **CSLAddStringMayFail( + char **papszStrList, const char *pszNewString) CPL_WARN_UNUSED_RESULT; +#ifdef __cplusplus + int CPL_DLL CSLCount(const char * const *papszStrList); +#else + int CPL_DLL CSLCount(char **papszStrList); +#endif +const char CPL_DLL *CSLGetField( char **, int ); +void CPL_DLL CPL_STDCALL CSLDestroy(char **papszStrList); +char CPL_DLL **CSLDuplicate(char **papszStrList) CPL_WARN_UNUSED_RESULT; +char CPL_DLL **CSLMerge( char **papszOrig, + char **papszOverride ) CPL_WARN_UNUSED_RESULT; + +char CPL_DLL **CSLTokenizeString(const char *pszString ) CPL_WARN_UNUSED_RESULT; +char CPL_DLL **CSLTokenizeStringComplex( + const char *pszString, const char *pszDelimiter, int bHonourStrings, + int bAllowEmptyTokens ) CPL_WARN_UNUSED_RESULT; +char CPL_DLL **CSLTokenizeString2( const char *pszString, + const char *pszDelimiter, + int nCSLTFlags ) CPL_WARN_UNUSED_RESULT; + +#define CSLT_HONOURSTRINGS 0x0001 +#define CSLT_ALLOWEMPTYTOKENS 0x0002 +#define CSLT_PRESERVEQUOTES 0x0004 +#define CSLT_PRESERVEESCAPES 0x0008 +#define CSLT_STRIPLEADSPACES 0x0010 +#define CSLT_STRIPENDSPACES 0x0020 + +int CPL_DLL CSLPrint(char **papszStrList, FILE *fpOut); +char CPL_DLL **CSLLoad(const char *pszFname) CPL_WARN_UNUSED_RESULT; +char CPL_DLL **CSLLoad2(const char *pszFname, int nMaxLines, int nMaxCols, + char** papszOptions) CPL_WARN_UNUSED_RESULT; +int CPL_DLL CSLSave(char **papszStrList, const char *pszFname); + +char CPL_DLL **CSLInsertStrings(char **papszStrList, int nInsertAtLineNo, + char **papszNewLines) CPL_WARN_UNUSED_RESULT; +char CPL_DLL **CSLInsertString(char **papszStrList, int nInsertAtLineNo, + const char *pszNewLine) CPL_WARN_UNUSED_RESULT; +char CPL_DLL **CSLRemoveStrings( + char **papszStrList, int nFirstLineToDelete, + int nNumToRemove, char ***ppapszRetStrings) CPL_WARN_UNUSED_RESULT; +int CPL_DLL CSLFindString( char **, const char * ); +int CPL_DLL CSLFindStringCaseSensitive( char **, const char * ); +int CPL_DLL CSLPartialFindString( char **papszHaystack, + const char * pszNeedle ); +int CPL_DLL CSLFindName(char **papszStrList, const char *pszName); +int CPL_DLL CSLFetchBoolean( char **papszStrList, const char *pszKey, + int bDefault ); + +/* TODO: Deprecate CSLTestBoolean. Remove in GDAL 3.x. */ +int CPL_DLL CSLTestBoolean( const char *pszValue ); +int CPL_DLL CPLTestBoolean( const char *pszValue ); + +#ifdef __cplusplus +#ifdef DO_NOT_USE_DEBUG_BOOL +#define CPLTestBool(x) CPL_TO_BOOL(CPLTestBoolean(x)) +#else +/* Prefer these for C++ code. */ +#ifdef DEBUG_BOOL +extern "C++" { +#endif +bool CPL_DLL CPLTestBool( const char *pszValue ); +#ifdef DEBUG_BOOL +} +#endif +#endif +bool CPL_DLL CPLFetchBool( const char **papszStrList, const char *pszKey, + bool bDefault ); +#endif /* __cplusplus */ + +const char CPL_DLL * + CPLParseNameValue(const char *pszNameValue, char **ppszKey ); +const char CPL_DLL * + CSLFetchNameValue(char **papszStrList, const char *pszName); +const char CPL_DLL * + CSLFetchNameValueDef(char **papszStrList, const char *pszName, + const char *pszDefault ); +char CPL_DLL ** + CSLFetchNameValueMultiple(char **papszStrList, const char *pszName); +char CPL_DLL ** + CSLAddNameValue(char **papszStrList, + const char *pszName, + const char *pszValue) CPL_WARN_UNUSED_RESULT; +char CPL_DLL ** + CSLSetNameValue(char **papszStrList, + const char *pszName, + const char *pszValue) CPL_WARN_UNUSED_RESULT; +void CPL_DLL CSLSetNameValueSeparator( char ** papszStrList, + const char *pszSeparator ); + +char CPL_DLL ** CSLParseCommandLine(const char* pszCommandLine); + +#define CPLES_BackslashQuotable 0 +#define CPLES_XML 1 +#define CPLES_URL 2 +#define CPLES_SQL 3 +#define CPLES_CSV 4 +#define CPLES_XML_BUT_QUOTES 5 + +char CPL_DLL *CPLEscapeString( const char *pszString, int nLength, + int nScheme ) CPL_WARN_UNUSED_RESULT; +char CPL_DLL *CPLUnescapeString( const char *pszString, int *pnLength, + int nScheme ) CPL_WARN_UNUSED_RESULT; + +char CPL_DLL *CPLBinaryToHex( int nBytes, + const GByte *pabyData ) CPL_WARN_UNUSED_RESULT; +GByte CPL_DLL *CPLHexToBinary( const char *pszHex, + int *pnBytes ) CPL_WARN_UNUSED_RESULT; + +char CPL_DLL *CPLBase64Encode( int nBytes, + const GByte *pabyData ) CPL_WARN_UNUSED_RESULT; +int CPL_DLL CPLBase64DecodeInPlace( GByte* pszBase64 ); + +typedef enum +{ + CPL_VALUE_STRING, + CPL_VALUE_REAL, + CPL_VALUE_INTEGER +} CPLValueType; + +CPLValueType CPL_DLL CPLGetValueType(const char* pszValue); + +size_t CPL_DLL CPLStrlcpy(char* pszDest, const char* pszSrc, size_t nDestSize); +size_t CPL_DLL CPLStrlcat(char* pszDest, const char* pszSrc, size_t nDestSize); +size_t CPL_DLL CPLStrnlen(const char *pszStr, size_t nMaxLen); + +/* -------------------------------------------------------------------- */ +/* Locale independent formatting functions. */ +/* -------------------------------------------------------------------- */ +int CPL_DLL CPLvsnprintf(char *str, size_t size, const char* fmt, + va_list args) CPL_PRINT_FUNC_FORMAT (3, 0); +int CPL_DLL CPLsnprintf(char *str, size_t size, + const char* fmt, ...) CPL_PRINT_FUNC_FORMAT(3,4); +#if defined(GDAL_COMPILATION) && !defined(DONT_DEPRECATE_SPRINTF) +int CPL_DLL CPLsprintf(char *str, const char* fmt, ...) + CPL_PRINT_FUNC_FORMAT(2, 3) CPL_WARN_DEPRECATED("Use CPLsnprintf instead"); +#else +int CPL_DLL CPLsprintf(char *str, const char* fmt, ...) + CPL_PRINT_FUNC_FORMAT(2, 3); +#endif +int CPL_DLL CPLprintf(const char* fmt, ...) CPL_PRINT_FUNC_FORMAT(1, 2); +/* caution: only works with limited number of formats */ +int CPL_DLL CPLsscanf(const char* str, const char* fmt, ...) + CPL_SCAN_FUNC_FORMAT(2, 3); + +const char CPL_DLL *CPLSPrintf(const char *fmt, ...) + CPL_PRINT_FUNC_FORMAT(1, 2) CPL_WARN_UNUSED_RESULT; +char CPL_DLL **CSLAppendPrintf(char **papszStrList, const char *fmt, ...) + CPL_PRINT_FUNC_FORMAT(2, 3) CPL_WARN_UNUSED_RESULT; +int CPL_DLL CPLVASPrintf(char **buf, const char *fmt, va_list args ) + CPL_PRINT_FUNC_FORMAT(2, 0); + +/* -------------------------------------------------------------------- */ +/* RFC 23 character set conversion/recoding API (cpl_recode.cpp). */ +/* -------------------------------------------------------------------- */ +#define CPL_ENC_LOCALE "" +#define CPL_ENC_UTF8 "UTF-8" +#define CPL_ENC_UTF16 "UTF-16" +#define CPL_ENC_UCS2 "UCS-2" +#define CPL_ENC_UCS4 "UCS-4" +#define CPL_ENC_ASCII "ASCII" +#define CPL_ENC_ISO8859_1 "ISO-8859-1" + +int CPL_DLL CPLEncodingCharSize( const char *pszEncoding ); +void CPL_DLL CPLClearRecodeWarningFlags( void ); +char CPL_DLL *CPLRecode( + const char *pszSource, const char *pszSrcEncoding, + const char *pszDstEncoding ) CPL_WARN_UNUSED_RESULT CPL_RETURNS_NONNULL; +char CPL_DLL *CPLRecodeFromWChar( + const wchar_t *pwszSource, const char *pszSrcEncoding, + const char *pszDstEncoding ) CPL_WARN_UNUSED_RESULT; +wchar_t CPL_DLL *CPLRecodeToWChar( + const char *pszSource, const char *pszSrcEncoding, + const char *pszDstEncoding ) CPL_WARN_UNUSED_RESULT; +int CPL_DLL CPLIsUTF8(const char* pabyData, int nLen); +char CPL_DLL *CPLForceToASCII( + const char* pabyData, int nLen, + char chReplacementChar) CPL_WARN_UNUSED_RESULT; +int CPL_DLL CPLStrlenUTF8(const char *pszUTF8Str); + +CPL_C_END + +/************************************************************************/ +/* CPLString */ +/************************************************************************/ + +#if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS) + +#include + +/* + * Simple trick to avoid "using" declaration in header for new compilers + * but make it still working with old compilers which throw C2614 errors. + * + * Define MSVC_OLD_STUPID_BEHAVIOUR + * for old compilers: VC++ 5 and 6 as well as eVC++ 3 and 4. + */ + +/* + * Detect old MSVC++ compiler <= 6.0 + * 1200 - VC++ 6.0 + * 1200-1202 - eVC++ 4.0 + */ +#if defined(_MSC_VER) +# if (_MSC_VER <= 1202) +# define MSVC_OLD_STUPID_BEHAVIOUR +# endif +#endif + +/* Avoid C2614 errors */ +#ifdef MSVC_OLD_STUPID_BEHAVIOUR + using std::string; +# define gdal_std_string string +#else +# define gdal_std_string std::string +#endif + +//! Convenient string class based on std::string. +class CPL_DLL CPLString : public gdal_std_string +{ +public: + + CPLString(void) {} + CPLString( const std::string &oStr ) : gdal_std_string( oStr ) {} + CPLString( const char *pszStr ) : gdal_std_string( pszStr ) {} + + operator const char* (void) const { return c_str(); } + + char& operator[](std::string::size_type i) + { + return gdal_std_string::operator[](i); + } + + const char& operator[](std::string::size_type i) const + { + return gdal_std_string::operator[](i); + } + + char& operator[](int i) + { + return gdal_std_string::operator[]( + static_cast(i)); + } + + const char& operator[](int i) const + { + return gdal_std_string::operator[]( + static_cast(i)); + } + + void Clear() { resize(0); } + + // NULL safe assign and free. + void Seize(char *pszValue) + { + if (pszValue == NULL ) + Clear(); + else + { + *this = pszValue; + CPLFree(pszValue); + } + } + + /* There seems to be a bug in the way the compiler count indices... + * Should be CPL_PRINT_FUNC_FORMAT (1, 2) */ + CPLString &Printf( + const char *pszFormat, ... ) CPL_PRINT_FUNC_FORMAT (2, 3); + CPLString &vPrintf( + const char *pszFormat, va_list args ) CPL_PRINT_FUNC_FORMAT(2, 0); + CPLString &FormatC( double dfValue, const char *pszFormat = NULL ); + CPLString &Trim(); + CPLString &Recode( const char *pszSrcEncoding, const char *pszDstEncoding ); + + /* case insensitive find alternates */ + size_t ifind( const std::string & str, size_t pos = 0 ) const; + size_t ifind( const char * s, size_t pos = 0 ) const; + CPLString &toupper( void ); + CPLString &tolower( void ); +}; + +CPLString CPLOPrintf(const char *pszFormat, ... ) CPL_PRINT_FUNC_FORMAT (1, 2); +CPLString CPLOvPrintf( + const char *pszFormat, va_list args) CPL_PRINT_FUNC_FORMAT (1, 0); + +/* -------------------------------------------------------------------- */ +/* URL processing functions, here since they depend on CPLString. */ +/* -------------------------------------------------------------------- */ +CPLString CPL_DLL CPLURLGetValue(const char* pszURL, const char* pszKey); +CPLString CPL_DLL CPLURLAddKVP(const char* pszURL, const char* pszKey, + const char* pszValue); + +/************************************************************************/ +/* CPLStringList */ +/************************************************************************/ + +//! String list class designed around our use of C "char**" string lists. +class CPL_DLL CPLStringList +{ + char **papszList; + mutable int nCount; + mutable int nAllocation; + bool bOwnList; + bool bIsSorted; + + void Initialize(); + void MakeOurOwnCopy(); + void EnsureAllocation( int nMaxLength ); + int FindSortedInsertionPoint( const char *pszLine ); + + public: + CPLStringList(); + CPLStringList( char **papszList, int bTakeOwnership=TRUE ); + CPLStringList( const CPLStringList& oOther ); + ~CPLStringList(); + + CPLStringList &Clear(); + + int size() const { return Count(); } + int Count() const; + + CPLStringList &AddString( const char *pszNewString ); + CPLStringList &AddStringDirectly( char *pszNewString ); + + CPLStringList &InsertString( int nInsertAtLineNo, const char *pszNewLine ) + { return InsertStringDirectly( nInsertAtLineNo, CPLStrdup(pszNewLine) ); } + CPLStringList &InsertStringDirectly( int nInsertAtLineNo, char *pszNewLine); + + // CPLStringList &InsertStrings( int nInsertAtLineNo, char **papszNewLines ); + // CPLStringList &RemoveStrings( int nFirstLineToDelete, int nNumToRemove=1 ); + + int FindString( const char *pszTarget ) const + { return CSLFindString( papszList, pszTarget ); } + int PartialFindString( const char *pszNeedle ) const + { return CSLPartialFindString( papszList, pszNeedle ); } + + int FindName( const char *pszName ) const; + bool FetchBool( const char *pszKey, bool bDefault ) const; + // Deprecated. + int FetchBoolean( const char *pszKey, int bDefault ) const; + const char *FetchNameValue( const char *pszKey ) const; + const char *FetchNameValueDef( + const char *pszKey, const char *pszDefault ) const; + CPLStringList &AddNameValue( const char *pszKey, const char *pszValue ); + CPLStringList &SetNameValue( const char *pszKey, const char *pszValue ); + + CPLStringList &Assign( char **papszListIn, int bTakeOwnership=TRUE ); + CPLStringList &operator=(char **papszListIn) { + return Assign( papszListIn, TRUE ); } + CPLStringList &operator=(const CPLStringList& oOther); + + char * operator[](int i); + char * operator[](size_t i) { return (*this)[static_cast(i)]; } + const char * operator[](int i) const; + const char * operator[](size_t i) const { + return (*this)[static_cast(i)]; } + + char **List() { return papszList; } + char **StealList(); + + CPLStringList &Sort(); + int IsSorted() const { return bIsSorted; } + + operator char**(void) { return List(); } +}; + +#endif /* def __cplusplus && !CPL_SUPRESS_CPLUSPLUS */ + +#endif /* CPL_STRING_H_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/cpl_time.h b/modules/globebrowsing/ext/gdal/include/cpl_time.h new file mode 100644 index 0000000000..4a60cb3f86 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/cpl_time.h @@ -0,0 +1,41 @@ +/********************************************************************** + * $Id$ + * + * Name: cpl_time.h + * Project: CPL - Common Portability Library + * Purpose: Time functions. + * Author: Even Rouault, + * + ********************************************************************** + * Copyright (c) 2009, Even Rouault + * + * 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. + ****************************************************************************/ + +#ifndef CPL_TIME_H_INCLUDED +#define CPL_TIME_H_INCLUDED + +#include + +#include "cpl_port.h" + +struct tm CPL_DLL * CPLUnixTimeToYMDHMS(GIntBig unixTime, struct tm* pRet); +GIntBig CPL_DLL CPLYMDHMSToUnixTime(const struct tm *brokendowntime); + +#endif // CPL_TIME_H_INCLUDED diff --git a/modules/globebrowsing/ext/gdal/include/cpl_virtualmem.h b/modules/globebrowsing/ext/gdal/include/cpl_virtualmem.h new file mode 100644 index 0000000000..eaf42e3129 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/cpl_virtualmem.h @@ -0,0 +1,390 @@ +/********************************************************************** + * $Id$ + * + * Name: cpl_virtualmem.h + * Project: CPL - Common Portability Library + * Purpose: Virtual memory + * Author: Even Rouault, + * + ********************************************************************** + * Copyright (c) 2014, Even Rouault + * + * 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. + ****************************************************************************/ + +#ifndef CPL_VIRTUAL_MEM_INCLUDED +#define CPL_VIRTUAL_MEM_INCLUDED + +#include "cpl_port.h" +#include "cpl_vsi.h" + +CPL_C_START + +/** + * \file cpl_virtualmem.h + * + * Virtual memory management. + * + * This file provides mechanism to define virtual memory mappings, whose content + * is allocated transparently and filled on-the-fly. Those virtual memory mappings + * can be much larger than the available RAM, but only parts of the virtual + * memory mapping, in the limit of the allowed the cache size, will actually be + * physically allocated. + * + * This exploits low-level mechanisms of the operating system (virtual memory + * allocation, page protection and handler of virtual memory exceptions). + * + * It is also possible to create a virtual memory mapping from a file or part + * of a file. + * + * The current implementation is Linux only. + */ + +/** Opaque type that represents a virtual memory mapping. */ +typedef struct CPLVirtualMem CPLVirtualMem; + +/** Callback triggered when a still unmapped page of virtual memory is accessed. + * The callback has the responsibility of filling the page with relevant values + * + * @param ctxt virtual memory handle. + * @param nOffset offset of the page in the memory mapping. + * @param pPageToFill address of the page to fill. Note that the address might + * be a temporary location, and not at CPLVirtualMemGetAddr() + nOffset. + * @param nToFill number of bytes of the page. + * @param pUserData user data that was passed to CPLVirtualMemNew(). + */ +typedef void (*CPLVirtualMemCachePageCbk)(CPLVirtualMem* ctxt, + size_t nOffset, + void* pPageToFill, + size_t nToFill, + void* pUserData); + +/** Callback triggered when a dirty mapped page is going to be freed. + * (saturation of cache, or termination of the virtual memory mapping). + * + * @param ctxt virtual memory handle. + * @param nOffset offset of the page in the memory mapping. + * @param pPageToBeEvicted address of the page that will be flushed. Note that the address might + * be a temporary location, and not at CPLVirtualMemGetAddr() + nOffset. + * @param nToBeEvicted number of bytes of the page. + * @param pUserData user data that was passed to CPLVirtualMemNew(). + */ +typedef void (*CPLVirtualMemUnCachePageCbk)(CPLVirtualMem* ctxt, + size_t nOffset, + const void* pPageToBeEvicted, + size_t nToBeEvicted, + void* pUserData); + +/** Callback triggered when a virtual memory mapping is destroyed. + * @param pUserData user data that was passed to CPLVirtualMemNew(). + */ +typedef void (*CPLVirtualMemFreeUserData)(void* pUserData); + +/** Access mode of a virtual memory mapping. */ +typedef enum +{ + /*! The mapping is meant at being read-only, but writes will not be prevented. + Note that any content written will be lost. */ + VIRTUALMEM_READONLY, + /*! The mapping is meant at being read-only, and this will be enforced + through the operating system page protection mechanism. */ + VIRTUALMEM_READONLY_ENFORCED, + /*! The mapping is meant at being read-write, and modified pages can be saved + thanks to the pfnUnCachePage callback */ + VIRTUALMEM_READWRITE +} CPLVirtualMemAccessMode; + + +/** Return the size of a page of virtual memory. + * + * @return the page size. + * + * @since GDAL 1.11 + */ +size_t CPL_DLL CPLGetPageSize(void); + +/** Create a new virtual memory mapping. + * + * This will reserve an area of virtual memory of size nSize, whose size + * might be potentially much larger than the physical memory available. Initially, + * no physical memory will be allocated. As soon as memory pages will be accessed, + * they will be allocated transparently and filled with the pfnCachePage callback. + * When the allowed cache size is reached, the least recently used pages will + * be unallocated. + * + * On Linux AMD64 platforms, the maximum value for nSize is 128 TB. + * On Linux x86 platforms, the maximum value for nSize is 2 GB. + * + * Only supported on Linux for now. + * + * Note that on Linux, this function will install a SIGSEGV handler. The + * original handler will be restored by CPLVirtualMemManagerTerminate(). + * + * @param nSize size in bytes of the virtual memory mapping. + * @param nCacheSize size in bytes of the maximum memory that will be really + * allocated (must ideally fit into RAM). + * @param nPageSizeHint hint for the page size. Must be a multiple of the + * system page size, returned by CPLGetPageSize(). + * Minimum value is generally 4096. Might be set to 0 to + * let the function determine a default page size. + * @param bSingleThreadUsage set to TRUE if there will be no concurrent threads + * that will access the virtual memory mapping. This can + * optimize performance a bit. + * @param eAccessMode permission to use for the virtual memory mapping. + * @param pfnCachePage callback triggered when a still unmapped page of virtual + * memory is accessed. The callback has the responsibility + * of filling the page with relevant values. + * @param pfnUnCachePage callback triggered when a dirty mapped page is going to + * be freed (saturation of cache, or termination of the + * virtual memory mapping). Might be NULL. + * @param pfnFreeUserData callback that can be used to free pCbkUserData. Might be + * NULL + * @param pCbkUserData user data passed to pfnCachePage and pfnUnCachePage. + * + * @return a virtual memory object that must be freed by CPLVirtualMemFree(), + * or NULL in case of failure. + * + * @since GDAL 1.11 + */ + +CPLVirtualMem CPL_DLL *CPLVirtualMemNew(size_t nSize, + size_t nCacheSize, + size_t nPageSizeHint, + int bSingleThreadUsage, + CPLVirtualMemAccessMode eAccessMode, + CPLVirtualMemCachePageCbk pfnCachePage, + CPLVirtualMemUnCachePageCbk pfnUnCachePage, + CPLVirtualMemFreeUserData pfnFreeUserData, + void *pCbkUserData); + + +/** Return if virtual memory mapping of a file is available. + * + * @return TRUE if virtual memory mapping of a file is available. + * @since GDAL 1.11 + */ +int CPL_DLL CPLIsVirtualMemFileMapAvailable(void); + +/** Create a new virtual memory mapping from a file. + * + * The file must be a "real" file recognized by the operating system, and not + * a VSI extended virtual file. + * + * In VIRTUALMEM_READWRITE mode, updates to the memory mapping will be written + * in the file. + * + * On Linux AMD64 platforms, the maximum value for nLength is 128 TB. + * On Linux x86 platforms, the maximum value for nLength is 2 GB. + * + * Supported on Linux only in GDAL <= 2.0, and all POSIX systems supporting + * mmap() in GDAL >= 2.1 + * + * @param fp Virtual file handle. + * @param nOffset Offset in the file to start the mapping from. + * @param nLength Length of the portion of the file to map into memory. + * @param eAccessMode Permission to use for the virtual memory mapping. This must + * be consistent with how the file has been opened. + * @param pfnFreeUserData callback that is called when the object is destroyed. + * @param pCbkUserData user data passed to pfnFreeUserData. + * @return a virtual memory object that must be freed by CPLVirtualMemFree(), + * or NULL in case of failure. + * + * @since GDAL 1.11 + */ +CPLVirtualMem CPL_DLL *CPLVirtualMemFileMapNew( VSILFILE* fp, + vsi_l_offset nOffset, + vsi_l_offset nLength, + CPLVirtualMemAccessMode eAccessMode, + CPLVirtualMemFreeUserData pfnFreeUserData, + void *pCbkUserData ); + +/** Create a new virtual memory mapping derived from an other virtual memory + * mapping. + * + * This may be useful in case of creating mapping for pixel interleaved data. + * + * The new mapping takes a reference on the base mapping. + * + * @param pVMemBase Base virtual memory mapping + * @param nOffset Offset in the base virtual memory mapping from which to start + * the new mapping. + * @param nSize Size of the base virtual memory mapping to expose in the + * the new mapping. + * @param pfnFreeUserData callback that is called when the object is destroyed. + * @param pCbkUserData user data passed to pfnFreeUserData. + * @return a virtual memory object that must be freed by CPLVirtualMemFree(), + * or NULL in case of failure. + * + * @since GDAL 1.11 + */ +CPLVirtualMem CPL_DLL *CPLVirtualMemDerivedNew(CPLVirtualMem* pVMemBase, + vsi_l_offset nOffset, + vsi_l_offset nSize, + CPLVirtualMemFreeUserData pfnFreeUserData, + void *pCbkUserData); + +/** Free a virtual memory mapping. + * + * The pointer returned by CPLVirtualMemGetAddr() will no longer be valid. + * If the virtual memory mapping was created with read/write permissions and that + * they are dirty (i.e. modified) pages, they will be flushed through the + * pfnUnCachePage callback before being freed. + * + * @param ctxt context returned by CPLVirtualMemNew(). + * + * @since GDAL 1.11 + */ +void CPL_DLL CPLVirtualMemFree(CPLVirtualMem* ctxt); + +/** Return the pointer to the start of a virtual memory mapping. + * + * The bytes in the range [p:p+CPLVirtualMemGetSize()-1] where p is the pointer + * returned by this function will be valid, until CPLVirtualMemFree() is called. + * + * Note that if a range of bytes used as an argument of a system call + * (such as read() or write()) contains pages that have not been "realized", the + * system call will fail with EFAULT. CPLVirtualMemPin() can be used to work + * around this issue. + * + * @param ctxt context returned by CPLVirtualMemNew(). + * @return the pointer to the start of a virtual memory mapping. + * + * @since GDAL 1.11 + */ +void CPL_DLL *CPLVirtualMemGetAddr(CPLVirtualMem* ctxt); + +/** Return the size of the virtual memory mapping. + * + * @param ctxt context returned by CPLVirtualMemNew(). + * @return the size of the virtual memory mapping. + * + * @since GDAL 1.11 + */ +size_t CPL_DLL CPLVirtualMemGetSize(CPLVirtualMem* ctxt); + +/** Return if the virtual memory mapping is a direct file mapping. + * + * @param ctxt context returned by CPLVirtualMemNew(). + * @return TRUE if the virtual memory mapping is a direct file mapping. + * + * @since GDAL 1.11 + */ +int CPL_DLL CPLVirtualMemIsFileMapping(CPLVirtualMem* ctxt); + +/** Return the access mode of the virtual memory mapping. + * + * @param ctxt context returned by CPLVirtualMemNew(). + * @return the access mode of the virtual memory mapping. + * + * @since GDAL 1.11 + */ +CPLVirtualMemAccessMode CPL_DLL CPLVirtualMemGetAccessMode(CPLVirtualMem* ctxt); + +/** Return the page size associated to a virtual memory mapping. + * + * The value returned will be at least CPLGetPageSize(), but potentially + * larger. + * + * @param ctxt context returned by CPLVirtualMemNew(). + * @return the page size + * + * @since GDAL 1.11 + */ +size_t CPL_DLL CPLVirtualMemGetPageSize(CPLVirtualMem* ctxt); + +/** Return TRUE if this memory mapping can be accessed safely from concurrent + * threads. + * + * The situation that can cause problems is when several threads try to access + * a page of the mapping that is not yet mapped. + * + * The return value of this function depends on whether bSingleThreadUsage has + * been set of not in CPLVirtualMemNew() and/or the implementation. + * + * On Linux, this will always return TRUE if bSingleThreadUsage = FALSE. + * + * @param ctxt context returned by CPLVirtualMemNew(). + * @return TRUE if this memory mapping can be accessed safely from concurrent + * threads. + * + * @since GDAL 1.11 + */ +int CPL_DLL CPLVirtualMemIsAccessThreadSafe(CPLVirtualMem* ctxt); + +/** Declare that a thread will access a virtual memory mapping. + * + * This function must be called by a thread that wants to access the + * content of a virtual memory mapping, except if the virtual memory mapping has + * been created with bSingleThreadUsage = TRUE. + * + * This function must be paired with CPLVirtualMemUnDeclareThread(). + * + * @param ctxt context returned by CPLVirtualMemNew(). + * + * @since GDAL 1.11 + */ +void CPL_DLL CPLVirtualMemDeclareThread(CPLVirtualMem* ctxt); + +/** Declare that a thread will stop accessing a virtual memory mapping. + * + * This function must be called by a thread that will no longer access the + * content of a virtual memory mapping, except if the virtual memory mapping has + * been created with bSingleThreadUsage = TRUE. + * + * This function must be paired with CPLVirtualMemDeclareThread(). + * + * @param ctxt context returned by CPLVirtualMemNew(). + * + * @since GDAL 1.11 + */ +void CPL_DLL CPLVirtualMemUnDeclareThread(CPLVirtualMem* ctxt); + +/** Make sure that a region of virtual memory will be realized. + * + * Calling this function is not required, but might be useful when debugging + * a process with tools like gdb or valgrind that do not naturally like + * segmentation fault signals. + * + * It is also needed when wanting to provide part of virtual memory mapping + * to a system call such as read() or write(). If read() or write() is called + * on a memory region not yet realized, the call will fail with EFAULT. + * + * @param ctxt context returned by CPLVirtualMemNew(). + * @param pAddr the memory region to pin. + * @param nSize the size of the memory region. + * @param bWriteOp set to TRUE if the memory are will be accessed in write mode. + * + * @since GDAL 1.11 + */ +void CPL_DLL CPLVirtualMemPin(CPLVirtualMem* ctxt, + void* pAddr, size_t nSize, int bWriteOp); + +/** Cleanup any resource and handlers related to virtual memory. + * + * This function must be called after the last CPLVirtualMem object has + * been freed. + * + * @since GDAL 2.0 + */ +void CPL_DLL CPLVirtualMemManagerTerminate(void); + + +CPL_C_END + +#endif /* CPL_VIRTUAL_MEM_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/cpl_vsi.h b/modules/globebrowsing/ext/gdal/include/cpl_vsi.h new file mode 100644 index 0000000000..405a8bc4f7 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/cpl_vsi.h @@ -0,0 +1,311 @@ +/****************************************************************************** + * $Id$ + * + * Project: CPL - Common Portability Library + * Author: Frank Warmerdam, warmerdam@pobox.com + * Purpose: Include file defining Virtual File System (VSI) functions, a + * layer over POSIX file and other system services. + * + ****************************************************************************** + * Copyright (c) 1998, Frank Warmerdam + * Copyright (c) 2008-2014, Even Rouault + * + * 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. + ****************************************************************************/ + +#ifndef CPL_VSI_H_INCLUDED +#define CPL_VSI_H_INCLUDED + +#include "cpl_port.h" +/** + * \file cpl_vsi.h + * + * Standard C Covers + * + * The VSI functions are intended to be hookable aliases for Standard C + * I/O, memory allocation and other system functions. They are intended + * to allow virtualization of disk I/O so that non file data sources + * can be made to appear as files, and so that additional error trapping + * and reporting can be interested. The memory access API is aliased + * so that special application memory management services can be used. + * + * It is intended that each of these functions retains exactly the same + * calling pattern as the original Standard C functions they relate to. + * This means we don't have to provide custom documentation, and also means + * that the default implementation is very simple. + */ + +/* -------------------------------------------------------------------- */ +/* We need access to ``struct stat''. */ +/* -------------------------------------------------------------------- */ + +/* Unix */ +#if !defined(_WIN32) +# include +#endif + +/* Windows */ +#include + +CPL_C_START + +#ifdef ENABLE_EXPERIMENTAL_CPL_WARN_UNUSED_RESULT +#define EXPERIMENTAL_CPL_WARN_UNUSED_RESULT CPL_WARN_UNUSED_RESULT +#else +#define EXPERIMENTAL_CPL_WARN_UNUSED_RESULT +#endif + +/* ==================================================================== */ +/* stdio file access functions. These may not support large */ +/* files, and don't necessarily go through the virtualization */ +/* API. */ +/* ==================================================================== */ + +FILE CPL_DLL * VSIFOpen( const char *, const char * ) CPL_WARN_UNUSED_RESULT; +int CPL_DLL VSIFClose( FILE * ); +int CPL_DLL VSIFSeek( FILE *, long, int ) EXPERIMENTAL_CPL_WARN_UNUSED_RESULT; +long CPL_DLL VSIFTell( FILE * ) CPL_WARN_UNUSED_RESULT; +void CPL_DLL VSIRewind( FILE * ); +void CPL_DLL VSIFFlush( FILE * ); + +size_t CPL_DLL VSIFRead( void *, size_t, size_t, FILE * ) EXPERIMENTAL_CPL_WARN_UNUSED_RESULT; +size_t CPL_DLL VSIFWrite( const void *, size_t, size_t, FILE * ) EXPERIMENTAL_CPL_WARN_UNUSED_RESULT; +char CPL_DLL *VSIFGets( char *, int, FILE * ) EXPERIMENTAL_CPL_WARN_UNUSED_RESULT; +int CPL_DLL VSIFPuts( const char *, FILE * ) EXPERIMENTAL_CPL_WARN_UNUSED_RESULT; +int CPL_DLL VSIFPrintf( FILE *, const char *, ... ) EXPERIMENTAL_CPL_WARN_UNUSED_RESULT CPL_PRINT_FUNC_FORMAT(2, 3); + +int CPL_DLL VSIFGetc( FILE * ) EXPERIMENTAL_CPL_WARN_UNUSED_RESULT; +int CPL_DLL VSIFPutc( int, FILE * ) EXPERIMENTAL_CPL_WARN_UNUSED_RESULT; +int CPL_DLL VSIUngetc( int, FILE * ) EXPERIMENTAL_CPL_WARN_UNUSED_RESULT; +int CPL_DLL VSIFEof( FILE * ) EXPERIMENTAL_CPL_WARN_UNUSED_RESULT; + +/* ==================================================================== */ +/* VSIStat() related. */ +/* ==================================================================== */ + +typedef struct stat VSIStatBuf; +int CPL_DLL VSIStat( const char *, VSIStatBuf * ) CPL_WARN_UNUSED_RESULT; + +#ifdef _WIN32 +# define VSI_ISLNK(x) ( 0 ) /* N/A on Windows */ +# define VSI_ISREG(x) ((x) & S_IFREG) +# define VSI_ISDIR(x) ((x) & S_IFDIR) +# define VSI_ISCHR(x) ((x) & S_IFCHR) +# define VSI_ISBLK(x) ( 0 ) /* N/A on Windows */ +#else +# define VSI_ISLNK(x) S_ISLNK(x) +# define VSI_ISREG(x) S_ISREG(x) +# define VSI_ISDIR(x) S_ISDIR(x) +# define VSI_ISCHR(x) S_ISCHR(x) +# define VSI_ISBLK(x) S_ISBLK(x) +#endif + +/* ==================================================================== */ +/* 64bit stdio file access functions. If we have a big size */ +/* defined, then provide prototypes for the large file API, */ +/* otherwise redefine to use the regular api. */ +/* ==================================================================== */ +typedef GUIntBig vsi_l_offset; +#define VSI_L_OFFSET_MAX GUINTBIG_MAX + +/* Make VSIL_STRICT_ENFORCE active in DEBUG builds */ +#ifdef DEBUG +#define VSIL_STRICT_ENFORCE +#endif + +#ifdef VSIL_STRICT_ENFORCE +typedef struct _VSILFILE VSILFILE; +#else +typedef FILE VSILFILE; +#endif + +VSILFILE CPL_DLL * VSIFOpenL( const char *, const char * ) CPL_WARN_UNUSED_RESULT; +VSILFILE CPL_DLL * VSIFOpenExL( const char *, const char *, int ) CPL_WARN_UNUSED_RESULT; +int CPL_DLL VSIFCloseL( VSILFILE * ) EXPERIMENTAL_CPL_WARN_UNUSED_RESULT; +int CPL_DLL VSIFSeekL( VSILFILE *, vsi_l_offset, int ) EXPERIMENTAL_CPL_WARN_UNUSED_RESULT; +vsi_l_offset CPL_DLL VSIFTellL( VSILFILE * ) CPL_WARN_UNUSED_RESULT; +void CPL_DLL VSIRewindL( VSILFILE * ); +size_t CPL_DLL VSIFReadL( void *, size_t, size_t, VSILFILE * ) EXPERIMENTAL_CPL_WARN_UNUSED_RESULT; +int CPL_DLL VSIFReadMultiRangeL( int nRanges, void ** ppData, const vsi_l_offset* panOffsets, const size_t* panSizes, VSILFILE * ) EXPERIMENTAL_CPL_WARN_UNUSED_RESULT; +size_t CPL_DLL VSIFWriteL( const void *, size_t, size_t, VSILFILE * ) EXPERIMENTAL_CPL_WARN_UNUSED_RESULT; +int CPL_DLL VSIFEofL( VSILFILE * ) EXPERIMENTAL_CPL_WARN_UNUSED_RESULT; +int CPL_DLL VSIFTruncateL( VSILFILE *, vsi_l_offset ) EXPERIMENTAL_CPL_WARN_UNUSED_RESULT; +int CPL_DLL VSIFFlushL( VSILFILE * ) EXPERIMENTAL_CPL_WARN_UNUSED_RESULT; +int CPL_DLL VSIFPrintfL( VSILFILE *, const char *, ... ) EXPERIMENTAL_CPL_WARN_UNUSED_RESULT CPL_PRINT_FUNC_FORMAT(2, 3); +int CPL_DLL VSIFPutcL( int, VSILFILE * ) EXPERIMENTAL_CPL_WARN_UNUSED_RESULT; + +int CPL_DLL VSIIngestFile( VSILFILE* fp, + const char* pszFilename, + GByte** ppabyRet, + vsi_l_offset* pnSize, + GIntBig nMaxSize ) CPL_WARN_UNUSED_RESULT; + +#if defined(VSI_STAT64_T) +typedef struct VSI_STAT64_T VSIStatBufL; +#else +#define VSIStatBufL VSIStatBuf +#endif + +int CPL_DLL VSIStatL( const char *, VSIStatBufL * ) CPL_WARN_UNUSED_RESULT; + +#define VSI_STAT_EXISTS_FLAG 0x1 +#define VSI_STAT_NATURE_FLAG 0x2 +#define VSI_STAT_SIZE_FLAG 0x4 +#define VSI_STAT_SET_ERROR_FLAG 0x8 + +int CPL_DLL VSIStatExL( const char * pszFilename, VSIStatBufL * psStatBuf, int nFlags ) CPL_WARN_UNUSED_RESULT; + +int CPL_DLL VSIIsCaseSensitiveFS( const char * pszFilename ); + +void CPL_DLL *VSIFGetNativeFileDescriptorL( VSILFILE* ); + +/* ==================================================================== */ +/* Memory allocation */ +/* ==================================================================== */ + +void CPL_DLL *VSICalloc( size_t, size_t ) CPL_WARN_UNUSED_RESULT; +void CPL_DLL *VSIMalloc( size_t ) CPL_WARN_UNUSED_RESULT; +void CPL_DLL VSIFree( void * ); +void CPL_DLL *VSIRealloc( void *, size_t ) CPL_WARN_UNUSED_RESULT; +char CPL_DLL *VSIStrdup( const char * ) CPL_WARN_UNUSED_RESULT; + +/** + VSIMalloc2 allocates (nSize1 * nSize2) bytes. + In case of overflow of the multiplication, or if memory allocation fails, a + NULL pointer is returned and a CE_Failure error is raised with CPLError(). + If nSize1 == 0 || nSize2 == 0, a NULL pointer will also be returned. + CPLFree() or VSIFree() can be used to free memory allocated by this function. +*/ +void CPL_DLL *VSIMalloc2( size_t nSize1, size_t nSize2 ) CPL_WARN_UNUSED_RESULT; + +/** + VSIMalloc3 allocates (nSize1 * nSize2 * nSize3) bytes. + In case of overflow of the multiplication, or if memory allocation fails, a + NULL pointer is returned and a CE_Failure error is raised with CPLError(). + If nSize1 == 0 || nSize2 == 0 || nSize3 == 0, a NULL pointer will also be returned. + CPLFree() or VSIFree() can be used to free memory allocated by this function. +*/ +void CPL_DLL *VSIMalloc3( size_t nSize1, size_t nSize2, size_t nSize3 ) CPL_WARN_UNUSED_RESULT; + + +void CPL_DLL *VSIMallocVerbose( size_t nSize, const char* pszFile, int nLine ) CPL_WARN_UNUSED_RESULT; +#define VSI_MALLOC_VERBOSE( size ) VSIMallocVerbose(size,__FILE__,__LINE__) + +void CPL_DLL *VSIMalloc2Verbose( size_t nSize1, size_t nSize2, const char* pszFile, int nLine ) CPL_WARN_UNUSED_RESULT; +#define VSI_MALLOC2_VERBOSE( nSize1, nSize2 ) VSIMalloc2Verbose(nSize1,nSize2,__FILE__,__LINE__) + +void CPL_DLL *VSIMalloc3Verbose( size_t nSize1, size_t nSize2, size_t nSize3, const char* pszFile, int nLine ) CPL_WARN_UNUSED_RESULT; +#define VSI_MALLOC3_VERBOSE( nSize1, nSize2, nSize3 ) VSIMalloc3Verbose(nSize1,nSize2,nSize3,__FILE__,__LINE__) + +void CPL_DLL *VSICallocVerbose( size_t nCount, size_t nSize, const char* pszFile, int nLine ) CPL_WARN_UNUSED_RESULT; +#define VSI_CALLOC_VERBOSE( nCount, nSize ) VSICallocVerbose(nCount,nSize,__FILE__,__LINE__) + +void CPL_DLL *VSIReallocVerbose( void* pOldPtr, size_t nNewSize, const char* pszFile, int nLine ) CPL_WARN_UNUSED_RESULT; +#define VSI_REALLOC_VERBOSE( pOldPtr, nNewSize ) VSIReallocVerbose(pOldPtr,nNewSize,__FILE__,__LINE__) + +char CPL_DLL *VSIStrdupVerbose( const char* pszStr, const char* pszFile, int nLine ) CPL_WARN_UNUSED_RESULT; +#define VSI_STRDUP_VERBOSE( pszStr ) VSIStrdupVerbose(pszStr,__FILE__,__LINE__) + + +GIntBig CPL_DLL CPLGetPhysicalRAM(void); +GIntBig CPL_DLL CPLGetUsablePhysicalRAM(void); + +/* ==================================================================== */ +/* Other... */ +/* ==================================================================== */ + +#define CPLReadDir VSIReadDir +char CPL_DLL **VSIReadDir( const char * ); +char CPL_DLL **VSIReadDirRecursive( const char *pszPath ); +char CPL_DLL **VSIReadDirEx( const char *pszPath, int nMaxFiles ); +int CPL_DLL VSIMkdir( const char * pathname, long mode ); +int CPL_DLL VSIRmdir( const char * pathname ); +int CPL_DLL VSIUnlink( const char * pathname ); +int CPL_DLL VSIRename( const char * oldpath, const char * newpath ); +char CPL_DLL *VSIStrerror( int ); +GIntBig CPL_DLL VSIGetDiskFreeSpace(const char *pszDirname); + +/* ==================================================================== */ +/* Install special file access handlers. */ +/* ==================================================================== */ +void CPL_DLL VSIInstallMemFileHandler(void); +void CPL_DLL VSIInstallLargeFileHandler(void); +void CPL_DLL VSIInstallSubFileHandler(void); +void VSIInstallCurlFileHandler(void); +void VSIInstallCurlStreamingFileHandler(void); +void VSIInstallS3FileHandler(void); +void VSIInstallS3StreamingFileHandler(void); +void VSIInstallGZipFileHandler(void); /* No reason to export that */ +void VSIInstallZipFileHandler(void); /* No reason to export that */ +void VSIInstallStdinHandler(void); /* No reason to export that */ +void VSIInstallStdoutHandler(void); /* No reason to export that */ +void CPL_DLL VSIInstallSparseFileHandler(void); +void VSIInstallTarFileHandler(void); /* No reason to export that */ +void CPL_DLL VSIInstallCryptFileHandler(void); +void CPL_DLL VSISetCryptKey(const GByte* pabyKey, int nKeySize); +void CPL_DLL VSICleanupFileManager(void); + +VSILFILE CPL_DLL *VSIFileFromMemBuffer( const char *pszFilename, + GByte *pabyData, + vsi_l_offset nDataLength, + int bTakeOwnership ) CPL_WARN_UNUSED_RESULT; +GByte CPL_DLL *VSIGetMemFileBuffer( const char *pszFilename, + vsi_l_offset *pnDataLength, + int bUnlinkAndSeize ); + +typedef size_t (*VSIWriteFunction)(const void* ptr, size_t size, size_t nmemb, FILE* stream); +void CPL_DLL VSIStdoutSetRedirection( VSIWriteFunction pFct, FILE* stream ); + +/* ==================================================================== */ +/* Time querying. */ +/* ==================================================================== */ + +unsigned long CPL_DLL VSITime( unsigned long * ); +const char CPL_DLL *VSICTime( unsigned long ); +struct tm CPL_DLL *VSIGMTime( const time_t *pnTime, + struct tm *poBrokenTime ); +struct tm CPL_DLL *VSILocalTime( const time_t *pnTime, + struct tm *poBrokenTime ); + +/* -------------------------------------------------------------------- */ +/* the following can be turned on for detailed logging of */ +/* almost all IO calls. */ +/* -------------------------------------------------------------------- */ +#ifdef VSI_DEBUG + +#ifndef DEBUG +# define DEBUG +#endif + +#include "cpl_error.h" + +#define VSIDebug4(f,a1,a2,a3,a4) CPLDebug( "VSI", f, a1, a2, a3, a4 ); +#define VSIDebug3( f, a1, a2, a3 ) CPLDebug( "VSI", f, a1, a2, a3 ); +#define VSIDebug2( f, a1, a2 ) CPLDebug( "VSI", f, a1, a2 ); +#define VSIDebug1( f, a1 ) CPLDebug( "VSI", f, a1 ); +#else +#define VSIDebug4( f, a1, a2, a3, a4 ) {} +#define VSIDebug3( f, a1, a2, a3 ) {} +#define VSIDebug2( f, a1, a2 ) {} +#define VSIDebug1( f, a1 ) {} +#endif + +CPL_C_END + +#endif /* ndef CPL_VSI_H_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/cpl_vsi_error.h b/modules/globebrowsing/ext/gdal/include/cpl_vsi_error.h new file mode 100644 index 0000000000..3a99b01ab6 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/cpl_vsi_error.h @@ -0,0 +1,67 @@ +/****************************************************************************** + * $Id$ + * + * Project: VSI Virtual File System + * Purpose: Implement an error system for reporting file system errors. + * Filesystem errors need to be handled separately from the + * CPLError architecture because they are potentially ignored. + * Author: Rob Emanuele, rdemanuele at gmail.com + * + ****************************************************************************** + * Copyright (c) 2016, Rob Emanuele + * + * 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. + ****************************************************************************/ + +#ifndef CPL_VSI_ERROR_H_INCLUDED +#define CPL_VSI_ERROR_H_INCLUDED + +#include "cpl_port.h" +#include "cpl_error.h" + +/* ==================================================================== + Filesystem error codes. + ==================================================================== */ + +CPL_C_START + +typedef int VSIErrorNum; + +#define VSIE_None 0 +#define VSIE_FileError 1 +#define VSIE_HttpError 2 + +#define VSIE_AWSError 5 +#define VSIE_AWSAccessDenied 6 +#define VSIE_AWSBucketNotFound 7 +#define VSIE_AWSObjectNotFound 8 +#define VSIE_AWSInvalidCredentials 9 +#define VSIE_AWSSignatureDoesNotMatch 10 + +void CPL_DLL VSIError(VSIErrorNum err_no, const char *fmt, ...) CPL_PRINT_FUNC_FORMAT (2, 3); + +void CPL_DLL CPL_STDCALL VSIErrorReset( void ); +VSIErrorNum CPL_DLL CPL_STDCALL VSIGetLastErrorNo( void ); +const char CPL_DLL * CPL_STDCALL VSIGetLastErrorMsg( void ); + +int CPL_DLL CPL_STDCALL VSIToCPLError(CPLErr eErrClass, CPLErrorNum eDefaultErrorNo); + +CPL_C_END + +#endif /* CPL_VSI_ERROR_H_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/cpl_vsi_virtual.h b/modules/globebrowsing/ext/gdal/include/cpl_vsi_virtual.h new file mode 100644 index 0000000000..7029404441 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/cpl_vsi_virtual.h @@ -0,0 +1,208 @@ +/****************************************************************************** + * $Id$ + * + * Project: VSI Virtual File System + * Purpose: Declarations for classes related to the virtual filesystem. + * These would only be normally required by applications implementing + * their own virtual file system classes which should be rare. + * The class interface may be fragile through versions. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2005, Frank Warmerdam + * Copyright (c) 2010-2014, Even Rouault + * + * 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. + ****************************************************************************/ + +#ifndef CPL_VSI_VIRTUAL_H_INCLUDED +#define CPL_VSI_VIRTUAL_H_INCLUDED + +#include "cpl_vsi.h" +#include "cpl_vsi_error.h" +#include "cpl_string.h" +#include "cpl_multiproc.h" + +#include +#include +#include + +/************************************************************************/ +/* VSIVirtualHandle */ +/************************************************************************/ + +class CPL_DLL VSIVirtualHandle { + public: + virtual int Seek( vsi_l_offset nOffset, int nWhence ) = 0; + virtual vsi_l_offset Tell() = 0; + virtual size_t Read( void *pBuffer, size_t nSize, size_t nMemb ) = 0; + virtual int ReadMultiRange( int nRanges, void ** ppData, const vsi_l_offset* panOffsets, const size_t* panSizes ); + virtual size_t Write( const void *pBuffer, size_t nSize,size_t nMemb)=0; + virtual int Eof() = 0; + virtual int Flush() {return 0;} + virtual int Close() = 0; + virtual int Truncate( CPL_UNUSED vsi_l_offset nNewSize ) { return -1; } + virtual void *GetNativeFileDescriptor() { return NULL; } + virtual ~VSIVirtualHandle() { } +}; + +/************************************************************************/ +/* VSIFilesystemHandler */ +/************************************************************************/ + +class CPL_DLL VSIFilesystemHandler { + +public: + + virtual ~VSIFilesystemHandler() {} + + VSIVirtualHandle *Open( const char *pszFilename, + const char *pszAccess ); + + virtual VSIVirtualHandle *Open( const char *pszFilename, + const char *pszAccess, + bool bSetError ) = 0; + virtual int Stat( const char *pszFilename, VSIStatBufL *pStatBuf, int nFlags) = 0; + virtual int Unlink( const char *pszFilename ) + { (void) pszFilename; errno=ENOENT; return -1; } + virtual int Mkdir( const char *pszDirname, long nMode ) + {(void)pszDirname; (void)nMode; errno=ENOENT; return -1;} + virtual int Rmdir( const char *pszDirname ) + { (void) pszDirname; errno=ENOENT; return -1; } + virtual char **ReadDir( const char *pszDirname ) + { (void) pszDirname; return NULL; } + virtual char **ReadDirEx( const char *pszDirname, int /* nMaxFiles */ ) + { return ReadDir(pszDirname); } + virtual int Rename( const char *oldpath, const char *newpath ) + { (void) oldpath; (void)newpath; errno=ENOENT; return -1; } + virtual int IsCaseSensitive( const char* pszFilename ) + { (void) pszFilename; return TRUE; } + virtual GIntBig GetDiskFreeSpace( const char* /* pszDirname */ ) { return -1; } +}; + +/************************************************************************/ +/* VSIFileManager */ +/************************************************************************/ + +class CPL_DLL VSIFileManager +{ +private: + VSIFilesystemHandler *poDefaultHandler; + std::map oHandlers; + + VSIFileManager(); + + static VSIFileManager *Get(); + +public: + ~VSIFileManager(); + + static VSIFilesystemHandler *GetHandler( const char * ); + static void InstallHandler( const std::string& osPrefix, + VSIFilesystemHandler * ); + /* RemoveHandler is never defined. */ + /* static void RemoveHandler( const std::string& osPrefix ); */ +}; + + +/************************************************************************/ +/* ==================================================================== */ +/* VSIArchiveFilesystemHandler */ +/* ==================================================================== */ +/************************************************************************/ + +class VSIArchiveEntryFileOffset +{ + public: + virtual ~VSIArchiveEntryFileOffset(); +}; + +typedef struct +{ + char *fileName; + vsi_l_offset uncompressed_size; + VSIArchiveEntryFileOffset* file_pos; + int bIsDir; + GIntBig nModifiedTime; +} VSIArchiveEntry; + +class VSIArchiveContent +{ +public: + time_t mTime; + vsi_l_offset nFileSize; + int nEntries; + VSIArchiveEntry* entries; + + VSIArchiveContent() : mTime(0), nFileSize(0), nEntries(0), entries(NULL) {} + ~VSIArchiveContent(); +}; + +class VSIArchiveReader +{ + public: + virtual ~VSIArchiveReader(); + + virtual int GotoFirstFile() = 0; + virtual int GotoNextFile() = 0; + virtual VSIArchiveEntryFileOffset* GetFileOffset() = 0; + virtual GUIntBig GetFileSize() = 0; + virtual CPLString GetFileName() = 0; + virtual GIntBig GetModifiedTime() = 0; + virtual int GotoFileOffset(VSIArchiveEntryFileOffset* pOffset) = 0; +}; + +class VSIArchiveFilesystemHandler : public VSIFilesystemHandler +{ +protected: + CPLMutex* hMutex; + /* We use a cache that contains the list of files contained in a VSIArchive file as */ + /* unarchive.c is quite inefficient in listing them. This speeds up access to VSIArchive files */ + /* containing ~1000 files like a CADRG product */ + std::map oFileList; + + virtual const char* GetPrefix() = 0; + virtual std::vector GetExtensions() = 0; + virtual VSIArchiveReader* CreateReader(const char* pszArchiveFileName) = 0; + +public: + VSIArchiveFilesystemHandler(); + virtual ~VSIArchiveFilesystemHandler(); + + virtual int Stat( const char *pszFilename, VSIStatBufL *pStatBuf, int nFlags ); + virtual int Unlink( const char *pszFilename ); + virtual int Rename( const char *oldpath, const char *newpath ); + virtual int Mkdir( const char *pszDirname, long nMode ); + virtual int Rmdir( const char *pszDirname ); + virtual char **ReadDirEx( const char *pszDirname, int nMaxFiles ); + + virtual const VSIArchiveContent* GetContentOfArchive(const char* archiveFilename, VSIArchiveReader* poReader = NULL); + virtual char* SplitFilename(const char *pszFilename, CPLString &osFileInArchive, int bCheckMainFileExists); + virtual VSIArchiveReader* OpenArchiveFile(const char* archiveFilename, const char* fileInArchiveName); + virtual int FindFileInArchive(const char* archiveFilename, const char* fileInArchiveName, const VSIArchiveEntry** archiveEntry); +}; + +VSIVirtualHandle CPL_DLL *VSICreateBufferedReaderHandle(VSIVirtualHandle* poBaseHandle); +VSIVirtualHandle* VSICreateBufferedReaderHandle(VSIVirtualHandle* poBaseHandle, + const GByte* pabyBeginningContent, + vsi_l_offset nCheatFileSize); +VSIVirtualHandle* VSICreateCachedFile( VSIVirtualHandle* poBaseHandle, size_t nChunkSize = 32768, size_t nCacheSize = 0 ); +VSIVirtualHandle CPL_DLL *VSICreateGZipWritable( VSIVirtualHandle* poBaseHandle, int bRegularZLibIn, int bAutoCloseBaseHandle ); + +#endif /* ndef CPL_VSI_VIRTUAL_H_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/cpl_vsil_curl_priv.h b/modules/globebrowsing/ext/gdal/include/cpl_vsil_curl_priv.h new file mode 100644 index 0000000000..e0bc25fcdb --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/cpl_vsil_curl_priv.h @@ -0,0 +1,49 @@ +/****************************************************************************** + * $Id$ + * + * Project: CPL - Common Portability Library + * Purpose: Private API for VSICurl + * Author: Even Rouault, even.rouault at mines-paris.org + * + ****************************************************************************** + * Copyright (c) 2012, Even Rouault + * + * 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. + ****************************************************************************/ + +#ifndef CPL_VSIL_CURL_PRIV_H_INCLUDED +#define CPL_VSIL_CURL_PRIV_H_INCLUDED + +#include "cpl_vsi_virtual.h" + +/* NOTE: this is private API for GDAL internal use. May change without notice. */ +/* Used by the MBTiles driver for now */ + +/* Return TRUE to go on downloading, FALSE to stop */ +typedef int (*VSICurlReadCbkFunc) (VSILFILE* fp, void *pabyBuffer, size_t nBufferSize, void* pfnUserData); + +/* fp must be a VSICurl file handle, otherwise bad things will happen ! */ +/* bStopOnInterrruptUntilUninstall must be set to TRUE if all downloads */ +/* must be canceled after a first one has been stopped by the callback function. */ +/* In that case, downloads will restart after uninstalling the callback. */ +int VSICurlInstallReadCbk(VSILFILE* fp, VSICurlReadCbkFunc pfnReadCbk, void* pfnUserData, + int bStopOnInterrruptUntilUninstall); +int VSICurlUninstallReadCbk(VSILFILE* fp); + +#endif // CPL_VSIL_CURL_PRIV_H_INCLUDED diff --git a/modules/globebrowsing/ext/gdal/include/cpl_worker_thread_pool.h b/modules/globebrowsing/ext/gdal/include/cpl_worker_thread_pool.h new file mode 100644 index 0000000000..7f0c23ba8e --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/cpl_worker_thread_pool.h @@ -0,0 +1,103 @@ +/********************************************************************** + * $Id$ + * + * Project: CPL - Common Portability Library + * Purpose: CPL worker thread pool + * Author: Even Rouault, + * + ********************************************************************** + * Copyright (c) 2015, Even Rouault, + * + * 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. + ****************************************************************************/ + +#ifndef CPL_WORKER_THREAD_POOL_H_INCLUDED_ +#define CPL_WORKER_THREAD_POOL_H_INCLUDED_ + +#include "cpl_multiproc.h" +#include "cpl_list.h" +#include + +/** + * \file cpl_worker_thread_pool.h + * + * Class to manage a pool of worker threads. + * @since GDAL 2.1 + */ + +class CPLWorkerThreadPool; + +typedef struct +{ + CPLThreadFunc pfnFunc; + void *pData; +} CPLWorkerThreadJob; + +typedef struct +{ + CPLThreadFunc pfnInitFunc; + void *pInitData; + CPLWorkerThreadPool *poTP; + CPLJoinableThread *hThread; + int bMarkedAsWaiting; + //CPLWorkerThreadJob *psNextJob; + + CPLMutex *hMutex; + CPLCond *hCond; +} CPLWorkerThread; + +typedef enum +{ + CPLWTS_OK, + CPLWTS_STOP, + CPLWTS_ERROR +} CPLWorkerThreadState; + +class CPL_DLL CPLWorkerThreadPool +{ + std::vector aWT; + CPLCond* hCond; + CPLMutex* hMutex; + volatile CPLWorkerThreadState eState; + CPLList* psJobQueue; + volatile int nPendingJobs; + + CPLList* psWaitingWorkerThreadsList; + int nWaitingWorkerThreads; + + static void WorkerThreadFunction(void* user_data); + + void DeclareJobFinished(); + CPLWorkerThreadJob* GetNextJob(CPLWorkerThread* psWorkerThread); + + public: + CPLWorkerThreadPool(); + ~CPLWorkerThreadPool(); + + bool Setup(int nThreads, + CPLThreadFunc pfnInitFunc, + void** pasInitData); + bool SubmitJob(CPLThreadFunc pfnFunc, void* pData); + bool SubmitJobs(CPLThreadFunc pfnFunc, const std::vector& apData); + void WaitCompletion(int nMaxRemainingJobs = 0); + + int GetThreadCount() const { return (int)aWT.size(); } +}; + +#endif // CPL_WORKER_THREAD_POOL_H_INCLUDED_ diff --git a/modules/globebrowsing/ext/gdal/include/cplkeywordparser.h b/modules/globebrowsing/ext/gdal/include/cplkeywordparser.h new file mode 100644 index 0000000000..ab627aa893 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/cplkeywordparser.h @@ -0,0 +1,66 @@ +/****************************************************************************** + * $Id$ + * + * Project: Common Portability Library + * Purpose: Implementation of CPLKeywordParser - a class for parsing + * the keyword format used for files like QuickBird .RPB files. + * This is a slight variation on the NASAKeywordParser used for + * the PDS/ISIS2/ISIS3 formats. + * Author: 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. + ****************************************************************************/ + +#ifndef CPL_KEYWORD_PARSER +#define CPL_KEYWORD_PARSER + +#include "cpl_string.h" + +/************************************************************************/ +/* ==================================================================== */ +/* CPLKeywordParser */ +/* ==================================================================== */ +/************************************************************************/ + +class CPLKeywordParser +{ + char **papszKeywordList; + + CPLString osHeaderText; + const char *pszHeaderNext; + + void SkipWhite(); + int ReadWord( CPLString &osWord ); + int ReadPair( CPLString &osName, CPLString &osValue ); + int ReadGroup( const char *pszPathPrefix ); + +public: + CPLKeywordParser(); + ~CPLKeywordParser(); + + int Ingest( VSILFILE *fp ); + + const char *GetKeyword( const char *pszPath, const char *pszDefault=NULL ); + char **GetAllKeywords() { return papszKeywordList; } +}; + +#endif /* def CPL_KEYWORD_PARSER */ diff --git a/modules/globebrowsing/ext/gdal/include/gdal.h b/modules/globebrowsing/ext/gdal/include/gdal.h new file mode 100644 index 0000000000..899c617503 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/gdal.h @@ -0,0 +1,1153 @@ +/****************************************************************************** + * $Id$ + * + * Project: GDAL Core + * Purpose: GDAL Core C/Public declarations. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1998, 2002 Frank Warmerdam + * Copyright (c) 2007-2014, Even Rouault + * + * 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. + ****************************************************************************/ + +#ifndef GDAL_H_INCLUDED +#define GDAL_H_INCLUDED + +/** + * \file gdal.h + * + * Public (C callable) GDAL entry points. + */ + +#ifndef DOXYGEN_SKIP +#include "gdal_version.h" +#include "cpl_port.h" +#include "cpl_error.h" +#include "cpl_progress.h" +#include "cpl_virtualmem.h" +#include "cpl_minixml.h" +#include "ogr_api.h" +#endif + +/* -------------------------------------------------------------------- */ +/* Significant constants. */ +/* -------------------------------------------------------------------- */ + +CPL_C_START + +/*! Pixel data types */ +typedef enum { + /*! Unknown or unspecified type */ GDT_Unknown = 0, + /*! Eight bit unsigned integer */ GDT_Byte = 1, + /*! Sixteen bit unsigned integer */ GDT_UInt16 = 2, + /*! Sixteen bit signed integer */ GDT_Int16 = 3, + /*! Thirty two bit unsigned integer */ GDT_UInt32 = 4, + /*! Thirty two bit signed integer */ GDT_Int32 = 5, + /*! Thirty two bit floating point */ GDT_Float32 = 6, + /*! Sixty four bit floating point */ GDT_Float64 = 7, + /*! Complex Int16 */ GDT_CInt16 = 8, + /*! Complex Int32 */ GDT_CInt32 = 9, + /*! Complex Float32 */ GDT_CFloat32 = 10, + /*! Complex Float64 */ GDT_CFloat64 = 11, + GDT_TypeCount = 12 /* maximum type # + 1 */ +} GDALDataType; + +int CPL_DLL CPL_STDCALL GDALGetDataTypeSize( GDALDataType ); // Deprecated. +int CPL_DLL CPL_STDCALL GDALGetDataTypeSizeBits( GDALDataType eDataType ); +int CPL_DLL CPL_STDCALL GDALGetDataTypeSizeBytes( GDALDataType ); +int CPL_DLL CPL_STDCALL GDALDataTypeIsComplex( GDALDataType ); +const char CPL_DLL * CPL_STDCALL GDALGetDataTypeName( GDALDataType ); +GDALDataType CPL_DLL CPL_STDCALL GDALGetDataTypeByName( const char * ); +GDALDataType CPL_DLL CPL_STDCALL GDALDataTypeUnion( GDALDataType, GDALDataType ); +double CPL_DLL GDALAdjustValueToDataType( GDALDataType eDT, double dfValue, int* pbClamped, int* pbRounded ); + +/** +* status of the asynchronous stream +*/ +typedef enum +{ + GARIO_PENDING = 0, + GARIO_UPDATE = 1, + GARIO_ERROR = 2, + GARIO_COMPLETE = 3, + GARIO_TypeCount = 4 +} GDALAsyncStatusType; + +const char CPL_DLL * CPL_STDCALL GDALGetAsyncStatusTypeName( GDALAsyncStatusType ); +GDALAsyncStatusType CPL_DLL CPL_STDCALL GDALGetAsyncStatusTypeByName( const char * ); + +/*! Flag indicating read/write, or read-only access to data. */ +typedef enum { + /*! Read only (no update) access */ GA_ReadOnly = 0, + /*! Read/write access. */ GA_Update = 1 +} GDALAccess; + +/*! Read/Write flag for RasterIO() method */ +typedef enum { + /*! Read data */ GF_Read = 0, + /*! Write data */ GF_Write = 1 +} GDALRWFlag; + +/* NOTE: values are selected to be consistent with GDALResampleAlg of alg/gdalwarper.h */ +/** RasterIO() resampling method. + * @since GDAL 2.0 + */ +typedef enum +{ + /*! Nearest neighbour */ GRIORA_NearestNeighbour = 0, + /*! Bilinear (2x2 kernel) */ GRIORA_Bilinear = 1, + /*! Cubic Convolution Approximation (4x4 kernel) */ GRIORA_Cubic = 2, + /*! Cubic B-Spline Approximation (4x4 kernel) */ GRIORA_CubicSpline = 3, + /*! Lanczos windowed sinc interpolation (6x6 kernel) */ GRIORA_Lanczos = 4, + /*! Average */ GRIORA_Average = 5, + /*! Mode (selects the value which appears most often of all the sampled points) */ + GRIORA_Mode = 6, + /*! Gauss blurring */ GRIORA_Gauss = 7 + /* NOTE: values 8 to 12 are reserved for max,min,med,Q1,Q3 */ +} GDALRIOResampleAlg; + +/* NOTE to developers: only add members, and if so edit INIT_RASTERIO_EXTRA_ARG */ +/* and INIT_RASTERIO_EXTRA_ARG */ +/** Structure to pass extra arguments to RasterIO() method + * @since GDAL 2.0 + */ +typedef struct +{ + /*! Version of structure (to allow future extensions of the structure) */ + int nVersion; + + /*! Resampling algorithm */ + GDALRIOResampleAlg eResampleAlg; + + /*! Progress callback */ + GDALProgressFunc pfnProgress; + /*! Progress callback user data */ + void *pProgressData; + + /*! Indicate if dfXOff, dfYOff, dfXSize and dfYSize are set. + Mostly reserved from the VRT driver to communicate a more precise + source window. Must be such that dfXOff - nXOff < 1.0 and + dfYOff - nYOff < 1.0 and nXSize - dfXSize < 1.0 and nYSize - dfYSize < 1.0 */ + int bFloatingPointWindowValidity; + /*! Pixel offset to the top left corner. Only valid if bFloatingPointWindowValidity = TRUE */ + double dfXOff; + /*! Line offset to the top left corner. Only valid if bFloatingPointWindowValidity = TRUE */ + double dfYOff; + /*! Width in pixels of the area of interest. Only valid if bFloatingPointWindowValidity = TRUE */ + double dfXSize; + /*! Height in pixels of the area of interest. Only valid if bFloatingPointWindowValidity = TRUE */ + double dfYSize; +} GDALRasterIOExtraArg; + +#define RASTERIO_EXTRA_ARG_CURRENT_VERSION 1 + +/** Macro to initialize an instance of GDALRasterIOExtraArg structure. + * @since GDAL 2.0 + */ +#define INIT_RASTERIO_EXTRA_ARG(s) \ + do { (s).nVersion = RASTERIO_EXTRA_ARG_CURRENT_VERSION; \ + (s).eResampleAlg = GRIORA_NearestNeighbour; \ + (s).pfnProgress = NULL; \ + (s).pProgressData = NULL; \ + (s).bFloatingPointWindowValidity = FALSE; } while(0) + +/*! Types of color interpretation for raster bands. */ +typedef enum +{ + GCI_Undefined=0, + /*! Greyscale */ GCI_GrayIndex=1, + /*! Paletted (see associated color table) */ GCI_PaletteIndex=2, + /*! Red band of RGBA image */ GCI_RedBand=3, + /*! Green band of RGBA image */ GCI_GreenBand=4, + /*! Blue band of RGBA image */ GCI_BlueBand=5, + /*! Alpha (0=transparent, 255=opaque) */ GCI_AlphaBand=6, + /*! Hue band of HLS image */ GCI_HueBand=7, + /*! Saturation band of HLS image */ GCI_SaturationBand=8, + /*! Lightness band of HLS image */ GCI_LightnessBand=9, + /*! Cyan band of CMYK image */ GCI_CyanBand=10, + /*! Magenta band of CMYK image */ GCI_MagentaBand=11, + /*! Yellow band of CMYK image */ GCI_YellowBand=12, + /*! Black band of CMLY image */ GCI_BlackBand=13, + /*! Y Luminance */ GCI_YCbCr_YBand=14, + /*! Cb Chroma */ GCI_YCbCr_CbBand=15, + /*! Cr Chroma */ GCI_YCbCr_CrBand=16, + /*! Max current value */ GCI_Max=16 +} GDALColorInterp; + +const char CPL_DLL *GDALGetColorInterpretationName( GDALColorInterp ); +GDALColorInterp CPL_DLL GDALGetColorInterpretationByName( const char *pszName ); + +/*! Types of color interpretations for a GDALColorTable. */ +typedef enum +{ + /*! Grayscale (in GDALColorEntry.c1) */ GPI_Gray=0, + /*! Red, Green, Blue and Alpha in (in c1, c2, c3 and c4) */ GPI_RGB=1, + /*! Cyan, Magenta, Yellow and Black (in c1, c2, c3 and c4)*/ GPI_CMYK=2, + /*! Hue, Lightness and Saturation (in c1, c2, and c3) */ GPI_HLS=3 +} GDALPaletteInterp; + +const char CPL_DLL *GDALGetPaletteInterpretationName( GDALPaletteInterp ); + +/* "well known" metadata items. */ + +#define GDALMD_AREA_OR_POINT "AREA_OR_POINT" +# define GDALMD_AOP_AREA "Area" +# define GDALMD_AOP_POINT "Point" + +/* -------------------------------------------------------------------- */ +/* GDAL Specific error codes. */ +/* */ +/* error codes 100 to 299 reserved for GDAL. */ +/* -------------------------------------------------------------------- */ +#define CPLE_WrongFormat (CPLErrorNum)200 + +/* -------------------------------------------------------------------- */ +/* Define handle types related to various internal classes. */ +/* -------------------------------------------------------------------- */ + +/** Opaque type used for the C bindings of the C++ GDALMajorObject class */ +typedef void *GDALMajorObjectH; + +/** Opaque type used for the C bindings of the C++ GDALDataset class */ +typedef void *GDALDatasetH; + +/** Opaque type used for the C bindings of the C++ GDALRasterBand class */ +typedef void *GDALRasterBandH; + +/** Opaque type used for the C bindings of the C++ GDALDriver class */ +typedef void *GDALDriverH; + +/** Opaque type used for the C bindings of the C++ GDALColorTable class */ +typedef void *GDALColorTableH; + +/** Opaque type used for the C bindings of the C++ GDALRasterAttributeTable class */ +typedef void *GDALRasterAttributeTableH; + +/** Opaque type used for the C bindings of the C++ GDALAsyncReader class */ +typedef void *GDALAsyncReaderH; + +/** Type to express pixel, line or band spacing. Signed 64 bit integer. */ +typedef GIntBig GSpacing; + +/* ==================================================================== */ +/* Registration/driver related. */ +/* ==================================================================== */ + +/** Long name of the driver */ +#define GDAL_DMD_LONGNAME "DMD_LONGNAME" + +/** URL (relative to http://gdal.org/) to the help page of the driver */ +#define GDAL_DMD_HELPTOPIC "DMD_HELPTOPIC" + +/** MIME type handled by the driver. */ +#define GDAL_DMD_MIMETYPE "DMD_MIMETYPE" + +/** Extension handled by the driver. */ +#define GDAL_DMD_EXTENSION "DMD_EXTENSION" + +/** Connection prefix to provide as the file name of the open function. + * Typically set for non-file based drivers. Generally used with open options. + * @since GDAL 2.0 + */ +#define GDAL_DMD_CONNECTION_PREFIX "DMD_CONNECTION_PREFIX" + +/** List of (space separated) extensions handled by the driver. + * @since GDAL 2.0 + */ +#define GDAL_DMD_EXTENSIONS "DMD_EXTENSIONS" + +/** XML snippet with creation options. */ +#define GDAL_DMD_CREATIONOPTIONLIST "DMD_CREATIONOPTIONLIST" + +/** XML snippet with open options. + * @since GDAL 2.0 + */ +#define GDAL_DMD_OPENOPTIONLIST "DMD_OPENOPTIONLIST" + +/** List of (space separated) raster data types support by the Create()/CreateCopy() API. */ +#define GDAL_DMD_CREATIONDATATYPES "DMD_CREATIONDATATYPES" + +/** List of (space separated) vector field types support by the CreateField() API. + * @since GDAL 2.0 + * */ +#define GDAL_DMD_CREATIONFIELDDATATYPES "DMD_CREATIONFIELDDATATYPES" + +/** Capability set by a driver that exposes Subdatasets. */ +#define GDAL_DMD_SUBDATASETS "DMD_SUBDATASETS" + +/** Capability set by a driver that implements the Open() API. */ +#define GDAL_DCAP_OPEN "DCAP_OPEN" + +/** Capability set by a driver that implements the Create() API. */ +#define GDAL_DCAP_CREATE "DCAP_CREATE" + +/** Capability set by a driver that implements the CreateCopy() API. */ +#define GDAL_DCAP_CREATECOPY "DCAP_CREATECOPY" + +/** Capability set by a driver that can read/create datasets through the VSI*L API. */ +#define GDAL_DCAP_VIRTUALIO "DCAP_VIRTUALIO" + +/** Capability set by a driver having raster capability. + * @since GDAL 2.0 + */ +#define GDAL_DCAP_RASTER "DCAP_RASTER" + +/** Capability set by a driver having vector capability. + * @since GDAL 2.0 + */ +#define GDAL_DCAP_VECTOR "DCAP_VECTOR" + +/** Capability set by a driver having vector capability. + * @since GDAL 2.1 + */ +#define GDAL_DCAP_GNM "DCAP_GNM" + +/** Capability set by a driver that can create fields with NOT NULL constraint. + * @since GDAL 2.0 + */ +#define GDAL_DCAP_NOTNULL_FIELDS "DCAP_NOTNULL_FIELDS" + +/** Capability set by a driver that can create fields with DEFAULT values. + * @since GDAL 2.0 + */ +#define GDAL_DCAP_DEFAULT_FIELDS "DCAP_DEFAULT_FIELDS" + +/** Capability set by a driver that can create geometry fields with NOT NULL constraint. + * @since GDAL 2.0 + */ +#define GDAL_DCAP_NOTNULL_GEOMFIELDS "DCAP_NOTNULL_GEOMFIELDS" + +void CPL_DLL CPL_STDCALL GDALAllRegister( void ); + +GDALDatasetH CPL_DLL CPL_STDCALL GDALCreate( GDALDriverH hDriver, + const char *, int, int, int, GDALDataType, + char ** ) CPL_WARN_UNUSED_RESULT; +GDALDatasetH CPL_DLL CPL_STDCALL +GDALCreateCopy( GDALDriverH, const char *, GDALDatasetH, + int, char **, GDALProgressFunc, void * ) CPL_WARN_UNUSED_RESULT; + +GDALDriverH CPL_DLL CPL_STDCALL GDALIdentifyDriver( const char * pszFilename, + char ** papszFileList ); +GDALDatasetH CPL_DLL CPL_STDCALL +GDALOpen( const char *pszFilename, GDALAccess eAccess ) CPL_WARN_UNUSED_RESULT; +GDALDatasetH CPL_DLL CPL_STDCALL GDALOpenShared( const char *, GDALAccess ) CPL_WARN_UNUSED_RESULT; + + +/* Note: we define GDAL_OF_READONLY and GDAL_OF_UPDATE to be on purpose */ +/* equals to GA_ReadOnly and GA_Update */ + +/** Open in read-only mode. + * Used by GDALOpenEx(). + * @since GDAL 2.0 + */ +#define GDAL_OF_READONLY 0x00 + +/** Open in update mode. + * Used by GDALOpenEx(). + * @since GDAL 2.0 + */ +#define GDAL_OF_UPDATE 0x01 + +/** Allow raster and vector drivers to be used. + * Used by GDALOpenEx(). + * @since GDAL 2.0 + */ +#define GDAL_OF_ALL 0x00 + +/** Allow raster drivers to be used. + * Used by GDALOpenEx(). + * @since GDAL 2.0 + */ +#define GDAL_OF_RASTER 0x02 + +/** Allow vector drivers to be used. + * Used by GDALOpenEx(). + * @since GDAL 2.0 + */ +#define GDAL_OF_VECTOR 0x04 + + +/** Allow gnm drivers to be used. + * Used by GDALOpenEx(). + * @since GDAL 2.1 + */ +#define GDAL_OF_GNM 0x08 + +/* Some space for GDAL 3.0 new types ;-) */ +/*#define GDAL_OF_OTHER_KIND1 0x08 */ +/*#define GDAL_OF_OTHER_KIND2 0x10 */ +#ifndef DOXYGEN_SKIP +#define GDAL_OF_KIND_MASK 0x1E +#endif + +/** Open in shared mode. + * Used by GDALOpenEx(). + * @since GDAL 2.0 + */ +#define GDAL_OF_SHARED 0x20 + +/** Emit error message in case of failed open. + * Used by GDALOpenEx(). + * @since GDAL 2.0 + */ +#define GDAL_OF_VERBOSE_ERROR 0x40 + +/** Open as internal dataset. Such dataset isn't registered in the global list + * of opened dataset. Cannot be used with GDAL_OF_SHARED. + * + * Used by GDALOpenEx(). + * @since GDAL 2.0 + */ +#define GDAL_OF_INTERNAL 0x80 + +/** Let GDAL decide if a array-based or hashset-based storage strategy for + * cached blocks must be used. + * + * GDAL_OF_DEFAULT_BLOCK_ACCESS, GDAL_OF_ARRAY_BLOCK_ACCESS and + * GDAL_OF_HASHSET_BLOCK_ACCESS are mutually exclusive. + * + * Used by GDALOpenEx(). + * @since GDAL 2.1 + */ +#define GDAL_OF_DEFAULT_BLOCK_ACCESS 0 + +/** Use a array-based storage strategy for cached blocks. + * + * GDAL_OF_DEFAULT_BLOCK_ACCESS, GDAL_OF_ARRAY_BLOCK_ACCESS and + * GDAL_OF_HASHSET_BLOCK_ACCESS are mutually exclusive. + * + * Used by GDALOpenEx(). + * @since GDAL 2.1 + */ +#define GDAL_OF_ARRAY_BLOCK_ACCESS 0x100 + +/** Use a hashset-based storage strategy for cached blocks. + * + * GDAL_OF_DEFAULT_BLOCK_ACCESS, GDAL_OF_ARRAY_BLOCK_ACCESS and + * GDAL_OF_HASHSET_BLOCK_ACCESS are mutually exclusive. + * + * Used by GDALOpenEx(). + * @since GDAL 2.1 + */ +#define GDAL_OF_HASHSET_BLOCK_ACCESS 0x200 + +#define GDAL_OF_RESERVED_1 0x300 +#define GDAL_OF_BLOCK_ACCESS_MASK 0x300 + +GDALDatasetH CPL_DLL CPL_STDCALL GDALOpenEx( const char* pszFilename, + unsigned int nOpenFlags, + const char* const* papszAllowedDrivers, + const char* const* papszOpenOptions, + const char* const* papszSiblingFiles ) CPL_WARN_UNUSED_RESULT; + +int CPL_DLL CPL_STDCALL GDALDumpOpenDatasets( FILE * ); + +GDALDriverH CPL_DLL CPL_STDCALL GDALGetDriverByName( const char * ); +int CPL_DLL CPL_STDCALL GDALGetDriverCount( void ); +GDALDriverH CPL_DLL CPL_STDCALL GDALGetDriver( int ); +void CPL_DLL CPL_STDCALL GDALDestroyDriver( GDALDriverH ); +int CPL_DLL CPL_STDCALL GDALRegisterDriver( GDALDriverH ); +void CPL_DLL CPL_STDCALL GDALDeregisterDriver( GDALDriverH ); +void CPL_DLL CPL_STDCALL GDALDestroyDriverManager( void ); +void CPL_DLL GDALDestroy( void ); +CPLErr CPL_DLL CPL_STDCALL GDALDeleteDataset( GDALDriverH, const char * ); +CPLErr CPL_DLL CPL_STDCALL GDALRenameDataset( GDALDriverH, + const char * pszNewName, + const char * pszOldName ); +CPLErr CPL_DLL CPL_STDCALL GDALCopyDatasetFiles( GDALDriverH, + const char * pszNewName, + const char * pszOldName); +int CPL_DLL CPL_STDCALL GDALValidateCreationOptions( GDALDriverH, + char** papszCreationOptions); + +/* The following are deprecated */ +const char CPL_DLL * CPL_STDCALL GDALGetDriverShortName( GDALDriverH ); +const char CPL_DLL * CPL_STDCALL GDALGetDriverLongName( GDALDriverH ); +const char CPL_DLL * CPL_STDCALL GDALGetDriverHelpTopic( GDALDriverH ); +const char CPL_DLL * CPL_STDCALL GDALGetDriverCreationOptionList( GDALDriverH ); + +/* ==================================================================== */ +/* GDAL_GCP */ +/* ==================================================================== */ + +/** Ground Control Point */ +typedef struct +{ + /** Unique identifier, often numeric */ + char *pszId; + + /** Informational message or "" */ + char *pszInfo; + + /** Pixel (x) location of GCP on raster */ + double dfGCPPixel; + /** Line (y) location of GCP on raster */ + double dfGCPLine; + + /** X position of GCP in georeferenced space */ + double dfGCPX; + + /** Y position of GCP in georeferenced space */ + double dfGCPY; + + /** Elevation of GCP, or zero if not known */ + double dfGCPZ; +} GDAL_GCP; + +void CPL_DLL CPL_STDCALL GDALInitGCPs( int, GDAL_GCP * ); +void CPL_DLL CPL_STDCALL GDALDeinitGCPs( int, GDAL_GCP * ); +GDAL_GCP CPL_DLL * CPL_STDCALL GDALDuplicateGCPs( int, const GDAL_GCP * ); + +int CPL_DLL CPL_STDCALL +GDALGCPsToGeoTransform( int nGCPCount, const GDAL_GCP *pasGCPs, + double *padfGeoTransform, int bApproxOK ) CPL_WARN_UNUSED_RESULT; +int CPL_DLL CPL_STDCALL +GDALInvGeoTransform( double *padfGeoTransformIn, + double *padfInvGeoTransformOut ) CPL_WARN_UNUSED_RESULT; +void CPL_DLL CPL_STDCALL GDALApplyGeoTransform( double *, double, double, + double *, double * ); +void CPL_DLL GDALComposeGeoTransforms(const double *padfGeoTransform1, + const double *padfGeoTransform2, + double *padfGeoTransformOut); + +/* ==================================================================== */ +/* major objects (dataset, and, driver, drivermanager). */ +/* ==================================================================== */ + +char CPL_DLL ** CPL_STDCALL GDALGetMetadataDomainList( GDALMajorObjectH hObject ); +char CPL_DLL ** CPL_STDCALL GDALGetMetadata( GDALMajorObjectH, const char * ); +CPLErr CPL_DLL CPL_STDCALL GDALSetMetadata( GDALMajorObjectH, char **, + const char * ); +const char CPL_DLL * CPL_STDCALL +GDALGetMetadataItem( GDALMajorObjectH, const char *, const char * ); +CPLErr CPL_DLL CPL_STDCALL +GDALSetMetadataItem( GDALMajorObjectH, const char *, const char *, + const char * ); +const char CPL_DLL * CPL_STDCALL GDALGetDescription( GDALMajorObjectH ); +void CPL_DLL CPL_STDCALL GDALSetDescription( GDALMajorObjectH, const char * ); + +/* ==================================================================== */ +/* GDALDataset class ... normally this represents one file. */ +/* ==================================================================== */ + +#define GDAL_DS_LAYER_CREATIONOPTIONLIST "DS_LAYER_CREATIONOPTIONLIST" + +GDALDriverH CPL_DLL CPL_STDCALL GDALGetDatasetDriver( GDALDatasetH ); +char CPL_DLL ** CPL_STDCALL GDALGetFileList( GDALDatasetH ); +void CPL_DLL CPL_STDCALL GDALClose( GDALDatasetH ); +int CPL_DLL CPL_STDCALL GDALGetRasterXSize( GDALDatasetH ); +int CPL_DLL CPL_STDCALL GDALGetRasterYSize( GDALDatasetH ); +int CPL_DLL CPL_STDCALL GDALGetRasterCount( GDALDatasetH ); +GDALRasterBandH CPL_DLL CPL_STDCALL GDALGetRasterBand( GDALDatasetH, int ); + +CPLErr CPL_DLL CPL_STDCALL GDALAddBand( GDALDatasetH hDS, GDALDataType eType, + char **papszOptions ); + +GDALAsyncReaderH CPL_DLL CPL_STDCALL +GDALBeginAsyncReader(GDALDatasetH hDS, int nXOff, int nYOff, + int nXSize, int nYSize, + void *pBuf, int nBufXSize, int nBufYSize, + GDALDataType eBufType, int nBandCount, int* panBandMap, + int nPixelSpace, int nLineSpace, int nBandSpace, + char **papszOptions) CPL_WARN_UNUSED_RESULT; + +void CPL_DLL CPL_STDCALL +GDALEndAsyncReader(GDALDatasetH hDS, GDALAsyncReaderH hAsynchReaderH); + +CPLErr CPL_DLL CPL_STDCALL GDALDatasetRasterIO( + GDALDatasetH hDS, GDALRWFlag eRWFlag, + int nDSXOff, int nDSYOff, int nDSXSize, int nDSYSize, + void * pBuffer, int nBXSize, int nBYSize, GDALDataType eBDataType, + int nBandCount, int *panBandCount, + int nPixelSpace, int nLineSpace, int nBandSpace) CPL_WARN_UNUSED_RESULT; + +CPLErr CPL_DLL CPL_STDCALL GDALDatasetRasterIOEx( + GDALDatasetH hDS, GDALRWFlag eRWFlag, + int nDSXOff, int nDSYOff, int nDSXSize, int nDSYSize, + void * pBuffer, int nBXSize, int nBYSize, GDALDataType eBDataType, + int nBandCount, int *panBandCount, + GSpacing nPixelSpace, GSpacing nLineSpace, GSpacing nBandSpace, + GDALRasterIOExtraArg* psExtraArg) CPL_WARN_UNUSED_RESULT; + +CPLErr CPL_DLL CPL_STDCALL GDALDatasetAdviseRead( GDALDatasetH hDS, + int nDSXOff, int nDSYOff, int nDSXSize, int nDSYSize, + int nBXSize, int nBYSize, GDALDataType eBDataType, + int nBandCount, int *panBandCount, char **papszOptions ); + +const char CPL_DLL * CPL_STDCALL GDALGetProjectionRef( GDALDatasetH ); +CPLErr CPL_DLL CPL_STDCALL GDALSetProjection( GDALDatasetH, const char * ); +CPLErr CPL_DLL CPL_STDCALL GDALGetGeoTransform( GDALDatasetH, double * ); +CPLErr CPL_DLL CPL_STDCALL GDALSetGeoTransform( GDALDatasetH, double * ); + +int CPL_DLL CPL_STDCALL GDALGetGCPCount( GDALDatasetH ); +const char CPL_DLL * CPL_STDCALL GDALGetGCPProjection( GDALDatasetH ); +const GDAL_GCP CPL_DLL * CPL_STDCALL GDALGetGCPs( GDALDatasetH ); +CPLErr CPL_DLL CPL_STDCALL GDALSetGCPs( GDALDatasetH, int, const GDAL_GCP *, + const char * ); + +void CPL_DLL * CPL_STDCALL GDALGetInternalHandle( GDALDatasetH, const char * ); +int CPL_DLL CPL_STDCALL GDALReferenceDataset( GDALDatasetH ); +int CPL_DLL CPL_STDCALL GDALDereferenceDataset( GDALDatasetH ); + +CPLErr CPL_DLL CPL_STDCALL +GDALBuildOverviews( GDALDatasetH, const char *, int, int *, + int, int *, GDALProgressFunc, void * ) CPL_WARN_UNUSED_RESULT; +void CPL_DLL CPL_STDCALL GDALGetOpenDatasets( GDALDatasetH **hDS, int *pnCount ); +int CPL_DLL CPL_STDCALL GDALGetAccess( GDALDatasetH hDS ); +void CPL_DLL CPL_STDCALL GDALFlushCache( GDALDatasetH hDS ); + +CPLErr CPL_DLL CPL_STDCALL + GDALCreateDatasetMaskBand( GDALDatasetH hDS, int nFlags ); + +CPLErr CPL_DLL CPL_STDCALL GDALDatasetCopyWholeRaster( + GDALDatasetH hSrcDS, GDALDatasetH hDstDS, char **papszOptions, + GDALProgressFunc pfnProgress, void *pProgressData ) CPL_WARN_UNUSED_RESULT; + +CPLErr CPL_DLL CPL_STDCALL GDALRasterBandCopyWholeRaster( + GDALRasterBandH hSrcBand, GDALRasterBandH hDstBand, char **papszOptions, + GDALProgressFunc pfnProgress, void *pProgressData ) CPL_WARN_UNUSED_RESULT; + +CPLErr CPL_DLL +GDALRegenerateOverviews( GDALRasterBandH hSrcBand, + int nOverviewCount, GDALRasterBandH *pahOverviewBands, + const char *pszResampling, + GDALProgressFunc pfnProgress, void *pProgressData ); + +int CPL_DLL GDALDatasetGetLayerCount( GDALDatasetH ); +OGRLayerH CPL_DLL GDALDatasetGetLayer( GDALDatasetH, int ); +OGRLayerH CPL_DLL GDALDatasetGetLayerByName( GDALDatasetH, const char * ); +OGRErr CPL_DLL GDALDatasetDeleteLayer( GDALDatasetH, int ); +OGRLayerH CPL_DLL GDALDatasetCreateLayer( GDALDatasetH, const char *, + OGRSpatialReferenceH, OGRwkbGeometryType, + char ** ); +OGRLayerH CPL_DLL GDALDatasetCopyLayer( GDALDatasetH, OGRLayerH, const char *, + char ** ); +int CPL_DLL GDALDatasetTestCapability( GDALDatasetH, const char * ); +OGRLayerH CPL_DLL GDALDatasetExecuteSQL( GDALDatasetH, const char *, + OGRGeometryH, const char * ); +void CPL_DLL GDALDatasetReleaseResultSet( GDALDatasetH, OGRLayerH ); +OGRStyleTableH CPL_DLL GDALDatasetGetStyleTable( GDALDatasetH ); +void CPL_DLL GDALDatasetSetStyleTableDirectly( GDALDatasetH, OGRStyleTableH ); +void CPL_DLL GDALDatasetSetStyleTable( GDALDatasetH, OGRStyleTableH ); +OGRErr CPL_DLL GDALDatasetStartTransaction(GDALDatasetH hDS, int bForce); +OGRErr CPL_DLL GDALDatasetCommitTransaction(GDALDatasetH hDS); +OGRErr CPL_DLL GDALDatasetRollbackTransaction(GDALDatasetH hDS); + + +/* ==================================================================== */ +/* GDALRasterBand ... one band/channel in a dataset. */ +/* ==================================================================== */ + +/** + * SRCVAL - Macro which may be used by pixel functions to obtain + * a pixel from a source buffer. + */ +#define SRCVAL(papoSource, eSrcType, ii) \ + (eSrcType == GDT_Byte ? \ + ((GByte *)papoSource)[ii] : \ + (eSrcType == GDT_Float32 ? \ + ((float *)papoSource)[ii] : \ + (eSrcType == GDT_Float64 ? \ + ((double *)papoSource)[ii] : \ + (eSrcType == GDT_Int32 ? \ + ((GInt32 *)papoSource)[ii] : \ + (eSrcType == GDT_UInt16 ? \ + ((GUInt16 *)papoSource)[ii] : \ + (eSrcType == GDT_Int16 ? \ + ((GInt16 *)papoSource)[ii] : \ + (eSrcType == GDT_UInt32 ? \ + ((GUInt32 *)papoSource)[ii] : \ + (eSrcType == GDT_CInt16 ? \ + ((GInt16 *)papoSource)[ii * 2] : \ + (eSrcType == GDT_CInt32 ? \ + ((GInt32 *)papoSource)[ii * 2] : \ + (eSrcType == GDT_CFloat32 ? \ + ((float *)papoSource)[ii * 2] : \ + (eSrcType == GDT_CFloat64 ? \ + ((double *)papoSource)[ii * 2] : 0))))))))))) + +typedef CPLErr +(*GDALDerivedPixelFunc)(void **papoSources, int nSources, void *pData, + int nBufXSize, int nBufYSize, + GDALDataType eSrcType, GDALDataType eBufType, + int nPixelSpace, int nLineSpace); + +GDALDataType CPL_DLL CPL_STDCALL GDALGetRasterDataType( GDALRasterBandH ); +void CPL_DLL CPL_STDCALL +GDALGetBlockSize( GDALRasterBandH, int * pnXSize, int * pnYSize ); + +CPLErr CPL_DLL CPL_STDCALL GDALRasterAdviseRead( GDALRasterBandH hRB, + int nDSXOff, int nDSYOff, int nDSXSize, int nDSYSize, + int nBXSize, int nBYSize, GDALDataType eBDataType, char **papszOptions ); + +CPLErr CPL_DLL CPL_STDCALL +GDALRasterIO( GDALRasterBandH hRBand, GDALRWFlag eRWFlag, + int nDSXOff, int nDSYOff, int nDSXSize, int nDSYSize, + void * pBuffer, int nBXSize, int nBYSize,GDALDataType eBDataType, + int nPixelSpace, int nLineSpace ) CPL_WARN_UNUSED_RESULT; +CPLErr CPL_DLL CPL_STDCALL +GDALRasterIOEx( GDALRasterBandH hRBand, GDALRWFlag eRWFlag, + int nDSXOff, int nDSYOff, int nDSXSize, int nDSYSize, + void * pBuffer, int nBXSize, int nBYSize,GDALDataType eBDataType, + GSpacing nPixelSpace, GSpacing nLineSpace, + GDALRasterIOExtraArg* psExtraArg ) CPL_WARN_UNUSED_RESULT; +CPLErr CPL_DLL CPL_STDCALL GDALReadBlock( GDALRasterBandH, int, int, void * ) CPL_WARN_UNUSED_RESULT; +CPLErr CPL_DLL CPL_STDCALL GDALWriteBlock( GDALRasterBandH, int, int, void * ) CPL_WARN_UNUSED_RESULT; +int CPL_DLL CPL_STDCALL GDALGetRasterBandXSize( GDALRasterBandH ); +int CPL_DLL CPL_STDCALL GDALGetRasterBandYSize( GDALRasterBandH ); +GDALAccess CPL_DLL CPL_STDCALL GDALGetRasterAccess( GDALRasterBandH ); +int CPL_DLL CPL_STDCALL GDALGetBandNumber( GDALRasterBandH ); +GDALDatasetH CPL_DLL CPL_STDCALL GDALGetBandDataset( GDALRasterBandH ); + +GDALColorInterp CPL_DLL CPL_STDCALL +GDALGetRasterColorInterpretation( GDALRasterBandH ); +CPLErr CPL_DLL CPL_STDCALL +GDALSetRasterColorInterpretation( GDALRasterBandH, GDALColorInterp ); +GDALColorTableH CPL_DLL CPL_STDCALL GDALGetRasterColorTable( GDALRasterBandH ); +CPLErr CPL_DLL CPL_STDCALL GDALSetRasterColorTable( GDALRasterBandH, GDALColorTableH ); +int CPL_DLL CPL_STDCALL GDALHasArbitraryOverviews( GDALRasterBandH ); +int CPL_DLL CPL_STDCALL GDALGetOverviewCount( GDALRasterBandH ); +GDALRasterBandH CPL_DLL CPL_STDCALL GDALGetOverview( GDALRasterBandH, int ); +double CPL_DLL CPL_STDCALL GDALGetRasterNoDataValue( GDALRasterBandH, int * ); +CPLErr CPL_DLL CPL_STDCALL GDALSetRasterNoDataValue( GDALRasterBandH, double ); +CPLErr CPL_DLL CPL_STDCALL GDALDeleteRasterNoDataValue( GDALRasterBandH ); +char CPL_DLL ** CPL_STDCALL GDALGetRasterCategoryNames( GDALRasterBandH ); +CPLErr CPL_DLL CPL_STDCALL GDALSetRasterCategoryNames( GDALRasterBandH, char ** ); +double CPL_DLL CPL_STDCALL GDALGetRasterMinimum( GDALRasterBandH, int *pbSuccess ); +double CPL_DLL CPL_STDCALL GDALGetRasterMaximum( GDALRasterBandH, int *pbSuccess ); +CPLErr CPL_DLL CPL_STDCALL GDALGetRasterStatistics( + GDALRasterBandH, int bApproxOK, int bForce, + double *pdfMin, double *pdfMax, double *pdfMean, double *pdfStdDev ); +CPLErr CPL_DLL CPL_STDCALL GDALComputeRasterStatistics( + GDALRasterBandH, int bApproxOK, + double *pdfMin, double *pdfMax, double *pdfMean, double *pdfStdDev, + GDALProgressFunc pfnProgress, void *pProgressData ); +CPLErr CPL_DLL CPL_STDCALL GDALSetRasterStatistics( + GDALRasterBandH hBand, + double dfMin, double dfMax, double dfMean, double dfStdDev ); + +const char CPL_DLL * CPL_STDCALL GDALGetRasterUnitType( GDALRasterBandH ); +CPLErr CPL_DLL CPL_STDCALL GDALSetRasterUnitType( GDALRasterBandH hBand, const char *pszNewValue ); +double CPL_DLL CPL_STDCALL GDALGetRasterOffset( GDALRasterBandH, int *pbSuccess ); +CPLErr CPL_DLL CPL_STDCALL GDALSetRasterOffset( GDALRasterBandH hBand, double dfNewOffset); +double CPL_DLL CPL_STDCALL GDALGetRasterScale( GDALRasterBandH, int *pbSuccess ); +CPLErr CPL_DLL CPL_STDCALL GDALSetRasterScale( GDALRasterBandH hBand, double dfNewOffset ); +void CPL_DLL CPL_STDCALL +GDALComputeRasterMinMax( GDALRasterBandH hBand, int bApproxOK, + double adfMinMax[2] ); +CPLErr CPL_DLL CPL_STDCALL GDALFlushRasterCache( GDALRasterBandH hBand ); +CPLErr CPL_DLL CPL_STDCALL GDALGetRasterHistogram( GDALRasterBandH hBand, + double dfMin, double dfMax, + int nBuckets, int *panHistogram, + int bIncludeOutOfRange, int bApproxOK, + GDALProgressFunc pfnProgress, + void * pProgressData ) CPL_WARN_DEPRECATED("Use GDALGetRasterHistogramEx() instead"); +CPLErr CPL_DLL CPL_STDCALL GDALGetRasterHistogramEx( GDALRasterBandH hBand, + double dfMin, double dfMax, + int nBuckets, GUIntBig *panHistogram, + int bIncludeOutOfRange, int bApproxOK, + GDALProgressFunc pfnProgress, + void * pProgressData ); +CPLErr CPL_DLL CPL_STDCALL GDALGetDefaultHistogram( GDALRasterBandH hBand, + double *pdfMin, double *pdfMax, + int *pnBuckets, int **ppanHistogram, + int bForce, + GDALProgressFunc pfnProgress, + void * pProgressData ) CPL_WARN_DEPRECATED("Use GDALGetDefaultHistogramEx() instead"); +CPLErr CPL_DLL CPL_STDCALL GDALGetDefaultHistogramEx( GDALRasterBandH hBand, + double *pdfMin, double *pdfMax, + int *pnBuckets, GUIntBig **ppanHistogram, + int bForce, + GDALProgressFunc pfnProgress, + void * pProgressData ); +CPLErr CPL_DLL CPL_STDCALL GDALSetDefaultHistogram( GDALRasterBandH hBand, + double dfMin, double dfMax, + int nBuckets, int *panHistogram ) CPL_WARN_DEPRECATED("Use GDALSetDefaultHistogramEx() instead"); +CPLErr CPL_DLL CPL_STDCALL GDALSetDefaultHistogramEx( GDALRasterBandH hBand, + double dfMin, double dfMax, + int nBuckets, GUIntBig *panHistogram ); +int CPL_DLL CPL_STDCALL +GDALGetRandomRasterSample( GDALRasterBandH, int, float * ); +GDALRasterBandH CPL_DLL CPL_STDCALL +GDALGetRasterSampleOverview( GDALRasterBandH, int ); +GDALRasterBandH CPL_DLL CPL_STDCALL +GDALGetRasterSampleOverviewEx( GDALRasterBandH, GUIntBig ); +CPLErr CPL_DLL CPL_STDCALL GDALFillRaster( GDALRasterBandH hBand, + double dfRealValue, double dfImaginaryValue ); +CPLErr CPL_DLL CPL_STDCALL +GDALComputeBandStats( GDALRasterBandH hBand, int nSampleStep, + double *pdfMean, double *pdfStdDev, + GDALProgressFunc pfnProgress, + void *pProgressData ); +CPLErr CPL_DLL GDALOverviewMagnitudeCorrection( GDALRasterBandH hBaseBand, + int nOverviewCount, + GDALRasterBandH *pahOverviews, + GDALProgressFunc pfnProgress, + void *pProgressData ); + +GDALRasterAttributeTableH CPL_DLL CPL_STDCALL GDALGetDefaultRAT( + GDALRasterBandH hBand ); +CPLErr CPL_DLL CPL_STDCALL GDALSetDefaultRAT( GDALRasterBandH, + GDALRasterAttributeTableH ); +CPLErr CPL_DLL CPL_STDCALL GDALAddDerivedBandPixelFunc( const char *pszName, + GDALDerivedPixelFunc pfnPixelFunc ); + +GDALRasterBandH CPL_DLL CPL_STDCALL GDALGetMaskBand( GDALRasterBandH hBand ); +int CPL_DLL CPL_STDCALL GDALGetMaskFlags( GDALRasterBandH hBand ); +CPLErr CPL_DLL CPL_STDCALL + GDALCreateMaskBand( GDALRasterBandH hBand, int nFlags ); + +#define GMF_ALL_VALID 0x01 +#define GMF_PER_DATASET 0x02 +#define GMF_ALPHA 0x04 +#define GMF_NODATA 0x08 + +/* ==================================================================== */ +/* GDALAsyncReader */ +/* ==================================================================== */ + +GDALAsyncStatusType CPL_DLL CPL_STDCALL +GDALARGetNextUpdatedRegion(GDALAsyncReaderH hARIO, double dfTimeout, + int* pnXBufOff, int* pnYBufOff, + int* pnXBufSize, int* pnYBufSize ); +int CPL_DLL CPL_STDCALL GDALARLockBuffer(GDALAsyncReaderH hARIO, + double dfTimeout); +void CPL_DLL CPL_STDCALL GDALARUnlockBuffer(GDALAsyncReaderH hARIO); + +/* -------------------------------------------------------------------- */ +/* Helper functions. */ +/* -------------------------------------------------------------------- */ +int CPL_DLL CPL_STDCALL GDALGeneralCmdLineProcessor( int nArgc, char ***ppapszArgv, + int nOptions ); +void CPL_DLL CPL_STDCALL GDALSwapWords( void *pData, int nWordSize, int nWordCount, + int nWordSkip ); +void CPL_DLL CPL_STDCALL GDALSwapWordsEx( void *pData, int nWordSize, size_t nWordCount, + int nWordSkip ); + +void CPL_DLL CPL_STDCALL + GDALCopyWords( const void * pSrcData, GDALDataType eSrcType, int nSrcPixelOffset, + void * pDstData, GDALDataType eDstType, int nDstPixelOffset, + int nWordCount ); + +void CPL_DLL +GDALCopyBits( const GByte *pabySrcData, int nSrcOffset, int nSrcStep, + GByte *pabyDstData, int nDstOffset, int nDstStep, + int nBitCount, int nStepCount ); + +int CPL_DLL CPL_STDCALL GDALLoadWorldFile( const char *, double * ); +int CPL_DLL CPL_STDCALL GDALReadWorldFile( const char *, const char *, + double * ); +int CPL_DLL CPL_STDCALL GDALWriteWorldFile( const char *, const char *, + double * ); +int CPL_DLL CPL_STDCALL GDALLoadTabFile( const char *, double *, char **, + int *, GDAL_GCP ** ); +int CPL_DLL CPL_STDCALL GDALReadTabFile( const char *, double *, char **, + int *, GDAL_GCP ** ); +int CPL_DLL CPL_STDCALL GDALLoadOziMapFile( const char *, double *, char **, + int *, GDAL_GCP ** ); +int CPL_DLL CPL_STDCALL GDALReadOziMapFile( const char *, double *, + char **, int *, GDAL_GCP ** ); + +const char CPL_DLL * CPL_STDCALL GDALDecToDMS( double, const char *, int ); +double CPL_DLL CPL_STDCALL GDALPackedDMSToDec( double ); +double CPL_DLL CPL_STDCALL GDALDecToPackedDMS( double ); + +/* Note to developers : please keep this section in sync with ogr_core.h */ + +#ifndef GDAL_VERSION_INFO_DEFINED +#define GDAL_VERSION_INFO_DEFINED +const char CPL_DLL * CPL_STDCALL GDALVersionInfo( const char * ); +#endif + +#ifndef GDAL_CHECK_VERSION + +int CPL_DLL CPL_STDCALL GDALCheckVersion( int nVersionMajor, int nVersionMinor, + const char* pszCallingComponentName); + +/** Helper macro for GDALCheckVersion() + @see GDALCheckVersion() + */ +#define GDAL_CHECK_VERSION(pszCallingComponentName) \ + GDALCheckVersion(GDAL_VERSION_MAJOR, GDAL_VERSION_MINOR, pszCallingComponentName) + +#endif + +typedef struct { + double dfLINE_OFF; + double dfSAMP_OFF; + double dfLAT_OFF; + double dfLONG_OFF; + double dfHEIGHT_OFF; + + double dfLINE_SCALE; + double dfSAMP_SCALE; + double dfLAT_SCALE; + double dfLONG_SCALE; + double dfHEIGHT_SCALE; + + double adfLINE_NUM_COEFF[20]; + double adfLINE_DEN_COEFF[20]; + double adfSAMP_NUM_COEFF[20]; + double adfSAMP_DEN_COEFF[20]; + + double dfMIN_LONG; + double dfMIN_LAT; + double dfMAX_LONG; + double dfMAX_LAT; + +} GDALRPCInfo; + +int CPL_DLL CPL_STDCALL GDALExtractRPCInfo( char **, GDALRPCInfo * ); + +/* ==================================================================== */ +/* Color tables. */ +/* ==================================================================== */ + +/** Color tuple */ +typedef struct +{ + /*! gray, red, cyan or hue */ + short c1; + + /*! green, magenta, or lightness */ + short c2; + + /*! blue, yellow, or saturation */ + short c3; + + /*! alpha or blackband */ + short c4; +} GDALColorEntry; + +GDALColorTableH CPL_DLL CPL_STDCALL GDALCreateColorTable( GDALPaletteInterp ) CPL_WARN_UNUSED_RESULT; +void CPL_DLL CPL_STDCALL GDALDestroyColorTable( GDALColorTableH ); +GDALColorTableH CPL_DLL CPL_STDCALL GDALCloneColorTable( GDALColorTableH ); +GDALPaletteInterp CPL_DLL CPL_STDCALL GDALGetPaletteInterpretation( GDALColorTableH ); +int CPL_DLL CPL_STDCALL GDALGetColorEntryCount( GDALColorTableH ); +const GDALColorEntry CPL_DLL * CPL_STDCALL GDALGetColorEntry( GDALColorTableH, int ); +int CPL_DLL CPL_STDCALL GDALGetColorEntryAsRGB( GDALColorTableH, int, GDALColorEntry *); +void CPL_DLL CPL_STDCALL GDALSetColorEntry( GDALColorTableH, int, const GDALColorEntry * ); +void CPL_DLL CPL_STDCALL GDALCreateColorRamp( GDALColorTableH hTable, + int nStartIndex, const GDALColorEntry *psStartColor, + int nEndIndex, const GDALColorEntry *psEndColor ); + +/* ==================================================================== */ +/* Raster Attribute Table */ +/* ==================================================================== */ + +/** Field type of raster attribute table */ +typedef enum { + /*! Integer field */ GFT_Integer, + /*! Floating point (double) field */ GFT_Real, + /*! String field */ GFT_String +} GDALRATFieldType; + +/** Field usage of raster attribute table */ +typedef enum { + /*! General purpose field. */ GFU_Generic = 0, + /*! Histogram pixel count */ GFU_PixelCount = 1, + /*! Class name */ GFU_Name = 2, + /*! Class range minimum */ GFU_Min = 3, + /*! Class range maximum */ GFU_Max = 4, + /*! Class value (min=max) */ GFU_MinMax = 5, + /*! Red class color (0-255) */ GFU_Red = 6, + /*! Green class color (0-255) */ GFU_Green = 7, + /*! Blue class color (0-255) */ GFU_Blue = 8, + /*! Alpha (0=transparent,255=opaque)*/ GFU_Alpha = 9, + /*! Color Range Red Minimum */ GFU_RedMin = 10, + /*! Color Range Green Minimum */ GFU_GreenMin = 11, + /*! Color Range Blue Minimum */ GFU_BlueMin = 12, + /*! Color Range Alpha Minimum */ GFU_AlphaMin = 13, + /*! Color Range Red Maximum */ GFU_RedMax = 14, + /*! Color Range Green Maximum */ GFU_GreenMax = 15, + /*! Color Range Blue Maximum */ GFU_BlueMax = 16, + /*! Color Range Alpha Maximum */ GFU_AlphaMax = 17, + /*! Maximum GFU value */ GFU_MaxCount +} GDALRATFieldUsage; + +GDALRasterAttributeTableH CPL_DLL CPL_STDCALL + GDALCreateRasterAttributeTable(void) CPL_WARN_UNUSED_RESULT; +void CPL_DLL CPL_STDCALL GDALDestroyRasterAttributeTable( + GDALRasterAttributeTableH ); + +int CPL_DLL CPL_STDCALL GDALRATGetColumnCount( GDALRasterAttributeTableH ); + +const char CPL_DLL * CPL_STDCALL GDALRATGetNameOfCol( + GDALRasterAttributeTableH, int ); +GDALRATFieldUsage CPL_DLL CPL_STDCALL GDALRATGetUsageOfCol( + GDALRasterAttributeTableH, int ); +GDALRATFieldType CPL_DLL CPL_STDCALL GDALRATGetTypeOfCol( + GDALRasterAttributeTableH, int ); + +int CPL_DLL CPL_STDCALL GDALRATGetColOfUsage( GDALRasterAttributeTableH, + GDALRATFieldUsage ); +int CPL_DLL CPL_STDCALL GDALRATGetRowCount( GDALRasterAttributeTableH ); + +const char CPL_DLL * CPL_STDCALL GDALRATGetValueAsString( + GDALRasterAttributeTableH, int, int); +int CPL_DLL CPL_STDCALL GDALRATGetValueAsInt( + GDALRasterAttributeTableH, int, int); +double CPL_DLL CPL_STDCALL GDALRATGetValueAsDouble( + GDALRasterAttributeTableH, int, int); + +void CPL_DLL CPL_STDCALL GDALRATSetValueAsString( GDALRasterAttributeTableH, int, int, + const char * ); +void CPL_DLL CPL_STDCALL GDALRATSetValueAsInt( GDALRasterAttributeTableH, int, int, + int ); +void CPL_DLL CPL_STDCALL GDALRATSetValueAsDouble( GDALRasterAttributeTableH, int, int, + double ); + +int CPL_DLL CPL_STDCALL GDALRATChangesAreWrittenToFile( GDALRasterAttributeTableH hRAT ); + +CPLErr CPL_DLL CPL_STDCALL GDALRATValuesIOAsDouble( GDALRasterAttributeTableH hRAT, GDALRWFlag eRWFlag, + int iField, int iStartRow, int iLength, double *pdfData ); +CPLErr CPL_DLL CPL_STDCALL GDALRATValuesIOAsInteger( GDALRasterAttributeTableH hRAT, GDALRWFlag eRWFlag, + int iField, int iStartRow, int iLength, int *pnData); +CPLErr CPL_DLL CPL_STDCALL GDALRATValuesIOAsString( GDALRasterAttributeTableH hRAT, GDALRWFlag eRWFlag, + int iField, int iStartRow, int iLength, char **papszStrList); + +void CPL_DLL CPL_STDCALL GDALRATSetRowCount( GDALRasterAttributeTableH, + int ); +CPLErr CPL_DLL CPL_STDCALL GDALRATCreateColumn( GDALRasterAttributeTableH, + const char *, + GDALRATFieldType, + GDALRATFieldUsage ); +CPLErr CPL_DLL CPL_STDCALL GDALRATSetLinearBinning( GDALRasterAttributeTableH, + double, double ); +int CPL_DLL CPL_STDCALL GDALRATGetLinearBinning( GDALRasterAttributeTableH, + double *, double * ); +CPLErr CPL_DLL CPL_STDCALL GDALRATInitializeFromColorTable( + GDALRasterAttributeTableH, GDALColorTableH ); +GDALColorTableH CPL_DLL CPL_STDCALL GDALRATTranslateToColorTable( + GDALRasterAttributeTableH, int nEntryCount ); +void CPL_DLL CPL_STDCALL GDALRATDumpReadable( GDALRasterAttributeTableH, + FILE * ); +GDALRasterAttributeTableH CPL_DLL CPL_STDCALL + GDALRATClone( GDALRasterAttributeTableH ); + +void CPL_DLL* CPL_STDCALL + GDALRATSerializeJSON( GDALRasterAttributeTableH ) CPL_WARN_UNUSED_RESULT; + +int CPL_DLL CPL_STDCALL GDALRATGetRowOfValue( GDALRasterAttributeTableH, double ); + + +/* ==================================================================== */ +/* GDAL Cache Management */ +/* ==================================================================== */ + +void CPL_DLL CPL_STDCALL GDALSetCacheMax( int nBytes ); +int CPL_DLL CPL_STDCALL GDALGetCacheMax(void); +int CPL_DLL CPL_STDCALL GDALGetCacheUsed(void); +void CPL_DLL CPL_STDCALL GDALSetCacheMax64( GIntBig nBytes ); +GIntBig CPL_DLL CPL_STDCALL GDALGetCacheMax64(void); +GIntBig CPL_DLL CPL_STDCALL GDALGetCacheUsed64(void); + +int CPL_DLL CPL_STDCALL GDALFlushCacheBlock(void); + +/* ==================================================================== */ +/* GDAL virtual memory */ +/* ==================================================================== */ + +CPLVirtualMem CPL_DLL* GDALDatasetGetVirtualMem( GDALDatasetH hDS, + GDALRWFlag eRWFlag, + int nXOff, int nYOff, + int nXSize, int nYSize, + int nBufXSize, int nBufYSize, + GDALDataType eBufType, + int nBandCount, int* panBandMap, + int nPixelSpace, + GIntBig nLineSpace, + GIntBig nBandSpace, + size_t nCacheSize, + size_t nPageSizeHint, + int bSingleThreadUsage, + char **papszOptions ) CPL_WARN_UNUSED_RESULT; + +CPLVirtualMem CPL_DLL* GDALRasterBandGetVirtualMem( GDALRasterBandH hBand, + GDALRWFlag eRWFlag, + int nXOff, int nYOff, + int nXSize, int nYSize, + int nBufXSize, int nBufYSize, + GDALDataType eBufType, + int nPixelSpace, + GIntBig nLineSpace, + size_t nCacheSize, + size_t nPageSizeHint, + int bSingleThreadUsage, + char **papszOptions ) CPL_WARN_UNUSED_RESULT; + +CPLVirtualMem CPL_DLL* GDALGetVirtualMemAuto( GDALRasterBandH hBand, + GDALRWFlag eRWFlag, + int *pnPixelSpace, + GIntBig *pnLineSpace, + char **papszOptions ) CPL_WARN_UNUSED_RESULT; + +typedef enum +{ + /*! Tile Interleaved by Pixel: tile (0,0) with internal band interleaved by pixel organization, tile (1, 0), ... */ + GTO_TIP, + /*! Band Interleaved by Tile : tile (0,0) of first band, tile (0,0) of second band, ... tile (1,0) of first band, tile (1,0) of second band, ... */ + GTO_BIT, + /*! Band SeQuential : all the tiles of first band, all the tiles of following band... */ + GTO_BSQ +} GDALTileOrganization; + +CPLVirtualMem CPL_DLL* GDALDatasetGetTiledVirtualMem( GDALDatasetH hDS, + GDALRWFlag eRWFlag, + int nXOff, int nYOff, + int nXSize, int nYSize, + int nTileXSize, int nTileYSize, + GDALDataType eBufType, + int nBandCount, int* panBandMap, + GDALTileOrganization eTileOrganization, + size_t nCacheSize, + int bSingleThreadUsage, + char **papszOptions ) CPL_WARN_UNUSED_RESULT; + +CPLVirtualMem CPL_DLL* GDALRasterBandGetTiledVirtualMem( GDALRasterBandH hBand, + GDALRWFlag eRWFlag, + int nXOff, int nYOff, + int nXSize, int nYSize, + int nTileXSize, int nTileYSize, + GDALDataType eBufType, + size_t nCacheSize, + int bSingleThreadUsage, + char **papszOptions ) CPL_WARN_UNUSED_RESULT; + +/* ==================================================================== */ +/* VRTPansharpenedDataset class. */ +/* ==================================================================== */ + +GDALDatasetH CPL_DLL GDALCreatePansharpenedVRT( const char* pszXML, + GDALRasterBandH hPanchroBand, + int nInputSpectralBands, + GDALRasterBandH* pahInputSpectralBands ) CPL_WARN_UNUSED_RESULT; + +/* =================================================================== */ +/* Misc API */ +/* ==================================================================== */ + +CPLXMLNode CPL_DLL* GDALGetJPEG2000Structure(const char* pszFilename, + char** papszOptions) CPL_WARN_UNUSED_RESULT; + +CPL_C_END + +#endif /* ndef GDAL_H_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/gdal_alg.h b/modules/globebrowsing/ext/gdal/include/gdal_alg.h new file mode 100644 index 0000000000..a75633fbc6 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/gdal_alg.h @@ -0,0 +1,603 @@ +/****************************************************************************** + * $Id$ + * + * Project: GDAL Image Processing Algorithms + * Purpose: Prototypes, and definitions for various GDAL based algorithms. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2001, Frank Warmerdam + * Copyright (c) 2008-2012, Even Rouault + * + * 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. + ****************************************************************************/ + +#ifndef GDAL_ALG_H_INCLUDED +#define GDAL_ALG_H_INCLUDED + +/** + * \file gdal_alg.h + * + * Public (C callable) GDAL algorithm entry points, and definitions. + */ + +#ifndef DOXYGEN_SKIP +#include "gdal.h" +#include "cpl_minixml.h" +#include "ogr_api.h" +#endif + +CPL_C_START + +int CPL_DLL CPL_STDCALL GDALComputeMedianCutPCT( GDALRasterBandH hRed, + GDALRasterBandH hGreen, + GDALRasterBandH hBlue, + int (*pfnIncludePixel)(int,int,void*), + int nColors, + GDALColorTableH hColorTable, + GDALProgressFunc pfnProgress, + void * pProgressArg ); + +int CPL_DLL CPL_STDCALL GDALDitherRGB2PCT( GDALRasterBandH hRed, + GDALRasterBandH hGreen, + GDALRasterBandH hBlue, + GDALRasterBandH hTarget, + GDALColorTableH hColorTable, + GDALProgressFunc pfnProgress, + void * pProgressArg ); + +int CPL_DLL CPL_STDCALL GDALChecksumImage( GDALRasterBandH hBand, + int nXOff, int nYOff, int nXSize, int nYSize ); + +CPLErr CPL_DLL CPL_STDCALL +GDALComputeProximity( GDALRasterBandH hSrcBand, + GDALRasterBandH hProximityBand, + char **papszOptions, + GDALProgressFunc pfnProgress, + void * pProgressArg ); + +CPLErr CPL_DLL CPL_STDCALL +GDALFillNodata( GDALRasterBandH hTargetBand, + GDALRasterBandH hMaskBand, + double dfMaxSearchDist, + int bDeprecatedOption, + int nSmoothingIterations, + char **papszOptions, + GDALProgressFunc pfnProgress, + void * pProgressArg ); + +CPLErr CPL_DLL CPL_STDCALL +GDALPolygonize( GDALRasterBandH hSrcBand, + GDALRasterBandH hMaskBand, + OGRLayerH hOutLayer, int iPixValField, + char **papszOptions, + GDALProgressFunc pfnProgress, + void * pProgressArg ); + +CPLErr CPL_DLL CPL_STDCALL +GDALFPolygonize( GDALRasterBandH hSrcBand, + GDALRasterBandH hMaskBand, + OGRLayerH hOutLayer, int iPixValField, + char **papszOptions, + GDALProgressFunc pfnProgress, + void * pProgressArg ); + +CPLErr CPL_DLL CPL_STDCALL +GDALSieveFilter( GDALRasterBandH hSrcBand, GDALRasterBandH hMaskBand, + GDALRasterBandH hDstBand, + int nSizeThreshold, int nConnectedness, + char **papszOptions, + GDALProgressFunc pfnProgress, + void * pProgressArg ); + +/* + * Warp Related. + */ + +typedef int +(*GDALTransformerFunc)( void *pTransformerArg, + int bDstToSrc, int nPointCount, + double *x, double *y, double *z, int *panSuccess ); + +#define GDAL_GTI2_SIGNATURE "GTI2" + +typedef struct { + GByte abySignature[4]; + const char *pszClassName; + GDALTransformerFunc pfnTransform; + void (*pfnCleanup)( void * pTransformerArg ); + CPLXMLNode *(*pfnSerialize)( void * pTransformerArg ); + void* (*pfnCreateSimilar)( void* pTransformerArg, double dfSrcRatioX, double dfSrcRatioY ); +} GDALTransformerInfo; + +void CPL_DLL GDALDestroyTransformer( void *pTransformerArg ); +int CPL_DLL GDALUseTransformer( void *pTransformerArg, + int bDstToSrc, int nPointCount, + double *x, double *y, double *z, + int *panSuccess ); +void* GDALCreateSimilarTransformer( void* psTransformerArg, double dfSrcRatioX, double dfSrcRatioY ); + + +/* High level transformer for going from image coordinates on one file + to image coordinates on another, potentially doing reprojection, + utilizing GCPs or using the geotransform. */ + +void CPL_DLL * +GDALCreateGenImgProjTransformer( GDALDatasetH hSrcDS, const char *pszSrcWKT, + GDALDatasetH hDstDS, const char *pszDstWKT, + int bGCPUseOK, double dfGCPErrorThreshold, + int nOrder ); +void CPL_DLL * +GDALCreateGenImgProjTransformer2( GDALDatasetH hSrcDS, GDALDatasetH hDstDS, + char **papszOptions ); +void CPL_DLL * +GDALCreateGenImgProjTransformer3( const char *pszSrcWKT, + const double *padfSrcGeoTransform, + const char *pszDstWKT, + const double *padfDstGeoTransform ); +void CPL_DLL GDALSetGenImgProjTransformerDstGeoTransform( void *, + const double * ); +void CPL_DLL GDALDestroyGenImgProjTransformer( void * ); +int CPL_DLL GDALGenImgProjTransform( + void *pTransformArg, int bDstToSrc, int nPointCount, + double *x, double *y, double *z, int *panSuccess ); + +void GDALSetTransformerDstGeoTransform( void *, const double * ); + +/* Geo to geo reprojection transformer. */ +void CPL_DLL * +GDALCreateReprojectionTransformer( const char *pszSrcWKT, + const char *pszDstWKT ); +void CPL_DLL GDALDestroyReprojectionTransformer( void * ); +int CPL_DLL GDALReprojectionTransform( + void *pTransformArg, int bDstToSrc, int nPointCount, + double *x, double *y, double *z, int *panSuccess ); + +/* GCP based transformer ... forward is to georef coordinates */ +void CPL_DLL * +GDALCreateGCPTransformer( int nGCPCount, const GDAL_GCP *pasGCPList, + int nReqOrder, int bReversed ); + +/* GCP based transformer with refinement of the GCPs ... forward is to georef coordinates */ +void CPL_DLL * +GDALCreateGCPRefineTransformer( int nGCPCount, const GDAL_GCP *pasGCPList, + int nReqOrder, int bReversed, double tolerance, int minimumGcps); + +void CPL_DLL GDALDestroyGCPTransformer( void *pTransformArg ); +int CPL_DLL GDALGCPTransform( + void *pTransformArg, int bDstToSrc, int nPointCount, + double *x, double *y, double *z, int *panSuccess ); + +/* Thin Plate Spine transformer ... forward is to georef coordinates */ + +void CPL_DLL * +GDALCreateTPSTransformer( int nGCPCount, const GDAL_GCP *pasGCPList, + int bReversed ); +void CPL_DLL GDALDestroyTPSTransformer( void *pTransformArg ); +int CPL_DLL GDALTPSTransform( + void *pTransformArg, int bDstToSrc, int nPointCount, + double *x, double *y, double *z, int *panSuccess ); + +char CPL_DLL ** RPCInfoToMD( GDALRPCInfo *psRPCInfo ); + +/* RPC based transformer ... src is pixel/line/elev, dst is long/lat/elev */ + +void CPL_DLL * +GDALCreateRPCTransformer( GDALRPCInfo *psRPC, int bReversed, + double dfPixErrThreshold, + char **papszOptions ); +void CPL_DLL GDALDestroyRPCTransformer( void *pTransformArg ); +int CPL_DLL GDALRPCTransform( + void *pTransformArg, int bDstToSrc, int nPointCount, + double *x, double *y, double *z, int *panSuccess ); + +/* Geolocation transformer */ + +void CPL_DLL * +GDALCreateGeoLocTransformer( GDALDatasetH hBaseDS, + char **papszGeolocationInfo, + int bReversed ); +void CPL_DLL GDALDestroyGeoLocTransformer( void *pTransformArg ); +int CPL_DLL GDALGeoLocTransform( + void *pTransformArg, int bDstToSrc, int nPointCount, + double *x, double *y, double *z, int *panSuccess ); + +/* Approximate transformer */ +void CPL_DLL * +GDALCreateApproxTransformer( GDALTransformerFunc pfnRawTransformer, + void *pRawTransformerArg, double dfMaxError ); +void CPL_DLL GDALApproxTransformerOwnsSubtransformer( void *pCBData, + int bOwnFlag ); +void CPL_DLL GDALDestroyApproxTransformer( void *pApproxArg ); +int CPL_DLL GDALApproxTransform( + void *pTransformArg, int bDstToSrc, int nPointCount, + double *x, double *y, double *z, int *panSuccess ); + + +int CPL_DLL CPL_STDCALL +GDALSimpleImageWarp( GDALDatasetH hSrcDS, + GDALDatasetH hDstDS, + int nBandCount, int *panBandList, + GDALTransformerFunc pfnTransform, + void *pTransformArg, + GDALProgressFunc pfnProgress, + void *pProgressArg, + char **papszWarpOptions ); + +CPLErr CPL_DLL CPL_STDCALL +GDALSuggestedWarpOutput( GDALDatasetH hSrcDS, + GDALTransformerFunc pfnTransformer, + void *pTransformArg, + double *padfGeoTransformOut, + int *pnPixels, int *pnLines ); +CPLErr CPL_DLL CPL_STDCALL +GDALSuggestedWarpOutput2( GDALDatasetH hSrcDS, + GDALTransformerFunc pfnTransformer, + void *pTransformArg, + double *padfGeoTransformOut, + int *pnPixels, int *pnLines, + double *padfExtents, + int nOptions ); + +CPLXMLNode CPL_DLL * +GDALSerializeTransformer( GDALTransformerFunc pfnFunc, void *pTransformArg ); +CPLErr CPL_DLL GDALDeserializeTransformer( CPLXMLNode *psTree, + GDALTransformerFunc *ppfnFunc, + void **ppTransformArg ); + +CPLErr CPL_DLL +GDALTransformGeolocations( GDALRasterBandH hXBand, + GDALRasterBandH hYBand, + GDALRasterBandH hZBand, + GDALTransformerFunc pfnTransformer, + void *pTransformArg, + GDALProgressFunc pfnProgress, + void *pProgressArg, + char **papszOptions ); + +/* -------------------------------------------------------------------- */ +/* Contour Line Generation */ +/* -------------------------------------------------------------------- */ + +typedef CPLErr (*GDALContourWriter)( double dfLevel, int nPoints, + double *padfX, double *padfY, void * ); + +typedef void *GDALContourGeneratorH; + +GDALContourGeneratorH CPL_DLL +GDAL_CG_Create( int nWidth, int nHeight, + int bNoDataSet, double dfNoDataValue, + double dfContourInterval, double dfContourBase, + GDALContourWriter pfnWriter, void *pCBData ); +CPLErr CPL_DLL GDAL_CG_FeedLine( GDALContourGeneratorH hCG, + double *padfScanline ); +void CPL_DLL GDAL_CG_Destroy( GDALContourGeneratorH hCG ); + +typedef struct +{ + void *hLayer; + + double adfGeoTransform[6]; + + int nElevField; + int nIDField; + int nNextID; +} OGRContourWriterInfo; + +CPLErr CPL_DLL +OGRContourWriter( double, int, double *, double *, void *pInfo ); + +CPLErr CPL_DLL +GDALContourGenerate( GDALRasterBandH hBand, + double dfContourInterval, double dfContourBase, + int nFixedLevelCount, double *padfFixedLevels, + int bUseNoData, double dfNoDataValue, + void *hLayer, int iIDField, int iElevField, + GDALProgressFunc pfnProgress, void *pProgressArg ); + +/************************************************************************/ +/* Rasterizer API - geometries burned into GDAL raster. */ +/************************************************************************/ + +CPLErr CPL_DLL +GDALRasterizeGeometries( GDALDatasetH hDS, + int nBandCount, int *panBandList, + int nGeomCount, OGRGeometryH *pahGeometries, + GDALTransformerFunc pfnTransformer, + void *pTransformArg, + double *padfGeomBurnValue, + char **papszOptions, + GDALProgressFunc pfnProgress, + void * pProgressArg ); +CPLErr CPL_DLL +GDALRasterizeLayers( GDALDatasetH hDS, + int nBandCount, int *panBandList, + int nLayerCount, OGRLayerH *pahLayers, + GDALTransformerFunc pfnTransformer, + void *pTransformArg, + double *padfLayerBurnValues, + char **papszOptions, + GDALProgressFunc pfnProgress, + void *pProgressArg ); + +CPLErr CPL_DLL +GDALRasterizeLayersBuf( void *pData, int nBufXSize, int nBufYSize, + GDALDataType eBufType, int nPixelSpace, int nLineSpace, + int nLayerCount, OGRLayerH *pahLayers, + const char *pszDstProjection, + double *padfDstGeoTransform, + GDALTransformerFunc pfnTransformer, + void *pTransformArg, double dfBurnValue, + char **papszOptions, GDALProgressFunc pfnProgress, + void *pProgressArg ); + + +/************************************************************************/ +/* Gridding interface. */ +/************************************************************************/ + +/** Gridding Algorithms */ +typedef enum { + /*! Inverse distance to a power */ GGA_InverseDistanceToAPower = 1, + /*! Moving Average */ GGA_MovingAverage = 2, + /*! Nearest Neighbor */ GGA_NearestNeighbor = 3, + /*! Minimum Value (Data Metric) */ GGA_MetricMinimum = 4, + /*! Maximum Value (Data Metric) */ GGA_MetricMaximum = 5, + /*! Data Range (Data Metric) */ GGA_MetricRange = 6, + /*! Number of Points (Data Metric) */ GGA_MetricCount = 7, + /*! Average Distance (Data Metric) */ GGA_MetricAverageDistance = 8, + /*! Average Distance Between Data Points (Data Metric) */ + GGA_MetricAverageDistancePts = 9, + /*! Linear interpolation (from Delaunay triangulation. Since GDAL 2.1 */ + GGA_Linear = 10, + /*! Inverse distance to a power with nearest neighbor search for max points */ + GGA_InverseDistanceToAPowerNearestNeighbor = 11 +} GDALGridAlgorithm; + +/** Inverse distance to a power method control options */ +typedef struct +{ + /*! Weighting power. */ + double dfPower; + /*! Smoothing parameter. */ + double dfSmoothing; + /*! Reserved for future use. */ + double dfAnisotropyRatio; + /*! Reserved for future use. */ + double dfAnisotropyAngle; + /*! The first radius (X axis if rotation angle is 0) of search ellipse. */ + double dfRadius1; + /*! The second radius (Y axis if rotation angle is 0) of search ellipse. */ + double dfRadius2; + /*! Angle of ellipse rotation in degrees. + * + * Ellipse rotated counter clockwise. + */ + double dfAngle; + /*! Maximum number of data points to use. + * + * Do not search for more points than this number. + * If less amount of points found the grid node considered empty and will + * be filled with NODATA marker. + */ + GUInt32 nMaxPoints; + /*! Minimum number of data points to use. + * + * If less amount of points found the grid node considered empty and will + * be filled with NODATA marker. + */ + GUInt32 nMinPoints; + /*! No data marker to fill empty points. */ + double dfNoDataValue; +} GDALGridInverseDistanceToAPowerOptions; + +typedef struct +{ + /*! Weighting power. */ + double dfPower; + /*! The radius of search circle. */ + double dfRadius; + + /*! Maximum number of data points to use. + * + * Do not search for more points than this number. + * If less amount of points found the grid node considered empty and will + * be filled with NODATA marker. + */ + GUInt32 nMaxPoints; + /*! Minimum number of data points to use. + * + * If less amount of points found the grid node considered empty and will + * be filled with NODATA marker. + */ + GUInt32 nMinPoints; + /*! No data marker to fill empty points. */ + double dfNoDataValue; +} GDALGridInverseDistanceToAPowerNearestNeighborOptions; + +/** Moving average method control options */ +typedef struct +{ + /*! The first radius (X axis if rotation angle is 0) of search ellipse. */ + double dfRadius1; + /*! The second radius (Y axis if rotation angle is 0) of search ellipse. */ + double dfRadius2; + /*! Angle of ellipse rotation in degrees. + * + * Ellipse rotated counter clockwise. + */ + double dfAngle; + /*! Minimum number of data points to average. + * + * If less amount of points found the grid node considered empty and will + * be filled with NODATA marker. + */ + GUInt32 nMinPoints; + /*! No data marker to fill empty points. */ + double dfNoDataValue; +} GDALGridMovingAverageOptions; + +/** Nearest neighbor method control options */ +typedef struct +{ + /*! The first radius (X axis if rotation angle is 0) of search ellipse. */ + double dfRadius1; + /*! The second radius (Y axis if rotation angle is 0) of search ellipse. */ + double dfRadius2; + /*! Angle of ellipse rotation in degrees. + * + * Ellipse rotated counter clockwise. + */ + double dfAngle; + /*! No data marker to fill empty points. */ + double dfNoDataValue; +} GDALGridNearestNeighborOptions; + +/** Data metrics method control options */ +typedef struct +{ + /*! The first radius (X axis if rotation angle is 0) of search ellipse. */ + double dfRadius1; + /*! The second radius (Y axis if rotation angle is 0) of search ellipse. */ + double dfRadius2; + /*! Angle of ellipse rotation in degrees. + * + * Ellipse rotated counter clockwise. + */ + double dfAngle; + /*! Minimum number of data points to average. + * + * If less amount of points found the grid node considered empty and will + * be filled with NODATA marker. + */ + GUInt32 nMinPoints; + /*! No data marker to fill empty points. */ + double dfNoDataValue; +} GDALGridDataMetricsOptions; + +/** Linear method control options */ +typedef struct +{ + /*! In case the point to be interpolated does not fit into a triangle of + * the Delaunay triangulation, use that maximum distance to search a nearest + * neighbour, or use nodata otherwise. If set to -1, the search distance is infinite. + * If set to 0, nodata value will be always used. + */ + double dfRadius; + /*! No data marker to fill empty points. */ + double dfNoDataValue; +} GDALGridLinearOptions; + + +CPLErr CPL_DLL +GDALGridCreate( GDALGridAlgorithm, const void *, GUInt32, + const double *, const double *, const double *, + double, double, double, double, + GUInt32, GUInt32, GDALDataType, void *, + GDALProgressFunc, void *); + +typedef struct GDALGridContext GDALGridContext; + +GDALGridContext CPL_DLL* +GDALGridContextCreate( GDALGridAlgorithm eAlgorithm, const void *poOptions, + GUInt32 nPoints, + const double *padfX, const double *padfY, const double *padfZ, + int bCallerWillKeepPointArraysAlive ); + +void CPL_DLL GDALGridContextFree(GDALGridContext* psContext); + +CPLErr CPL_DLL GDALGridContextProcess(GDALGridContext* psContext, + double dfXMin, double dfXMax, double dfYMin, double dfYMax, + GUInt32 nXSize, GUInt32 nYSize, GDALDataType eType, void *pData, + GDALProgressFunc pfnProgress, void *pProgressArg ); + +GDAL_GCP CPL_DLL * +GDALComputeMatchingPoints( GDALDatasetH hFirstImage, + GDALDatasetH hSecondImage, + char **papszOptions, + int *pnGCPCount ); + +/************************************************************************/ +/* Delaunay triangulation interface. */ +/************************************************************************/ + +typedef struct +{ + int anVertexIdx[3]; /* index to the padfX/padfY arrays */ + int anNeighborIdx[3]; /* index to GDALDelaunayTriangulation.pasFacets, or -1 */ + /* anNeighborIdx[k] is the triangle to the opposite side */ + /* of the opposite segment of anVertexIdx[k] */ +} GDALTriFacet; + +/* Conversion from cartesian (x,y) to barycentric (l1,l2,l3) with : + l1 = dfMul1X * (x - dfCxtX) + dfMul1Y * (y - dfCstY) + l2 = dfMul2X * (x - dfCxtX) + dfMul2Y * (y - dfCstY) + l3 = 1 - l1 - l2 +*/ +typedef struct +{ + double dfMul1X; + double dfMul1Y; + double dfMul2X; + double dfMul2Y; + double dfCstX; + double dfCstY; +} GDALTriBarycentricCoefficients; + +typedef struct +{ + int nFacets; + GDALTriFacet *pasFacets; /* nFacets elements */ + GDALTriBarycentricCoefficients *pasFacetCoefficients; /* nFacets elements */ +} GDALTriangulation; + +int CPL_DLL GDALHasTriangulation(void); + +GDALTriangulation CPL_DLL *GDALTriangulationCreateDelaunay(int nPoints, + const double* padfX, + const double* padfY); +int CPL_DLL GDALTriangulationComputeBarycentricCoefficients( + GDALTriangulation* psDT, + const double* padfX, + const double* padfY); +int CPL_DLL GDALTriangulationComputeBarycentricCoordinates( + const GDALTriangulation* psDT, + int nFacetIdx, + double dfX, + double dfY, + double* pdfL1, + double* pdfL2, + double* pdfL3); +int CPL_DLL GDALTriangulationFindFacetBruteForce( const GDALTriangulation* psDT, + double dfX, + double dfY, + int* panOutputFacetIdx ); +int CPL_DLL GDALTriangulationFindFacetDirected( const GDALTriangulation* psDT, + int nFacetIdx, + double dfX, + double dfY, + int* panOutputFacetIdx ); +void CPL_DLL GDALTriangulationFree(GDALTriangulation* psDT); + +// GDAL internal use only +void GDALTriangulationTerminate(void); + +CPL_C_END + +#endif /* ndef GDAL_ALG_H_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/gdal_alg_priv.h b/modules/globebrowsing/ext/gdal/include/gdal_alg_priv.h new file mode 100644 index 0000000000..93b5a7fbec --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/gdal_alg_priv.h @@ -0,0 +1,209 @@ +/****************************************************************************** + * $Id$ + * + * Project: GDAL Image Processing Algorithms + * Purpose: Prototypes and definitions for various GDAL based algorithms: + * private declarations. + * Author: Andrey Kiselev, dron@ak4719.spb.edu + * + ****************************************************************************** + * Copyright (c) 2008, Andrey Kiselev + * Copyright (c) 2010-2013, Even Rouault + * + * 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. + ****************************************************************************/ + +#ifndef GDAL_ALG_PRIV_H_INCLUDED +#define GDAL_ALG_PRIV_H_INCLUDED + +#include "gdal_alg.h" + +CPL_C_START + +/** Source of the burn value */ +typedef enum { + /*! Use value from padfBurnValue */ GBV_UserBurnValue = 0, + /*! Use value from the Z coordinate */ GBV_Z = 1, + /*! Use value form the M value */ GBV_M = 2 +} GDALBurnValueSrc; + +typedef enum { + GRMA_Replace = 0, + GRMA_Add = 1, +} GDALRasterMergeAlg; + +typedef struct { + unsigned char * pabyChunkBuf; + int nXSize; + int nYSize; + int nBands; + GDALDataType eType; + double *padfBurnValue; + GDALBurnValueSrc eBurnValueSource; + GDALRasterMergeAlg eMergeAlg; +} GDALRasterizeInfo; + +/************************************************************************/ +/* Low level rasterizer API. */ +/************************************************************************/ + +typedef void (*llScanlineFunc)( void *, int, int, int, double ); +typedef void (*llPointFunc)( void *, int, int, double ); + +void GDALdllImagePoint( int nRasterXSize, int nRasterYSize, + int nPartCount, int *panPartSize, + double *padfX, double *padfY, double *padfVariant, + llPointFunc pfnPointFunc, void *pCBData ); + +void GDALdllImageLine( int nRasterXSize, int nRasterYSize, + int nPartCount, int *panPartSize, + double *padfX, double *padfY, double *padfVariant, + llPointFunc pfnPointFunc, void *pCBData ); + +void GDALdllImageLineAllTouched(int nRasterXSize, int nRasterYSize, + int nPartCount, int *panPartSize, + double *padfX, double *padfY, + double *padfVariant, + llPointFunc pfnPointFunc, void *pCBData ); + +void GDALdllImageFilledPolygon(int nRasterXSize, int nRasterYSize, + int nPartCount, int *panPartSize, + double *padfX, double *padfY, + double *padfVariant, + llScanlineFunc pfnScanlineFunc, void *pCBData ); + +CPL_C_END + +/************************************************************************/ +/* Polygon Enumerator */ +/************************************************************************/ + +#define GP_NODATA_MARKER -51502112 + +template class GDALRasterPolygonEnumeratorT + +{ +private: + void MergePolygon( int nSrcId, int nDstId ); + int NewPolygon( DataType nValue ); + +public: // these are intended to be readonly. + + GInt32 *panPolyIdMap; + DataType *panPolyValue; + + int nNextPolygonId; + int nPolyAlloc; + + int nConnectedness; + +public: + GDALRasterPolygonEnumeratorT( int nConnectedness=4 ); + ~GDALRasterPolygonEnumeratorT(); + + void ProcessLine( DataType *panLastLineVal, DataType *panThisLineVal, + GInt32 *panLastLineId, GInt32 *panThisLineId, + int nXSize ); + + void CompleteMerges(); + + void Clear(); +}; + +struct IntEqualityTest +{ + bool operator()(GInt32 a, GInt32 b) { return a == b; } +}; + +typedef GDALRasterPolygonEnumeratorT GDALRasterPolygonEnumerator; + +typedef void* (*GDALTransformDeserializeFunc)( CPLXMLNode *psTree ); + +void* GDALRegisterTransformDeserializer(const char* pszTransformName, + GDALTransformerFunc pfnTransformerFunc, + GDALTransformDeserializeFunc pfnDeserializeFunc); +void GDALUnregisterTransformDeserializer(void* pData); + +void GDALCleanupTransformDeserializerMutex(); + +/* Transformer cloning */ + +void* GDALCreateTPSTransformerInt( int nGCPCount, const GDAL_GCP *pasGCPList, + int bReversed, char** papszOptions ); + +void CPL_DLL * GDALCloneTransformer( void *pTransformerArg ); + +/************************************************************************/ +/* Color table related */ +/************************************************************************/ + +/* definitions exists for T = GUInt32 and T = GUIntBig */ +template int +GDALComputeMedianCutPCTInternal( GDALRasterBandH hRed, + GDALRasterBandH hGreen, + GDALRasterBandH hBlue, + GByte* pabyRedBand, + GByte* pabyGreenBand, + GByte* pabyBlueBand, + int (*pfnIncludePixel)(int,int,void*), + int nColors, + int nBits, + T* panHistogram, + GDALColorTableH hColorTable, + GDALProgressFunc pfnProgress, + void * pProgressArg ); + +int GDALDitherRGB2PCTInternal( GDALRasterBandH hRed, + GDALRasterBandH hGreen, + GDALRasterBandH hBlue, + GDALRasterBandH hTarget, + GDALColorTableH hColorTable, + int nBits, + GInt16* pasDynamicColorMap, + int bDither, + GDALProgressFunc pfnProgress, + void * pProgressArg ); + +#define PRIME_FOR_65536 98317 + +/* See HashHistogram structure in gdalmediancut.cpp and ColorIndex structure in gdaldither.cpp */ +/* 6 * sizeof(int) should be the size of the largest of both structures */ +#define MEDIAN_CUT_AND_DITHER_BUFFER_SIZE_65536 (6 * sizeof(int) * PRIME_FOR_65536) + + +/************************************************************************/ +/* Float comparison function. */ +/************************************************************************/ + +/** + * Units in the Last Place. This specifies how big an error we are willing to + * accept in terms of the value of the least significant digit of the floating + * point number’s representation. MAX_ULPS can also be interpreted in terms of + * how many representable floats we are willing to accept between A and B. + */ +#define MAX_ULPS 10 + +GBool GDALFloatEquals(float A, float B); + +struct FloatEqualityTest +{ + bool operator()(float a, float b) { return GDALFloatEquals(a,b) == TRUE; } +}; + +#endif /* ndef GDAL_ALG_PRIV_H_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/gdal_csv.h b/modules/globebrowsing/ext/gdal/include/gdal_csv.h new file mode 100644 index 0000000000..ea48f26dcf --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/gdal_csv.h @@ -0,0 +1,41 @@ +/****************************************************************************** + * $Id$ + * + * Project: Common Portability Library + * Purpose: Functions for reading and scanning CSV (comma separated, + * variable length text files holding tables) files. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, Frank Warmerdam + * Copyright (c) 2010, Even Rouault + * + * 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. + ****************************************************************************/ + +#ifndef GDAL_CSV_H_INCLUDED +#define GDAL_CSV_H_INCLUDED + +#include "cpl_port.h" + +CPL_C_START +const char * GDALDefaultCSVFilename( const char *pszBasename ); +CPL_C_END + +#endif diff --git a/modules/globebrowsing/ext/gdal/include/gdal_frmts.h b/modules/globebrowsing/ext/gdal/include/gdal_frmts.h new file mode 100644 index 0000000000..8c9bafd96f --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/gdal_frmts.h @@ -0,0 +1,191 @@ +/****************************************************************************** + * $Id$ + * + * Project: GDAL + * Purpose: Prototypes for all format specific driver initialization. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2001, Frank Warmerdam + * Copyright (c) 2007-2014, Even Rouault + * + * 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. + ****************************************************************************/ + +#ifndef GDAL_FRMTS_H_INCLUDED +#define GDAL_FRMTS_H_INCLUDED + +#include "cpl_port.h" + +CPL_C_START +void CPL_DLL GDALRegister_GTiff(void); +void CPL_DLL GDALRegister_GXF(void); +void CPL_DLL GDALRegister_OGDI(void); +void CPL_DLL GDALRegister_HFA(void); +void CPL_DLL GDALRegister_AAIGrid(void); +void CPL_DLL GDALRegister_GRASSASCIIGrid(void); +void CPL_DLL GDALRegister_AIGrid(void); +// void CPL_DLL GDALRegister_AIGrid2(void); +void CPL_DLL GDALRegister_CEOS(void); +void CPL_DLL GDALRegister_SAR_CEOS(void); +void CPL_DLL GDALRegister_SDTS(void); +void CPL_DLL GDALRegister_ELAS(void); +void CPL_DLL GDALRegister_EHdr(void); +void CPL_DLL GDALRegister_GenBin(void); +void CPL_DLL GDALRegister_PAux(void); +void CPL_DLL GDALRegister_ENVI(void); +void CPL_DLL GDALRegister_DOQ1(void); +void CPL_DLL GDALRegister_DOQ2(void); +void CPL_DLL GDALRegister_DTED(void); +void CPL_DLL GDALRegister_MFF(void); +void CPL_DLL GDALRegister_HKV(void); +void CPL_DLL GDALRegister_PNG(void); +void CPL_DLL GDALRegister_DDS(void); +void CPL_DLL GDALRegister_GTA(void); +void CPL_DLL GDALRegister_JPEG(void); +void CPL_DLL GDALRegister_JPEG2000(void); +void CPL_DLL GDALRegister_JP2KAK(void); +void CPL_DLL GDALRegister_JPIPKAK(void); +void CPL_DLL GDALRegister_MEM(void); +void CPL_DLL GDALRegister_JDEM(void); +void CPL_DLL GDALRegister_RASDAMAN(void); +void CPL_DLL GDALRegister_GRASS(void); +void CPL_DLL GDALRegister_PNM(void); +void CPL_DLL GDALRegister_GIF(void); +void CPL_DLL GDALRegister_BIGGIF(void); +void CPL_DLL GDALRegister_Envisat(void); +void CPL_DLL GDALRegister_FITS(void); +void CPL_DLL GDALRegister_ECW(void); +void CPL_DLL GDALRegister_JP2ECW(void); +void CPL_DLL GDALRegister_ECW_JP2ECW(); +void CPL_DLL GDALRegister_FujiBAS(void); +void CPL_DLL GDALRegister_FIT(void); +void CPL_DLL GDALRegister_VRT(void); +void CPL_DLL GDALRegister_USGSDEM(void); +void CPL_DLL GDALRegister_FAST(void); +void CPL_DLL GDALRegister_HDF4(void); +void CPL_DLL GDALRegister_HDF4Image(void); +void CPL_DLL GDALRegister_L1B(void); +void CPL_DLL GDALRegister_LDF(void); +void CPL_DLL GDALRegister_BSB(void); +void CPL_DLL GDALRegister_XPM(void); +void CPL_DLL GDALRegister_BMP(void); +void CPL_DLL GDALRegister_GSC(void); +void CPL_DLL GDALRegister_NITF(void); +void CPL_DLL GDALRegister_RPFTOC(void); +void CPL_DLL GDALRegister_ECRGTOC(void); +void CPL_DLL GDALRegister_MrSID(void); +void CPL_DLL GDALRegister_MG4Lidar(void); +void CPL_DLL GDALRegister_PCIDSK(void); +void CPL_DLL GDALRegister_BT(void); +void CPL_DLL GDALRegister_DODS(void); +void CPL_DLL GDALRegister_GMT(void); +void CPL_DLL GDALRegister_netCDF(void); +void CPL_DLL GDALRegister_LAN(void); +void CPL_DLL GDALRegister_CPG(void); +void CPL_DLL GDALRegister_AirSAR(void); +void CPL_DLL GDALRegister_RS2(void); +void CPL_DLL GDALRegister_ILWIS(void); +void CPL_DLL GDALRegister_PCRaster(void); +void CPL_DLL GDALRegister_IDA(void); +void CPL_DLL GDALRegister_NDF(void); +void CPL_DLL GDALRegister_RMF(void); +void CPL_DLL GDALRegister_BAG(void); +void CPL_DLL GDALRegister_HDF5(void); +void CPL_DLL GDALRegister_HDF5Image(void); +void CPL_DLL GDALRegister_MSGN(void); +void CPL_DLL GDALRegister_MSG(void); +void CPL_DLL GDALRegister_RIK(void); +void CPL_DLL GDALRegister_Leveller(void); +void CPL_DLL GDALRegister_SGI(void); +void CPL_DLL GDALRegister_SRTMHGT(void); +void CPL_DLL GDALRegister_DIPEx(void); +void CPL_DLL GDALRegister_ISIS3(void); +void CPL_DLL GDALRegister_ISIS2(void); +void CPL_DLL GDALRegister_PDS(void); +void CPL_DLL GDALRegister_VICAR(void); +void CPL_DLL GDALRegister_IDRISI(void); +void CPL_DLL GDALRegister_Terragen(void); +void CPL_DLL GDALRegister_WCS(void); +void CPL_DLL GDALRegister_WMS(void); +void CPL_DLL GDALRegister_HTTP(void); +void CPL_DLL GDALRegister_SDE(void); +void CPL_DLL GDALRegister_GSAG(void); +void CPL_DLL GDALRegister_GSBG(void); +void CPL_DLL GDALRegister_GS7BG(void); +void CPL_DLL GDALRegister_GRIB(void); +void CPL_DLL GDALRegister_INGR(void); +void CPL_DLL GDALRegister_ERS(void); +void CPL_DLL GDALRegister_PALSARJaxa(void); +void CPL_DLL GDALRegister_DIMAP(); +void CPL_DLL GDALRegister_GFF(void); +void CPL_DLL GDALRegister_COSAR(void); +void CPL_DLL GDALRegister_TSX(void); +void CPL_DLL GDALRegister_ADRG(void); +void CPL_DLL GDALRegister_SRP(void); +void CPL_DLL GDALRegister_COASP(void); +void CPL_DLL GDALRegister_BLX(void); +void CPL_DLL GDALRegister_LCP(void); +void CPL_DLL GDALRegister_TMS(void); +void CPL_DLL GDALRegister_EIR(void); +void CPL_DLL GDALRegister_GEOR(void); +void CPL_DLL GDALRegister_TIL(void); +void CPL_DLL GDALRegister_R(void); +void CPL_DLL GDALRegister_Rasterlite(void); +void CPL_DLL GDALRegister_EPSILON(void); +void CPL_DLL GDALRegister_PostGISRaster(void); +void CPL_DLL GDALRegister_NWT_GRD(void); +void CPL_DLL GDALRegister_NWT_GRC(void); +void CPL_DLL GDALRegister_SAGA(void); +void CPL_DLL GDALRegister_KMLSUPEROVERLAY(void); +void CPL_DLL GDALRegister_GTX(void); +void CPL_DLL GDALRegister_LOSLAS(void); +void CPL_DLL GDALRegister_Istar(void); +void CPL_DLL GDALRegister_NTv2(void); +void CPL_DLL GDALRegister_CTable2(void); +void CPL_DLL GDALRegister_JP2OpenJPEG(void); +void CPL_DLL GDALRegister_XYZ(void); +void CPL_DLL GDALRegister_HF2(void); +void CPL_DLL GDALRegister_PDF(void); +void CPL_DLL GDALRegister_JPEGLS(void); +void CPL_DLL GDALRegister_MAP(void); +void CPL_DLL GDALRegister_OZI(void); +void CPL_DLL GDALRegister_ACE2(void); +void CPL_DLL GDALRegister_CTG(void); +void CPL_DLL GDALRegister_E00GRID(void); +void CPL_DLL GDALRegister_SNODAS(void); +void CPL_DLL GDALRegister_WEBP(void); +void CPL_DLL GDALRegister_ZMap(void); +void CPL_DLL GDALRegister_NGSGEOID(void); +void CPL_DLL GDALRegister_MBTiles(void); +void CPL_DLL GDALRegister_ARG(void); +void CPL_DLL GDALRegister_IRIS(void); +void CPL_DLL GDALRegister_KRO(void); +void CPL_DLL GDALRegister_KEA(void); +void CPL_DLL GDALRegister_ROIPAC(void); +void CPL_DLL GDALRegister_PLMOSAIC(void); +void CPL_DLL GDALRegister_CALS(void); +void CPL_DLL GDALRegister_ISCE(void); +void CPL_DLL GDALRegister_WMTS(void); +void CPL_DLL GDALRegister_SAFE(void); +void CPL_DLL GDALRegister_SENTINEL2(void); +void CPL_DLL GDALRegister_mrf(void); +CPL_C_END + +#endif /* ndef GDAL_FRMTS_H_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/gdal_mdreader.h b/modules/globebrowsing/ext/gdal/include/gdal_mdreader.h new file mode 100644 index 0000000000..926cf1281c --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/gdal_mdreader.h @@ -0,0 +1,207 @@ +/****************************************************************************** + * $Id$ + * + * Project: GDAL Core + * Purpose: Read metadata (mainly the remote sensing imagery) from files of + * different providers like DigitalGlobe, GeoEye etc. + * Author: Dmitry Baryshnikov, polimax@mail.ru + * + ****************************************************************************** + * Copyright (c) 2014-2015, NextGIS info@nextgis.ru + * + * 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. + ****************************************************************************/ + +#ifndef GDAL_MDREADER_H_INCLUDED +#define GDAL_MDREADER_H_INCLUDED + + +#include "cpl_port.h" +#include "gdal_priv.h" + +#define MD_DOMAIN_IMD "IMD" /**< image metadata section */ +#define MD_DOMAIN_RPC "RPC" /**< rpc metadata section */ +#define MD_DOMAIN_IMAGERY "IMAGERY" /**< imagery metadata section */ +#define MD_DOMAIN_DEFAULT "" /**< default metadata section */ + +#define MD_NAME_ACQDATETIME "ACQUISITIONDATETIME" /**< Acquisition Date Time property name. The time should be in UTC */ +#define MD_NAME_SATELLITE "SATELLITEID" /**< Satellite identificator property name */ +#define MD_NAME_CLOUDCOVER "CLOUDCOVER" /**< Cloud coverage property name. The value between 0 - 100 or 999 if n/a */ +#define MD_NAME_MDTYPE "METADATATYPE" /**< Metadata reader type property name. The reader processed this metadata */ + +#define MD_DATETIMEFORMAT "%Y-%m-%d %H:%M:%S" /**< Date time format */ +#define MD_CLOUDCOVER_NA "999" /**< The value if cloud cover is n/a */ + +/** + * RPC/RPB specific defines + */ + +#define RPC_LINE_OFF "LINE_OFF" +#define RPC_SAMP_OFF "SAMP_OFF" +#define RPC_LAT_OFF "LAT_OFF" +#define RPC_LONG_OFF "LONG_OFF" +#define RPC_HEIGHT_OFF "HEIGHT_OFF" +#define RPC_LINE_SCALE "LINE_SCALE" +#define RPC_SAMP_SCALE "SAMP_SCALE" +#define RPC_LAT_SCALE "LAT_SCALE" +#define RPC_LONG_SCALE "LONG_SCALE" +#define RPC_HEIGHT_SCALE "HEIGHT_SCALE" +#define RPC_LINE_NUM_COEFF "LINE_NUM_COEFF" +#define RPC_LINE_DEN_COEFF "LINE_DEN_COEFF" +#define RPC_SAMP_NUM_COEFF "SAMP_NUM_COEFF" +#define RPC_SAMP_DEN_COEFF "SAMP_DEN_COEFF" + +/** + * Enumerator of metadata readers + */ + +typedef enum { + MDR_None = 0x00000000, /**< no reader */ + MDR_DG = 0x00000001, /**< Digital Globe, METADATATYPE=DG */ + MDR_GE = 0x00000002, /**< Geo Eye, METADATATYPE=GE */ + MDR_OV = 0x00000004, /**< Orb View, METADATATYPE=OV */ + MDR_PLEIADES = 0x00000008, /**< Pleiades, METADATATYPE=DIMAP */ + MDR_SPOT = 0x00000010, /**< Spot, METADATATYPE=DIMAP */ + MDR_RDK1 = 0x00000020, /**< Resurs DK1, METADATATYPE=MSP */ + MDR_LS = 0x00000040, /**< Landsat, METADATATYPE=ODL */ + MDR_RE = 0x00000080, /**< RapidEye, METADATATYPE=RE */ + MDR_KOMPSAT = 0x00000100, /**< Kompsat, METADATATYPE=KARI */ + MDR_EROS = 0x00000200, /**< EROS, METADATATYPE=EROS */ + MDR_ALOS = 0x00000400, /**< ALOS, METADATATYPE=ALOS */ + MDR_ANY = MDR_DG | MDR_GE | MDR_OV | MDR_PLEIADES | MDR_SPOT | MDR_RDK1 | + MDR_LS | MDR_RE | MDR_KOMPSAT | MDR_EROS | MDR_ALOS /**< any reader */ +} MDReaders; + + +/** + * The base class for all metadata readers + */ +class GDALMDReaderBase{ +public: + GDALMDReaderBase(const char *pszPath, char **papszSiblingFiles); + virtual ~GDALMDReaderBase(); + + /** + * @brief Get specified metadata domain + * @param pszDomain The metadata domain to return + * @return List of metadata items + */ + virtual char ** GetMetadataDomain(const char *pszDomain); + /** + * @brief Fill provided metadata store class + * @param poMDMD Metadata store class + * @return true on success or false + */ + virtual bool FillMetadata(GDALMultiDomainMetadata* poMDMD); + /** + * @brief Determine whether the input parameter correspond to the particular + * provider of remote sensing data completely + * @return True if all needed sources files found + */ + virtual bool HasRequiredFiles() const = 0; + /** + * @brief Get metadata file names. The caller become owner of returned list + * and have to free it via CSLDestroy. + * @return A file name list + */ + virtual char** GetMetadataFiles() const = 0; +protected: + /** + * @brief Load metadata to the correspondent IMD, RPB, IMAGERY and DEFAULT + * domains + */ + virtual void LoadMetadata(); + /** + * @brief Convert string like 2012-02-25T00:25:59.9440000Z to time + * @param pszDateTime String to convert + * @return value in time_t + */ + virtual time_t GetAcquisitionTimeFromString(const char* pszDateTime); + /** + * @brief ReadXMLToList Transform xml to list of NULL terminated name=value + * strings + * @param psNode A xml node to process + * @param papszList A list to fill with name=value strings + * @param pszName A name of parent node. For root xml node should be empty. + * If name is not empty, the sibling nodes will not proceed + * @return An input list filled with values + */ + virtual char** ReadXMLToList(CPLXMLNode* psNode, char** papszList, + const char* pszName = ""); + /** + * @brief AddXMLNameValueToList Execute from ReadXMLToList to add name and + * value to list. One can override this function for special + * processing input values before add to list. + * @param papszList A list to fill with name=value strings + * @param pszName A name to add + * @param pszValue A value to add + * @return An input list filled with values + */ + virtual char** AddXMLNameValueToList(char** papszList, const char *pszName, + const char *pszValue); +protected: + char **m_papszIMDMD; + char **m_papszRPCMD; + char **m_papszIMAGERYMD; + char **m_papszDEFAULTMD; + bool m_bIsMetadataLoad; +}; + +/** + * The metadata reader main class. + * The main purpose of this class is to provide an correspondent reader + * for provided path. + */ +class CPL_DLL GDALMDReaderManager{ +public: + GDALMDReaderManager(); + virtual ~GDALMDReaderManager(); + + /** + * @brief Try to detect metadata reader correspondent to the provided + * datasource path + * @param pszPath a path to GDALDataset + * @param papszSiblingFiles file list for metadata search purposes + * @param nType a preferable reader type (may be the OR of MDReaders) + * @return an appropriate reader or NULL if no such reader or error. + * The pointer delete by the GDALMDReaderManager, so the user have not + * delete it. + */ + virtual GDALMDReaderBase* GetReader(const char *pszPath, + char **papszSiblingFiles, + GUInt32 nType = MDR_ANY); +protected: + GDALMDReaderBase *m_pReader; +}; + +// misc +CPLString CPLStrip(const CPLString& osString, const char cChar); +CPLString CPLStripQuotes(const CPLString& osString); +char** GDALLoadRPBFile( const CPLString& osFilePath ); +char** GDALLoadRPCFile( const CPLString& osFilePath ); +char** GDALLoadIMDFile( const CPLString& osFilePath ); +bool GDALCheckFileHeader(const CPLString& soFilePath, + const char * pszTestString, + int nBufferSize = 256); + +CPLErr GDALWriteRPBFile( const char *pszFilename, char **papszMD ); +CPLErr GDALWriteRPCTXTFile( const char *pszFilename, char **papszMD ); +CPLErr GDALWriteIMDFile( const char *pszFilename, char **papszMD ); + +#endif //GDAL_MDREADER_H_INCLUDED diff --git a/modules/globebrowsing/ext/gdal/include/gdal_pam.h b/modules/globebrowsing/ext/gdal/include/gdal_pam.h new file mode 100644 index 0000000000..8c342538f7 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/gdal_pam.h @@ -0,0 +1,324 @@ +/****************************************************************************** + * $Id$ + * + * Project: GDAL Core + * Purpose: Declaration for Peristable Auxiliary Metadata classes. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2005, 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. + ****************************************************************************/ + +#ifndef GDAL_PAM_H_INCLUDED +#define GDAL_PAM_H_INCLUDED + +#include "gdal_priv.h" + +class GDALPamRasterBand; + +/* Clone Info Flags */ + +#define GCIF_GEOTRANSFORM 0x01 +#define GCIF_PROJECTION 0x02 +#define GCIF_METADATA 0x04 +#define GCIF_GCPS 0x08 + +#define GCIF_NODATA 0x001000 +#define GCIF_CATEGORYNAMES 0x002000 +#define GCIF_MINMAX 0x004000 +#define GCIF_SCALEOFFSET 0x008000 +#define GCIF_UNITTYPE 0x010000 +#define GCIF_COLORTABLE 0x020000 +#define GCIF_COLORINTERP 0x020000 +#define GCIF_BAND_METADATA 0x040000 +#define GCIF_RAT 0x080000 +#define GCIF_MASK 0x100000 +#define GCIF_BAND_DESCRIPTION 0x200000 + +#define GCIF_ONLY_IF_MISSING 0x10000000 +#define GCIF_PROCESS_BANDS 0x20000000 + +#define GCIF_PAM_DEFAULT (GCIF_GEOTRANSFORM | GCIF_PROJECTION | \ + GCIF_METADATA | GCIF_GCPS | \ + GCIF_NODATA | GCIF_CATEGORYNAMES | \ + GCIF_MINMAX | GCIF_SCALEOFFSET | \ + GCIF_UNITTYPE | GCIF_COLORTABLE | \ + GCIF_COLORINTERP | GCIF_BAND_METADATA | \ + GCIF_RAT | GCIF_MASK | \ + GCIF_ONLY_IF_MISSING | GCIF_PROCESS_BANDS|\ + GCIF_BAND_DESCRIPTION) + +/* GDAL PAM Flags */ +/* ERO 2011/04/13 : GPF_AUXMODE seems to be unimplemented */ +#define GPF_DIRTY 0x01 // .pam file needs to be written on close +#define GPF_TRIED_READ_FAILED 0x02 // no need to keep trying to read .pam. +#define GPF_DISABLED 0x04 // do not try any PAM stuff. +#define GPF_AUXMODE 0x08 // store info in .aux (HFA) file. +#define GPF_NOSAVE 0x10 // do not try to save pam info. + +/* ==================================================================== */ +/* GDALDatasetPamInfo */ +/* */ +/* We make these things a separate structure of information */ +/* primarily so we can modify it without altering the size of */ +/* the GDALPamDataset. It is an effort to reduce ABI churn for */ +/* driver plugins. */ +/* ==================================================================== */ +class GDALDatasetPamInfo +{ +public: + char *pszPamFilename; + + char *pszProjection; + + int bHaveGeoTransform; + double adfGeoTransform[6]; + + int nGCPCount; + GDAL_GCP *pasGCPList; + char *pszGCPProjection; + + CPLString osPhysicalFilename; + CPLString osSubdatasetName; + CPLString osAuxFilename; + + int bHasMetadata; +}; + +/* ******************************************************************** */ +/* GDALPamDataset */ +/* ******************************************************************** */ + +class CPL_DLL GDALPamDataset : public GDALDataset +{ + friend class GDALPamRasterBand; + + private: + int IsPamFilenameAPotentialSiblingFile(); + + protected: + GDALPamDataset(void); + + int nPamFlags; + GDALDatasetPamInfo *psPam; + + virtual CPLXMLNode *SerializeToXML( const char *); + virtual CPLErr XMLInit( CPLXMLNode *, const char * ); + + virtual CPLErr TryLoadXML(char **papszSiblingFiles = NULL); + virtual CPLErr TrySaveXML(); + + CPLErr TryLoadAux(char **papszSiblingFiles = NULL); + CPLErr TrySaveAux(); + + virtual const char *BuildPamFilename(); + + void PamInitialize(); + void PamClear(); + + void SetPhysicalFilename( const char * ); + const char *GetPhysicalFilename(); + void SetSubdatasetName( const char *); + const char *GetSubdatasetName(); + + public: + virtual ~GDALPamDataset(); + + virtual void FlushCache(void); + + virtual const char *GetProjectionRef(void); + virtual CPLErr SetProjection( const char * ); + + virtual CPLErr GetGeoTransform( double * ); + virtual CPLErr SetGeoTransform( double * ); + + virtual int GetGCPCount(); + virtual const char *GetGCPProjection(); + virtual const GDAL_GCP *GetGCPs(); + virtual CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList, + const char *pszGCPProjection ); + + virtual CPLErr SetMetadata( char ** papszMetadata, + const char * pszDomain = "" ); + virtual CPLErr SetMetadataItem( const char * pszName, + const char * pszValue, + const char * pszDomain = "" ); + virtual char **GetMetadata( const char * pszDomain = "" ); + virtual const char *GetMetadataItem( const char * pszName, + const char * pszDomain = "" ); + + virtual char **GetFileList(void); + + virtual CPLErr CloneInfo( GDALDataset *poSrcDS, int nCloneInfoFlags ); + + virtual CPLErr IBuildOverviews( const char *pszResampling, + int nOverviews, int *panOverviewList, + int nListBands, int *panBandList, + GDALProgressFunc pfnProgress, + void * pProgressData ); + + + // "semi private" methods. + void MarkPamDirty() { nPamFlags |= GPF_DIRTY; } + GDALDatasetPamInfo *GetPamInfo() { return psPam; } + int GetPamFlags() { return nPamFlags; } + void SetPamFlags(int nValue ) { nPamFlags = nValue; } + + private: + CPL_DISALLOW_COPY_ASSIGN(GDALPamDataset); +}; + +/* ==================================================================== */ +/* GDALRasterBandPamInfo */ +/* */ +/* We make these things a separate structure of information */ +/* primarily so we can modify it without altering the size of */ +/* the GDALPamDataset. It is an effort to reduce ABI churn for */ +/* driver plugins. */ +/* ==================================================================== */ +typedef struct { + GDALPamDataset *poParentDS; + + int bNoDataValueSet; + double dfNoDataValue; + + GDALColorTable *poColorTable; + + GDALColorInterp eColorInterp; + + char *pszUnitType; + char **papszCategoryNames; + + double dfOffset; + double dfScale; + + int bHaveMinMax; + double dfMin; + double dfMax; + + int bHaveStats; + double dfMean; + double dfStdDev; + + CPLXMLNode *psSavedHistograms; + + GDALRasterAttributeTable *poDefaultRAT; + +} GDALRasterBandPamInfo; + +/* ******************************************************************** */ +/* GDALPamRasterBand */ +/* ******************************************************************** */ +class CPL_DLL GDALPamRasterBand : public GDALRasterBand +{ + friend class GDALPamDataset; + + protected: + + virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath ); + virtual CPLErr XMLInit( CPLXMLNode *, const char * ); + + void PamInitialize(); + void PamClear(); + + GDALRasterBandPamInfo *psPam; + + public: + GDALPamRasterBand(); + GDALPamRasterBand(int bForceCachedIO); + virtual ~GDALPamRasterBand(); + + virtual void SetDescription( const char * ); + + virtual CPLErr SetNoDataValue( double ); + virtual double GetNoDataValue( int *pbSuccess = NULL ); + virtual CPLErr DeleteNoDataValue(); + + virtual CPLErr SetColorTable( GDALColorTable * ); + virtual GDALColorTable *GetColorTable(); + + virtual CPLErr SetColorInterpretation( GDALColorInterp ); + virtual GDALColorInterp GetColorInterpretation(); + + virtual const char *GetUnitType(); + CPLErr SetUnitType( const char * ); + + virtual char **GetCategoryNames(); + virtual CPLErr SetCategoryNames( char ** ); + + virtual double GetOffset( int *pbSuccess = NULL ); + CPLErr SetOffset( double ); + virtual double GetScale( int *pbSuccess = NULL ); + CPLErr SetScale( double ); + + virtual CPLErr GetHistogram( double dfMin, double dfMax, + int nBuckets, GUIntBig * panHistogram, + int bIncludeOutOfRange, int bApproxOK, + GDALProgressFunc, void *pProgressData ); + + virtual CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax, + int *pnBuckets, GUIntBig ** ppanHistogram, + int bForce, + GDALProgressFunc, void *pProgressData); + + virtual CPLErr SetDefaultHistogram( double dfMin, double dfMax, + int nBuckets, GUIntBig *panHistogram ); + + virtual CPLErr SetMetadata( char ** papszMetadata, + const char * pszDomain = "" ); + virtual CPLErr SetMetadataItem( const char * pszName, + const char * pszValue, + const char * pszDomain = "" ); + + virtual GDALRasterAttributeTable *GetDefaultRAT(); + virtual CPLErr SetDefaultRAT( const GDALRasterAttributeTable * ); + + // new in GDALPamRasterBand. + virtual CPLErr CloneInfo( GDALRasterBand *poSrcBand, int nCloneInfoFlags ); + + // "semi private" methods. + GDALRasterBandPamInfo *GetPamInfo() { return psPam; } + + private: + CPL_DISALLOW_COPY_ASSIGN(GDALPamRasterBand); +}; + +// These are mainly helper functions for internal use. +int CPL_DLL PamParseHistogram( CPLXMLNode *psHistItem, + double *pdfMin, double *pdfMax, + int *pnBuckets, GUIntBig **ppanHistogram, + int *pbIncludeOutOfRange, int *pbApproxOK ); +CPLXMLNode CPL_DLL * +PamFindMatchingHistogram( CPLXMLNode *psSavedHistograms, + double dfMin, double dfMax, int nBuckets, + int bIncludeOutOfRange, int bApproxOK ); +CPLXMLNode CPL_DLL * +PamHistogramToXMLTree( double dfMin, double dfMax, + int nBuckets, GUIntBig * panHistogram, + int bIncludeOutOfRange, int bApprox ); + +// For managing the proxy file database. +const char CPL_DLL * PamGetProxy( const char * ); +const char CPL_DLL * PamAllocateProxy( const char * ); +const char CPL_DLL * PamDeallocateProxy( const char * ); +void CPL_DLL PamCleanProxyDB( void ); + +#endif /* ndef GDAL_PAM_H_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/gdal_priv.h b/modules/globebrowsing/ext/gdal/include/gdal_priv.h new file mode 100644 index 0000000000..71b9ee6ff2 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/gdal_priv.h @@ -0,0 +1,1423 @@ +/****************************************************************************** + * $Id$ + * + * Name: gdal_priv.h + * Project: GDAL Core + * Purpose: GDAL Core C++/Private declarations. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1998, Frank Warmerdam + * Copyright (c) 2007-2014, Even Rouault + * + * 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. + ****************************************************************************/ + +#ifndef GDAL_PRIV_H_INCLUDED +#define GDAL_PRIV_H_INCLUDED + +/** + * \file gdal_priv.h + * + * C++ GDAL entry points. + */ + +/* -------------------------------------------------------------------- */ +/* Predeclare various classes before pulling in gdal.h, the */ +/* public declarations. */ +/* -------------------------------------------------------------------- */ +class GDALMajorObject; +class GDALDataset; +class GDALRasterBand; +class GDALDriver; +class GDALRasterAttributeTable; +class GDALProxyDataset; +class GDALProxyRasterBand; +class GDALAsyncReader; + +/* -------------------------------------------------------------------- */ +/* Pull in the public declarations. This gets the C apis, and */ +/* also various constants. However, we will still get to */ +/* provide the real class definitions for the GDAL classes. */ +/* -------------------------------------------------------------------- */ + +#include "gdal.h" +#include "gdal_frmts.h" +#include "cpl_vsi.h" +#include "cpl_conv.h" +#include "cpl_string.h" +#include "cpl_minixml.h" +#include "cpl_multiproc.h" +#include "cpl_atomic_ops.h" +#include +#include +#include "ogr_core.h" + +#define GMO_VALID 0x0001 +#define GMO_IGNORE_UNIMPLEMENTED 0x0002 +#define GMO_SUPPORT_MD 0x0004 +#define GMO_SUPPORT_MDMD 0x0008 +#define GMO_MD_DIRTY 0x0010 +#define GMO_PAM_CLASS 0x0020 + +/************************************************************************/ +/* GDALMultiDomainMetadata */ +/************************************************************************/ + +class CPL_DLL GDALMultiDomainMetadata +{ +private: + char **papszDomainList; + CPLStringList **papoMetadataLists; + +public: + GDALMultiDomainMetadata(); + ~GDALMultiDomainMetadata(); + + int XMLInit( CPLXMLNode *psMetadata, int bMerge ); + CPLXMLNode *Serialize(); + + char **GetDomainList() { return papszDomainList; } + + char **GetMetadata( const char * pszDomain = "" ); + CPLErr SetMetadata( char ** papszMetadata, + const char * pszDomain = "" ); + const char *GetMetadataItem( const char * pszName, + const char * pszDomain = "" ); + CPLErr SetMetadataItem( const char * pszName, + const char * pszValue, + const char * pszDomain = "" ); + + void Clear(); + + private: + CPL_DISALLOW_COPY_ASSIGN(GDALMultiDomainMetadata); +}; + +/* ******************************************************************** */ +/* GDALMajorObject */ +/* */ +/* Base class providing metadata, description and other */ +/* services shared by major objects. */ +/* ******************************************************************** */ + +//! Object with metadata. + +class CPL_DLL GDALMajorObject +{ + protected: + int nFlags; // GMO_* flags. + CPLString sDescription; + GDALMultiDomainMetadata oMDMD; + + char **BuildMetadataDomainList(char** papszList, int bCheckNonEmpty, ...) CPL_NULL_TERMINATED; + + public: + GDALMajorObject(); + virtual ~GDALMajorObject(); + + int GetMOFlags(); + void SetMOFlags(int nFlagsIn); + + virtual const char *GetDescription() const; + virtual void SetDescription( const char * ); + + virtual char **GetMetadataDomainList(); + + virtual char **GetMetadata( const char * pszDomain = "" ); + virtual CPLErr SetMetadata( char ** papszMetadata, + const char * pszDomain = "" ); + virtual const char *GetMetadataItem( const char * pszName, + const char * pszDomain = "" ); + virtual CPLErr SetMetadataItem( const char * pszName, + const char * pszValue, + const char * pszDomain = "" ); +}; + +/* ******************************************************************** */ +/* GDALDefaultOverviews */ +/* ******************************************************************** */ +class CPL_DLL GDALDefaultOverviews +{ + friend class GDALDataset; + + GDALDataset *poDS; + GDALDataset *poODS; + + CPLString osOvrFilename; + + int bOvrIsAux; + + int bCheckedForMask; + int bOwnMaskDS; + GDALDataset *poMaskDS; + + // for "overview datasets" we record base level info so we can + // find our way back to get overview masks. + GDALDataset *poBaseDS; + + // Stuff for deferred initialize/overviewscans... + bool bCheckedForOverviews; + void OverviewScan(); + char *pszInitName; + int bInitNameIsOVR; + char **papszInitSiblingFiles; + + public: + GDALDefaultOverviews(); + ~GDALDefaultOverviews(); + + void Initialize( GDALDataset *poDSIn, const char *pszName = NULL, + char **papszSiblingFiles = NULL, + int bNameIsOVR = FALSE ); + + void TransferSiblingFiles(char** papszSiblingFiles); + + int IsInitialized(); + + int CloseDependentDatasets(); + + // Overview Related + + int GetOverviewCount(int); + GDALRasterBand *GetOverview(int,int); + + CPLErr BuildOverviews( const char * pszBasename, + const char * pszResampling, + int nOverviews, int * panOverviewList, + int nBands, int * panBandList, + GDALProgressFunc pfnProgress, + void *pProgressData ); + + CPLErr BuildOverviewsSubDataset( const char * pszPhysicalFile, + const char * pszResampling, + int nOverviews, int * panOverviewList, + int nBands, int * panBandList, + GDALProgressFunc pfnProgress, + void *pProgressData ); + + CPLErr CleanOverviews(); + + // Mask Related + + CPLErr CreateMaskBand( int nFlags, int nBand = -1 ); + GDALRasterBand *GetMaskBand( int nBand ); + int GetMaskFlags( int nBand ); + + int HaveMaskFile( char **papszSiblings = NULL, + const char *pszBasename = NULL ); + + char** GetSiblingFiles() { return papszInitSiblingFiles; } + + private: + CPL_DISALLOW_COPY_ASSIGN(GDALDefaultOverviews); +}; + +/* ******************************************************************** */ +/* GDALOpenInfo */ +/* */ +/* Structure of data about dataset for open functions. */ +/* ******************************************************************** */ + +class CPL_DLL GDALOpenInfo +{ + bool bHasGotSiblingFiles; + char **papszSiblingFiles; + int nHeaderBytesTried; + + public: + GDALOpenInfo( const char * pszFile, int nOpenFlagsIn, + char **papszSiblingFiles = NULL ); + ~GDALOpenInfo( void ); + + char *pszFilename; + char** papszOpenOptions; + + GDALAccess eAccess; + int nOpenFlags; + + int bStatOK; + int bIsDirectory; + + VSILFILE *fpL; + + int nHeaderBytes; + GByte *pabyHeader; + + int TryToIngest(int nBytes); + char **GetSiblingFiles(); + char **StealSiblingFiles(); + bool AreSiblingFilesLoaded() const; + + private: + CPL_DISALLOW_COPY_ASSIGN(GDALOpenInfo); +}; + +/* ******************************************************************** */ +/* GDALDataset */ +/* ******************************************************************** */ + +class OGRLayer; +class OGRGeometry; +class OGRSpatialReference; +class OGRStyleTable; +class swq_select; +class swq_select_parse_options; +typedef struct GDALSQLParseInfo GDALSQLParseInfo; + +#ifdef DETECT_OLD_IRASTERIO +typedef void signature_changed; +#endif + +#ifdef GDAL_COMPILATION +#define OPTIONAL_OUTSIDE_GDAL(val) +#else +#define OPTIONAL_OUTSIDE_GDAL(val) = val +#endif + +//! A set of associated raster bands, usually from one file. + +class CPL_DLL GDALDataset : public GDALMajorObject +{ + friend GDALDatasetH CPL_STDCALL GDALOpenEx( const char* pszFilename, + unsigned int nOpenFlags, + const char* const* papszAllowedDrivers, + const char* const* papszOpenOptions, + const char* const* papszSiblingFiles ); + friend void CPL_STDCALL GDALClose( GDALDatasetH hDS ); + + friend class GDALDriver; + friend class GDALDefaultOverviews; + friend class GDALProxyDataset; + friend class GDALDriverManager; + + void AddToDatasetOpenList(); + + void Init(int bForceCachedIO); + + protected: + GDALDriver *poDriver; + GDALAccess eAccess; + + // Stored raster information. + int nRasterXSize; + int nRasterYSize; + int nBands; + GDALRasterBand **papoBands; + + int nOpenFlags; + + int nRefCount; + GByte bForceCachedIO; + GByte bShared; + GByte bIsInternal; + GByte bSuppressOnClose; + + GDALDataset(void); + GDALDataset(int bForceCachedIO); + + void RasterInitialize( int, int ); + void SetBand( int, GDALRasterBand * ); + + GDALDefaultOverviews oOvManager; + + virtual CPLErr IBuildOverviews( const char *, int, int *, + int, int *, GDALProgressFunc, void * ); + +#ifdef DETECT_OLD_IRASTERIO + virtual signature_changed IRasterIO( GDALRWFlag, int, int, int, int, + void *, int, int, GDALDataType, + int, int *, int, int, int ) {}; +#endif + + virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int, + void *, int, int, GDALDataType, + int, int *, GSpacing, GSpacing, GSpacing, + GDALRasterIOExtraArg* psExtraArg ) CPL_WARN_UNUSED_RESULT; + + CPLErr BlockBasedRasterIO( GDALRWFlag, int, int, int, int, + void *, int, int, GDALDataType, + int, int *, GSpacing, GSpacing, GSpacing, + GDALRasterIOExtraArg* psExtraArg ) CPL_WARN_UNUSED_RESULT; + void BlockBasedFlushCache(); + + CPLErr BandBasedRasterIO( GDALRWFlag eRWFlag, + int nXOff, int nYOff, int nXSize, int nYSize, + void * pData, int nBufXSize, int nBufYSize, + GDALDataType eBufType, + int nBandCount, int *panBandMap, + GSpacing nPixelSpace, GSpacing nLineSpace, + GSpacing nBandSpace, + GDALRasterIOExtraArg* psExtraArg ) CPL_WARN_UNUSED_RESULT; + + CPLErr RasterIOResampled( GDALRWFlag eRWFlag, + int nXOff, int nYOff, int nXSize, int nYSize, + void * pData, int nBufXSize, int nBufYSize, + GDALDataType eBufType, + int nBandCount, int *panBandMap, + GSpacing nPixelSpace, GSpacing nLineSpace, + GSpacing nBandSpace, + GDALRasterIOExtraArg* psExtraArg ) CPL_WARN_UNUSED_RESULT; + + CPLErr ValidateRasterIOOrAdviseReadParameters( + const char* pszCallingFunc, + int* pbStopProcessingOnCENone, + int nXOff, int nYOff, int nXSize, int nYSize, + int nBufXSize, int nBufYSize, + int nBandCount, int *panBandMap); + + CPLErr TryOverviewRasterIO( GDALRWFlag eRWFlag, + int nXOff, int nYOff, int nXSize, int nYSize, + void * pData, int nBufXSize, int nBufYSize, + GDALDataType eBufType, + int nBandCount, int *panBandMap, + GSpacing nPixelSpace, GSpacing nLineSpace, + GSpacing nBandSpace, + GDALRasterIOExtraArg* psExtraArg, + int* pbTried); + + virtual int CloseDependentDatasets(); + + int ValidateLayerCreationOptions( const char* const* papszLCO ); + + char **papszOpenOptions; + + friend class GDALRasterBand; + + // The below methods related to read write mutex are fragile logic, and + // should not be used by out-of-tree code if possible. + int EnterReadWrite(GDALRWFlag eRWFlag); + void LeaveReadWrite(); + + void TemporarilyDropReadWriteLock(); + void ReacquireReadWriteLock(); + + void DisableReadWriteMutex(); + + int AcquireMutex(); + void ReleaseMutex(); + + public: + virtual ~GDALDataset(); + + int GetRasterXSize( void ); + int GetRasterYSize( void ); + int GetRasterCount( void ); + GDALRasterBand *GetRasterBand( int ); + + virtual void FlushCache(void); + + virtual const char *GetProjectionRef(void); + virtual CPLErr SetProjection( const char * ); + + virtual CPLErr GetGeoTransform( double * ); + virtual CPLErr SetGeoTransform( double * ); + + virtual CPLErr AddBand( GDALDataType eType, + char **papszOptions=NULL ); + + virtual void *GetInternalHandle( const char * ); + virtual GDALDriver *GetDriver(void); + virtual char **GetFileList(void); + + virtual const char* GetDriverName(); + + virtual int GetGCPCount(); + virtual const char *GetGCPProjection(); + virtual const GDAL_GCP *GetGCPs(); + virtual CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList, + const char *pszGCPProjection ); + + virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize, + int nBufXSize, int nBufYSize, + GDALDataType eDT, + int nBandCount, int *panBandList, + char **papszOptions ); + + virtual CPLErr CreateMaskBand( int nFlagsIn ); + + virtual GDALAsyncReader* + BeginAsyncReader(int nXOff, int nYOff, int nXSize, int nYSize, + void *pBuf, int nBufXSize, int nBufYSize, + GDALDataType eBufType, + int nBandCount, int* panBandMap, + int nPixelSpace, int nLineSpace, int nBandSpace, + char **papszOptions); + virtual void EndAsyncReader(GDALAsyncReader *); + + CPLErr RasterIO( GDALRWFlag, int, int, int, int, + void *, int, int, GDALDataType, + int, int *, GSpacing, GSpacing, GSpacing, + GDALRasterIOExtraArg* psExtraArg +#ifndef DOXYGEN_SKIP + OPTIONAL_OUTSIDE_GDAL(NULL) +#endif + ) CPL_WARN_UNUSED_RESULT; + + int Reference(); + int Dereference(); + GDALAccess GetAccess() const { return eAccess; } + + int GetShared(); + void MarkAsShared(); + + void MarkSuppressOnClose() { bSuppressOnClose = TRUE; } + + char **GetOpenOptions() { return papszOpenOptions; } + + static GDALDataset **GetOpenDatasets( int *pnDatasetCount ); + + CPLErr BuildOverviews( const char *, int, int *, + int, int *, GDALProgressFunc, void * ); + + void ReportError(CPLErr eErrClass, CPLErrorNum err_no, const char *fmt, ...) CPL_PRINT_FUNC_FORMAT (4, 5); + +private: + void *m_hPrivateData; + + OGRLayer* BuildLayerFromSelectInfo(swq_select* psSelectInfo, + OGRGeometry *poSpatialFilter, + const char *pszDialect, + swq_select_parse_options* poSelectParseOptions); + + public: + + virtual int GetLayerCount(); + virtual OGRLayer *GetLayer(int); + virtual OGRLayer *GetLayerByName(const char *); + virtual OGRErr DeleteLayer(int); + + virtual int TestCapability( const char * ); + + virtual OGRLayer *CreateLayer( const char *pszName, + OGRSpatialReference *poSpatialRef = NULL, + OGRwkbGeometryType eGType = wkbUnknown, + char ** papszOptions = NULL ); + virtual OGRLayer *CopyLayer( OGRLayer *poSrcLayer, + const char *pszNewName, + char **papszOptions = NULL ); + + virtual OGRStyleTable *GetStyleTable(); + virtual void SetStyleTableDirectly( OGRStyleTable *poStyleTable ); + + virtual void SetStyleTable(OGRStyleTable *poStyleTable); + + virtual OGRLayer * ExecuteSQL( const char *pszStatement, + OGRGeometry *poSpatialFilter, + const char *pszDialect ); + virtual void ReleaseResultSet( OGRLayer * poResultsSet ); + + int GetRefCount() const; + int GetSummaryRefCount() const; + OGRErr Release(); + + virtual OGRErr StartTransaction(int bForce=FALSE); + virtual OGRErr CommitTransaction(); + virtual OGRErr RollbackTransaction(); + + static int IsGenericSQLDialect(const char* pszDialect); + + // Semi-public methods. Only to be used by in-tree drivers. + GDALSQLParseInfo* BuildParseInfo(swq_select* psSelectInfo, + swq_select_parse_options* poSelectParseOptions); + void DestroyParseInfo(GDALSQLParseInfo* psParseInfo ); + OGRLayer * ExecuteSQL( const char *pszStatement, + OGRGeometry *poSpatialFilter, + const char *pszDialect, + swq_select_parse_options* poSelectParseOptions); + + protected: + + virtual OGRLayer *ICreateLayer( const char *pszName, + OGRSpatialReference *poSpatialRef = NULL, + OGRwkbGeometryType eGType = wkbUnknown, + char ** papszOptions = NULL ); + + OGRErr ProcessSQLCreateIndex( const char * ); + OGRErr ProcessSQLDropIndex( const char * ); + OGRErr ProcessSQLDropTable( const char * ); + OGRErr ProcessSQLAlterTableAddColumn( const char * ); + OGRErr ProcessSQLAlterTableDropColumn( const char * ); + OGRErr ProcessSQLAlterTableAlterColumn( const char * ); + OGRErr ProcessSQLAlterTableRenameColumn( const char * ); + + OGRStyleTable *m_poStyleTable; + + private: + CPL_DISALLOW_COPY_ASSIGN(GDALDataset); +}; + +/* ******************************************************************** */ +/* GDALRasterBlock */ +/* ******************************************************************** */ + +//! A single raster block in the block cache. +// And the global block manager that manages a least-recently-used list of +// blocks from various datasets/bands + +class CPL_DLL GDALRasterBlock +{ + friend class GDALAbstractBandBlockCache; + + GDALDataType eType; + + int bDirty; + volatile int nLockCount; + + int nXOff; + int nYOff; + + int nXSize; + int nYSize; + + void *pData; + + GDALRasterBand *poBand; + + GDALRasterBlock *poNext; + GDALRasterBlock *poPrevious; + + int bMustDetach; + + void Detach_unlocked( void ); + void Touch_unlocked( void ); + + void RecycleFor( int nXOffIn, int nYOffIn ); + + public: + GDALRasterBlock( GDALRasterBand *, int, int ); + GDALRasterBlock( int nXOffIn, int nYOffIn ); /* only for lookup purpose */ + virtual ~GDALRasterBlock(); + + CPLErr Internalize( void ); + void Touch( void ); + void MarkDirty( void ); + void MarkClean( void ); + int AddLock( void ) { return CPLAtomicInc(&nLockCount); } + int DropLock( void ) { return CPLAtomicDec(&nLockCount); } + void Detach(); + + CPLErr Write(); + + GDALDataType GetDataType() const { return eType; } + int GetXOff() const { return nXOff; } + int GetYOff() const { return nYOff; } + int GetXSize() const { return nXSize; } + int GetYSize() const { return nYSize; } + int GetDirty() const { return bDirty; } + + void *GetDataRef( void ) { return pData; } + int GetBlockSize() const { + return nXSize * nYSize * GDALGetDataTypeSizeBytes(eType); } + + int TakeLock(); + int DropLockForRemovalFromStorage(); + + /// @brief Accessor to source GDALRasterBand object. + /// @return source raster band of the raster block. + GDALRasterBand *GetBand() { return poBand; } + + static void FlushDirtyBlocks(); + static int FlushCacheBlock(int bDirtyBlocksOnly = FALSE); + static void Verify(); + +#ifdef notdef + static void CheckNonOrphanedBlocks(GDALRasterBand* poBand); + void DumpBlock(); + static void DumpAll(); +#endif + + /* Should only be called by GDALDestroyDriverManager() */ + static void DestroyRBMutex(); + + private: + CPL_DISALLOW_COPY_ASSIGN(GDALRasterBlock); +}; + +/* ******************************************************************** */ +/* GDALColorTable */ +/* ******************************************************************** */ + +/*! A color table / palette. */ + +class CPL_DLL GDALColorTable +{ + GDALPaletteInterp eInterp; + + std::vector aoEntries; + +public: + GDALColorTable( GDALPaletteInterp = GPI_RGB ); + ~GDALColorTable(); + + GDALColorTable *Clone() const; + int IsSame(const GDALColorTable* poOtherCT) const; + + GDALPaletteInterp GetPaletteInterpretation() const; + + int GetColorEntryCount() const; + const GDALColorEntry *GetColorEntry( int ) const; + int GetColorEntryAsRGB( int, GDALColorEntry * ) const; + void SetColorEntry( int, const GDALColorEntry * ); + int CreateColorRamp( int, const GDALColorEntry * , + int, const GDALColorEntry * ); +}; + +/* ******************************************************************** */ +/* GDALAbstractBandBlockCache */ +/* ******************************************************************** */ + +//! This manages how a raster band store its cached block. +// CPL_DLL is just technical here. This is really a private concept +// only used by GDALRasterBand implementation. + +class CPL_DLL GDALAbstractBandBlockCache +{ + // List of blocks that can be freed or recycled, and its lock + CPLLock *hSpinLock; + GDALRasterBlock *psListBlocksToFree; + + // Band keep alive counter, and its lock & condition + CPLCond *hCond; + CPLMutex *hCondMutex; + volatile int nKeepAliveCounter; + + protected: + GDALRasterBand *poBand; + + void FreeDanglingBlocks(); + void UnreferenceBlockBase(); + void WaitKeepAliveCounter(); + + public: + GDALAbstractBandBlockCache(GDALRasterBand* poBand); + virtual ~GDALAbstractBandBlockCache(); + + GDALRasterBlock* CreateBlock(int nXBlockOff, int nYBlockOff); + void AddBlockToFreeList( GDALRasterBlock * ); + + virtual bool Init() = 0; + virtual bool IsInitOK() = 0; + virtual CPLErr FlushCache() = 0; + virtual CPLErr AdoptBlock( GDALRasterBlock* poBlock ) = 0; + virtual GDALRasterBlock *TryGetLockedBlockRef( int nXBlockOff, + int nYBlockYOff ) = 0; + virtual CPLErr UnreferenceBlock( GDALRasterBlock* poBlock ) = 0; + virtual CPLErr FlushBlock( int nXBlockOff, int nYBlockOff, + int bWriteDirtyBlock ) = 0; +}; + +GDALAbstractBandBlockCache* GDALArrayBandBlockCacheCreate(GDALRasterBand* poBand); +GDALAbstractBandBlockCache* GDALHashSetBandBlockCacheCreate(GDALRasterBand* poBand); + +/* ******************************************************************** */ +/* GDALRasterBand */ +/* ******************************************************************** */ + +//! A single raster band (or channel). + +class CPL_DLL GDALRasterBand : public GDALMajorObject +{ + private: + friend class GDALArrayBandBlockCache; + friend class GDALHashSetBandBlockCache; + friend class GDALRasterBlock; + + CPLErr eFlushBlockErr; + GDALAbstractBandBlockCache* poBandBlockCache; + + void SetFlushBlockErr( CPLErr eErr ); + CPLErr UnreferenceBlock( GDALRasterBlock* poBlock ); + + void Init(int bForceCachedIO); + + protected: + GDALDataset *poDS; + int nBand; /* 1 based */ + + int nRasterXSize; + int nRasterYSize; + + GDALDataType eDataType; + GDALAccess eAccess; + + /* stuff related to blocking, and raster cache */ + int nBlockXSize; + int nBlockYSize; + int nBlocksPerRow; + int nBlocksPerColumn; + + int nBlockReads; + int bForceCachedIO; + + GDALRasterBand *poMask; + bool bOwnMask; + int nMaskFlags; + + void InvalidateMaskBand(); + + friend class GDALDataset; + friend class GDALProxyRasterBand; + friend class GDALDefaultOverviews; + + CPLErr RasterIOResampled( GDALRWFlag, int, int, int, int, + void *, int, int, GDALDataType, + GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg ) CPL_WARN_UNUSED_RESULT; + + int EnterReadWrite(GDALRWFlag eRWFlag); + void LeaveReadWrite(); + + protected: + virtual CPLErr IReadBlock( int, int, void * ) = 0; + virtual CPLErr IWriteBlock( int, int, void * ); + +#ifdef DETECT_OLD_IRASTERIO + virtual signature_changed IRasterIO( GDALRWFlag, int, int, int, int, + void *, int, int, GDALDataType, + int, int ) {}; +#endif + + virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int, + void *, int, int, GDALDataType, + GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg ) CPL_WARN_UNUSED_RESULT; + CPLErr OverviewRasterIO( GDALRWFlag, int, int, int, int, + void *, int, int, GDALDataType, + GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg ) CPL_WARN_UNUSED_RESULT; + + CPLErr TryOverviewRasterIO( GDALRWFlag eRWFlag, + int nXOff, int nYOff, int nXSize, int nYSize, + void * pData, int nBufXSize, int nBufYSize, + GDALDataType eBufType, + GSpacing nPixelSpace, GSpacing nLineSpace, + GDALRasterIOExtraArg* psExtraArg, + int* pbTried ); + + int InitBlockInfo(); + + CPLErr AdoptBlock( GDALRasterBlock * ); + GDALRasterBlock *TryGetLockedBlockRef( int nXBlockOff, int nYBlockYOff ); + void AddBlockToFreeList( GDALRasterBlock * ); + + public: + GDALRasterBand(); + GDALRasterBand(int bForceCachedIO); + + virtual ~GDALRasterBand(); + + int GetXSize(); + int GetYSize(); + int GetBand(); + GDALDataset*GetDataset(); + + GDALDataType GetRasterDataType( void ); + void GetBlockSize( int *, int * ); + GDALAccess GetAccess(); + + CPLErr RasterIO( GDALRWFlag, int, int, int, int, + void *, int, int, GDALDataType, + GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg +#ifndef DOXYGEN_SKIP + OPTIONAL_OUTSIDE_GDAL(NULL) +#endif + ) CPL_WARN_UNUSED_RESULT; + CPLErr ReadBlock( int, int, void * ) CPL_WARN_UNUSED_RESULT; + + CPLErr WriteBlock( int, int, void * ) CPL_WARN_UNUSED_RESULT; + + GDALRasterBlock *GetLockedBlockRef( int nXBlockOff, int nYBlockOff, + int bJustInitialize = FALSE ) CPL_WARN_UNUSED_RESULT; + CPLErr FlushBlock( int, int, int bWriteDirtyBlock = TRUE ); + + unsigned char* GetIndexColorTranslationTo(/* const */ GDALRasterBand* poReferenceBand, + unsigned char* pTranslationTable = NULL, + int* pApproximateMatching = NULL); + + // New OpengIS CV_SampleDimension stuff. + + virtual CPLErr FlushCache(); + virtual char **GetCategoryNames(); + virtual double GetNoDataValue( int *pbSuccess = NULL ); + virtual double GetMinimum( int *pbSuccess = NULL ); + virtual double GetMaximum(int *pbSuccess = NULL ); + virtual double GetOffset( int *pbSuccess = NULL ); + virtual double GetScale( int *pbSuccess = NULL ); + virtual const char *GetUnitType(); + virtual GDALColorInterp GetColorInterpretation(); + virtual GDALColorTable *GetColorTable(); + virtual CPLErr Fill(double dfRealValue, double dfImaginaryValue = 0); + + virtual CPLErr SetCategoryNames( char ** ); + virtual CPLErr SetNoDataValue( double ); + virtual CPLErr DeleteNoDataValue(); + virtual CPLErr SetColorTable( GDALColorTable * ); + virtual CPLErr SetColorInterpretation( GDALColorInterp ); + virtual CPLErr SetOffset( double ); + virtual CPLErr SetScale( double ); + virtual CPLErr SetUnitType( const char * ); + + virtual CPLErr GetStatistics( int bApproxOK, int bForce, + double *pdfMin, double *pdfMax, + double *pdfMean, double *padfStdDev ); + virtual CPLErr ComputeStatistics( int bApproxOK, + double *pdfMin, double *pdfMax, + double *pdfMean, double *pdfStdDev, + GDALProgressFunc, void *pProgressData ); + virtual CPLErr SetStatistics( double dfMin, double dfMax, + double dfMean, double dfStdDev ); + virtual CPLErr ComputeRasterMinMax( int, double* ); + + virtual int HasArbitraryOverviews(); + virtual int GetOverviewCount(); + virtual GDALRasterBand *GetOverview(int); + virtual GDALRasterBand *GetRasterSampleOverview( GUIntBig ); + virtual CPLErr BuildOverviews( const char *, int, int *, + GDALProgressFunc, void * ); + + virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize, + int nBufXSize, int nBufYSize, + GDALDataType eDT, char **papszOptions ); + + virtual CPLErr GetHistogram( double dfMin, double dfMax, + int nBuckets, GUIntBig * panHistogram, + int bIncludeOutOfRange, int bApproxOK, + GDALProgressFunc, void *pProgressData ); + + virtual CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax, + int *pnBuckets, GUIntBig ** ppanHistogram, + int bForce, + GDALProgressFunc, void *pProgressData); + virtual CPLErr SetDefaultHistogram( double dfMin, double dfMax, + int nBuckets, GUIntBig *panHistogram ); + + virtual GDALRasterAttributeTable *GetDefaultRAT(); + virtual CPLErr SetDefaultRAT( const GDALRasterAttributeTable * ); + + virtual GDALRasterBand *GetMaskBand(); + virtual int GetMaskFlags(); + virtual CPLErr CreateMaskBand( int nFlagsIn ); + + virtual CPLVirtualMem *GetVirtualMemAuto( GDALRWFlag eRWFlag, + int *pnPixelSpace, + GIntBig *pnLineSpace, + char **papszOptions ) CPL_WARN_UNUSED_RESULT; + + void ReportError(CPLErr eErrClass, CPLErrorNum err_no, const char *fmt, ...) CPL_PRINT_FUNC_FORMAT (4, 5); + +private: + CPL_DISALLOW_COPY_ASSIGN(GDALRasterBand); +}; + +/* ******************************************************************** */ +/* GDALAllValidMaskBand */ +/* ******************************************************************** */ + +class CPL_DLL GDALAllValidMaskBand : public GDALRasterBand +{ + protected: + virtual CPLErr IReadBlock( int, int, void * ); + + public: + GDALAllValidMaskBand( GDALRasterBand * ); + virtual ~GDALAllValidMaskBand(); + + virtual GDALRasterBand *GetMaskBand(); + virtual int GetMaskFlags(); +}; + +/* ******************************************************************** */ +/* GDALNoDataMaskBand */ +/* ******************************************************************** */ + +class CPL_DLL GDALNoDataMaskBand : public GDALRasterBand +{ + double dfNoDataValue; + GDALRasterBand *poParent; + + protected: + virtual CPLErr IReadBlock( int, int, void * ); + virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int, + void *, int, int, GDALDataType, + GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg ); + + public: + GDALNoDataMaskBand( GDALRasterBand * ); + virtual ~GDALNoDataMaskBand(); +}; + +/* ******************************************************************** */ +/* GDALNoDataValuesMaskBand */ +/* ******************************************************************** */ + +class CPL_DLL GDALNoDataValuesMaskBand : public GDALRasterBand +{ + double *padfNodataValues; + + protected: + virtual CPLErr IReadBlock( int, int, void * ); + + public: + GDALNoDataValuesMaskBand( GDALDataset * ); + virtual ~GDALNoDataValuesMaskBand(); +}; + +/* ******************************************************************** */ +/* GDALRescaledAlphaBand */ +/* ******************************************************************** */ + +class GDALRescaledAlphaBand : public GDALRasterBand +{ + GDALRasterBand *poParent; + void *pTemp; + + protected: + virtual CPLErr IReadBlock( int, int, void * ); + virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int, + void *, int, int, GDALDataType, + GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg ); + + public: + GDALRescaledAlphaBand( GDALRasterBand * ); + virtual ~GDALRescaledAlphaBand(); +}; + +/* ******************************************************************** */ +/* GDALIdentifyEnum */ +/* ******************************************************************** */ + +/** + * Enumeration used by GDALDriver::pfnIdentify(). + * + * @since GDAL 2.1 + */ +typedef enum +{ + /** Identify could not determine if the file is recognized or not by the probed driver. */ + GDAL_IDENTIFY_UNKNOWN = -1, + /** Identify determined the file is not recognized by the probed driver. */ + GDAL_IDENTIFY_FALSE = 0, + /** Identify determined the file is recognized by the probed driver. */ + GDAL_IDENTIFY_TRUE = 1 +} GDALIdentifyEnum; + +/* ******************************************************************** */ +/* GDALDriver */ +/* ******************************************************************** */ + + +/** + * \brief Format specific driver. + * + * An instance of this class is created for each supported format, and + * manages information about the format. + * + * This roughly corresponds to a file format, though some + * drivers may be gateways to many formats through a secondary + * multi-library. + */ + +class CPL_DLL GDALDriver : public GDALMajorObject +{ + public: + GDALDriver(); + ~GDALDriver(); + + virtual CPLErr SetMetadataItem( const char * pszName, + const char * pszValue, + const char * pszDomain = "" ); + +/* -------------------------------------------------------------------- */ +/* Public C++ methods. */ +/* -------------------------------------------------------------------- */ + GDALDataset *Create( const char * pszName, + int nXSize, int nYSize, int nBands, + GDALDataType eType, char ** papszOptions ) CPL_WARN_UNUSED_RESULT; + + CPLErr Delete( const char * pszName ); + CPLErr Rename( const char * pszNewName, + const char * pszOldName ); + CPLErr CopyFiles( const char * pszNewName, + const char * pszOldName ); + + GDALDataset *CreateCopy( const char *, GDALDataset *, + int, char **, + GDALProgressFunc pfnProgress, + void * pProgressData ) CPL_WARN_UNUSED_RESULT; + +/* -------------------------------------------------------------------- */ +/* The following are semiprivate, not intended to be accessed */ +/* by anyone but the formats instantiating and populating the */ +/* drivers. */ +/* -------------------------------------------------------------------- */ + GDALDataset *(*pfnOpen)( GDALOpenInfo * ); + + GDALDataset *(*pfnCreate)( const char * pszName, + int nXSize, int nYSize, int nBands, + GDALDataType eType, + char ** papszOptions ); + + CPLErr (*pfnDelete)( const char * pszName ); + + GDALDataset *(*pfnCreateCopy)( const char *, GDALDataset *, + int, char **, + GDALProgressFunc pfnProgress, + void * pProgressData ); + + void *pDriverData; + + void (*pfnUnloadDriver)(GDALDriver *); + + /** Identify() if the file is recognized or not by the driver. + + Return GDAL_IDENTIFY_TRUE (1) if the passed file is certainly recognized by the driver. + Return GDAL_IDENTIFY_FALSE (0) if the passed file is certainly NOT recognized by the driver. + Return GDAL_IDENTIFY_UNKNOWN (-1) if the passed file may be or may not be recognized by the driver, + and that a potentially costly test must be done with pfnOpen. + */ + int (*pfnIdentify)( GDALOpenInfo * ); + + CPLErr (*pfnRename)( const char * pszNewName, + const char * pszOldName ); + CPLErr (*pfnCopyFiles)( const char * pszNewName, + const char * pszOldName ); + + /* For legacy OGR drivers */ + GDALDataset *(*pfnOpenWithDriverArg)( GDALDriver*, GDALOpenInfo * ); + GDALDataset *(*pfnCreateVectorOnly)( GDALDriver*, + const char * pszName, + char ** papszOptions ); + CPLErr (*pfnDeleteDataSource)( GDALDriver*, + const char * pszName ); + +/* -------------------------------------------------------------------- */ +/* Helper methods. */ +/* -------------------------------------------------------------------- */ + GDALDataset *DefaultCreateCopy( const char *, GDALDataset *, + int, char **, + GDALProgressFunc pfnProgress, + void * pProgressData ) CPL_WARN_UNUSED_RESULT; + static CPLErr DefaultCopyMasks( GDALDataset *poSrcDS, + GDALDataset *poDstDS, + int bStrict ); + static CPLErr QuietDelete( const char * pszName ); + + CPLErr DefaultRename( const char * pszNewName, + const char * pszOldName ); + CPLErr DefaultCopyFiles( const char * pszNewName, + const char * pszOldName ); +private: + CPL_DISALLOW_COPY_ASSIGN(GDALDriver); +}; + +/* ******************************************************************** */ +/* GDALDriverManager */ +/* ******************************************************************** */ + +/** + * Class for managing the registration of file format drivers. + * + * Use GetGDALDriverManager() to fetch the global singleton instance of + * this class. + */ + +class CPL_DLL GDALDriverManager : public GDALMajorObject +{ + int nDrivers; + GDALDriver **papoDrivers; + std::map oMapNameToDrivers; + + GDALDriver *GetDriver_unlocked( int iDriver ) + { return (iDriver >= 0 && iDriver < nDrivers) ? papoDrivers[iDriver] : NULL; } + + GDALDriver *GetDriverByName_unlocked( const char * pszName ) + { return oMapNameToDrivers[CPLString(pszName).toupper()]; } + + public: + GDALDriverManager(); + ~GDALDriverManager(); + + int GetDriverCount( void ); + GDALDriver *GetDriver( int ); + GDALDriver *GetDriverByName( const char * ); + + int RegisterDriver( GDALDriver * ); + void DeregisterDriver( GDALDriver * ); + + // AutoLoadDrivers is a no-op if compiled with GDAL_NO_AUTOLOAD defined. + void AutoLoadDrivers(); + void AutoSkipDrivers(); +}; + +CPL_C_START +GDALDriverManager CPL_DLL * GetGDALDriverManager( void ); +CPL_C_END + +/* ******************************************************************** */ +/* GDALAsyncReader */ +/* ******************************************************************** */ + +/** + * Class used as a session object for asynchronous requests. They are + * created with GDALDataset::BeginAsyncReader(), and destroyed with + * GDALDataset::EndAsyncReader(). + */ +class CPL_DLL GDALAsyncReader +{ + protected: + GDALDataset* poDS; + int nXOff; + int nYOff; + int nXSize; + int nYSize; + void * pBuf; + int nBufXSize; + int nBufYSize; + GDALDataType eBufType; + int nBandCount; + int* panBandMap; + int nPixelSpace; + int nLineSpace; + int nBandSpace; + + public: + GDALAsyncReader(); + virtual ~GDALAsyncReader(); + + GDALDataset* GetGDALDataset() {return poDS;} + int GetXOffset() const { return nXOff; } + int GetYOffset() const { return nYOff; } + int GetXSize() const { return nXSize; } + int GetYSize() const { return nYSize; } + void * GetBuffer() {return pBuf;} + int GetBufferXSize() const { return nBufXSize; } + int GetBufferYSize() const { return nBufYSize; } + GDALDataType GetBufferType() const { return eBufType; } + int GetBandCount() const { return nBandCount; } + int* GetBandMap() { return panBandMap; } + int GetPixelSpace() const { return nPixelSpace; } + int GetLineSpace() const { return nLineSpace; } + int GetBandSpace() const { return nBandSpace; } + + virtual GDALAsyncStatusType + GetNextUpdatedRegion(double dfTimeout, + int* pnBufXOff, int* pnBufYOff, + int* pnBufXSize, int* pnBufYSize) = 0; + virtual int LockBuffer( double dfTimeout = -1.0 ); + virtual void UnlockBuffer(); +}; + +/* ==================================================================== */ +/* An assortment of overview related stuff. */ +/* ==================================================================== */ + +/* Only exported for drivers as plugin. Signature may change */ +CPLErr CPL_DLL +GDALRegenerateOverviewsMultiBand(int nBands, GDALRasterBand** papoSrcBands, + int nOverviews, + GDALRasterBand*** papapoOverviewBands, + const char * pszResampling, + GDALProgressFunc pfnProgress, void * pProgressData ); + +typedef CPLErr (*GDALResampleFunction) + ( double dfXRatioDstToSrc, + double dfYRatioDstToSrc, + double dfSrcXDelta, + double dfSrcYDelta, + GDALDataType eWrkDataType, + void * pChunk, + GByte * pabyChunkNodataMask, + int nChunkXOff, int nChunkXSize, + int nChunkYOff, int nChunkYSize, + int nDstXOff, int nDstXOff2, + int nDstYOff, int nDstYOff2, + GDALRasterBand * poOverview, + const char * pszResampling, + int bHasNoData, float fNoDataValue, + GDALColorTable* poColorTable, + GDALDataType eSrcDataType); + +GDALResampleFunction GDALGetResampleFunction(const char* pszResampling, + int* pnRadius); + +#ifdef GDAL_ENABLE_RESAMPLING_MULTIBAND +typedef CPLErr (*GDALResampleFunctionMultiBands) + ( double dfXRatioDstToSrc, + double dfYRatioDstToSrc, + double dfSrcXDelta, + double dfSrcYDelta, + GDALDataType eWrkDataType, + void * pChunk, int nBands, + GByte * pabyChunkNodataMask, + int nChunkXOff, int nChunkXSize, + int nChunkYOff, int nChunkYSize, + int nDstXOff, int nDstXOff2, + int nDstYOff, int nDstYOff2, + GDALRasterBand ** papoDstBands, + const char * pszResampling, + int bHasNoData, float fNoDataValue, + GDALColorTable* poColorTable, + GDALDataType eSrcDataType); + +GDALResampleFunctionMultiBands GDALGetResampleFunctionMultiBands(const char* pszResampling, + int* pnRadius); +#endif + +GDALDataType GDALGetOvrWorkDataType(const char* pszResampling, + GDALDataType eSrcDataType); + +CPL_C_START + +CPLErr CPL_DLL +HFAAuxBuildOverviews( const char *pszOvrFilename, GDALDataset *poParentDS, + GDALDataset **ppoDS, + int nBands, int *panBandList, + int nNewOverviews, int *panNewOverviewList, + const char *pszResampling, + GDALProgressFunc pfnProgress, + void *pProgressData ); + +CPLErr CPL_DLL +GTIFFBuildOverviews( const char * pszFilename, + int nBands, GDALRasterBand **papoBandList, + int nOverviews, int * panOverviewList, + const char * pszResampling, + GDALProgressFunc pfnProgress, void * pProgressData ); + +CPLErr CPL_DLL +GDALDefaultBuildOverviews( GDALDataset *hSrcDS, const char * pszBasename, + const char * pszResampling, + int nOverviews, int * panOverviewList, + int nBands, int * panBandList, + GDALProgressFunc pfnProgress, void * pProgressData); + +int CPL_DLL GDALBandGetBestOverviewLevel(GDALRasterBand* poBand, + int &nXOff, int &nYOff, + int &nXSize, int &nYSize, + int nBufXSize, int nBufYSize) CPL_WARN_DEPRECATED("Use GDALBandGetBestOverviewLevel2 instead"); +int CPL_DLL GDALBandGetBestOverviewLevel2(GDALRasterBand* poBand, + int &nXOff, int &nYOff, + int &nXSize, int &nYSize, + int nBufXSize, int nBufYSize, + GDALRasterIOExtraArg* psExtraArg); + +int CPL_DLL GDALOvLevelAdjust( int nOvLevel, int nXSize ) CPL_WARN_DEPRECATED("Use GDALOvLevelAdjust2 instead"); +int CPL_DLL GDALOvLevelAdjust2( int nOvLevel, int nXSize, int nYSize ); +int CPL_DLL GDALComputeOvFactor( int nOvrXSize, int nRasterXSize, + int nOvrYSize, int nRasterYSize ); + +GDALDataset CPL_DLL * +GDALFindAssociatedAuxFile( const char *pszBasefile, GDALAccess eAccess, + GDALDataset *poDependentDS ); + +/* ==================================================================== */ +/* Misc functions. */ +/* ==================================================================== */ + +CPLErr CPL_DLL GDALParseGMLCoverage( CPLXMLNode *psTree, + int *pnXSize, int *pnYSize, + double *padfGeoTransform, + char **ppszProjection ); + +/* ==================================================================== */ +/* Infrastructure to check that dataset characteristics are valid */ +/* ==================================================================== */ + +int CPL_DLL GDALCheckDatasetDimensions( int nXSize, int nYSize ); +int CPL_DLL GDALCheckBandCount( int nBands, int bIsZeroAllowed ); + + +// Test if 2 floating point values match. Useful when comparing values +// stored as a string at some point. See #3573, #4183, #4506 +#define ARE_REAL_EQUAL(dfVal1, dfVal2) \ + (dfVal1 == dfVal2 || fabs(dfVal1 - dfVal2) < 1e-10 || (dfVal2 != 0 && fabs(1 - dfVal1 / dfVal2) < 1e-10 )) + +/* Internal use only */ + +/* CPL_DLL exported, but only for in-tree drivers that can be built as plugins */ +int CPL_DLL GDALReadWorldFile2( const char *pszBaseFilename, const char *pszExtension, + double *padfGeoTransform, char** papszSiblingFiles, + char** ppszWorldFileNameOut); +int GDALReadTabFile2( const char * pszBaseFilename, + double *padfGeoTransform, char **ppszWKT, + int *pnGCPCount, GDAL_GCP **ppasGCPs, + char** papszSiblingFiles, char** ppszTabFileNameOut ); + +void CPL_DLL GDALCopyRasterIOExtraArg(GDALRasterIOExtraArg* psDestArg, + GDALRasterIOExtraArg* psSrcArg); + +CPL_C_END + +void GDALNullifyOpenDatasetsList(); +CPLMutex** GDALGetphDMMutex(); +CPLMutex** GDALGetphDLMutex(); +void GDALNullifyProxyPoolSingleton(); +GDALDriver* GDALGetAPIPROXYDriver(); +void GDALSetResponsiblePIDForCurrentThread(GIntBig responsiblePID); +GIntBig GDALGetResponsiblePIDForCurrentThread(); + +CPLString GDALFindAssociatedFile( const char *pszBasename, const char *pszExt, + char **papszSiblingFiles, int nFlags ); + +CPLErr EXIFExtractMetadata(char**& papszMetadata, + void *fpL, int nOffset, + int bSwabflag, int nTIFFHEADER, + int& nExifOffset, int& nInterOffset, int& nGPSOffset); + +int GDALValidateOpenOptions( GDALDriverH hDriver, + const char* const* papszOptionOptions); +int GDALValidateOptions( const char* pszOptionList, + const char* const* papszOptionsToValidate, + const char* pszErrorMessageOptionType, + const char* pszErrorMessageContainerName); + +GDALRIOResampleAlg GDALRasterIOGetResampleAlg(const char* pszResampling); +const char* GDALRasterIOGetResampleAlg(GDALRIOResampleAlg eResampleAlg); + +void GDALRasterIOExtraArgSetResampleAlg(GDALRasterIOExtraArg* psExtraArg, + int nXSize, int nYSize, + int nBufXSize, int nBufYSize); + +/* CPL_DLL exported, but only for gdalwarp */ +GDALDataset CPL_DLL* GDALCreateOverviewDataset(GDALDataset* poDS, int nOvrLevel, + int bThisLevelOnly, int bOwnDS); + +#define DIV_ROUND_UP(a, b) ( ((a) % (b)) == 0 ? ((a) / (b)) : (((a) / (b)) + 1) ) + +// Number of data samples that will be used to compute approximate statistics +// (minimum value, maximum value, etc.) +#define GDALSTAT_APPROX_NUMSAMPLES 2500 + +CPL_C_START +/* Caution: for technical reason this declaration is duplicated in gdal_crs.c */ +/* so any signature change should be reflected there too */ +void GDALSerializeGCPListToXML( CPLXMLNode* psParentNode, + GDAL_GCP* pasGCPList, + int nGCPCount, + const char* pszGCPProjection ); +void GDALDeserializeGCPListFromXML( CPLXMLNode* psGCPList, + GDAL_GCP** ppasGCPList, + int* pnGCPCount, + char** ppszGCPProjection ); +CPL_C_END + +void GDALSerializeOpenOptionsToXML( CPLXMLNode* psParentNode, char** papszOpenOptions); +char** GDALDeserializeOpenOptionsFromXML( CPLXMLNode* psParentNode ); + +int GDALCanFileAcceptSidecarFile(const char* pszFilename); + +#endif /* ndef GDAL_PRIV_H_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/gdal_proxy.h b/modules/globebrowsing/ext/gdal/include/gdal_proxy.h new file mode 100644 index 0000000000..561902fc4e --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/gdal_proxy.h @@ -0,0 +1,396 @@ +/****************************************************************************** + * $Id$ + * + * Project: GDAL Core + * Purpose: GDAL Core C++/Private declarations + * Author: Even Rouault + * + ****************************************************************************** + * Copyright (c) 2008-2014, Even Rouault + * + * 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. + ****************************************************************************/ + +#ifndef GDAL_PROXY_H_INCLUDED +#define GDAL_PROXY_H_INCLUDED + +#include "gdal.h" + +#ifdef __cplusplus + +#include "gdal_priv.h" +#include "cpl_hash_set.h" + +/* ******************************************************************** */ +/* GDALProxyDataset */ +/* ******************************************************************** */ + +class CPL_DLL GDALProxyDataset : public GDALDataset +{ + protected: + GDALProxyDataset() {}; + + virtual GDALDataset *RefUnderlyingDataset() = 0; + virtual void UnrefUnderlyingDataset(GDALDataset* poUnderlyingDataset); + + virtual CPLErr IBuildOverviews( const char *, int, int *, + int, int *, GDALProgressFunc, void * ); + virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int, + void *, int, int, GDALDataType, + int, int *, GSpacing, GSpacing, GSpacing, + GDALRasterIOExtraArg* psExtraArg ); + public: + + virtual char **GetMetadataDomainList(); + virtual char **GetMetadata( const char * pszDomain ); + virtual CPLErr SetMetadata( char ** papszMetadata, + const char * pszDomain ); + virtual const char *GetMetadataItem( const char * pszName, + const char * pszDomain ); + virtual CPLErr SetMetadataItem( const char * pszName, + const char * pszValue, + const char * pszDomain ); + + virtual void FlushCache(void); + + virtual const char *GetProjectionRef(void); + virtual CPLErr SetProjection( const char * ); + + virtual CPLErr GetGeoTransform( double * ); + virtual CPLErr SetGeoTransform( double * ); + + virtual void *GetInternalHandle( const char * ); + virtual GDALDriver *GetDriver(void); + virtual char **GetFileList(void); + + virtual int GetGCPCount(); + virtual const char *GetGCPProjection(); + virtual const GDAL_GCP *GetGCPs(); + virtual CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList, + const char *pszGCPProjection ); + + virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize, + int nBufXSize, int nBufYSize, + GDALDataType eDT, + int nBandCount, int *panBandList, + char **papszOptions ); + + virtual CPLErr CreateMaskBand( int nFlags ); + + private: + CPL_DISALLOW_COPY_ASSIGN(GDALProxyDataset); +}; + +/* ******************************************************************** */ +/* GDALProxyRasterBand */ +/* ******************************************************************** */ + +class CPL_DLL GDALProxyRasterBand : public GDALRasterBand +{ + protected: + GDALProxyRasterBand() {}; + + virtual GDALRasterBand* RefUnderlyingRasterBand() = 0; + virtual void UnrefUnderlyingRasterBand(GDALRasterBand* poUnderlyingRasterBand); + + virtual CPLErr IReadBlock( int, int, void * ); + virtual CPLErr IWriteBlock( int, int, void * ); + virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int, + void *, int, int, GDALDataType, + GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg ); + + public: + + virtual char **GetMetadataDomainList(); + virtual char **GetMetadata( const char * pszDomain ); + virtual CPLErr SetMetadata( char ** papszMetadata, + const char * pszDomain ); + virtual const char *GetMetadataItem( const char * pszName, + const char * pszDomain ); + virtual CPLErr SetMetadataItem( const char * pszName, + const char * pszValue, + const char * pszDomain ); + virtual CPLErr FlushCache(); + virtual char **GetCategoryNames(); + virtual double GetNoDataValue( int *pbSuccess = NULL ); + virtual double GetMinimum( int *pbSuccess = NULL ); + virtual double GetMaximum(int *pbSuccess = NULL ); + virtual double GetOffset( int *pbSuccess = NULL ); + virtual double GetScale( int *pbSuccess = NULL ); + virtual const char *GetUnitType(); + virtual GDALColorInterp GetColorInterpretation(); + virtual GDALColorTable *GetColorTable(); + virtual CPLErr Fill(double dfRealValue, double dfImaginaryValue = 0); + + virtual CPLErr SetCategoryNames( char ** ); + virtual CPLErr SetNoDataValue( double ); + virtual CPLErr DeleteNoDataValue(); + virtual CPLErr SetColorTable( GDALColorTable * ); + virtual CPLErr SetColorInterpretation( GDALColorInterp ); + virtual CPLErr SetOffset( double ); + virtual CPLErr SetScale( double ); + virtual CPLErr SetUnitType( const char * ); + + virtual CPLErr GetStatistics( int bApproxOK, int bForce, + double *pdfMin, double *pdfMax, + double *pdfMean, double *padfStdDev ); + virtual CPLErr ComputeStatistics( int bApproxOK, + double *pdfMin, double *pdfMax, + double *pdfMean, double *pdfStdDev, + GDALProgressFunc, void *pProgressData ); + virtual CPLErr SetStatistics( double dfMin, double dfMax, + double dfMean, double dfStdDev ); + virtual CPLErr ComputeRasterMinMax( int, double* ); + + virtual int HasArbitraryOverviews(); + virtual int GetOverviewCount(); + virtual GDALRasterBand *GetOverview(int); + virtual GDALRasterBand *GetRasterSampleOverview( GUIntBig ); + virtual CPLErr BuildOverviews( const char *, int, int *, + GDALProgressFunc, void * ); + + virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize, + int nBufXSize, int nBufYSize, + GDALDataType eDT, char **papszOptions ); + + virtual CPLErr GetHistogram( double dfMin, double dfMax, + int nBuckets, GUIntBig * panHistogram, + int bIncludeOutOfRange, int bApproxOK, + GDALProgressFunc, void *pProgressData ); + + virtual CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax, + int *pnBuckets, GUIntBig ** ppanHistogram, + int bForce, + GDALProgressFunc, void *pProgressData); + virtual CPLErr SetDefaultHistogram( double dfMin, double dfMax, + int nBuckets, GUIntBig *panHistogram ); + + virtual GDALRasterAttributeTable *GetDefaultRAT(); + virtual CPLErr SetDefaultRAT( const GDALRasterAttributeTable * ); + + virtual GDALRasterBand *GetMaskBand(); + virtual int GetMaskFlags(); + virtual CPLErr CreateMaskBand( int nFlags ); + + virtual CPLVirtualMem *GetVirtualMemAuto( GDALRWFlag eRWFlag, + int *pnPixelSpace, + GIntBig *pnLineSpace, + char **papszOptions ); + private: + CPL_DISALLOW_COPY_ASSIGN(GDALProxyRasterBand); +}; + + +/* ******************************************************************** */ +/* GDALProxyPoolDataset */ +/* ******************************************************************** */ + +typedef struct _GDALProxyPoolCacheEntry GDALProxyPoolCacheEntry; +class GDALProxyPoolRasterBand; + +class CPL_DLL GDALProxyPoolDataset : public GDALProxyDataset +{ + private: + GIntBig responsiblePID; + + char *pszProjectionRef; + double adfGeoTransform[6]; + int bHasSrcProjection; + int bHasSrcGeoTransform; + char *pszGCPProjection; + int nGCPCount; + GDAL_GCP *pasGCPList; + CPLHashSet *metadataSet; + CPLHashSet *metadataItemSet; + + GDALProxyPoolCacheEntry* cacheEntry; + + protected: + virtual GDALDataset *RefUnderlyingDataset(); + virtual void UnrefUnderlyingDataset(GDALDataset* poUnderlyingDataset); + + friend class GDALProxyPoolRasterBand; + + public: + GDALProxyPoolDataset(const char* pszSourceDatasetDescription, + int nRasterXSize, int nRasterYSize, + GDALAccess eAccess = GA_ReadOnly, + int bShared = FALSE, + const char * pszProjectionRef = NULL, + double * padfGeoTransform = NULL); + ~GDALProxyPoolDataset(); + + void SetOpenOptions(char** papszOpenOptions); + void AddSrcBandDescription( GDALDataType eDataType, int nBlockXSize, int nBlockYSize); + + virtual const char *GetProjectionRef(void); + virtual CPLErr SetProjection( const char * ); + + virtual CPLErr GetGeoTransform( double * ); + virtual CPLErr SetGeoTransform( double * ); + + /* Special behaviour for the following methods : they return a pointer */ + /* data type, that must be cached by the proxy, so it doesn't become invalid */ + /* when the underlying object get closed */ + virtual char **GetMetadata( const char * pszDomain ); + virtual const char *GetMetadataItem( const char * pszName, + const char * pszDomain ); + + virtual void *GetInternalHandle( const char * pszRequest ); + + virtual const char *GetGCPProjection(); + virtual const GDAL_GCP *GetGCPs(); + private: + CPL_DISALLOW_COPY_ASSIGN(GDALProxyPoolDataset); +}; + +/* ******************************************************************** */ +/* GDALProxyPoolRasterBand */ +/* ******************************************************************** */ + +class GDALProxyPoolOverviewRasterBand; +class GDALProxyPoolMaskBand; + +class CPL_DLL GDALProxyPoolRasterBand : public GDALProxyRasterBand +{ + private: + CPLHashSet *metadataSet; + CPLHashSet *metadataItemSet; + char *pszUnitType; + char **papszCategoryNames; + GDALColorTable *poColorTable; + + int nSizeProxyOverviewRasterBand; + GDALProxyPoolOverviewRasterBand **papoProxyOverviewRasterBand; + GDALProxyPoolMaskBand *poProxyMaskBand; + + void Init(); + + protected: + virtual GDALRasterBand* RefUnderlyingRasterBand(); + virtual void UnrefUnderlyingRasterBand(GDALRasterBand* poUnderlyingRasterBand); + + friend class GDALProxyPoolOverviewRasterBand; + friend class GDALProxyPoolMaskBand; + + public: + GDALProxyPoolRasterBand(GDALProxyPoolDataset* poDS, int nBand, + GDALDataType eDataType, + int nBlockXSize, int nBlockYSize); + GDALProxyPoolRasterBand(GDALProxyPoolDataset* poDS, + GDALRasterBand* poUnderlyingRasterBand); + ~GDALProxyPoolRasterBand(); + + void AddSrcMaskBandDescription( GDALDataType eDataType, int nBlockXSize, int nBlockYSize); + + /* Special behaviour for the following methods : they return a pointer */ + /* data type, that must be cached by the proxy, so it doesn't become invalid */ + /* when the underlying object get closed */ + virtual char **GetMetadata( const char * pszDomain ); + virtual const char *GetMetadataItem( const char * pszName, + const char * pszDomain ); + virtual char **GetCategoryNames(); + virtual const char *GetUnitType(); + virtual GDALColorTable *GetColorTable(); + virtual GDALRasterBand *GetOverview(int); + virtual GDALRasterBand *GetRasterSampleOverview( GUIntBig nDesiredSamples); // TODO + virtual GDALRasterBand *GetMaskBand(); + private: + CPL_DISALLOW_COPY_ASSIGN(GDALProxyPoolRasterBand); +}; + +/* ******************************************************************** */ +/* GDALProxyPoolOverviewRasterBand */ +/* ******************************************************************** */ + +class GDALProxyPoolOverviewRasterBand : public GDALProxyPoolRasterBand +{ + private: + GDALProxyPoolRasterBand *poMainBand; + int nOverviewBand; + + GDALRasterBand *poUnderlyingMainRasterBand; + int nRefCountUnderlyingMainRasterBand; + + protected: + virtual GDALRasterBand* RefUnderlyingRasterBand(); + virtual void UnrefUnderlyingRasterBand(GDALRasterBand* poUnderlyingRasterBand); + + public: + GDALProxyPoolOverviewRasterBand(GDALProxyPoolDataset* poDS, + GDALRasterBand* poUnderlyingOverviewBand, + GDALProxyPoolRasterBand* poMainBand, + int nOverviewBand); + ~GDALProxyPoolOverviewRasterBand(); +}; + +/* ******************************************************************** */ +/* GDALProxyPoolMaskBand */ +/* ******************************************************************** */ + +class GDALProxyPoolMaskBand : public GDALProxyPoolRasterBand +{ + private: + GDALProxyPoolRasterBand *poMainBand; + + GDALRasterBand *poUnderlyingMainRasterBand; + int nRefCountUnderlyingMainRasterBand; + + protected: + virtual GDALRasterBand* RefUnderlyingRasterBand(); + virtual void UnrefUnderlyingRasterBand(GDALRasterBand* poUnderlyingRasterBand); + + public: + GDALProxyPoolMaskBand(GDALProxyPoolDataset* poDS, + GDALRasterBand* poUnderlyingMaskBand, + GDALProxyPoolRasterBand* poMainBand); + GDALProxyPoolMaskBand(GDALProxyPoolDataset* poDS, + GDALProxyPoolRasterBand* poMainBand, + GDALDataType eDataType, + int nBlockXSize, int nBlockYSize); + ~GDALProxyPoolMaskBand(); +}; + +#endif + + +/* ******************************************************************** */ +/* C types and methods declarations */ +/* ******************************************************************** */ + + +CPL_C_START + +typedef struct GDALProxyPoolDatasetHS *GDALProxyPoolDatasetH; + +GDALProxyPoolDatasetH CPL_DLL GDALProxyPoolDatasetCreate(const char* pszSourceDatasetDescription, + int nRasterXSize, int nRasterYSize, + GDALAccess eAccess, int bShared, + const char * pszProjectionRef, + double * padfGeoTransform); + +void CPL_DLL GDALProxyPoolDatasetDelete(GDALProxyPoolDatasetH hProxyPoolDataset); + +void CPL_DLL GDALProxyPoolDatasetAddSrcBandDescription( GDALProxyPoolDatasetH hProxyPoolDataset, + GDALDataType eDataType, + int nBlockXSize, int nBlockYSize); + +CPL_C_END + +#endif /* GDAL_PROXY_H_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/gdal_rat.h b/modules/globebrowsing/ext/gdal/include/gdal_rat.h new file mode 100644 index 0000000000..5ceafb9f36 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/gdal_rat.h @@ -0,0 +1,362 @@ +/****************************************************************************** + * $Id$ + * + * Project: GDAL Core + * Purpose: GDALRasterAttributeTable class declarations. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2005, 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. + ****************************************************************************/ + +#ifndef GDAL_RAT_H_INCLUDED +#define GDAL_RAT_H_INCLUDED + +#include "cpl_minixml.h" + +// Clone and Serialize are allowed to fail if GetRowCount()*GetColCount() +// greater than this number +#define RAT_MAX_ELEM_FOR_CLONE 1000000 + +/************************************************************************/ +/* GDALRasterAttributeTable */ +/************************************************************************/ + +//! Raster Attribute Table interface. +class GDALDefaultRasterAttributeTable; + +class CPL_DLL GDALRasterAttributeTable +{ +public: + virtual ~GDALRasterAttributeTable(); + /** + * \brief Copy Raster Attribute Table + * + * Creates a new copy of an existing raster attribute table. The new copy + * becomes the responsibility of the caller to destroy. + * May fail (return NULL) if the attribute table is too large to clone + * (GetRowCount() * GetColCount() > RAT_MAX_ELEM_FOR_CLONE) + * + * This method is the same as the C function GDALRATClone(). + * + * @return new copy of the RAT as an in-memory implementation. + */ + virtual GDALDefaultRasterAttributeTable *Clone() const = 0; + + /** + * \brief Fetch table column count. + * + * This method is the same as the C function GDALRATGetColumnCount(). + * + * @return the number of columns. + */ + virtual int GetColumnCount() const = 0; + + /** + * \brief Fetch name of indicated column. + * + * This method is the same as the C function GDALRATGetNameOfCol(). + * + * @param iCol the column index (zero based). + * + * @return the column name or an empty string for invalid column numbers. + */ + virtual const char *GetNameOfCol( int ) const = 0; + + /** + * \brief Fetch column usage value. + * + * This method is the same as the C function GDALRATGetUsageOfCol(). + * + * @param iCol the column index (zero based). + * + * @return the column usage, or GFU_Generic for improper column numbers. + */ + virtual GDALRATFieldUsage GetUsageOfCol( int ) const = 0; + + /** + * \brief Fetch column type. + * + * This method is the same as the C function GDALRATGetTypeOfCol(). + * + * @param iCol the column index (zero based). + * + * @return column type or GFT_Integer if the column index is illegal. + */ + virtual GDALRATFieldType GetTypeOfCol( int ) const = 0; + + /** + * \brief Fetch column index for given usage. + * + * Returns the index of the first column of the requested usage type, or -1 + * if no match is found. + * + * This method is the same as the C function GDALRATGetUsageOfCol(). + * + * @param eUsage usage type to search for. + * + * @return column index, or -1 on failure. + */ + virtual int GetColOfUsage( GDALRATFieldUsage ) const = 0; + + /** + * \brief Fetch row count. + * + * This method is the same as the C function GDALRATGetRowCount(). + * + * @return the number of rows. + */ + virtual int GetRowCount() const = 0; + + /** + * \brief Fetch field value as a string. + * + * The value of the requested column in the requested row is returned + * as a string. If the field is numeric, it is formatted as a string + * using default rules, so some precision may be lost. + * + * The returned string is temporary and cannot be expected to be + * available after the next GDAL call. + * + * This method is the same as the C function GDALRATGetValueAsString(). + * + * @param iRow row to fetch (zero based). + * @param iField column to fetch (zero based). + * + * @return field value. + */ + virtual const char *GetValueAsString( int iRow, int iField ) const = 0; + + /** + * \brief Fetch field value as a integer. + * + * The value of the requested column in the requested row is returned + * as an integer. Non-integer fields will be converted to integer with + * the possibility of data loss. + * + * This method is the same as the C function GDALRATGetValueAsInt(). + * + * @param iRow row to fetch (zero based). + * @param iField column to fetch (zero based). + * + * @return field value + */ + virtual int GetValueAsInt( int iRow, int iField ) const = 0; + + /** + * \brief Fetch field value as a double. + * + * The value of the requested column in the requested row is returned + * as a double. Non double fields will be converted to double with + * the possibility of data loss. + * + * This method is the same as the C function GDALRATGetValueAsDouble(). + * + * @param iRow row to fetch (zero based). + * @param iField column to fetch (zero based). + * + * @return field value + */ + virtual double GetValueAsDouble( int iRow, int iField ) const = 0; + + /** + * \brief Set field value from string. + * + * The indicated field (column) on the indicated row is set from the + * passed value. The value will be automatically converted for other field + * types, with a possible loss of precision. + * + * This method is the same as the C function GDALRATSetValueAsString(). + * + * @param iRow row to fetch (zero based). + * @param iField column to fetch (zero based). + * @param pszValue the value to assign. + */ + virtual void SetValue( int iRow, int iField, + const char *pszValue ) = 0; + + /** + * \brief Set field value from integer. + * + * The indicated field (column) on the indicated row is set from the + * passed value. The value will be automatically converted for other field + * types, with a possible loss of precision. + * + * This method is the same as the C function GDALRATSetValueAsInteger(). + * + * @param iRow row to fetch (zero based). + * @param iField column to fetch (zero based). + * @param nValue the value to assign. + */ + virtual void SetValue( int iRow, int iField, int nValue ) = 0; + + /** + * \brief Set field value from double. + * + * The indicated field (column) on the indicated row is set from the + * passed value. The value will be automatically converted for other field + * types, with a possible loss of precision. + * + * This method is the same as the C function GDALRATSetValueAsDouble(). + * + * @param iRow row to fetch (zero based). + * @param iField column to fetch (zero based). + * @param dfValue the value to assign. + */ + virtual void SetValue( int iRow, int iField, double dfValue) = 0; + + /** + * \brief Determine whether changes made to this RAT are reflected directly + * in the dataset + * + * If this returns FALSE then GDALRasterBand.SetDefaultRAT() should be + * called. Otherwise this is unnecessary since changes to this object are + * reflected in the dataset. + * + * This method is the same as the C function + * GDALRATChangesAreWrittenToFile(). + * + */ + virtual int ChangesAreWrittenToFile() = 0; + + virtual CPLErr ValuesIO( GDALRWFlag eRWFlag, int iField, + int iStartRow, int iLength, + double *pdfData); + virtual CPLErr ValuesIO( GDALRWFlag eRWFlag, int iField, + int iStartRow, int iLength, int *pnData); + virtual CPLErr ValuesIO( GDALRWFlag eRWFlag, int iField, + int iStartRow, int iLength, + char **papszStrList); + + virtual void SetRowCount( int iCount ); + virtual int GetRowOfValue( double dfValue ) const; + virtual int GetRowOfValue( int nValue ) const; + + virtual CPLErr CreateColumn( const char *pszFieldName, + GDALRATFieldType eFieldType, + GDALRATFieldUsage eFieldUsage ); + virtual CPLErr SetLinearBinning( double dfRow0Min, + double dfBinSize ); + virtual int GetLinearBinning( double *pdfRow0Min, + double *pdfBinSize ) const; + + /** + * \brief Serialize + * + * May fail (return NULL) if the attribute table is too large to serialize + * (GetRowCount() * GetColCount() > RAT_MAX_ELEM_FOR_CLONE) + */ + virtual CPLXMLNode *Serialize() const; + virtual void *SerializeJSON() const; + virtual CPLErr XMLInit( CPLXMLNode *, const char * ); + + virtual CPLErr InitializeFromColorTable( const GDALColorTable * ); + virtual GDALColorTable *TranslateToColorTable( int nEntryCount = -1 ); + + virtual void DumpReadable( FILE * = NULL ); +}; + +/************************************************************************/ +/* GDALRasterAttributeField */ +/* */ +/* (private) */ +/************************************************************************/ + +class GDALRasterAttributeField +{ + public: + CPLString sName; + + GDALRATFieldType eType; + + GDALRATFieldUsage eUsage; + + std::vector anValues; + std::vector adfValues; + std::vector aosValues; +}; + +/************************************************************************/ +/* GDALDefaultRasterAttributeTable */ +/************************************************************************/ + +//! Raster Attribute Table container. + +class CPL_DLL GDALDefaultRasterAttributeTable : public GDALRasterAttributeTable +{ + private: + std::vector aoFields; + + int bLinearBinning; // TODO(schwehr): Can this be a bool? + double dfRow0Min; + double dfBinSize; + + void AnalyseColumns(); + int bColumnsAnalysed; // TODO(schwehr): Can this be a bool? + int nMinCol; + int nMaxCol; + + int nRowCount; + + CPLString osWorkingResult; + + public: + GDALDefaultRasterAttributeTable(); + GDALDefaultRasterAttributeTable( const GDALDefaultRasterAttributeTable& ); + ~GDALDefaultRasterAttributeTable(); + + GDALDefaultRasterAttributeTable *Clone() const; + + virtual int GetColumnCount() const; + + virtual const char *GetNameOfCol( int ) const; + virtual GDALRATFieldUsage GetUsageOfCol( int ) const; + virtual GDALRATFieldType GetTypeOfCol( int ) const; + + virtual int GetColOfUsage( GDALRATFieldUsage ) const; + + virtual int GetRowCount() const; + + virtual const char *GetValueAsString( int iRow, int iField ) const; + virtual int GetValueAsInt( int iRow, int iField ) const; + virtual double GetValueAsDouble( int iRow, int iField ) const; + + virtual void SetValue( int iRow, int iField, + const char *pszValue ); + virtual void SetValue( int iRow, int iField, double dfValue); + virtual void SetValue( int iRow, int iField, int nValue ); + + virtual int ChangesAreWrittenToFile(); + virtual void SetRowCount( int iCount ); + + virtual int GetRowOfValue( double dfValue ) const; + virtual int GetRowOfValue( int nValue ) const; + + virtual CPLErr CreateColumn( const char *pszFieldName, + GDALRATFieldType eFieldType, + GDALRATFieldUsage eFieldUsage ); + virtual CPLErr SetLinearBinning( double dfRow0Min, + double dfBinSize ); + virtual int GetLinearBinning( double *pdfRow0Min, + double *pdfBinSize ) const; +}; + +#endif /* ndef GDAL_RAT_H_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/gdal_simplesurf.h b/modules/globebrowsing/ext/gdal/include/gdal_simplesurf.h new file mode 100644 index 0000000000..ca262dced6 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/gdal_simplesurf.h @@ -0,0 +1,554 @@ +/****************************************************************************** + * Project: GDAL + * Purpose: Correlator + * Author: Andrew Migal, migal.drew@gmail.com + * + ****************************************************************************** + * Copyright (c) 2012, Andrew Migal + * + * 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. + ****************************************************************************/ + +/** + * @file + * @author Andrew Migal migal.drew@gmail.com + * @brief Class for searching corresponding points on images. + */ + +#ifndef GDALSIMPLESURF_H_ +#define GDALSIMPLESURF_H_ + +#include "gdal_priv.h" +#include "cpl_conv.h" +#include + +/** + * @brief Class of "feature point" in raster. Used by SURF-based algorithm. + * + * @details This point presents coordinates of distinctive pixel in image. + * In computer vision, feature points - the most "strong" and "unique" + * pixels (or areas) in picture, which can be distinguished from others. + * For more details, see FAST corner detector, SIFT, SURF and similar algorithms. + */ +class GDALFeaturePoint +{ +public: + /** + * Standard constructor. Initializes all parameters with negative numbers + * and allocates memory for descriptor. + */ + GDALFeaturePoint(); + + /** + * Copy constructor + * @param fp Copied instance of GDALFeaturePoint class + */ + GDALFeaturePoint(const GDALFeaturePoint& fp); + + /** + * Create instance of GDALFeaturePoint class + * + * @param nX X-coordinate (pixel) + * @param nY Y-coordinate (line) + * @param nScale Scale which contains this point (2, 4, 8, 16 and so on) + * @param nRadius Half of the side of descriptor area + * @param nSign Sign of Hessian determinant for this point + * + * @note This constructor normally is invoked by SURF-based algorithm, + * which provides all necessary parameters. + */ + GDALFeaturePoint(int nX, int nY, int nScale, int nRadius, int nSign); + virtual ~GDALFeaturePoint(); + + GDALFeaturePoint& operator=(const GDALFeaturePoint& point); + + /** + * Provide access to point's descriptor. + * + * @param nIndex Position of descriptor's value. + * nIndex should be within range from 0 to DESC_SIZE (in current version - 64) + * + * @return Reference to value of descriptor in 'nIndex' position. + * If index is out of range then behaviour is undefined. + */ + double& operator[](int nIndex); + + // Descriptor length + static const int DESC_SIZE = 64; + + /** + * Fetch X-coordinate (pixel) of point + * + * @return X-coordinate in pixels + */ + int GetX(); + + /** + * Set X coordinate of point + * + * @param nX X coordinate in pixels + */ + void SetX(int nX); + + /** + * Fetch Y-coordinate (line) of point. + * + * @return Y-coordinate in pixels. + */ + int GetY(); + + /** + * Set Y coordinate of point. + * + * @param nY Y coordinate in pixels. + */ + void SetY(int nY); + + /** + * Fetch scale of point. + * + * @return Scale for this point. + */ + int GetScale(); + + /** + * Set scale of point. + * + * @param nScale Scale for this point. + */ + void SetScale(int nScale); + + /** + * Fetch radius of point. + * + * @return Radius for this point. + */ + int GetRadius(); + + /** + * Set radius of point. + * + * @param nRadius Radius for this point. + */ + void SetRadius(int nRadius); + + /** + * Fetch sign of Hessian determinant of point. + * + * @return Sign for this point. + */ + int GetSign(); + + /** + * Set sign of point. + * + * @param nSign Sign of Hessian determinant for this point. + */ + void SetSign(int nSign); + +private: + // Coordinates of point in image + int nX; + int nY; + // -------------------- + int nScale; + int nRadius; + int nSign; + // Descriptor array + double *padfDescriptor; +}; + +/** + * @author Andrew Migal migal.drew@gmail.com + * @brief Integral image class (summed area table). + * @details Integral image is a table for fast computing the sum of + * values in rectangular subarea. In more detail, for 2-dimensional array + * of numbers this class provides capability to get sum of values in + * rectangular arbitrary area with any size in constant time. + * Integral image is constructed from grayscale picture. + */ +class GDALIntegralImage +{ +public: + GDALIntegralImage(); + virtual ~GDALIntegralImage(); + + /** + * Compute integral image for specified array. Result is stored internally. + * + * @param padfImg Pointer to 2-dimensional array of values + * @param nHeight Number of rows in array + * @param nWidth Number of columns in array + */ + void Initialize(const double **padfImg, int nHeight, int nWidth); + + /** + * Fetch value of specified position in integral image. + * + * @param nRow Row of this position + * @param nCol Column of this position + * + * @return Value in specified position or zero if parameters are out of range. + */ + double GetValue(int nRow, int nCol); + + /** + * Get sum of values in specified rectangular grid. Rectangle is constructed + * from left top point. + * + * @param nRow Row of left top point of rectangle + * @param nCol Column of left top point of rectangle + * @param nWidth Width of rectangular area (number of columns) + * @param nHeight Height of rectangular area (number of rows) + * + * @return Sum of values in specified grid. + */ + double GetRectangleSum(int nRow, int nCol, int nWidth, int nHeight); + + /** + * Get value of horizontal Haar wavelet in specified square grid. + * + * @param nRow Row of left top point of square + * @param nCol Column of left top point of square + * @param nSize Side of the square + * + * @return Value of horizontal Haar wavelet in specified square grid. + */ + double HaarWavelet_X(int nRow, int nCol, int nSize); + + /** + * Get value of vertical Haar wavelet in specified square grid. + * + * @param nRow Row of left top point of square + * @param nCol Column of left top point of square + * @param nSize Side of the square + * + * @return Value of vertical Haar wavelet in specified square grid. + */ + double HaarWavelet_Y(int nRow, int nCol, int nSize); + + /** + * Fetch height of integral image. + * + * @return Height of integral image (number of rows). + */ + int GetHeight(); + + /** + * Fetch width of integral image. + * + * @return Width of integral image (number of columns). + */ + int GetWidth(); + +private: + double **pMatrix; + int nWidth; + int nHeight; +}; + +/** + * @author Andrew Migal migal.drew@gmail.com + * @brief Class for computation and storage of Hessian values in SURF-based algorithm. + * + * @details SURF-based algorithm normally uses this class for searching + * feature points on raster images. Class also contains traces of Hessian matrices + * to provide fast computations. + */ +class GDALOctaveLayer +{ +public: + GDALOctaveLayer(); + + /** + * Create instance with provided parameters. + * + * @param nOctave Number of octave which contains this layer + * @param nInterval Number of position in octave + * + * @note Normally constructor is invoked only by SURF-based algorithm. + */ + GDALOctaveLayer(int nOctave, int nInterval); + virtual ~GDALOctaveLayer(); + + /** + * Perform calculation of Hessian determinants and their signs + * for specified integral image. Result is stored internally. + * + * @param poImg Integral image object, which provides all necessary + * data for computation + * + * @note Normally method is invoked only by SURF-based algorithm. + */ + void ComputeLayer(GDALIntegralImage *poImg); + + /** + * Octave which contains this layer (1,2,3...) + */ + int octaveNum; + /** + * Length of the side of filter + */ + int filterSize; + /** + * Length of the border + */ + int radius; + /** + * Scale for this layer + */ + int scale; + /** + * Image width in pixels + */ + int width; + /** + * Image height in pixels + */ + int height; + /** + * Hessian values for image pixels + */ + double **detHessians; + /** + * Hessian signs for speeded matching + */ + int **signs; +}; + +/** + * @author Andrew Migal migal.drew@gmail.com + * @brief Class for handling octave layers in SURF-based algorithm. + * @details Class contains OctaveLayers and provides capability to construct octave space and distinguish + * feature points. Normally this class is used only by SURF-based algorithm. + */ +class GDALOctaveMap +{ +public: + /** + * Create octave space. Octave numbers are start with one. (1, 2, 3, 4, ... ) + * + * @param nOctaveStart Number of bottom octave + * @param nOctaveEnd Number of top octave. Should be equal or greater than OctaveStart + */ + GDALOctaveMap(int nOctaveStart, int nOctaveEnd); + virtual ~GDALOctaveMap(); + + /** + * Calculate Hessian values for octave space + * (for all stored octave layers) using specified integral image + * @param poImg Integral image instance which provides necessary data + * @see GDALOctaveLayer + */ + void ComputeMap(GDALIntegralImage *poImg); + + /** + * Method makes decision that specified point + * in middle octave layer is maximum among all points + * from 3x3x3 neighbourhood (surrounding points in + * bottom, middle and top layers). Provided layers should be from the same octave's interval. + * Detects feature points. + * + * @param row Row of point, which is candidate to be feature point + * @param col Column of point, which is candidate to be feature point + * @param bot Bottom octave layer + * @param mid Middle octave layer + * @param top Top octave layer + * @param threshold Threshold for feature point recognition. Detected feature point + * will have Hessian value greater than this provided threshold. + * + * @return TRUE if candidate was evaluated as feature point or FALSE otherwise. + */ + bool PointIsExtremum(int row, int col, GDALOctaveLayer *bot, + GDALOctaveLayer *mid, GDALOctaveLayer *top, double threshold); + + /** + * 2-dimensional array of octave layers + */ + GDALOctaveLayer ***pMap; + + /** + * Value for constructing internal octave space + */ + static const int INTERVALS = 4; + + /** + * Number of bottom octave + */ + int octaveStart; + + /** + * Number of top octave. Should be equal or greater than OctaveStart + */ + int octaveEnd; +}; + +/** + * @author Andrew Migal migal.drew@gmail.com + * @brief Class for searching corresponding points on images. + * @details Provides capability for detection feature points + * and finding equal points on different images. + * Class implements simplified version of SURF algorithm (Speeded Up Robust Features). + * As original, this realization is scale invariant, but sensitive to rotation. + * Images should have similar rotation angles (maximum difference is up to 10-15 degrees), + * otherwise algorithm produces incorrect and very unstable results. + */ + +class GDALSimpleSURF +{ +private: + /** + * Class stores indexes of pair of point + * and distance between them. + */ + class MatchedPointPairInfo + { + public: + MatchedPointPairInfo(int nInd_1, int nInd_2, double dfDist) + { + ind_1 = nInd_1; + ind_2 = nInd_2; + euclideanDist = dfDist; + } + + int ind_1; + int ind_2; + double euclideanDist; + }; + +public: + /** + * Prepare class according to specified parameters. Octave numbers affects + * to amount of detected points and their robustness. + * Range between bottom and top octaves also affects to required time of detection points + * (if range is large, algorithm should perform more operations). + * @param nOctaveStart Number of bottom octave. Octave numbers starts with one + * @param nOctaveEnd Number of top octave. Should be equal or greater than OctaveStart + * + * @note + * Every octave finds points with specific size. For small images + * use small octave numbers, for high resolution - large. + * For 1024x1024 images it's normal to use any octave numbers from range 1-6. + * (for example, octave start - 1, octave end - 3, or octave start - 2, octave end - 2.) + * For larger images, try 1-10 range or even higher. + * Pay attention that number of detected point decreases quickly per octave + * for particular image. Algorithm finds more points in case of small octave numbers. + * If method detects nothing, reduce bottom bound of octave range. + * + * NOTICE that every octave requires time to compute. Use a little range + * or only one octave if execution time is significant. + */ + GDALSimpleSURF(int nOctaveStart, int nOctaveEnd); + virtual ~GDALSimpleSURF(); + + /** + * Convert image with RGB channels to grayscale using "luminosity" method. + * Result is used in SURF-based algorithm, but may be used anywhere where + * grayscale images with nice contrast are required. + * + * @param red Image's red channel + * @param green Image's green channel + * @param blue Image's blue channel + * @param nXSize Width of initial image + * @param nYSize Height of initial image + * @param padfImg Array for resulting grayscale image + * @param nHeight Height of resulting image + * @param nWidth Width of resulting image + * + * @return CE_None or CE_Failure if error occurs. + */ + static CPLErr ConvertRGBToLuminosity( + GDALRasterBand *red, + GDALRasterBand *green, + GDALRasterBand *blue, + int nXSize, int nYSize, + double **padfImg, int nHeight, int nWidth); + + /** + * Find feature points using specified integral image. + * + * @param poImg Integral image to be used + * @param dfThreshold Threshold for feature point recognition. Detected feature point + * will have Hessian value greater than this provided threshold. + * + * @note Typical threshold's value is 0,001. But this value + * can be various in each case and depends on image's nature. + * For example, value can be 0.002 or 0.005. + * Fill free to experiment with it. + * If threshold is high, than number of detected feature points is small, + * and vice versa. + */ + std::vector* + ExtractFeaturePoints(GDALIntegralImage *poImg, double dfThreshold); + + /** + * Find corresponding points (equal points in two collections). + * + * @param poMatchPairs Resulting collection for matched points + * @param poSecondCollect Points on the first image + * @param poSecondCollect Points on the second image + * @param dfThreshold Value from 0 to 1. Threshold affects to number of + * matched points. If threshold is lower, amount of corresponding + * points is larger, and vice versa + * + * @return CE_None or CE_Failure if error occurs. + */ + static CPLErr MatchFeaturePoints( + std::vector *poMatchPairs, + std::vector *poFirstCollect, + std::vector *poSecondCollect, + double dfThreshold); + +private: + /** + * Compute euclidean distance between descriptors of two feature points. + * It's used in comparison and matching of points. + * + * @param firstPoint First feature point to be compared + * @param secondPoint Second feature point to be compared + * + * @return Euclidean distance between descriptors. + */ + static double GetEuclideanDistance( + GDALFeaturePoint &firstPoint, GDALFeaturePoint &secondPoint); + + /** + * Set provided distance values to range from 0 to 1. + * + * @param poList List of distances to be normalized + */ + static void NormalizeDistances(std::list *poList); + + /** + * Compute descriptor for specified feature point. + * + * @param poPoint Feature point instance + * @param poImg image where feature point was found + */ + void SetDescriptor(GDALFeaturePoint *poPoint, GDALIntegralImage *poImg); + + +private: + int octaveStart; + int octaveEnd; + GDALOctaveMap *poOctMap; +}; + + +#endif /* GDALSIMPLESURF_H_ */ diff --git a/modules/globebrowsing/ext/gdal/include/gdal_utils.h b/modules/globebrowsing/ext/gdal/include/gdal_utils.h new file mode 100644 index 0000000000..1777131a2a --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/gdal_utils.h @@ -0,0 +1,214 @@ +/****************************************************************************** + * $Id$ + * + * Project: GDAL Utilities + * Purpose: GDAL Utilities Public Declarations. + * Author: Faza Mahamood, fazamhd at gmail dot com + * + * **************************************************************************** + * Copyright (c) 1998, Frank Warmerdam + * Copyright (c) 2007-2015, Even Rouault + * Copyright (c) 2015, Faza Mahamood + * + * 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. + ****************************************************************************/ + +#ifndef GDAL_UTILS_H_INCLUDED +#define GDAL_UTILS_H_INCLUDED + +/** + * \file gdal_utils.h + * + * Public (C callable) GDAL Utilities entry points. + * + * @since GDAL 2.1 + */ + +#include "cpl_port.h" +#include "gdal.h" + +CPL_C_START + +/*! Options for GDALInfo(). Opaque type */ +typedef struct GDALInfoOptions GDALInfoOptions; + +typedef struct GDALInfoOptionsForBinary GDALInfoOptionsForBinary; + +GDALInfoOptions CPL_DLL *GDALInfoOptionsNew(char** papszArgv, GDALInfoOptionsForBinary* psOptionsForBinary); + +void CPL_DLL GDALInfoOptionsFree( GDALInfoOptions *psOptions ); + +char CPL_DLL *GDALInfo( GDALDatasetH hDataset, const GDALInfoOptions *psOptions ); + + +/*! Options for GDALTranslate(). Opaque type */ +typedef struct GDALTranslateOptions GDALTranslateOptions; + +typedef struct GDALTranslateOptionsForBinary GDALTranslateOptionsForBinary; + +GDALTranslateOptions CPL_DLL *GDALTranslateOptionsNew(char** papszArgv, + GDALTranslateOptionsForBinary* psOptionsForBinary); + +void CPL_DLL GDALTranslateOptionsFree( GDALTranslateOptions *psOptions ); + +void CPL_DLL GDALTranslateOptionsSetProgress( GDALTranslateOptions *psOptions, + GDALProgressFunc pfnProgress, + void *pProgressData ); + +GDALDatasetH CPL_DLL GDALTranslate(const char *pszDestFilename, + GDALDatasetH hSrcDataset, + const GDALTranslateOptions *psOptions, + int *pbUsageError); + +/*! Options for GDALWarp(). Opaque type */ +typedef struct GDALWarpAppOptions GDALWarpAppOptions; + +typedef struct GDALWarpAppOptionsForBinary GDALWarpAppOptionsForBinary; + +GDALWarpAppOptions CPL_DLL *GDALWarpAppOptionsNew(char** papszArgv, + GDALWarpAppOptionsForBinary* psOptionsForBinary); + +void CPL_DLL GDALWarpAppOptionsFree( GDALWarpAppOptions *psOptions ); + +void CPL_DLL GDALWarpAppOptionsSetProgress( GDALWarpAppOptions *psOptions, + GDALProgressFunc pfnProgress, + void *pProgressData ); +void CPL_DLL GDALWarpAppOptionsSetWarpOption( GDALWarpAppOptions *psOptions, + const char* pszKey, + const char* pszValue ); + +GDALDatasetH CPL_DLL GDALWarp( const char *pszDest, GDALDatasetH hDstDS, + int nSrcCount, GDALDatasetH *pahSrcDS, + const GDALWarpAppOptions *psOptions, int *pbUsageError ); + +/*! Options for GDALVectorTranslate(). Opaque type */ +typedef struct GDALVectorTranslateOptions GDALVectorTranslateOptions; + +typedef struct GDALVectorTranslateOptionsForBinary GDALVectorTranslateOptionsForBinary; + +GDALVectorTranslateOptions CPL_DLL *GDALVectorTranslateOptionsNew(char** papszArgv, + GDALVectorTranslateOptionsForBinary* psOptionsForBinary); + +void CPL_DLL GDALVectorTranslateOptionsFree( GDALVectorTranslateOptions *psOptions ); + +void CPL_DLL GDALVectorTranslateOptionsSetProgress( GDALVectorTranslateOptions *psOptions, + GDALProgressFunc pfnProgress, + void *pProgressData ); + +GDALDatasetH CPL_DLL GDALVectorTranslate( const char *pszDest, GDALDatasetH hDstDS, int nSrcCount, + GDALDatasetH *pahSrcDS, + const GDALVectorTranslateOptions *psOptions, int *pbUsageError ); + + +/*! Options for GDALDEMProcessing(). Opaque type */ +typedef struct GDALDEMProcessingOptions GDALDEMProcessingOptions; + +typedef struct GDALDEMProcessingOptionsForBinary GDALDEMProcessingOptionsForBinary; + +GDALDEMProcessingOptions CPL_DLL *GDALDEMProcessingOptionsNew(char** papszArgv, + GDALDEMProcessingOptionsForBinary* psOptionsForBinary); + +void CPL_DLL GDALDEMProcessingOptionsFree( GDALDEMProcessingOptions *psOptions ); + +void CPL_DLL GDALDEMProcessingOptionsSetProgress( GDALDEMProcessingOptions *psOptions, + GDALProgressFunc pfnProgress, + void *pProgressData ); + +GDALDatasetH CPL_DLL GDALDEMProcessing(const char *pszDestFilename, + GDALDatasetH hSrcDataset, + const char* pszProcessing, + const char* pszColorFilename, + const GDALDEMProcessingOptions *psOptions, + int *pbUsageError); + +/*! Options for GDALNearblack(). Opaque type */ +typedef struct GDALNearblackOptions GDALNearblackOptions; + +typedef struct GDALNearblackOptionsForBinary GDALNearblackOptionsForBinary; + +GDALNearblackOptions CPL_DLL *GDALNearblackOptionsNew(char** papszArgv, + GDALNearblackOptionsForBinary* psOptionsForBinary); + +void CPL_DLL GDALNearblackOptionsFree( GDALNearblackOptions *psOptions ); + +void CPL_DLL GDALNearblackOptionsSetProgress( GDALNearblackOptions *psOptions, + GDALProgressFunc pfnProgress, + void *pProgressData ); + +GDALDatasetH CPL_DLL GDALNearblack( const char *pszDest, GDALDatasetH hDstDS, + GDALDatasetH hSrcDS, + const GDALNearblackOptions *psOptions, int *pbUsageError ); + +/*! Options for GDALGrid(). Opaque type */ +typedef struct GDALGridOptions GDALGridOptions; + +typedef struct GDALGridOptionsForBinary GDALGridOptionsForBinary; + +GDALGridOptions CPL_DLL *GDALGridOptionsNew(char** papszArgv, + GDALGridOptionsForBinary* psOptionsForBinary); + +void CPL_DLL GDALGridOptionsFree( GDALGridOptions *psOptions ); + +void CPL_DLL GDALGridOptionsSetProgress( GDALGridOptions *psOptions, + GDALProgressFunc pfnProgress, + void *pProgressData ); + +GDALDatasetH CPL_DLL GDALGrid( const char *pszDest, + GDALDatasetH hSrcDS, + const GDALGridOptions *psOptions, int *pbUsageError ); + +/*! Options for GDALRasterize(). Opaque type */ +typedef struct GDALRasterizeOptions GDALRasterizeOptions; + +typedef struct GDALRasterizeOptionsForBinary GDALRasterizeOptionsForBinary; + +GDALRasterizeOptions CPL_DLL *GDALRasterizeOptionsNew(char** papszArgv, + GDALRasterizeOptionsForBinary* psOptionsForBinary); + +void CPL_DLL GDALRasterizeOptionsFree( GDALRasterizeOptions *psOptions ); + +void CPL_DLL GDALRasterizeOptionsSetProgress( GDALRasterizeOptions *psOptions, + GDALProgressFunc pfnProgress, + void *pProgressData ); + +GDALDatasetH CPL_DLL GDALRasterize( const char *pszDest, GDALDatasetH hDstDS, + GDALDatasetH hSrcDS, + const GDALRasterizeOptions *psOptions, int *pbUsageError ); + +/*! Options for GDALBuildVRT(). Opaque type */ +typedef struct GDALBuildVRTOptions GDALBuildVRTOptions; + +typedef struct GDALBuildVRTOptionsForBinary GDALBuildVRTOptionsForBinary; + +GDALBuildVRTOptions CPL_DLL *GDALBuildVRTOptionsNew(char** papszArgv, + GDALBuildVRTOptionsForBinary* psOptionsForBinary); + +void CPL_DLL GDALBuildVRTOptionsFree( GDALBuildVRTOptions *psOptions ); + +void CPL_DLL GDALBuildVRTOptionsSetProgress( GDALBuildVRTOptions *psOptions, + GDALProgressFunc pfnProgress, + void *pProgressData ); + +GDALDatasetH CPL_DLL GDALBuildVRT( const char *pszDest, + int nSrcCount, GDALDatasetH *pahSrcDS, const char* const* papszSrcDSNames, + const GDALBuildVRTOptions *psOptions, int *pbUsageError ); + +CPL_C_END + +#endif /* GDAL_UTILS_H_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/gdal_version.h b/modules/globebrowsing/ext/gdal/include/gdal_version.h new file mode 100644 index 0000000000..2995652ca6 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/gdal_version.h @@ -0,0 +1,29 @@ + +/* -------------------------------------------------------------------- */ +/* GDAL Version Information. */ +/* -------------------------------------------------------------------- */ + +#ifndef GDAL_VERSION_MAJOR +# define GDAL_VERSION_MAJOR 2 +# define GDAL_VERSION_MINOR 1 +# define GDAL_VERSION_REV 0 +# define GDAL_VERSION_BUILD 0 +#endif + +/* GDAL_COMPUTE_VERSION macro introduced in GDAL 1.10 */ +/* Must be used ONLY to compare with version numbers for GDAL >= 1.10 */ +#ifndef GDAL_COMPUTE_VERSION +#define GDAL_COMPUTE_VERSION(maj,min,rev) ((maj)*1000000+(min)*10000+(rev)*100) +#endif + +/* Note: the formula to compute GDAL_VERSION_NUM has changed in GDAL 1.10 */ +#ifndef GDAL_VERSION_NUM +# define GDAL_VERSION_NUM (GDAL_COMPUTE_VERSION(GDAL_VERSION_MAJOR,GDAL_VERSION_MINOR,GDAL_VERSION_REV)+GDAL_VERSION_BUILD) +#endif + +#ifndef GDAL_RELEASE_DATE +# define GDAL_RELEASE_DATE 20160401 +#endif +#ifndef GDAL_RELEASE_NAME +# define GDAL_RELEASE_NAME "2.1.0beta1" +#endif diff --git a/modules/globebrowsing/ext/gdal/include/gdal_vrt.h b/modules/globebrowsing/ext/gdal/include/gdal_vrt.h new file mode 100644 index 0000000000..ca89715476 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/gdal_vrt.h @@ -0,0 +1,104 @@ +/****************************************************************************** + * $Id$ + * + * Project: Virtual GDAL Datasets + * Purpose: C/Public declarations of virtual GDAL dataset objects. + * Author: Andrey Kiselev, dron@ak4719.spb.edu + * + ****************************************************************************** + * Copyright (c) 2007, Andrey Kiselev + * + * 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. + ****************************************************************************/ + +#ifndef GDAL_VRT_H_INCLUDED +#define GDAL_VRT_H_INCLUDED + +/** + * \file gdal_vrt.h + * + * Public (C callable) entry points for virtual GDAL dataset objects. + */ + +#include "gdal.h" +#include "cpl_error.h" +#include "cpl_minixml.h" +#include "cpl_port.h" + +#define VRT_NODATA_UNSET -1234.56 + +CPL_C_START + +void GDALRegister_VRT(); +typedef CPLErr +(*VRTImageReadFunc)( void *hCBData, + int nXOff, int nYOff, int nXSize, int nYSize, + void *pData ); + +/* -------------------------------------------------------------------- */ +/* Define handle types related to various VRT dataset classes. */ +/* -------------------------------------------------------------------- */ +typedef void *VRTAveragedSourceH; +typedef void *VRTAverageFilteredSourceH; +typedef void *VRTComplexSourceH; +typedef void *VRTDatasetH; +typedef void *VRTDerivedRasterBandH; +typedef void *VRTDriverH; +typedef void *VRTFilteredSourceH; +typedef void *VRTFuncSourceH; +typedef void *VRTKernelFilteredSourceH; +typedef void *VRTRasterBandH; +typedef void *VRTRawRasterBandH; +typedef void *VRTSimpleSourceH; +typedef void *VRTSourceH; +typedef void *VRTSourcedRasterBandH; +typedef void *VRTWarpedDatasetH; +typedef void *VRTWarpedRasterBandH; + +/* ==================================================================== */ +/* VRTDataset class. */ +/* ==================================================================== */ + +VRTDatasetH CPL_DLL CPL_STDCALL VRTCreate( int, int ); +void CPL_DLL CPL_STDCALL VRTFlushCache( VRTDatasetH ); +CPLXMLNode CPL_DLL * CPL_STDCALL VRTSerializeToXML( VRTDatasetH, const char * ); +int CPL_DLL CPL_STDCALL VRTAddBand( VRTDatasetH, GDALDataType, char ** ); + +/* ==================================================================== */ +/* VRTSourcedRasterBand class. */ +/* ==================================================================== */ + +CPLErr CPL_STDCALL VRTAddSource( VRTSourcedRasterBandH, VRTSourceH ); +CPLErr CPL_DLL CPL_STDCALL VRTAddSimpleSource( VRTSourcedRasterBandH, + GDALRasterBandH, + int, int, int, int, + int, int, int, int, + const char *, double ); +CPLErr CPL_DLL CPL_STDCALL VRTAddComplexSource( VRTSourcedRasterBandH, + GDALRasterBandH, + int, int, int, int, + int, int, int, int, + double, double, double ); +CPLErr CPL_DLL CPL_STDCALL VRTAddFuncSource( VRTSourcedRasterBandH, + VRTImageReadFunc, + void *, double ); + +CPL_C_END + +#endif /* GDAL_VRT_H_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/gdalexif.h b/modules/globebrowsing/ext/gdal/include/gdalexif.h new file mode 100644 index 0000000000..247abf6164 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/gdalexif.h @@ -0,0 +1,235 @@ +/****************************************************************************** + * $Id$ + * + * Project: JPEG JFIF Driver + * Purpose: Implement GDAL JPEG Support based on IJG libjpeg. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2000, 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. + ****************************************************************************/ + +#ifdef RENAME_INTERNAL_LIBTIFF_SYMBOLS +#include "../frmts/gtiff/libtiff/gdal_libtiff_symbol_rename.h" +#endif + +static const struct gpsname { + GUInt16 tag; + const char* name; +} gpstags [] = { + { 0x00, "EXIF_GPSVersionID" }, + { 0x01, "EXIF_GPSLatitudeRef" }, + { 0x02, "EXIF_GPSLatitude" }, + { 0x03, "EXIF_GPSLongitudeRef" }, + { 0x04, "EXIF_GPSLongitude" }, + { 0x05, "EXIF_GPSAltitudeRef" }, + { 0x06, "EXIF_GPSAltitude" }, + { 0x07, "EXIF_GPSTimeStamp" }, + { 0x08, "EXIF_GPSSatellites" }, + { 0x09, "EXIF_GPSStatus" }, + { 0x0a, "EXIF_GPSMeasureMode" }, + { 0x0b, "EXIF_GPSDOP" }, + { 0x0c, "EXIF_GPSSpeedRef"}, + { 0x0d, "EXIF_GPSSpeed"}, + { 0x0e, "EXIF_GPSTrackRef"}, + { 0x0f, "EXIF_GPSTrack"}, + { 0x10, "EXIF_GPSImgDirectionRef"}, + { 0x11, "EXIF_GPSImgDirection"}, + { 0x12, "EXIF_GPSMapDatum"}, + { 0x13, "EXIF_GPSDestLatitudeRef"}, + { 0x14, "EXIF_GPSDestLatitude"}, + { 0x15, "EXIF_GPSDestLongitudeRef"}, + { 0x16, "EXIF_GPSDestLongitude"}, + { 0x17, "EXIF_GPSDestBearingRef"}, + { 0x18, "EXIF_GPSDestBearing"}, + { 0x19, "EXIF_GPSDestDistanceRef"}, + { 0x1a, "EXIF_GPSDestDistance"}, + { 0x1b, "EXIF_GPSProcessingMethod"}, + { 0x1c, "EXIF_GPSAreaInformation"}, + { 0x1d, "EXIF_GPSDateStamp"}, + { 0x1e, "EXIF_GPSDifferential"}, + { 0xffff, ""} +}; + +static const struct tagname { + GUInt16 tag; + const char* name; +} tagnames [] = { + +// { 0x100, "EXIF_Image_Width"}, +// { 0x101, "EXIF_Image_Length"}, + { 0x102, "EXIF_BitsPerSample"}, + { 0x103, "EXIF_Compression"}, + { 0x106, "EXIF_PhotometricInterpretation"}, + { 0x10A, "EXIF_Fill_Order"}, + { 0x10D, "EXIF_Document_Name"}, + { 0x10E, "EXIF_ImageDescription"}, + { 0x10F, "EXIF_Make"}, + { 0x110, "EXIF_Model"}, + { 0x111, "EXIF_StripOffsets"}, + { 0x112, "EXIF_Orientation"}, + { 0x115, "EXIF_SamplesPerPixel"}, + { 0x116, "EXIF_RowsPerStrip"}, + { 0x117, "EXIF_StripByteCounts"}, + { 0x11A, "EXIF_XResolution"}, + { 0x11B, "EXIF_YResolution"}, + { 0x11C, "EXIF_PlanarConfiguration"}, + { 0x128, "EXIF_ResolutionUnit"}, + { 0x12D, "EXIF_TransferFunction"}, + { 0x131, "EXIF_Software"}, + { 0x132, "EXIF_DateTime"}, + { 0x13B, "EXIF_Artist"}, + { 0x13E, "EXIF_WhitePoint"}, + { 0x13F, "EXIF_PrimaryChromaticities"}, + { 0x156, "EXIF_Transfer_Range"}, + { 0x200, "EXIF_JPEG_Proc"}, + { 0x201, "EXIF_JPEGInterchangeFormat"}, + { 0x202, "EXIF_JPEGInterchangeFormatLength"}, + { 0x211, "EXIF_YCbCrCoefficients"}, + { 0x212, "EXIF_YCbCrSubSampling"}, + { 0x213, "EXIF_YCbCrPositioning"}, + { 0x214, "EXIF_ReferenceBlackWhite"}, + { 0x828D, "EXIF_CFA_Repeat_Pattern_Dim"}, + { 0x828E, "EXIF_CFA_Pattern"}, + { 0x828F, "EXIF_Battery_Level"}, + { 0x8298, "EXIF_Copyright"}, + { 0x829A, "EXIF_ExposureTime"}, + { 0x829D, "EXIF_FNumber"}, + { 0x83BB, "EXIF_IPTC/NAA"}, +// { 0x8769, "EXIF_Offset"}, + { 0x8773, "EXIF_Inter_Color_Profile"}, + { 0x8822, "EXIF_ExposureProgram"}, + { 0x8824, "EXIF_SpectralSensitivity"}, +// { 0x8825, "EXIF_GPSOffset"}, + { 0x8827, "EXIF_ISOSpeedRatings"}, + { 0x8828, "EXIF_OECF"}, + { 0x9000, "EXIF_ExifVersion"}, + { 0x9003, "EXIF_DateTimeOriginal"}, + { 0x9004, "EXIF_DateTimeDigitized"}, + { 0x9101, "EXIF_ComponentsConfiguration"}, + { 0x9102, "EXIF_CompressedBitsPerPixel"}, + { 0x9201, "EXIF_ShutterSpeedValue"}, + { 0x9202, "EXIF_ApertureValue"}, + { 0x9203, "EXIF_BrightnessValue"}, + { 0x9204, "EXIF_ExposureBiasValue"}, + { 0x9205, "EXIF_MaxApertureValue"}, + { 0x9206, "EXIF_SubjectDistance"}, + { 0x9207, "EXIF_MeteringMode"}, + { 0x9208, "EXIF_LightSource"}, + { 0x9209, "EXIF_Flash"}, + { 0x920A, "EXIF_FocalLength"}, + { 0x9214, "EXIF_SubjectArea"}, + { 0x927C, "EXIF_MakerNote"}, + { 0x9286, "EXIF_UserComment"}, + { 0x9290, "EXIF_SubSecTime"}, + { 0x9291, "EXIF_SubSecTime_Original"}, + { 0x9292, "EXIF_SubSecTime_Digitized"}, + { 0xA000, "EXIF_FlashpixVersion"}, + { 0xA001, "EXIF_ColorSpace"}, + { 0xA002, "EXIF_PixelXDimension"}, + { 0xA003, "EXIF_PixelYDimension"}, + { 0xA004, "EXIF_RelatedSoundFile"}, +// { 0xA005, "EXIF_InteroperabilityOffset"}, + { 0xA20B, "EXIF_FlashEnergy"}, // 0x920B in TIFF/EP + { 0xA20C, "EXIF_SpatialFrequencyResponse"}, // 0x920C - - + { 0xA20E, "EXIF_FocalPlaneXResolution"}, // 0x920E - - + { 0xA20F, "EXIF_FocalPlaneYResolution"}, // 0x920F - - + { 0xA210, "EXIF_FocalPlaneResolutionUnit"}, // 0x9210 - - + { 0xA214, "EXIF_SubjectLocation"}, // 0x9214 - - + { 0xA215, "EXIF_ExposureIndex"}, // 0x9215 - - + { 0xA217, "EXIF_SensingMethod"}, // 0x9217 - - + { 0xA300, "EXIF_FileSource"}, + { 0xA301, "EXIF_SceneType"}, + { 0xA302, "EXIF_CFAPattern"}, + { 0xA401, "EXIF_CustomRendered"}, + { 0xA402, "EXIF_ExposureMode"}, + { 0XA403, "EXIF_WhiteBalance"}, + { 0xA404, "EXIF_DigitalZoomRatio"}, + { 0xA405, "EXIF_FocalLengthIn35mmFilm"}, + { 0xA406, "EXIF_SceneCaptureType"}, + { 0xA407, "EXIF_GainControl"}, + { 0xA408, "EXIF_Contrast"}, + { 0xA409, "EXIF_Saturation"}, + { 0xA40A, "EXIF_Sharpness"}, + { 0xA40B, "EXIF_DeviceSettingDescription"}, + { 0xA40C, "EXIF_SubjectDistanceRange"}, + { 0xA420, "EXIF_ImageUniqueID"}, + { 0x0000, ""} +}; + + +static const struct intr_tag { + GInt16 tag; + const char* name; +} intr_tags [] = { + + { 0x1, "EXIF_Interoperability_Index"}, + { 0x2, "EXIF_Interoperability_Version"}, + { 0x1000, "EXIF_Related_Image_File_Format"}, + { 0x1001, "EXIF_Related_Image_Width"}, + { 0x1002, "EXIF_Related_Image_Length"}, + { 0x0000, ""} +}; + +typedef enum { + TIFF_NOTYPE = 0, /* placeholder */ + TIFF_BYTE = 1, /* 8-bit unsigned integer */ + TIFF_ASCII = 2, /* 8-bit bytes w/ last byte null */ + TIFF_SHORT = 3, /* 16-bit unsigned integer */ + TIFF_LONG = 4, /* 32-bit unsigned integer */ + TIFF_RATIONAL = 5, /* 64-bit unsigned fraction */ + TIFF_SBYTE = 6, /* !8-bit signed integer */ + TIFF_UNDEFINED = 7, /* !8-bit untyped data */ + TIFF_SSHORT = 8, /* !16-bit signed integer */ + TIFF_SLONG = 9, /* !32-bit signed integer */ + TIFF_SRATIONAL = 10, /* !64-bit signed fraction */ + TIFF_FLOAT = 11, /* !32-bit IEEE floating point */ + TIFF_DOUBLE = 12, /* !64-bit IEEE floating point */ + TIFF_IFD = 13 /* %32-bit unsigned integer (offset) */ +} GDALEXIFTIFFDataType; + +/* + * TIFF Image File Directories are comprised of a table of field + * descriptors of the form shown below. The table is sorted in + * ascending order by tag. The values associated with each entry are + * disjoint and may appear anywhere in the file (so long as they are + * placed on a word boundary). + * + * If the value is 4 bytes or less, then it is placed in the offset + * field to save space. If the value is less than 4 bytes, it is + * left-justified in the offset field. + */ +typedef struct { + GUInt16 tdir_tag; /* see below */ + GUInt16 tdir_type; /* data type; see below */ + GUInt32 tdir_count; /* number of items; length in spec */ + GUInt32 tdir_offset; /* byte offset to field data */ +} GDALEXIFTIFFDirEntry; + +CPL_C_START +extern int TIFFDataWidth(GDALEXIFTIFFDataType); /* table of tag datatype widths */ +extern void TIFFSwabShort(GUInt16*); +extern void TIFFSwabLong(GUInt32*); +extern void TIFFSwabDouble(double*); +extern void TIFFSwabArrayOfShort(GUInt16*, unsigned long); +extern void TIFFSwabArrayOfLong(GUInt32*, unsigned long); +extern void TIFFSwabArrayOfDouble(double*, unsigned long); +CPL_C_END diff --git a/modules/globebrowsing/ext/gdal/include/gdalgeorefpamdataset.h b/modules/globebrowsing/ext/gdal/include/gdalgeorefpamdataset.h new file mode 100644 index 0000000000..749cdb89a1 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/gdalgeorefpamdataset.h @@ -0,0 +1,57 @@ +/****************************************************************************** + * $Id$ + * + * Project: GDAL + * Purpose: GDALPamDataset with internal storage for georeferencing, with + * priority for PAM over internal georeferencing + * Author: Even Rouault + * + ****************************************************************************** + * Copyright (c) 2013, Even Rouault + * + * 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. + ****************************************************************************/ + +#ifndef GDAL_GEOREF_PAM_DATASET_H_INCLUDED +#define GDAL_GEOREF_PAM_DATASET_H_INCLUDED + +#include "gdal_pam.h" + +class CPL_DLL GDALGeorefPamDataset : public GDALPamDataset +{ + protected: + bool bGeoTransformValid; + double adfGeoTransform[6]; + char *pszProjection; + int nGCPCount; + GDAL_GCP *pasGCPList; + + public: + GDALGeorefPamDataset(); + virtual ~GDALGeorefPamDataset(); + + virtual CPLErr GetGeoTransform( double * ); + virtual const char *GetProjectionRef(); + + virtual int GetGCPCount(); + virtual const char *GetGCPProjection(); + virtual const GDAL_GCP *GetGCPs(); +}; + +#endif /* GDAL_GEOREF_PAM_DATASET_H_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/gdalgrid.h b/modules/globebrowsing/ext/gdal/include/gdalgrid.h new file mode 100644 index 0000000000..3f3c4c77c9 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/gdalgrid.h @@ -0,0 +1,137 @@ +/****************************************************************************** + * $Id$ + * + * Project: GDAL Gridding API. + * Purpose: Prototypes, and definitions for of GDAL scattered data gridder. + * Author: Andrey Kiselev, dron@ak4719.spb.edu + * + ****************************************************************************** + * Copyright (c) 2007, Andrey Kiselev + * Copyright (c) 2012, Even Rouault + * + * 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. + ****************************************************************************/ + +#ifndef GDALGRID_H_INCLUDED +#define GDALGRID_H_INCLUDED + +/** + * \file gdalgrid.h + * + * GDAL gridder related entry points and definitions. + */ + +#include "gdal_alg.h" + +/* + * GridCreate Algorithm names + */ + +static const char szAlgNameInvDist[] = "invdist"; +static const char szAlgNameInvDistNearestNeighbor[] = "invdistnn"; +static const char szAlgNameAverage[] = "average"; +static const char szAlgNameNearest[] = "nearest"; +static const char szAlgNameMinimum[] = "minimum"; +static const char szAlgNameMaximum[] = "maximum"; +static const char szAlgNameRange[] = "range"; +static const char szAlgNameCount[] = "count"; +static const char szAlgNameAverageDistance[] = "average_distance"; +static const char szAlgNameAverageDistancePts[] = "average_distance_pts"; +static const char szAlgNameLinear[] = "linear"; + +CPL_C_START + +typedef CPLErr (*GDALGridFunction)( const void *, GUInt32, + const double *, const double *, + const double *, + double, double, double *, + void* ); +CPLErr +GDALGridInverseDistanceToAPower( const void *, GUInt32, + const double *, const double *, + const double *, + double, double, double *, + void* ); +CPLErr +GDALGridInverseDistanceToAPowerNearestNeighbor( const void *, GUInt32, + const double *, const double *, + const double *, + double, double, double *, + void* ); +CPLErr +GDALGridInverseDistanceToAPowerNoSearch( const void *, GUInt32, + const double *, const double *, + const double *, + double, double, double *, + void* ); +CPLErr +GDALGridMovingAverage( const void *, GUInt32, + const double *, const double *, const double *, + double, double, double *, + void* ); +CPLErr +GDALGridNearestNeighbor( const void *, GUInt32, + const double *, const double *, const double *, + double, double, double *, + void* ); +CPLErr +GDALGridDataMetricMinimum( const void *, GUInt32, + const double *, const double *, const double *, + double, double, double *, + void* ); +CPLErr +GDALGridDataMetricMaximum( const void *, GUInt32, + const double *, const double *, const double *, + double, double, double *, + void* ); +CPLErr +GDALGridDataMetricRange( const void *, GUInt32, + const double *, const double *, const double *, + double, double, double *, + void* ); +CPLErr +GDALGridDataMetricCount( const void *, GUInt32, + const double *, const double *, const double *, + double, double, double *, + void* ); +CPLErr +GDALGridDataMetricAverageDistance( const void *, GUInt32, + const double *, const double *, + const double *, double, double, double *, + void* ); +CPLErr +GDALGridDataMetricAverageDistancePts( const void *, GUInt32, + const double *, const double *, + const double *, double, double, + double *, + void* ); +CPLErr +GDALGridLinear( const void *, GUInt32, + const double *, const double *, + const double *, + double, double, double *, + void* ); + +CPLErr CPL_DLL +ParseAlgorithmAndOptions( const char *, + GDALGridAlgorithm *, + void ** ); +CPL_C_END + +#endif /* GDALGRID_H_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/gdalgrid_priv.h b/modules/globebrowsing/ext/gdal/include/gdalgrid_priv.h new file mode 100644 index 0000000000..d54ea41762 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/gdalgrid_priv.h @@ -0,0 +1,106 @@ +/****************************************************************************** + * $Id$ + * + * Project: GDAL Gridding API. + * Purpose: Prototypes, and definitions for of GDAL scattered data gridder. + * Author: Even Rouault, + * + ****************************************************************************** + * Copyright (c) 2013, Even Rouault + * + * 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. + ****************************************************************************/ + +#include "cpl_error.h" +#include "cpl_quad_tree.h" + +typedef struct +{ + const double* padfX; + const double* padfY; +} GDALGridXYArrays; + +typedef struct +{ + GDALGridXYArrays* psXYArrays; + int i; +} GDALGridPoint; + +typedef struct +{ + CPLQuadTree* hQuadTree; + double dfInitialSearchRadius; + const float *pafX; + const float *pafY; + const float *pafZ; + GDALTriangulation* psTriangulation; + int nInitialFacetIdx; + /*! Weighting power divided by 2 (pre-computation). */ + double dfPowerDiv2PreComp; + /*! The radius of search circle squared (pre-computation). */ + double dfRadiusPower2PreComp; + /*! The radius of search circle to power 4 (pre-computation). */ + double dfRadiusPower4PreComp; +} GDALGridExtraParameters; + +#ifdef HAVE_SSE_AT_COMPILE_TIME +int CPLHaveRuntimeSSE(); + +CPLErr +GDALGridInverseDistanceToAPower2NoSmoothingNoSearchSSE( + const void *poOptions, + GUInt32 nPoints, + const double *unused_padfX, + const double *unused_padfY, + const double *unused_padfZ, + double dfXPoint, double dfYPoint, + double *pdfValue, + void* hExtraParamsIn ); +#endif + +#ifdef HAVE_AVX_AT_COMPILE_TIME +int CPLHaveRuntimeAVX(); + +CPLErr GDALGridInverseDistanceToAPower2NoSmoothingNoSearchAVX( + const void *poOptions, + GUInt32 nPoints, + const double *unused_padfX, + const double *unused_padfY, + const double *unused_padfZ, + double dfXPoint, double dfYPoint, + double *pdfValue, + void* hExtraParamsIn ); +#endif +#if defined(__GNUC__) +#if defined(__x86_64) +#define GCC_CPUID(level, a, b, c, d) \ + __asm__ ("xchgq %%rbx, %q1\n" \ + "cpuid\n" \ + "xchgq %%rbx, %q1" \ + : "=a" (a), "=r" (b), "=c" (c), "=d" (d) \ + : "0" (level)) +#else +#define GCC_CPUID(level, a, b, c, d) \ + __asm__ ("xchgl %%ebx, %1\n" \ + "cpuid\n" \ + "xchgl %%ebx, %1" \ + : "=a" (a), "=r" (b), "=c" (c), "=d" (d) \ + : "0" (level)) +#endif +#endif diff --git a/modules/globebrowsing/ext/gdal/include/gdaljp2abstractdataset.h b/modules/globebrowsing/ext/gdal/include/gdaljp2abstractdataset.h new file mode 100644 index 0000000000..2bd5562121 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/gdaljp2abstractdataset.h @@ -0,0 +1,60 @@ +/****************************************************************************** + * $Id$ + * + * Project: GDAL + * Purpose: GDALGeorefPamDataset with helper to read georeferencing and other + * metadata from JP2Boxes + * Author: Even Rouault + * + ****************************************************************************** + * Copyright (c) 2013, Even Rouault + * + * 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. + ****************************************************************************/ + +#ifndef GDAL_JP2_ABSTRACT_DATASET_H_INCLUDED +#define GDAL_JP2_ABSTRACT_DATASET_H_INCLUDED + +#include "gdalgeorefpamdataset.h" + +class CPL_DLL GDALJP2AbstractDataset: public GDALGeorefPamDataset +{ + char* pszWldFilename; + + GDALDataset* poMemDS; + char** papszMetadataFiles; + + protected: + virtual int CloseDependentDatasets(); + + public: + GDALJP2AbstractDataset(); + virtual ~GDALJP2AbstractDataset(); + + void LoadJP2Metadata(GDALOpenInfo* poOpenInfo, + const char* pszOverrideFilename = NULL); + void LoadVectorLayers(int bOpenRemoteResources = FALSE); + + virtual char **GetFileList(void); + + virtual int GetLayerCount(); + virtual OGRLayer *GetLayer(int i); +}; + +#endif /* GDAL_JP2_ABSTRACT_DATASET_H_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/gdaljp2metadata.h b/modules/globebrowsing/ext/gdal/include/gdaljp2metadata.h new file mode 100644 index 0000000000..638bff3cef --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/gdaljp2metadata.h @@ -0,0 +1,196 @@ +/****************************************************************************** + * $Id$ + * + * Project: GDAL + * Purpose: JP2 Box Reader (and GMLJP2 Interpreter) + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2005, Frank Warmerdam + * Copyright (c) 2010-2013, Even Rouault + * + * 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. + ****************************************************************************/ + +#ifndef GDAL_JP2READER_H_INCLUDED +#define GDAL_JP2READER_H_INCLUDED + +#include "cpl_conv.h" +#include "cpl_minixml.h" +#include "cpl_vsi.h" +#include "gdal.h" +#include "gdal_priv.h" + +/************************************************************************/ +/* GDALJP2Box */ +/************************************************************************/ + +class CPL_DLL GDALJP2Box +{ + + VSILFILE *fpVSIL; + + char szBoxType[5]; + + GIntBig nBoxOffset; + GIntBig nBoxLength; + + GIntBig nDataOffset; + + GByte abyUUID[16]; + + GByte *pabyData; + +public: + GDALJP2Box( VSILFILE * = NULL ); + ~GDALJP2Box(); + + int SetOffset( GIntBig nNewOffset ); + int ReadBox(); + + int ReadFirst(); + int ReadNext(); + + int ReadFirstChild( GDALJP2Box *poSuperBox ); + int ReadNextChild( GDALJP2Box *poSuperBox ); + + GIntBig GetBoxOffset() const { return nBoxOffset; } + GIntBig GetBoxLength() const { return nBoxLength; } + + GIntBig GetDataOffset() const { return nDataOffset; } + GIntBig GetDataLength(); + + const char *GetType() { return szBoxType; } + + GByte *ReadBoxData(); + + int IsSuperBox(); + + int DumpReadable( FILE *, int nIndentLevel = 0 ); + + VSILFILE *GetFILE() { return fpVSIL; } + + const GByte *GetUUID() { return abyUUID; } + + // write support + void SetType( const char * ); + void SetWritableData( int nLength, const GByte *pabyData ); + void AppendWritableData( int nLength, const void *pabyDataIn ); + void AppendUInt32( GUInt32 nVal ); + void AppendUInt16( GUInt16 nVal ); + void AppendUInt8( GByte nVal ); + const GByte*GetWritableData() { return pabyData; } + + // factory methods. + static GDALJP2Box *CreateSuperBox( const char* pszType, + int nCount, GDALJP2Box **papoBoxes ); + static GDALJP2Box *CreateAsocBox( int nCount, GDALJP2Box **papoBoxes ); + static GDALJP2Box *CreateLblBox( const char *pszLabel ); + static GDALJP2Box *CreateLabelledXMLAssoc( const char *pszLabel, + const char *pszXML ); + static GDALJP2Box *CreateUUIDBox( const GByte *pabyUUID, + int nDataSize, const GByte *pabyData ); +}; + +/************************************************************************/ +/* GDALJP2Metadata */ +/************************************************************************/ + +typedef struct _GDALJP2GeoTIFFBox GDALJP2GeoTIFFBox; + +class CPL_DLL GDALJP2Metadata + +{ +private: + void CollectGMLData( GDALJP2Box * ); + int GMLSRSLookup( const char *pszURN ); + + int nGeoTIFFBoxesCount; + GDALJP2GeoTIFFBox *pasGeoTIFFBoxes; + + int nMSIGSize; + GByte *pabyMSIGData; + + int GetGMLJP2GeoreferencingInfo( int& nEPSGCode, + double adfOrigin[2], + double adfXVector[2], + double adfYVector[2], + const char*& pszComment, + CPLString& osDictBox, + int& bNeedAxisFlip ); + static CPLXMLNode* CreateGDALMultiDomainMetadataXML( + GDALDataset* poSrcDS, + int bMainMDDomainOnly ); + +public: + char **papszGMLMetadata; + + int bHaveGeoTransform; + double adfGeoTransform[6]; + int bPixelIsPoint; + + char *pszProjection; + + int nGCPCount; + GDAL_GCP *pasGCPList; + + char **papszRPCMD; + + char **papszMetadata; /* TIFFTAG_?RESOLUTION* for now from resd box */ + char *pszXMPMetadata; + char *pszGDALMultiDomainMetadata; /* as serialized XML */ + char *pszXMLIPR; /* if an IPR box with XML content has been found */ + +public: + GDALJP2Metadata(); + ~GDALJP2Metadata(); + + int ReadBoxes( VSILFILE * fpVSIL ); + + int ParseJP2GeoTIFF(); + int ParseMSIG(); + int ParseGMLCoverageDesc(); + + int ReadAndParse( VSILFILE * fpVSIL ); + int ReadAndParse( const char *pszFilename ); + + // Write oriented. + void SetProjection( const char *pszWKT ); + void SetGeoTransform( double * ); + void SetGCPs( int, const GDAL_GCP * ); + void SetRPCMD( char** papszRPCMDIn ); + + GDALJP2Box *CreateJP2GeoTIFF(); + GDALJP2Box *CreateGMLJP2( int nXSize, int nYSize ); + GDALJP2Box *CreateGMLJP2V2( int nXSize, int nYSize, + const char* pszDefFilename, + GDALDataset* poSrcDS ); + + static GDALJP2Box* CreateGDALMultiDomainMetadataXMLBox( + GDALDataset* poSrcDS, + int bMainMDDomainOnly ); + static GDALJP2Box** CreateXMLBoxes( GDALDataset* poSrcDS, + int* pnBoxes ); + static GDALJP2Box *CreateXMPBox ( GDALDataset* poSrcDS ); + static GDALJP2Box *CreateIPRBox ( GDALDataset* poSrcDS ); + static int IsUUID_MSI(const GByte *abyUUID); + static int IsUUID_XMP(const GByte *abyUUID); +}; + +#endif /* ndef GDAL_JP2READER_H_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/gdaljp2metadatagenerator.h b/modules/globebrowsing/ext/gdal/include/gdaljp2metadatagenerator.h new file mode 100644 index 0000000000..88de9b4c9e --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/gdaljp2metadatagenerator.h @@ -0,0 +1,40 @@ +/****************************************************************************** + * $Id$ + * + * Project: GDAL + * Purpose: GDALJP2Metadata: metadata generator + * Author: Even Rouault + * + ****************************************************************************** + * Copyright (c) 2015, European Union Satellite Centre + * + * 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. + ****************************************************************************/ + +#ifndef GDAL_JP2METADATA_GENERATOR_H_INCLUDED +#define GDAL_JP2METADATA_GENERATOR_H_INCLUDED + + +#include "cpl_string.h" +#include "cpl_minixml.h" + +CPLXMLNode* GDALGMLJP2GenerateMetadata(const CPLString& osTemplateFile, + const CPLString& osSourceFile); + +#endif /* GDAL_JP2METADATA_GENERATOR_H_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/gdalpansharpen.h b/modules/globebrowsing/ext/gdal/include/gdalpansharpen.h new file mode 100644 index 0000000000..f5ae8b74b1 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/gdalpansharpen.h @@ -0,0 +1,270 @@ +/****************************************************************************** + * $Id$ + * + * Project: GDAL Pansharpening module + * Purpose: Prototypes, and definitions for pansharpening related work. + * Author: Even Rouault + * + ****************************************************************************** + * Copyright (c) 2015, Even Rouault + * + * 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. + ****************************************************************************/ + +#ifndef GDALPANSHARPEN_H_INCLUDED +#define GDALPANSHARPEN_H_INCLUDED + +#include "gdal.h" + +CPL_C_START + +/** + * \file gdalpansharpen.h + * + * GDAL pansharpening related entry points and definitions. + * + * @since GDAL 2.1 + */ + +/** Pansharpening algorithms. + */ +typedef enum +{ + /*! Weighted Brovery. */ + GDAL_PSH_WEIGHTED_BROVEY +} GDALPansharpenAlg; + +/** Pansharpening options. + */ +typedef struct +{ + /*! Pan sharpening algorithm/method. Only weighed Brovey for now. */ + GDALPansharpenAlg ePansharpenAlg; + + /*! Resampling algorithm to upsample spectral bands to pan band resolution. */ + GDALRIOResampleAlg eResampleAlg; + + /*! Bit depth of the spectral bands. Can be let to 0 for default behaviour. */ + int nBitDepth; + + /*! Number of weight coefficients in padfWeights. */ + int nWeightCount; + + /*! Array of nWeightCount weights used by weighted Brovey. */ + double *padfWeights; + + /*! Panchromatic band. */ + GDALRasterBandH hPanchroBand; + + /*! Number of input spectral bands. */ + int nInputSpectralBands; + + /** Array of nInputSpectralBands input spectral bands. The spectral band have + * generally a coarser resolution than the panchromatic band, but they + * are assumed to have the same spatial extent (and projection) at that point. + * Necessary spatial adjustments must be done beforehand, for example by wrapping + * inside a VRT dataset. + */ + GDALRasterBandH *pahInputSpectralBands; + + /*! Number of output pansharpened spectral bands. */ + int nOutPansharpenedBands; + + /*! Array of nOutPansharpendBands values such as panOutPansharpenedBands[k] is a value in the range [0,nInputSpectralBands-1] . */ + int *panOutPansharpenedBands; + + /*! Whether the panchromatic and spectral bands have a noData value. */ + int bHasNoData; + + /** NoData value of the panchromatic and spectral bands (only taken into account if bHasNoData = TRUE). + This will also be use has the output nodata value. */ + double dfNoData; + + /** Number of threads or -1 to mean ALL_CPUS. By default (0), single threaded mode is enabled + * unless the GDAL_NUM_THREADS configuration option is set to an integer or ALL_CPUS. */ + int nThreads; + + double dfMSShiftX; + double dfMSShiftY; + +} GDALPansharpenOptions; + + +GDALPansharpenOptions CPL_DLL * GDALCreatePansharpenOptions(void); +void CPL_DLL GDALDestroyPansharpenOptions( GDALPansharpenOptions * ); +GDALPansharpenOptions CPL_DLL * GDALClonePansharpenOptions( + const GDALPansharpenOptions* psOptions); + +/*! Pansharpening operation handle. */ +typedef void* GDALPansharpenOperationH; + +GDALPansharpenOperationH CPL_DLL GDALCreatePansharpenOperation(const GDALPansharpenOptions* ); +void CPL_DLL GDALDestroyPansharpenOperation( GDALPansharpenOperationH ); +CPLErr CPL_DLL GDALPansharpenProcessRegion( GDALPansharpenOperationH hOperation, + int nXOff, int nYOff, + int nXSize, int nYSize, + void *pDataBuf, + GDALDataType eBufDataType); + +CPL_C_END + +#ifdef __cplusplus + +#include +#include "gdal_priv.h" +#include "cpl_worker_thread_pool.h" + +#ifdef DEBUG_TIMING +#include +#endif + +class GDALPansharpenOperation; + +typedef struct +{ + GDALPansharpenOperation* poPansharpenOperation; + GDALDataType eWorkDataType; + GDALDataType eBufDataType; + const void* pPanBuffer; + const void* pUpsampledSpectralBuffer; + void* pDataBuf; + int nValues; + int nBandValues; + GUInt32 nMaxValue; + +#ifdef DEBUG_TIMING + struct timeval* ptv; +#endif + + CPLErr eErr; +} GDALPansharpenJob; + +typedef struct +{ + GDALDataset* poMEMDS; + int nXOff; + int nYOff; + int nXSize; + int nYSize; + double dfXOff; + double dfYOff; + double dfXSize; + double dfYSize; + void *pBuffer; + GDALDataType eDT; + int nBufXSize; + int nBufYSize; + int nBandCount; + GDALRIOResampleAlg eResampleAlg; + GSpacing nBandSpace; + +#ifdef DEBUG_TIMING + struct timeval* ptv; +#endif +} GDALPansharpenResampleJob; + +/** Pansharpening operation class. + */ +class GDALPansharpenOperation +{ + GDALPansharpenOptions* psOptions; + std::vector anInputBands; + std::vector aVDS; // to destroy + std::vector aMSBands; // original multispectral bands potentially warped into a VRT + int bPositiveWeights; + CPLWorkerThreadPool* poThreadPool; + int nKernelRadius; + + static void PansharpenJobThreadFunc(void* pUserData); + static void PansharpenResampleJobThreadFunc(void* pUserData); + + template void WeightedBroveyWithNoData( + const WorkDataType* pPanBuffer, + const WorkDataType* pUpsampledSpectralBuffer, + OutDataType* pDataBuf, + int nValues, + int nBandValues, + WorkDataType nMaxValue) const; + template void WeightedBrovey3( + const WorkDataType* pPanBuffer, + const WorkDataType* pUpsampledSpectralBuffer, + OutDataType* pDataBuf, + int nValues, + int nBandValues, + WorkDataType nMaxValue) const; + template void WeightedBrovey( + const WorkDataType* pPanBuffer, + const WorkDataType* pUpsampledSpectralBuffer, + OutDataType* pDataBuf, + int nValues, + int nBandValues, + WorkDataType nMaxValue) const; + template CPLErr WeightedBrovey( + const WorkDataType* pPanBuffer, + const WorkDataType* pUpsampledSpectralBuffer, + void *pDataBuf, + GDALDataType eBufDataType, + int nValues, + int nBandValues, + WorkDataType nMaxValue) const; + template CPLErr WeightedBrovey( + const WorkDataType* pPanBuffer, + const WorkDataType* pUpsampledSpectralBuffer, + void *pDataBuf, + GDALDataType eBufDataType, + int nValues, + int nBandValues) const; + void WeightedBroveyPositiveWeights( + const GUInt16* pPanBuffer, + const GUInt16* pUpsampledSpectralBuffer, + GUInt16* pDataBuf, + int nValues, + int nBandValues, + GUInt16 nMaxValue) const; + + template int WeightedBroveyPositiveWeightsInternal( + const GUInt16* pPanBuffer, + const GUInt16* pUpsampledSpectralBuffer, + GUInt16* pDataBuf, + int nValues, + int nBandValues, + GUInt16 nMaxValue) const; + + CPLErr PansharpenChunk( GDALDataType eWorkDataType, GDALDataType eBufDataType, + const void* pPanBuffer, + const void* pUpsampledSpectralBuffer, + void* pDataBuf, + int nValues, + int nBandValues, + GUInt32 nMaxValue) const; + public: + GDALPansharpenOperation(); + ~GDALPansharpenOperation(); + + CPLErr Initialize(const GDALPansharpenOptions* psOptions); + CPLErr ProcessRegion(int nXOff, int nYOff, + int nXSize, int nYSize, + void *pDataBuf, + GDALDataType eBufDataType); + GDALPansharpenOptions* GetOptions(); +}; + +#endif /* __cplusplus */ + +#endif /* GDALPANSHARPEN_H_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/gdalsse_priv.h b/modules/globebrowsing/ext/gdal/include/gdalsse_priv.h new file mode 100644 index 0000000000..fb0d1b1019 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/gdalsse_priv.h @@ -0,0 +1,855 @@ +/****************************************************************************** + * $Id$ + * + * Project: GDAL + * Purpose: SSE2 helper + * Author: Even Rouault + * + ****************************************************************************** + * Copyright (c) 2014, Even Rouault + * + * 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. + ****************************************************************************/ + +#ifndef GDALSSE_PRIV_H_INCLUDED +#define GDALSSE_PRIV_H_INCLUDED + +#include "cpl_port.h" + +/* We restrict to 64bit processors because they are guaranteed to have SSE2 */ +/* Could possibly be used too on 32bit, but we would need to check at runtime */ +#if (defined(__x86_64) || defined(_M_X64)) && !defined(USE_SSE2_EMULATION) + +/* Requires SSE2 */ +#include +#include + +class XMMReg2Double +{ + public: + __m128d xmm; + + /* coverity[uninit_member] */ + XMMReg2Double() {} + + XMMReg2Double(double val) { xmm = _mm_load_sd (&val); } + XMMReg2Double(const XMMReg2Double& other) : xmm(other.xmm) {} + + static inline XMMReg2Double Zero() + { + XMMReg2Double reg; + reg.Zeroize(); + return reg; + } + + static inline XMMReg2Double Load1ValHighAndLow(const double* ptr) + { + XMMReg2Double reg; + reg.nsLoad1ValHighAndLow(ptr); + return reg; + } + + static inline XMMReg2Double Load2Val(const double* ptr) + { + XMMReg2Double reg; + reg.nsLoad2Val(ptr); + return reg; + } + + static inline XMMReg2Double Load2Val(const float* ptr) + { + XMMReg2Double reg; + reg.nsLoad2Val(ptr); + return reg; + } + + static inline XMMReg2Double Load2ValAligned(const double* ptr) + { + XMMReg2Double reg; + reg.nsLoad2ValAligned(ptr); + return reg; + } + + static inline XMMReg2Double Load2Val(const unsigned char* ptr) + { + XMMReg2Double reg; + reg.nsLoad2Val(ptr); + return reg; + } + + static inline XMMReg2Double Load2Val(const short* ptr) + { + XMMReg2Double reg; + reg.nsLoad2Val(ptr); + return reg; + } + + static inline XMMReg2Double Load2Val(const unsigned short* ptr) + { + XMMReg2Double reg; + reg.nsLoad2Val(ptr); + return reg; + } + + static inline XMMReg2Double Equals(const XMMReg2Double& expr1, const XMMReg2Double& expr2) + { + XMMReg2Double reg; + reg.xmm = _mm_cmpeq_pd(expr1.xmm, expr2.xmm); + return reg; + } + + static inline XMMReg2Double NotEquals(const XMMReg2Double& expr1, const XMMReg2Double& expr2) + { + XMMReg2Double reg; + reg.xmm = _mm_cmpneq_pd(expr1.xmm, expr2.xmm); + return reg; + } + + static inline XMMReg2Double Greater(const XMMReg2Double& expr1, const XMMReg2Double& expr2) + { + XMMReg2Double reg; + reg.xmm = _mm_cmpgt_pd(expr1.xmm, expr2.xmm); + return reg; + } + + static inline XMMReg2Double And(const XMMReg2Double& expr1, const XMMReg2Double& expr2) + { + XMMReg2Double reg; + reg.xmm = _mm_and_pd(expr1.xmm, expr2.xmm); + return reg; + } + + static inline XMMReg2Double Ternary(const XMMReg2Double& cond, const XMMReg2Double& true_expr, const XMMReg2Double& false_expr) + { + XMMReg2Double reg; + reg.xmm = _mm_or_pd(_mm_and_pd (cond.xmm, true_expr.xmm), _mm_andnot_pd(cond.xmm, false_expr.xmm)); + return reg; + } + + static inline XMMReg2Double Min(const XMMReg2Double& expr1, const XMMReg2Double& expr2) + { + XMMReg2Double reg; + reg.xmm = _mm_min_pd(expr1.xmm, expr2.xmm); + return reg; + } + + inline void nsLoad1ValHighAndLow(const double* ptr) + { + xmm = _mm_load1_pd(ptr); + } + + inline void nsLoad2Val(const double* ptr) + { + xmm = _mm_loadu_pd(ptr); + } + + inline void nsLoad2ValAligned(const double* pval) + { + xmm = _mm_load_pd(pval); + } + + inline void nsLoad2Val(const float* pval) + { + __m128 temp1 = _mm_load_ss(pval); + __m128 temp2 = _mm_load_ss(pval + 1); + temp1 = _mm_shuffle_ps(temp1, temp2, _MM_SHUFFLE(1,0,1,0)); + temp1 = _mm_shuffle_ps(temp1, temp1, _MM_SHUFFLE(3,3,2,0)); + xmm = _mm_cvtps_pd(temp1); + } + + inline void nsLoad2Val(const unsigned char* ptr) + { +#ifdef CPL_CPU_REQUIRES_ALIGNED_ACCESS + unsigned short s; + memcpy(&s, ptr, 2); + __m128i xmm_i = _mm_cvtsi32_si128(s); +#else + __m128i xmm_i = _mm_cvtsi32_si128(*(unsigned short*)(ptr)); +#endif + xmm_i = _mm_unpacklo_epi8(xmm_i, _mm_setzero_si128()); + xmm_i = _mm_unpacklo_epi16(xmm_i, _mm_setzero_si128()); + xmm = _mm_cvtepi32_pd(xmm_i); + } + + inline void nsLoad2Val(const short* ptr) + { + int i; + memcpy(&i, ptr, 4); + __m128i xmm_i = _mm_cvtsi32_si128(i); + xmm_i = _mm_unpacklo_epi16(xmm_i,xmm_i); /* 0|0|0|0|0|0|b|a --> 0|0|0|0|b|b|a|a */ + xmm_i = _mm_srai_epi32(xmm_i, 16); /* 0|0|0|0|b|b|a|a --> 0|0|0|0|sign(b)|b|sign(a)|a */ + xmm = _mm_cvtepi32_pd(xmm_i); + } + + inline void nsLoad2Val(const unsigned short* ptr) + { + int i; + memcpy(&i, ptr, 4); + __m128i xmm_i = _mm_cvtsi32_si128(i); + xmm_i = _mm_unpacklo_epi16(xmm_i,xmm_i); /* 0|0|0|0|0|0|b|a --> 0|0|0|0|b|b|a|a */ + xmm_i = _mm_srli_epi32(xmm_i, 16); /* 0|0|0|0|b|b|a|a --> 0|0|0|0|0|b|0|a */ + xmm = _mm_cvtepi32_pd(xmm_i); + } + + static inline void Load4Val(const unsigned char* ptr, XMMReg2Double& low, XMMReg2Double& high) + { +#ifdef CPL_CPU_REQUIRES_ALIGNED_ACCESS + int i; + memcpy(&i, ptr, 4); + __m128i xmm_i = _mm_cvtsi32_si128(i); +#else + __m128i xmm_i = _mm_cvtsi32_si128(*(int*)(ptr)); +#endif + xmm_i = _mm_unpacklo_epi8(xmm_i, _mm_setzero_si128()); + xmm_i = _mm_unpacklo_epi16(xmm_i, _mm_setzero_si128()); + low.xmm = _mm_cvtepi32_pd(xmm_i); + high.xmm = _mm_cvtepi32_pd(_mm_shuffle_epi32(xmm_i,_MM_SHUFFLE(3,2,3,2))); + } + + static inline void Load4Val(const short* ptr, XMMReg2Double& low, XMMReg2Double& high) + { + low.nsLoad2Val(ptr); + high.nsLoad2Val(ptr+2); + } + + static inline void Load4Val(const unsigned short* ptr, XMMReg2Double& low, XMMReg2Double& high) + { + low.nsLoad2Val(ptr); + high.nsLoad2Val(ptr+2); + } + + static inline void Load4Val(const double* ptr, XMMReg2Double& low, XMMReg2Double& high) + { + low.nsLoad2Val(ptr); + high.nsLoad2Val(ptr+2); + } + + static inline void Load4Val(const float* ptr, XMMReg2Double& low, XMMReg2Double& high) + { + __m128 temp1 = _mm_loadu_ps(ptr); + __m128 temp2 = _mm_shuffle_ps(temp1, temp1, _MM_SHUFFLE(3,2,3,2)); + low.xmm = _mm_cvtps_pd(temp1); + high.xmm = _mm_cvtps_pd(temp2); + } + + inline void Zeroize() + { + xmm = _mm_setzero_pd(); + } + + inline XMMReg2Double& operator= (const XMMReg2Double& other) + { + xmm = other.xmm; + return *this; + } + + inline XMMReg2Double& operator+= (const XMMReg2Double& other) + { + xmm = _mm_add_pd(xmm, other.xmm); + return *this; + } + + inline XMMReg2Double& operator*= (const XMMReg2Double& other) + { + xmm = _mm_mul_pd(xmm, other.xmm); + return *this; + } + + inline XMMReg2Double operator+ (const XMMReg2Double& other) const + { + XMMReg2Double ret; + ret.xmm = _mm_add_pd(xmm, other.xmm); + return ret; + } + + inline XMMReg2Double operator- (const XMMReg2Double& other) const + { + XMMReg2Double ret; + ret.xmm = _mm_sub_pd(xmm, other.xmm); + return ret; + } + + inline XMMReg2Double operator* (const XMMReg2Double& other) const + { + XMMReg2Double ret; + ret.xmm = _mm_mul_pd(xmm, other.xmm); + return ret; + } + + inline XMMReg2Double operator/ (const XMMReg2Double& other) const + { + XMMReg2Double ret; + ret.xmm = _mm_div_pd(xmm, other.xmm); + return ret; + } + + inline void AddLowAndHigh() + { + __m128d xmm2; + xmm2 = _mm_shuffle_pd(xmm,xmm,_MM_SHUFFLE2(0,1)); /* transfer high word into low word of xmm2 */ + xmm = _mm_add_pd(xmm, xmm2); + } + + inline void Store2Double(double* pval) const + { + _mm_storeu_pd(pval, xmm); + } + + inline void Store2DoubleAligned(double* pval) const + { + _mm_store_pd(pval, xmm); + } + + void Store2Val(unsigned short* ptr) const + { + __m128i tmp = _mm_cvtpd_epi32(xmm); /* Convert the 2 double values to 2 integers */ + ptr[0] = (GUInt16)_mm_extract_epi16(tmp, 0); + ptr[1] = (GUInt16)_mm_extract_epi16(tmp, 2); + } + + inline operator double () const + { + double val; + _mm_store_sd(&val, xmm); + return val; + } +}; + +#else + +#warning "Software emulation of SSE2 !" + +class XMMReg2Double +{ + public: + double low; + double high; + + XMMReg2Double() {} + XMMReg2Double(double val) { low = val; high = 0.0; } + XMMReg2Double(const XMMReg2Double& other) : low(other.low), high(other.high) {} + + static inline XMMReg2Double Zero() + { + XMMReg2Double reg; + reg.Zeroize(); + return reg; + } + + static inline XMMReg2Double Load1ValHighAndLow(const double* ptr) + { + XMMReg2Double reg; + reg.nsLoad1ValHighAndLow(ptr); + return reg; + } + + static inline XMMReg2Double Equals(const XMMReg2Double& expr1, const XMMReg2Double& expr2) + { + XMMReg2Double reg; + + if (expr1.low == expr2.low) + memset(&(reg.low), 0xFF, sizeof(double)); + else + reg.low = 0; + + if (expr1.high == expr2.high) + memset(&(reg.high), 0xFF, sizeof(double)); + else + reg.high = 0; + + return reg; + } + + static inline XMMReg2Double NotEquals(const XMMReg2Double& expr1, const XMMReg2Double& expr2) + { + XMMReg2Double reg; + + if (expr1.low != expr2.low) + memset(&(reg.low), 0xFF, sizeof(double)); + else + reg.low = 0; + + if (expr1.high != expr2.high) + memset(&(reg.high), 0xFF, sizeof(double)); + else + reg.high = 0; + + return reg; + } + + static inline XMMReg2Double Greater(const XMMReg2Double& expr1, const XMMReg2Double& expr2) + { + XMMReg2Double reg; + + if (expr1.low > expr2.low) + memset(&(reg.low), 0xFF, sizeof(double)); + else + reg.low = 0; + + if (expr1.high > expr2.high) + memset(&(reg.high), 0xFF, sizeof(double)); + else + reg.high = 0; + + return reg; + } + + static inline XMMReg2Double And(const XMMReg2Double& expr1, const XMMReg2Double& expr2) + { + XMMReg2Double reg; + int low1[2], high1[2]; + int low2[2], high2[2]; + memcpy(low1, &expr1.low, sizeof(double)); + memcpy(high1, &expr1.high, sizeof(double)); + memcpy(low2, &expr2.low, sizeof(double)); + memcpy(high2, &expr2.high, sizeof(double)); + low1[0] &= low2[0]; + low1[1] &= low2[1]; + high1[0] &= high2[0]; + high1[1] &= high2[1]; + memcpy(®.low, low1, sizeof(double)); + memcpy(®.high, high1, sizeof(double)); + return reg; + } + + static inline XMMReg2Double Ternary(const XMMReg2Double& cond, const XMMReg2Double& true_expr, const XMMReg2Double& false_expr) + { + XMMReg2Double reg; + if( cond.low ) + reg.low = true_expr.low; + else + reg.low = false_expr.low; + if( cond.high ) + reg.high = true_expr.high; + else + reg.high = false_expr.high; + return reg; + } + + static inline XMMReg2Double Min(const XMMReg2Double& expr1, const XMMReg2Double& expr2) + { + XMMReg2Double reg; + reg.low = (expr1.low < expr2.low) ? expr1.low : expr2.high; + reg.high = (expr1.high < expr2.high) ? expr1.high : expr2.low; + return reg; + } + + static inline XMMReg2Double Load2Val(const double* ptr) + { + XMMReg2Double reg; + reg.nsLoad2Val(ptr); + return reg; + } + + static inline XMMReg2Double Load2ValAligned(const double* ptr) + { + XMMReg2Double reg; + reg.nsLoad2ValAligned(ptr); + return reg; + } + + static inline XMMReg2Double Load2Val(const float* ptr) + { + XMMReg2Double reg; + reg.nsLoad2Val(ptr); + return reg; + } + + static inline XMMReg2Double Load2Val(const unsigned char* ptr) + { + XMMReg2Double reg; + reg.nsLoad2Val(ptr); + return reg; + } + + static inline XMMReg2Double Load2Val(const short* ptr) + { + XMMReg2Double reg; + reg.nsLoad2Val(ptr); + return reg; + } + + static inline XMMReg2Double Load2Val(const unsigned short* ptr) + { + XMMReg2Double reg; + reg.nsLoad2Val(ptr); + return reg; + } + + inline void nsLoad1ValHighAndLow(const double* pval) + { + low = pval[0]; + high = pval[0]; + } + + inline void nsLoad2Val(const double* pval) + { + low = pval[0]; + high = pval[1]; + } + + inline void nsLoad2ValAligned(const double* pval) + { + low = pval[0]; + high = pval[1]; + } + + inline void nsLoad2Val(const float* pval) + { + low = pval[0]; + high = pval[1]; + } + + inline void nsLoad2Val(const unsigned char* ptr) + { + low = ptr[0]; + high = ptr[1]; + } + + inline void nsLoad2Val(const short* ptr) + { + low = ptr[0]; + high = ptr[1]; + } + + inline void nsLoad2Val(const unsigned short* ptr) + { + low = ptr[0]; + high = ptr[1]; + } + + static inline void Load4Val(const unsigned char* ptr, XMMReg2Double& low, XMMReg2Double& high) + { + low.low = ptr[0]; + low.high = ptr[1]; + high.low = ptr[2]; + high.high = ptr[3]; + } + + static inline void Load4Val(const short* ptr, XMMReg2Double& low, XMMReg2Double& high) + { + low.nsLoad2Val(ptr); + high.nsLoad2Val(ptr+2); + } + + static inline void Load4Val(const unsigned short* ptr, XMMReg2Double& low, XMMReg2Double& high) + { + low.nsLoad2Val(ptr); + high.nsLoad2Val(ptr+2); + } + + static inline void Load4Val(const double* ptr, XMMReg2Double& low, XMMReg2Double& high) + { + low.nsLoad2Val(ptr); + high.nsLoad2Val(ptr+2); + } + + static inline void Load4Val(const float* ptr, XMMReg2Double& low, XMMReg2Double& high) + { + low.nsLoad2Val(ptr); + high.nsLoad2Val(ptr+2); + } + + inline void Zeroize() + { + low = 0.0; + high = 0.0; + } + + inline XMMReg2Double& operator= (const XMMReg2Double& other) + { + low = other.low; + high = other.high; + return *this; + } + + inline XMMReg2Double& operator+= (const XMMReg2Double& other) + { + low += other.low; + high += other.high; + return *this; + } + + inline XMMReg2Double& operator*= (const XMMReg2Double& other) + { + low *= other.low; + high *= other.high; + return *this; + } + + inline XMMReg2Double operator+ (const XMMReg2Double& other) const + { + XMMReg2Double ret; + ret.low = low + other.low; + ret.high = high + other.high; + return ret; + } + + inline XMMReg2Double operator- (const XMMReg2Double& other) const + { + XMMReg2Double ret; + ret.low = low - other.low; + ret.high = high - other.high; + return ret; + } + + inline XMMReg2Double operator* (const XMMReg2Double& other) const + { + XMMReg2Double ret; + ret.low = low * other.low; + ret.high = high * other.high; + return ret; + } + + inline XMMReg2Double operator/ (const XMMReg2Double& other) const + { + XMMReg2Double ret; + ret.low = low / other.low; + ret.high = high / other.high; + return ret; + } + + inline void AddLowAndHigh() + { + double add = low + high; + low = add; + high = add; + } + + inline void Store2Double(double* pval) const + { + pval[0] = low; + pval[1] = high; + } + + inline void Store2DoubleAligned(double* pval) const + { + pval[0] = low; + pval[1] = high; + } + + void Store2Val(unsigned short* ptr) const + { + ptr[0] = (GUInt16)low; + ptr[1] = (GUInt16)high; + } + + inline operator double () const + { + return low; + } +}; + +#endif /* defined(__x86_64) || defined(_M_X64) */ + +class XMMReg4Double +{ + public: + XMMReg2Double low, high; + + XMMReg4Double() {} + XMMReg4Double(const XMMReg4Double& other) : low(other.low), high(other.high) {} + + static inline XMMReg4Double Zero() + { + XMMReg4Double reg; + reg.low.Zeroize(); + reg.high.Zeroize(); + return reg; + } + + static inline XMMReg4Double Load1ValHighAndLow(const double* ptr) + { + XMMReg4Double reg; + reg.low.nsLoad1ValHighAndLow(ptr); + reg.high = reg.low; + return reg; + } + + static inline XMMReg4Double Load4Val(const unsigned char* ptr) + { + XMMReg4Double reg; + XMMReg2Double::Load4Val(ptr, reg.low, reg.high); + return reg; + } + + static inline XMMReg4Double Load4Val(const short* ptr) + { + XMMReg4Double reg; + reg.low.nsLoad2Val(ptr); + reg.high.nsLoad2Val(ptr+2); + return reg; + } + + static inline XMMReg4Double Load4Val(const unsigned short* ptr) + { + XMMReg4Double reg; + reg.low.nsLoad2Val(ptr); + reg.high.nsLoad2Val(ptr+2); + return reg; + } + + static inline XMMReg4Double Load4Val(const double* ptr) + { + XMMReg4Double reg; + reg.low.nsLoad2Val(ptr); + reg.high.nsLoad2Val(ptr+2); + return reg; + } + + static inline XMMReg4Double Load4ValAligned(const double* ptr) + { + XMMReg4Double reg; + reg.low.nsLoad2ValAligned(ptr); + reg.high.nsLoad2ValAligned(ptr+2); + return reg; + } + + static inline XMMReg4Double Load4Val(const float* ptr) + { + XMMReg4Double reg; + XMMReg2Double::Load4Val(ptr, reg.low, reg.high); + return reg; + } + + static inline XMMReg4Double Equals(const XMMReg4Double& expr1, const XMMReg4Double& expr2) + { + XMMReg4Double reg; + reg.low = XMMReg2Double::Equals(expr1.low, expr2.low); + reg.high = XMMReg2Double::Equals(expr1.high, expr2.high); + return reg; + } + + static inline XMMReg4Double NotEquals(const XMMReg4Double& expr1, const XMMReg4Double& expr2) + { + XMMReg4Double reg; + reg.low = XMMReg2Double::NotEquals(expr1.low, expr2.low); + reg.high = XMMReg2Double::NotEquals(expr1.high, expr2.high); + return reg; + } + + static inline XMMReg4Double Greater(const XMMReg4Double& expr1, const XMMReg4Double& expr2) + { + XMMReg4Double reg; + reg.low = XMMReg2Double::Greater(expr1.low, expr2.low); + reg.high = XMMReg2Double::Greater(expr1.high, expr2.high); + return reg; + } + + static inline XMMReg4Double And(const XMMReg4Double& expr1, const XMMReg4Double& expr2) + { + XMMReg4Double reg; + reg.low = XMMReg2Double::And(expr1.low, expr2.low); + reg.high = XMMReg2Double::And(expr1.high, expr2.high); + return reg; + } + + static inline XMMReg4Double Ternary(const XMMReg4Double& cond, const XMMReg4Double& true_expr, const XMMReg4Double& false_expr) + { + XMMReg4Double reg; + reg.low = XMMReg2Double::Ternary(cond.low, true_expr.low, false_expr.low); + reg.high = XMMReg2Double::Ternary(cond.high, true_expr.high, false_expr.high); + return reg; + } + + static inline XMMReg4Double Min(const XMMReg4Double& expr1, const XMMReg4Double& expr2) + { + XMMReg4Double reg; + reg.low = XMMReg2Double::Min(expr1.low, expr2.low); + reg.high = XMMReg2Double::Min(expr1.high, expr2.high); + return reg; + } + + inline XMMReg4Double& operator= (const XMMReg4Double& other) + { + low = other.low; + high = other.high; + return *this; + } + + inline XMMReg4Double& operator+= (const XMMReg4Double& other) + { + low += other.low; + high += other.high; + return *this; + } + + inline XMMReg4Double& operator*= (const XMMReg4Double& other) + { + low *= other.low; + high *= other.high; + return *this; + } + + inline XMMReg4Double operator+ (const XMMReg4Double& other) const + { + XMMReg4Double ret; + ret.low = low + other.low; + ret.high = high + other.high; + return ret; + } + + inline XMMReg4Double operator- (const XMMReg4Double& other) const + { + XMMReg4Double ret; + ret.low = low - other.low; + ret.high = high - other.high; + return ret; + } + + inline XMMReg4Double operator* (const XMMReg4Double& other) const + { + XMMReg4Double ret; + ret.low = low * other.low; + ret.high = high * other.high; + return ret; + } + + inline XMMReg4Double operator/ (const XMMReg4Double& other) const + { + XMMReg4Double ret; + ret.low = low / other.low; + ret.high = high / other.high; + return ret; + } + + inline void AddLowAndHigh() + { + low = low + high; + low.AddLowAndHigh(); + } + + inline XMMReg2Double& GetLow() + { + return low; + } + + inline XMMReg2Double& GetHigh() + { + return high; + } + + void Store4Val(unsigned short* ptr) const + { + low.Store2Val(ptr); + high.Store2Val(ptr+2); + } +}; + +#endif /* GDALSSE_PRIV_H_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/gdalwarper.h b/modules/globebrowsing/ext/gdal/include/gdalwarper.h new file mode 100644 index 0000000000..9d88ff8a51 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/gdalwarper.h @@ -0,0 +1,459 @@ +/****************************************************************************** + * $Id$ + * + * Project: GDAL High Performance Warper + * Purpose: Prototypes, and definitions for warping related work. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2003, Frank Warmerdam + * Copyright (c) 2009-2012, Even Rouault + * + * 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. + ****************************************************************************/ + +#ifndef GDALWARPER_H_INCLUDED +#define GDALWARPER_H_INCLUDED + +/** + * \file gdalwarper.h + * + * GDAL warper related entry points and definitions. Eventually it is + * expected that this file will be mostly private to the implementation, + * and the public C entry points will be available in gdal_alg.h. + */ + +#include "gdal_alg.h" +#include "cpl_minixml.h" +#include "cpl_multiproc.h" + +CPL_C_START + +/* Note: values are selected to be consistent with GDALRIOResampleAlg of gcore/gdal.h */ +/*! Warp Resampling Algorithm */ +typedef enum { + /*! Nearest neighbour (select on one input pixel) */ GRA_NearestNeighbour=0, + /*! Bilinear (2x2 kernel) */ GRA_Bilinear=1, + /*! Cubic Convolution Approximation (4x4 kernel) */ GRA_Cubic=2, + /*! Cubic B-Spline Approximation (4x4 kernel) */ GRA_CubicSpline=3, + /*! Lanczos windowed sinc interpolation (6x6 kernel) */ GRA_Lanczos=4, + /*! Average (computes the average of all non-NODATA contributing pixels) */ GRA_Average=5, + /*! Mode (selects the value which appears most often of all the sampled points) */ GRA_Mode=6, + // GRA_Gauss=7 reserved. + /*! Max (selects maximum of all non-NODATA contributing pixels) */ GRA_Max=8, + /*! Min (selects minimum of all non-NODATA contributing pixels) */ GRA_Min=9, + /*! Med (selects median of all non-NODATA contributing pixels) */ GRA_Med=10, + /*! Q1 (selects first quartile of all non-NODATA contributing pixels) */ GRA_Q1=11, + /*! Q3 (selects third quartile of all non-NODATA contributing pixels) */ GRA_Q3=12 +} GDALResampleAlg; + +/*! GWKAverageOrMode Algorithm */ +typedef enum { + /*! Average */ GWKAOM_Average=1, + /*! Mode */ GWKAOM_Fmode=2, + /*! Mode of GDT_Byte, GDT_UInt16, or GDT_Int16 */ GWKAOM_Imode=3, + /*! Maximum */ GWKAOM_Max=4, + /*! Minimum */ GWKAOM_Min=5, + /*! Quantile */ GWKAOM_Quant=6 +} GWKAverageOrModeAlg; + +typedef int +(*GDALMaskFunc)( void *pMaskFuncArg, + int nBandCount, GDALDataType eType, + int nXOff, int nYOff, + int nXSize, int nYSize, + GByte **papabyImageData, + int bMaskIsFloat, void *pMask ); + +CPLErr CPL_DLL +GDALWarpNoDataMasker( void *pMaskFuncArg, int nBandCount, GDALDataType eType, + int nXOff, int nYOff, int nXSize, int nYSize, + GByte **papabyImageData, int bMaskIsFloat, + void *pValidityMask, int* pbOutAllValid ); + +CPLErr CPL_DLL +GDALWarpDstAlphaMasker( void *pMaskFuncArg, int nBandCount, GDALDataType eType, + int nXOff, int nYOff, int nXSize, int nYSize, + GByte ** /*ppImageData */, + int bMaskIsFloat, void *pValidityMask ); +CPLErr CPL_DLL +GDALWarpSrcAlphaMasker( void *pMaskFuncArg, int nBandCount, GDALDataType eType, + int nXOff, int nYOff, int nXSize, int nYSize, + GByte ** /*ppImageData */, + int bMaskIsFloat, void *pValidityMask, int* pbOutAllOpaque ); + +CPLErr CPL_DLL +GDALWarpSrcMaskMasker( void *pMaskFuncArg, int nBandCount, GDALDataType eType, + int nXOff, int nYOff, int nXSize, int nYSize, + GByte ** /*ppImageData */, + int bMaskIsFloat, void *pValidityMask ); + +CPLErr CPL_DLL +GDALWarpCutlineMasker( void *pMaskFuncArg, int nBandCount, GDALDataType eType, + int nXOff, int nYOff, int nXSize, int nYSize, + GByte ** /* ppImageData */, + int bMaskIsFloat, void *pValidityMask ); + +/************************************************************************/ +/* GDALWarpOptions */ +/************************************************************************/ + +/** Warp control options for use with GDALWarpOperation::Initialize() */ +typedef struct { + + char **papszWarpOptions; + + /*! In bytes, 0.0 for internal default */ + double dfWarpMemoryLimit; + + /*! Resampling algorithm to use */ + GDALResampleAlg eResampleAlg; + + /*! data type to use during warp operation, GDT_Unknown lets the algorithm + select the type */ + GDALDataType eWorkingDataType; + + /*! Source image dataset. */ + GDALDatasetH hSrcDS; + + /*! Destination image dataset - may be NULL if only using GDALWarpOperation::WarpRegionToBuffer(). */ + GDALDatasetH hDstDS; + + /*! Number of bands to process, may be 0 to select all bands. */ + int nBandCount; + + /*! The band numbers for the source bands to process (1 based) */ + int *panSrcBands; + + /*! The band numbers for the destination bands to process (1 based) */ + int *panDstBands; + + /*! The source band so use as an alpha (transparency) value, 0=disabled */ + int nSrcAlphaBand; + + /*! The dest. band so use as an alpha (transparency) value, 0=disabled */ + int nDstAlphaBand; + + /*! The "nodata" value real component for each input band, if NULL there isn't one */ + double *padfSrcNoDataReal; + /*! The "nodata" value imaginary component - may be NULL even if real + component is provided. */ + double *padfSrcNoDataImag; + + /*! The "nodata" value real component for each output band, if NULL there isn't one */ + double *padfDstNoDataReal; + /*! The "nodata" value imaginary component - may be NULL even if real + component is provided. */ + double *padfDstNoDataImag; + + /*! GDALProgressFunc() compatible progress reporting function, or NULL + if there isn't one. */ + GDALProgressFunc pfnProgress; + + /*! Callback argument to be passed to pfnProgress. */ + void *pProgressArg; + + /*! Type of spatial point transformer function */ + GDALTransformerFunc pfnTransformer; + + /*! Handle to image transformer setup structure */ + void *pTransformerArg; + + GDALMaskFunc *papfnSrcPerBandValidityMaskFunc; + void **papSrcPerBandValidityMaskFuncArg; + + GDALMaskFunc pfnSrcValidityMaskFunc; + void *pSrcValidityMaskFuncArg; + + GDALMaskFunc pfnSrcDensityMaskFunc; + void *pSrcDensityMaskFuncArg; + + GDALMaskFunc pfnDstDensityMaskFunc; + void *pDstDensityMaskFuncArg; + + GDALMaskFunc pfnDstValidityMaskFunc; + void *pDstValidityMaskFuncArg; + + CPLErr (*pfnPreWarpChunkProcessor)( void *pKern, void *pArg ); + void *pPreWarpProcessorArg; + + CPLErr (*pfnPostWarpChunkProcessor)( void *pKern, void *pArg); + void *pPostWarpProcessorArg; + + /*! Optional OGRPolygonH for a masking cutline. */ + void *hCutline; + + /*! Optional blending distance to apply across cutline in pixels, default is zero. */ + double dfCutlineBlendDist; + +} GDALWarpOptions; + +GDALWarpOptions CPL_DLL * CPL_STDCALL GDALCreateWarpOptions(void); +void CPL_DLL CPL_STDCALL GDALDestroyWarpOptions( GDALWarpOptions * ); +GDALWarpOptions CPL_DLL * CPL_STDCALL +GDALCloneWarpOptions( const GDALWarpOptions * ); + +CPLXMLNode CPL_DLL * CPL_STDCALL + GDALSerializeWarpOptions( const GDALWarpOptions * ); +GDALWarpOptions CPL_DLL * CPL_STDCALL + GDALDeserializeWarpOptions( CPLXMLNode * ); + +/************************************************************************/ +/* GDALReprojectImage() */ +/************************************************************************/ + +CPLErr CPL_DLL CPL_STDCALL +GDALReprojectImage( GDALDatasetH hSrcDS, const char *pszSrcWKT, + GDALDatasetH hDstDS, const char *pszDstWKT, + GDALResampleAlg eResampleAlg, double dfWarpMemoryLimit, + double dfMaxError, + GDALProgressFunc pfnProgress, void *pProgressArg, + GDALWarpOptions *psOptions ); + +CPLErr CPL_DLL CPL_STDCALL +GDALCreateAndReprojectImage( GDALDatasetH hSrcDS, const char *pszSrcWKT, + const char *pszDstFilename, const char *pszDstWKT, + GDALDriverH hDstDriver, char **papszCreateOptions, + GDALResampleAlg eResampleAlg, double dfWarpMemoryLimit, + double dfMaxError, + GDALProgressFunc pfnProgress, void *pProgressArg, + GDALWarpOptions *psOptions ); + +/************************************************************************/ +/* VRTWarpedDataset */ +/************************************************************************/ + +GDALDatasetH CPL_DLL CPL_STDCALL +GDALAutoCreateWarpedVRT( GDALDatasetH hSrcDS, + const char *pszSrcWKT, const char *pszDstWKT, + GDALResampleAlg eResampleAlg, + double dfMaxError, const GDALWarpOptions *psOptions ); + +GDALDatasetH CPL_DLL CPL_STDCALL +GDALCreateWarpedVRT( GDALDatasetH hSrcDS, + int nPixels, int nLines, double *padfGeoTransform, + GDALWarpOptions *psOptions ); + +CPLErr CPL_DLL CPL_STDCALL +GDALInitializeWarpedVRT( GDALDatasetH hDS, + GDALWarpOptions *psWO ); + +CPL_C_END + +#ifdef __cplusplus + +/************************************************************************/ +/* GDALWarpKernel */ +/* */ +/* This class represents the lowest level of abstraction. It */ +/* is holds the imagery for one "chunk" of a warp, and the */ +/* pre-prepared masks. All IO is done before and after it's */ +/* operation. This class is not normally used by the */ +/* application. */ +/************************************************************************/ + +// This is the number of dummy pixels that must be reserved in source arrays +// in order to satisfy assumptions made in GWKResample(), and more specifically +// by GWKGetPixelRow() that always read a even number of pixels. So if we are +// in the situation to read the last pixel of the source array, we need 1 extra +// dummy pixel to avoid reading out of bounds. +#define WARP_EXTRA_ELTS 1 + +class CPL_DLL GDALWarpKernel +{ +public: + char **papszWarpOptions; + + GDALResampleAlg eResample; + GDALDataType eWorkingDataType; + int nBands; + + int nSrcXSize; + int nSrcYSize; + int nSrcXExtraSize; /* extra pixels (included in nSrcXSize) reserved for filter window. Should be ignored in scale computation */ + int nSrcYExtraSize; /* extra pixels (included in nSrcYSize) reserved for filter window. Should be ignored in scale computation */ + GByte **papabySrcImage; /* each subarray must have WARP_EXTRA_ELTS at the end */ + + GUInt32 **papanBandSrcValid; /* each subarray must have WARP_EXTRA_ELTS at the end */ + GUInt32 *panUnifiedSrcValid; /* must have WARP_EXTRA_ELTS at the end */ + float *pafUnifiedSrcDensity; /* must have WARP_EXTRA_ELTS at the end */ + + int nDstXSize; + int nDstYSize; + GByte **papabyDstImage; + GUInt32 *panDstValid; + float *pafDstDensity; + + double dfXScale; // Resampling scale, i.e. + double dfYScale; // nDstSize/nSrcSize. + double dfXFilter; // Size of filter kernel. + double dfYFilter; + int nXRadius; // Size of window to filter. + int nYRadius; + int nFiltInitX; // Filtering offset + int nFiltInitY; + + int nSrcXOff; + int nSrcYOff; + + int nDstXOff; + int nDstYOff; + + GDALTransformerFunc pfnTransformer; + void *pTransformerArg; + + GDALProgressFunc pfnProgress; + void *pProgress; + + double dfProgressBase; + double dfProgressScale; + + double *padfDstNoDataReal; + + void *psThreadData; + + GDALWarpKernel(); + virtual ~GDALWarpKernel(); + + CPLErr Validate(); + CPLErr PerformWarp(); +}; + +void* GWKThreadsCreate(char** papszWarpOptions, + GDALTransformerFunc pfnTransformer, + void* pTransformerArg); +void GWKThreadsEnd(void* psThreadDataIn); + +/************************************************************************/ +/* GDALWarpOperation() */ +/* */ +/* This object is application created, or created by a higher */ +/* level convenience function. It is responsible for */ +/* subdividing the operation into chunks, loading and saving */ +/* imagery, and establishing the varios validity and density */ +/* masks. Actual resampling is done by the GDALWarpKernel. */ +/************************************************************************/ + +typedef struct _GDALWarpChunk GDALWarpChunk; + +class CPL_DLL GDALWarpOperation { +private: + GDALWarpOptions *psOptions; + + void WipeOptions(); + int ValidateOptions(); + + CPLErr ComputeSourceWindow( int nDstXOff, int nDstYOff, + int nDstXSize, int nDstYSize, + int *pnSrcXOff, int *pnSrcYOff, + int *pnSrcXSize, int *pnSrcYSize, + int *pnSrcXExtraSize, int *pnSrcYExtraSize, + double* pdfSrcFillRatio ); + + CPLErr CreateKernelMask( GDALWarpKernel *, int iBand, + const char *pszType ); + + CPLMutex *hIOMutex; + CPLMutex *hWarpMutex; + + int nChunkListCount; + int nChunkListMax; + GDALWarpChunk *pasChunkList; + + int bReportTimings; + unsigned long nLastTimeReported; + + void *psThreadData; + + void WipeChunkList(); + CPLErr CollectChunkList( int nDstXOff, int nDstYOff, + int nDstXSize, int nDstYSize ); + void ReportTiming( const char * ); + +public: + GDALWarpOperation(); + virtual ~GDALWarpOperation(); + + CPLErr Initialize( const GDALWarpOptions *psNewOptions ); + + const GDALWarpOptions *GetOptions(); + + CPLErr ChunkAndWarpImage( int nDstXOff, int nDstYOff, + int nDstXSize, int nDstYSize ); + CPLErr ChunkAndWarpMulti( int nDstXOff, int nDstYOff, + int nDstXSize, int nDstYSize ); + CPLErr WarpRegion( int nDstXOff, int nDstYOff, + int nDstXSize, int nDstYSize, + int nSrcXOff=0, int nSrcYOff=0, + int nSrcXSize=0, int nSrcYSize=0, + double dfProgressBase=0.0, double dfProgressScale=1.0); + CPLErr WarpRegion( int nDstXOff, int nDstYOff, + int nDstXSize, int nDstYSize, + int nSrcXOff, int nSrcYOff, + int nSrcXSize, int nSrcYSize, + int nSrcXExtraSize, int nSrcYExtraSize, + double dfProgressBase, double dfProgressScale); + CPLErr WarpRegionToBuffer( int nDstXOff, int nDstYOff, + int nDstXSize, int nDstYSize, + void *pDataBuf, + GDALDataType eBufDataType, + int nSrcXOff=0, int nSrcYOff=0, + int nSrcXSize=0, int nSrcYSize=0, + double dfProgressBase=0.0, double dfProgressScale=1.0); + CPLErr WarpRegionToBuffer( int nDstXOff, int nDstYOff, + int nDstXSize, int nDstYSize, + void *pDataBuf, + GDALDataType eBufDataType, + int nSrcXOff, int nSrcYOff, + int nSrcXSize, int nSrcYSize, + int nSrcXExtraSize, int nSrcYExtraSize, + double dfProgressBase, double dfProgressScale); +}; + +#endif /* def __cplusplus */ + +CPL_C_START + +typedef void * GDALWarpOperationH; + +GDALWarpOperationH CPL_DLL GDALCreateWarpOperation(const GDALWarpOptions* ); +void CPL_DLL GDALDestroyWarpOperation( GDALWarpOperationH ); +CPLErr CPL_DLL GDALChunkAndWarpImage( GDALWarpOperationH, int, int, int, int ); +CPLErr CPL_DLL GDALChunkAndWarpMulti( GDALWarpOperationH, int, int, int, int ); +CPLErr CPL_DLL GDALWarpRegion( GDALWarpOperationH, + int, int, int, int, int, int, int, int ); +CPLErr CPL_DLL GDALWarpRegionToBuffer( GDALWarpOperationH, int, int, int, int, + void *, GDALDataType, + int, int, int, int ); + +/************************************************************************/ +/* Warping kernel functions */ +/************************************************************************/ + +int GWKGetFilterRadius(GDALResampleAlg eResampleAlg); + +typedef double (*FilterFuncType)(double dfX); +FilterFuncType GWKGetFilterFunc(GDALResampleAlg eResampleAlg); + +typedef double (*FilterFunc4ValuesType)(double* padfVals); +FilterFunc4ValuesType GWKGetFilterFunc4Values(GDALResampleAlg eResampleAlg); + +CPL_C_END + +#endif /* ndef GDAL_ALG_H_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/gdalwarpkernel_opencl.h b/modules/globebrowsing/ext/gdal/include/gdalwarpkernel_opencl.h new file mode 100644 index 0000000000..be3a1b32d7 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/gdalwarpkernel_opencl.h @@ -0,0 +1,197 @@ +/****************************************************************************** + * $Id$ + * + * Project: OpenCL Image Reprojector + * Purpose: Implementation of the GDALWarpKernel reprojector in OpenCL. + * Author: Seth Price, seth@pricepages.org + * + ****************************************************************************** + * Copyright (c) 2010, Seth Price + * + * 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. + ****************************************************************************/ + +#if defined(HAVE_OPENCL) + +/* The following relates to the profiling calls to + clSetCommandQueueProperty() which are not available by default + with some OpenCL implementation (i.e. ATI) */ + +#if defined(DEBUG_OPENCL) && DEBUG_OPENCL == 1 +#define CL_USE_DEPRECATED_OPENCL_1_0_APIS +#endif + +#ifdef __APPLE__ +#include +#else +#include +#endif + +#ifdef __cplusplus /* If this is a C++ compiler, use C linkage */ +extern "C" { +#endif + +typedef enum { + OCL_Bilinear=10, + OCL_Cubic=11, + OCL_CubicSpline=12, + OCL_Lanczos=13 +} OCLResampAlg; + +typedef enum +{ + VENDOR_OTHER, + VENDOR_AMD, + VENDOR_INTEL +} OCLVendor; + +struct oclWarper { + cl_command_queue queue; + cl_context context; + cl_device_id dev; + cl_kernel kern1; + cl_kernel kern4; + + int srcWidth; + int srcHeight; + int dstWidth; + int dstHeight; + + int useUnifiedSrcDensity; + int useUnifiedSrcValid; + int useDstDensity; + int useDstValid; + + int numBands; + int numImages; + OCLResampAlg resampAlg; + + cl_channel_type imageFormat; + cl_mem *realWorkCL; + union { + void **v; + char **c; + unsigned char **uc; + short **s; + unsigned short **us; + float **f; + } realWork; + + cl_mem *imagWorkCL; + union { + void **v; + char **c; + unsigned char **uc; + short **s; + unsigned short **us; + float **f; + } imagWork; + + cl_mem *dstRealWorkCL; + union { + void **v; + char **c; + unsigned char **uc; + short **s; + unsigned short **us; + float **f; + } dstRealWork; + + cl_mem *dstImagWorkCL; + union { + void **v; + char **c; + unsigned char **uc; + short **s; + unsigned short **us; + float **f; + } dstImagWork; + + unsigned int imgChSize1; + cl_channel_order imgChOrder1; + unsigned int imgChSize4; + cl_channel_order imgChOrder4; + char useVec; + + cl_mem useBandSrcValidCL; + char *useBandSrcValid; + + cl_mem nBandSrcValidCL; + float *nBandSrcValid; + + cl_mem xyWorkCL; + float *xyWork; + + int xyWidth; + int xyHeight; + int coordMult; + + unsigned int xyChSize; + cl_channel_order xyChOrder; + + cl_mem fDstNoDataRealCL; + float *fDstNoDataReal; + + OCLVendor eCLVendor; +}; + +struct oclWarper* GDALWarpKernelOpenCL_createEnv(int srcWidth, int srcHeight, + int dstWidth, int dstHeight, + cl_channel_type imageFormat, + int numBands, int coordMult, + int useImag, int useBandSrcValid, + float *fDstDensity, + double *dfDstNoDataReal, + OCLResampAlg resampAlg, cl_int *envErr); + +cl_int GDALWarpKernelOpenCL_setSrcValid(struct oclWarper *warper, + int *bandSrcValid, int bandNum); + +cl_int GDALWarpKernelOpenCL_setSrcImg(struct oclWarper *warper, void *imgData, + int bandNum); + +cl_int GDALWarpKernelOpenCL_setDstImg(struct oclWarper *warper, void *imgData, + int bandNum); + +cl_int GDALWarpKernelOpenCL_setCoordRow(struct oclWarper *warper, + double *rowSrcX, double *rowSrcY, + double srcXOff, double srcYOff, + int *success, int rowNum); + +cl_int GDALWarpKernelOpenCL_runResamp(struct oclWarper *warper, + float *unifiedSrcDensity, + unsigned int *unifiedSrcValid, + float *dstDensity, + unsigned int *dstValid, + double dfXScale, double dfYScale, + double dfXFilter, double dfYFilter, + int nXRadius, int nYRadius, + int nFiltInitX, int nFiltInitY); + +cl_int GDALWarpKernelOpenCL_getRow(struct oclWarper *warper, + void **rowReal, void **rowImag, + int rowNum, int bandNum); + +cl_int GDALWarpKernelOpenCL_deleteEnv(struct oclWarper *warper); + +#ifdef __cplusplus /* If this is a C++ compiler, end C linkage */ +} +#endif + +#endif /* defined(HAVE_OPENCL) */ diff --git a/modules/globebrowsing/ext/gdal/include/gvgcpfit.h b/modules/globebrowsing/ext/gdal/include/gvgcpfit.h new file mode 100644 index 0000000000..4496c5909c --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/gvgcpfit.h @@ -0,0 +1,94 @@ +#ifndef GVGCPFIT_H_INCLUDED +#define GVGCPFIT_H_INCLUDED + +#include "cpl_port.h" +#include "cpl_conv.h" +#include "cpl_error.h" + +#define EXTERNAL +#define LOCAL static + +#define SUCCESS 0 +#define ABORT -1 + + +/*------------------------ Start of file CURVEFIT.H -----------------------*/ + +/* +****************************************************************************** +* * +* CURVEFIT.H * +* ========= * +* * +* This file contains the function prototype for CURVEFIT.C. * +****************************************************************************** +*/ + + +#ifndef CURVEFIT_H +#define CURVEFIT_H + +/*- Function prototypes in CURVEFIT.C. -*/ + +EXTERNAL int svdfit(float x[], float y[], int ndata, + double a[], int ma, double **u, double **v, double w[], + double *chisq, void (*funcs)(double, double *, int)); + +EXTERNAL void svbksb(double **u, double w[], double **v, int m,int n, + double b[], double x[]); + +EXTERNAL void svdvar(double **v, int ma, double w[], double **cvm); + +EXTERNAL int svdcmp(double **a, int m, int n, double *w, double **v); + + +#endif + + +/*-------------------------- End of file CURVEFIT.H -----------------------*/ + + + + +/*----------------------------- FILE polyfit.h ----------------------------*/ +#ifndef POLYFIT_H +#define POLYFIT_H + +EXTERNAL int OneDPolyFit( double *rms_err, double *coeffs_array, + int fit_order, int no_samples, double *f_array, double *x_array ); + +EXTERNAL double OneDPolyEval( double *coeff, int order, double x ); + +EXTERNAL int TwoDPolyFit( double *rms_err, double *coeffs_array, + int fit_order, int no_samples, double *f_array, double *x_array, + double *y_array ); + +EXTERNAL double TwoDPolyEval( double *coeff, int order, double x, double y ); + +EXTERNAL int TwoDPolyGradFit( double *rms_err, double *coeffs_array, + int fit_order, int no_samples, double *gradxy_array, + double *x_array, double *y_array ); + +EXTERNAL void TwoDPolyGradEval(double *fgradx, double *fgrady, + double *coeff, int order, double x, double y); + +EXTERNAL void GetPolyInX (double *xcoeffs, double *xycoeffs, int order, + double y); + +EXTERNAL void GetPolyInY(double *ycoeffs, double *xycoeffs, int order, + double x); + +EXTERNAL int ThreeDPolyFit( double *rms_err, double *coeffs_array, + int fit_order, int no_samples, double *f_array, double *x_array, + double *y_array, double *z_array ); + +EXTERNAL double ThreeDPolyEval( double *coeff, int order, double x, double y, double z ); + + + +#endif /* POLYFIT_H */ + + +/*---------------------- End of FILE polyfit.h ----------------------------*/ + +#endif /* ndef _GVGCPFIT_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/internal_qhull_headers.h b/modules/globebrowsing/ext/gdal/include/internal_qhull_headers.h new file mode 100644 index 0000000000..61f2bf1d5b --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/internal_qhull_headers.h @@ -0,0 +1,1006 @@ +/****************************************************************************** + * + * Project: GDAL + * Purpose: Includes internal qhull headers + * Author: Even Rouault + * + ****************************************************************************** + * Copyright (c) 2015, Even Rouault + * + * 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. + *****************************************************************************/ + +#ifndef INTERNAL_QHULL_HEADERS_H +#define INTERNAL_QHULL_HEADERS_H + +#ifdef HAVE_GCC_SYSTEM_HEADER +#pragma GCC system_header +#endif + +#if defined(__MINGW64__) +/* See https://github.com/scipy/scipy/issues/3237 */ +/* This ensures that ptr_intT is a long lon on MinGW 64 */ +#define _MSC_VER 1 +#endif + +// To avoid issue with icc that defines a template in qhull_a.h +#if defined(__INTEL_COMPILER) +#define QHULL_OS_WIN +#endif + +/* Below a lot of renames and static definition of the symbols so as */ +/* to avoid "contaminating" with a potential external qhull */ +typedef struct setT gdal_setT; +typedef struct facetT gdal_facetT; +typedef struct vertexT gdal_vertexT; +typedef struct qhT gdal_qhT; +typedef struct ridgeT gdal_ridgeT; +#define gdal_realT double +#define gdal_pointT double +#define gdal_realT double +#define gdal_coordT double +#define gdal_boolT unsigned int + +#define qhmem gdal_qhmem +#define qh_rand_seed gdal_qh_rand_seed +#define qh_qh gdal_qh_qh +#define qh_qhstat gdal_qh_qhstat +#define qh_version gdal_qh_version +#define qhull_inuse gdal_qhull_inuse + +#define qh_compare_vertexpoint gdal_qh_compare_vertexpoint +static int qh_compare_vertexpoint(); + +#define qh_intcompare gdal_qh_intcompare + +#ifdef notdef + +Generated by the following Python script + manual cleaning of the result + +f = open('headers.txt') +for line in f.readlines(): + line = line[0:-1].strip() + if len(line) > 3 and line[0] != '#' and (line[-2:] == ');' or line[-1:] == ',') and \ + line.find('(') > 0 and line.find('=') < 0 and line.find('typedef') < 0 and line.find('are used by') < 0 and \ + line.find('&') < 0 and line.find('"') < 0 and line.find(' ') < line.find('('): + line = line[0:line.find('(')].strip() + last_star = line.rfind('*') + last_space = line.rfind(' ') + if last_star > last_space: + (type, name) = (line[0:last_star+1], line[last_star+1:]) + else: + (type, name) = (line[0:last_space], line[last_space+1:]) + type = type.strip() + print('#define %s gdal_%s' % (name, name)) + if type.find('void') != 0 and type.find('int') != 0 and type.find('char') != 0 and type.find('double') != 0 and type.find('unsigned') != 0: + type = 'gdal_' + type + print("static %s %s();" % (type, name)) +#endif + +#define qh_backnormal gdal_qh_backnormal +static void qh_backnormal(); +#define qh_distplane gdal_qh_distplane +static void qh_distplane(); +#define qh_findbest gdal_qh_findbest +static gdal_facetT * qh_findbest(); +#define qh_findbesthorizon gdal_qh_findbesthorizon +static gdal_facetT * qh_findbesthorizon(); +#define qh_findbestnew gdal_qh_findbestnew +static gdal_facetT * qh_findbestnew(); +#define qh_gausselim gdal_qh_gausselim +static void qh_gausselim(); +#define qh_getangle gdal_qh_getangle +static gdal_realT qh_getangle(); +#define qh_getcenter gdal_qh_getcenter +static gdal_pointT * qh_getcenter(); +#define qh_getcentrum gdal_qh_getcentrum +static gdal_pointT * qh_getcentrum(); +#define qh_getdistance gdal_qh_getdistance +static gdal_realT qh_getdistance(); +#define qh_normalize gdal_qh_normalize +static void qh_normalize(); +#define qh_normalize2 gdal_qh_normalize2 +static void qh_normalize2(); +#define qh_projectpoint gdal_qh_projectpoint +static gdal_pointT * qh_projectpoint(); +#define qh_setfacetplane gdal_qh_setfacetplane +static void qh_setfacetplane(); +#define qh_sethyperplane_det gdal_qh_sethyperplane_det +static void qh_sethyperplane_det(); +#define qh_sethyperplane_gauss gdal_qh_sethyperplane_gauss +static void qh_sethyperplane_gauss(); +#define qh_sharpnewfacets gdal_qh_sharpnewfacets +static gdal_boolT qh_sharpnewfacets(); +#define qh_copypoints gdal_qh_copypoints +static gdal_coordT * qh_copypoints(); +#define qh_crossproduct gdal_qh_crossproduct +static void qh_crossproduct(); +#define qh_determinant gdal_qh_determinant +static gdal_realT qh_determinant(); +#define qh_detjoggle gdal_qh_detjoggle +static gdal_realT qh_detjoggle(); +#define qh_detroundoff gdal_qh_detroundoff +static void qh_detroundoff(); +#define qh_detsimplex gdal_qh_detsimplex +static gdal_realT qh_detsimplex(); +#define qh_distnorm gdal_qh_distnorm +static gdal_realT qh_distnorm(); +#define qh_distround gdal_qh_distround +static gdal_realT qh_distround(); +#define qh_divzero gdal_qh_divzero +static gdal_realT qh_divzero(); +#define qh_facetarea gdal_qh_facetarea +static gdal_realT qh_facetarea(); +#define qh_facetarea_simplex gdal_qh_facetarea_simplex +static gdal_realT qh_facetarea_simplex(); +#define qh_facetcenter gdal_qh_facetcenter +static gdal_pointT * qh_facetcenter(); +#define qh_findgooddist gdal_qh_findgooddist +static gdal_facetT * qh_findgooddist(); +#define qh_getarea gdal_qh_getarea +static void qh_getarea(); +#define qh_gram_schmidt gdal_qh_gram_schmidt +static gdal_boolT qh_gram_schmidt(); +#define qh_inthresholds gdal_qh_inthresholds +static gdal_boolT qh_inthresholds(); +#define qh_joggleinput gdal_qh_joggleinput +static void qh_joggleinput(); +#define qh_maxabsval gdal_qh_maxabsval +static gdal_realT * qh_maxabsval(); +#define qh_maxmin gdal_qh_maxmin +static gdal_setT * qh_maxmin(); +#define qh_maxouter gdal_qh_maxouter +static gdal_realT qh_maxouter(); +#define qh_maxsimplex gdal_qh_maxsimplex +static void qh_maxsimplex(); +#define qh_minabsval gdal_qh_minabsval +static gdal_realT qh_minabsval(); +#define qh_mindiff gdal_qh_mindiff +static int qh_mindiff(); +#define qh_orientoutside gdal_qh_orientoutside +static gdal_boolT qh_orientoutside(); +#define qh_outerinner gdal_qh_outerinner +static void qh_outerinner(); +#define qh_pointdist gdal_qh_pointdist +static gdal_coordT qh_pointdist(); +#define qh_printmatrix gdal_qh_printmatrix +static void qh_printmatrix(); +#define qh_printpoints gdal_qh_printpoints +static void qh_printpoints(); +#define qh_projectinput gdal_qh_projectinput +static void qh_projectinput(); +#define qh_projectpoints gdal_qh_projectpoints +static void qh_projectpoints(); +#define qh_rotateinput gdal_qh_rotateinput +static void qh_rotateinput(); +#define qh_rotatepoints gdal_qh_rotatepoints +static void qh_rotatepoints(); +#define qh_scaleinput gdal_qh_scaleinput +static void qh_scaleinput(); +#define qh_scalelast gdal_qh_scalelast +static void qh_scalelast(); +#define qh_scalepoints gdal_qh_scalepoints +static void qh_scalepoints(); +#define qh_sethalfspace gdal_qh_sethalfspace +static gdal_boolT qh_sethalfspace(); +#define qh_sethalfspace_all gdal_qh_sethalfspace_all +static gdal_coordT * qh_sethalfspace_all(); +#define qh_voronoi_center gdal_qh_voronoi_center +static gdal_pointT * qh_voronoi_center(); +#define dfacet gdal_dfacet +static void dfacet(); +#define dvertex gdal_dvertex +static void dvertex(); +#define qh_compare_facetarea gdal_qh_compare_facetarea +static int qh_compare_facetarea(); +#define qh_compare_facetmerge gdal_qh_compare_facetmerge +static int qh_compare_facetmerge(); +#define qh_compare_facetvisit gdal_qh_compare_facetvisit +static int qh_compare_facetvisit(); +#define qh_copyfilename gdal_qh_copyfilename +static void qh_copyfilename(); +#define qh_countfacets gdal_qh_countfacets +static void qh_countfacets(); +#define qh_detvnorm gdal_qh_detvnorm +static gdal_pointT * qh_detvnorm(); +#define qh_detvridge gdal_qh_detvridge +static gdal_setT * qh_detvridge(); +#define qh_detvridge3 gdal_qh_detvridge3 +static gdal_setT * qh_detvridge3(); +#define qh_eachvoronoi gdal_qh_eachvoronoi +static int qh_eachvoronoi(); +#define qh_eachvoronoi_all gdal_qh_eachvoronoi_all +static int qh_eachvoronoi_all(); +#define qh_facet2point gdal_qh_facet2point +static void qh_facet2point(); +#define qh_facetvertices gdal_qh_facetvertices +static gdal_setT * qh_facetvertices(); +#define qh_geomplanes gdal_qh_geomplanes +static void qh_geomplanes(); +#define qh_markkeep gdal_qh_markkeep +static void qh_markkeep(); +#define qh_markvoronoi gdal_qh_markvoronoi +static gdal_setT * qh_markvoronoi(); +#define qh_order_vertexneighbors gdal_qh_order_vertexneighbors +static void qh_order_vertexneighbors(); +#define qh_prepare_output gdal_qh_prepare_output +static void qh_prepare_output(); +#define qh_printafacet gdal_qh_printafacet +static void qh_printafacet(); +#define qh_printbegin gdal_qh_printbegin +static void qh_printbegin(); +#define qh_printcenter gdal_qh_printcenter +static void qh_printcenter(); +#define qh_printcentrum gdal_qh_printcentrum +static void qh_printcentrum(); +#define qh_printend gdal_qh_printend +static void qh_printend(); +#define qh_printend4geom gdal_qh_printend4geom +static void qh_printend4geom(); +#define qh_printextremes gdal_qh_printextremes +static void qh_printextremes(); +#define qh_printextremes_2d gdal_qh_printextremes_2d +static void qh_printextremes_2d(); +#define qh_printextremes_d gdal_qh_printextremes_d +static void qh_printextremes_d(); +#define qh_printfacet gdal_qh_printfacet +static void qh_printfacet(); +#define qh_printfacet2math gdal_qh_printfacet2math +static void qh_printfacet2math(); +#define qh_printfacet2geom gdal_qh_printfacet2geom +static void qh_printfacet2geom(); +#define qh_printfacet2geom_points gdal_qh_printfacet2geom_points +static void qh_printfacet2geom_points(); +#define qh_printfacet3math gdal_qh_printfacet3math +static void qh_printfacet3math(); +#define qh_printfacet3geom_nonsimplicial gdal_qh_printfacet3geom_nonsimplicial +static void qh_printfacet3geom_nonsimplicial(); +#define qh_printfacet3geom_points gdal_qh_printfacet3geom_points +static void qh_printfacet3geom_points(); +#define qh_printfacet3geom_simplicial gdal_qh_printfacet3geom_simplicial +static void qh_printfacet3geom_simplicial(); +#define qh_printfacet3vertex gdal_qh_printfacet3vertex +static void qh_printfacet3vertex(); +#define qh_printfacet4geom_nonsimplicial gdal_qh_printfacet4geom_nonsimplicial +static void qh_printfacet4geom_nonsimplicial(); +#define qh_printfacet4geom_simplicial gdal_qh_printfacet4geom_simplicial +static void qh_printfacet4geom_simplicial(); +#define qh_printfacetNvertex_nonsimplicial gdal_qh_printfacetNvertex_nonsimplicial +static void qh_printfacetNvertex_nonsimplicial(); +#define qh_printfacetNvertex_simplicial gdal_qh_printfacetNvertex_simplicial +static void qh_printfacetNvertex_simplicial(); +#define qh_printfacetheader gdal_qh_printfacetheader +static void qh_printfacetheader(); +#define qh_printfacetridges gdal_qh_printfacetridges +static void qh_printfacetridges(); +#define qh_printfacets gdal_qh_printfacets +static void qh_printfacets(); +#define qh_printhyperplaneintersection gdal_qh_printhyperplaneintersection +static void qh_printhyperplaneintersection(); +#define qh_printneighborhood gdal_qh_printneighborhood +static void qh_printneighborhood(); +#define qh_printline3geom gdal_qh_printline3geom +static void qh_printline3geom(); +#define qh_printpoint gdal_qh_printpoint +static void qh_printpoint(); +#define qh_printpointid gdal_qh_printpointid +static void qh_printpointid(); +#define qh_printpoint3 gdal_qh_printpoint3 +static void qh_printpoint3(); +#define qh_printpoints_out gdal_qh_printpoints_out +static void qh_printpoints_out(); +#define qh_printpointvect gdal_qh_printpointvect +static void qh_printpointvect(); +#define qh_printpointvect2 gdal_qh_printpointvect2 +static void qh_printpointvect2(); +#define qh_printridge gdal_qh_printridge +static void qh_printridge(); +#define qh_printspheres gdal_qh_printspheres +static void qh_printspheres(); +#define qh_printvdiagram gdal_qh_printvdiagram +static void qh_printvdiagram(); +#define qh_printvdiagram2 gdal_qh_printvdiagram2 +static int qh_printvdiagram2(); +#define qh_printvertex gdal_qh_printvertex +static void qh_printvertex(); +#define qh_printvertexlist gdal_qh_printvertexlist +static void qh_printvertexlist(); +#define qh_printvertices gdal_qh_printvertices +static void qh_printvertices(); +#define qh_printvneighbors gdal_qh_printvneighbors +static void qh_printvneighbors(); +#define qh_printvoronoi gdal_qh_printvoronoi +static void qh_printvoronoi(); +#define qh_printvnorm gdal_qh_printvnorm +static void qh_printvnorm(); +#define qh_printvridge gdal_qh_printvridge +static void qh_printvridge(); +#define qh_produce_output gdal_qh_produce_output +static void qh_produce_output(); +#define qh_produce_output2 gdal_qh_produce_output2 +static void qh_produce_output2(); +#define qh_projectdim3 gdal_qh_projectdim3 +static void qh_projectdim3(); +#define qh_readfeasible gdal_qh_readfeasible +static int qh_readfeasible(); +#define qh_readpoints gdal_qh_readpoints +static gdal_coordT * qh_readpoints(); +#define qh_setfeasible gdal_qh_setfeasible +static void qh_setfeasible(); +#define qh_skipfacet gdal_qh_skipfacet +static gdal_boolT qh_skipfacet(); +#define qh_skipfilename gdal_qh_skipfilename +static char * qh_skipfilename(); +#define qh_qhull gdal_qh_qhull +static void qh_qhull(); +#define qh_addpoint gdal_qh_addpoint +static gdal_boolT qh_addpoint(); +#define qh_printsummary gdal_qh_printsummary +static void qh_printsummary(); +#define qh_errexit gdal_qh_errexit +static void qh_errexit(); +#define qh_errprint gdal_qh_errprint +static void qh_errprint(); +#define qh_new_qhull gdal_qh_new_qhull +static int qh_new_qhull(); +#define qh_printfacetlist gdal_qh_printfacetlist +static void qh_printfacetlist(); +#define qh_printhelp_degenerate gdal_qh_printhelp_degenerate +static void qh_printhelp_degenerate(); +#define qh_printhelp_narrowhull gdal_qh_printhelp_narrowhull +static void qh_printhelp_narrowhull(); +#define qh_printhelp_singular gdal_qh_printhelp_singular +static void qh_printhelp_singular(); +#define qh_user_memsizes gdal_qh_user_memsizes +static void qh_user_memsizes(); +#define qh_exit gdal_qh_exit +static void qh_exit(); +#define qh_free gdal_qh_free +static void qh_free(); +#define qh_malloc gdal_qh_malloc +static void * qh_malloc(); +#define qh_fprintf gdal_qh_fprintf +static void qh_fprintf(FILE *fp, int msgcode, const char *fmt, ... ); +/*#define qh_fprintf_rbox gdal_qh_fprintf_rbox*/ +/*static void qh_fprintf_rbox(FILE *fp, int msgcode, const char *fmt, ... );*/ +#define qh_findbest gdal_qh_findbest +static gdal_facetT * qh_findbest(); +#define qh_findbestnew gdal_qh_findbestnew +static gdal_facetT * qh_findbestnew(); +#define qh_gram_schmidt gdal_qh_gram_schmidt +static gdal_boolT qh_gram_schmidt(); +#define qh_outerinner gdal_qh_outerinner +static void qh_outerinner(); +#define qh_printsummary gdal_qh_printsummary +static void qh_printsummary(); +#define qh_projectinput gdal_qh_projectinput +static void qh_projectinput(); +#define qh_randommatrix gdal_qh_randommatrix +static void qh_randommatrix(); +#define qh_rotateinput gdal_qh_rotateinput +static void qh_rotateinput(); +#define qh_scaleinput gdal_qh_scaleinput +static void qh_scaleinput(); +#define qh_setdelaunay gdal_qh_setdelaunay +static void qh_setdelaunay(); +#define qh_sethalfspace_all gdal_qh_sethalfspace_all +static gdal_coordT * qh_sethalfspace_all(); +#define qh_clock gdal_qh_clock +static unsigned long qh_clock(); +#define qh_checkflags gdal_qh_checkflags +static void qh_checkflags(); +#define qh_clear_outputflags gdal_qh_clear_outputflags +static void qh_clear_outputflags(); +#define qh_freebuffers gdal_qh_freebuffers +static void qh_freebuffers(); +#define qh_freeqhull gdal_qh_freeqhull +static void qh_freeqhull(); +#define qh_freeqhull2 gdal_qh_freeqhull2 +static void qh_freeqhull2(); +#define qh_init_A gdal_qh_init_A +static void qh_init_A(); +#define qh_init_B gdal_qh_init_B +static void qh_init_B(); +#define qh_init_qhull_command gdal_qh_init_qhull_command +static void qh_init_qhull_command(); +/*#define qh_initbuffers gdal_qh_initbuffers*/ +/*static void qh_initbuffers();*/ +#define qh_initflags gdal_qh_initflags +static void qh_initflags(); +#define qh_initqhull_buffers gdal_qh_initqhull_buffers +static void qh_initqhull_buffers(); +#define qh_initqhull_globals gdal_qh_initqhull_globals +static void qh_initqhull_globals(); +#define qh_initqhull_mem gdal_qh_initqhull_mem +static void qh_initqhull_mem(); +#define qh_initqhull_outputflags gdal_qh_initqhull_outputflags +static void qh_initqhull_outputflags(); +#define qh_initqhull_start gdal_qh_initqhull_start +static void qh_initqhull_start(); +#define qh_initqhull_start2 gdal_qh_initqhull_start2 +static void qh_initqhull_start2(); +#define qh_initthresholds gdal_qh_initthresholds +static void qh_initthresholds(); +#define qh_option gdal_qh_option +static void qh_option(); +/*#define qh_restore_qhull gdal_qh_restore_qhull*/ +/*static void qh_restore_qhull();*/ +/*#define qh_save_qhull gdal_qh_save_qhull*/ +/*static gdal_qhT * qh_save_qhull();*/ +#define dfacet gdal_dfacet +static void dfacet(); +#define dvertex gdal_dvertex +static void dvertex(); +#define qh_printneighborhood gdal_qh_printneighborhood +static void qh_printneighborhood(); +#define qh_produce_output gdal_qh_produce_output +static void qh_produce_output(); +#define qh_readpoints gdal_qh_readpoints +static gdal_coordT * qh_readpoints(); +#define qh_meminit gdal_qh_meminit +static void qh_meminit(); +#define qh_memfreeshort gdal_qh_memfreeshort +static void qh_memfreeshort(); +#define qh_check_output gdal_qh_check_output +static void qh_check_output(); +#define qh_check_points gdal_qh_check_points +static void qh_check_points(); +#define qh_facetvertices gdal_qh_facetvertices +static gdal_setT * qh_facetvertices(); +#define qh_findbestfacet gdal_qh_findbestfacet +static gdal_facetT * qh_findbestfacet(); +#define qh_nearvertex gdal_qh_nearvertex +static gdal_vertexT * qh_nearvertex(); +#define qh_point gdal_qh_point +static gdal_pointT * qh_point(); +#define qh_pointfacet gdal_qh_pointfacet +static gdal_setT * qh_pointfacet(); +#define qh_pointid gdal_qh_pointid +static int qh_pointid(); +#define qh_pointvertex gdal_qh_pointvertex +static gdal_setT * qh_pointvertex(); +#define qh_setvoronoi_all gdal_qh_setvoronoi_all +static void qh_setvoronoi_all(); +#define qh_triangulate gdal_qh_triangulate +static void qh_triangulate(); +/*#define qh_rboxpoints gdal_qh_rboxpoints*/ +/*static int qh_rboxpoints();*/ +/*#define qh_errexit_rbox gdal_qh_errexit_rbox*/ +/*static void qh_errexit_rbox();*/ +#define qh_collectstatistics gdal_qh_collectstatistics +static void qh_collectstatistics(); +#define qh_printallstatistics gdal_qh_printallstatistics +static void qh_printallstatistics(); +/*#define machines gdal_machines*/ +/*static gdal_of machines();*/ +#define qh_memalloc gdal_qh_memalloc +static void * qh_memalloc(); +#define qh_memfree gdal_qh_memfree +static void qh_memfree(); +#define qh_memfreeshort gdal_qh_memfreeshort +static void qh_memfreeshort(); +#define qh_meminit gdal_qh_meminit +static void qh_meminit(); +#define qh_meminitbuffers gdal_qh_meminitbuffers +static void qh_meminitbuffers(); +#define qh_memsetup gdal_qh_memsetup +static void qh_memsetup(); +#define qh_memsize gdal_qh_memsize +static void qh_memsize(); +#define qh_memstatistics gdal_qh_memstatistics +static void qh_memstatistics(); +#define qh_memtotal gdal_qh_memtotal +static void qh_memtotal(); +/*#define qh_mergefacet gdal_qh_mergefacet*/ +/*static gdal_if qh_mergefacet();*/ +#define qh_premerge gdal_qh_premerge +static void qh_premerge(); +#define qh_postmerge gdal_qh_postmerge +static void qh_postmerge(); +#define qh_all_merges gdal_qh_all_merges +static void qh_all_merges(); +#define qh_appendmergeset gdal_qh_appendmergeset +static void qh_appendmergeset(); +#define qh_basevertices gdal_qh_basevertices +static gdal_setT * qh_basevertices(); +#define qh_checkconnect gdal_qh_checkconnect +static void qh_checkconnect(); +#define qh_checkzero gdal_qh_checkzero +static gdal_boolT qh_checkzero(); +#define qh_compareangle gdal_qh_compareangle +static int qh_compareangle(); +#define qh_comparemerge gdal_qh_comparemerge +static int qh_comparemerge(); +#define qh_comparevisit gdal_qh_comparevisit +static int qh_comparevisit(); +#define qh_copynonconvex gdal_qh_copynonconvex +static void qh_copynonconvex(); +#define qh_degen_redundant_facet gdal_qh_degen_redundant_facet +static void qh_degen_redundant_facet(); +#define qh_degen_redundant_neighbors gdal_qh_degen_redundant_neighbors +static void qh_degen_redundant_neighbors(); +#define qh_find_newvertex gdal_qh_find_newvertex +static gdal_vertexT * qh_find_newvertex(); +#define qh_findbest_test gdal_qh_findbest_test +static void qh_findbest_test(); +#define qh_findbestneighbor gdal_qh_findbestneighbor +static gdal_facetT * qh_findbestneighbor(); +#define qh_flippedmerges gdal_qh_flippedmerges +static void qh_flippedmerges(); +#define qh_forcedmerges gdal_qh_forcedmerges +static void qh_forcedmerges(); +#define qh_getmergeset gdal_qh_getmergeset +static void qh_getmergeset(); +#define qh_getmergeset_initial gdal_qh_getmergeset_initial +static void qh_getmergeset_initial(); +#define qh_hashridge gdal_qh_hashridge +static void qh_hashridge(); +#define qh_hashridge_find gdal_qh_hashridge_find +static gdal_ridgeT * qh_hashridge_find(); +#define qh_makeridges gdal_qh_makeridges +static void qh_makeridges(); +#define qh_mark_dupridges gdal_qh_mark_dupridges +static void qh_mark_dupridges(); +#define qh_maydropneighbor gdal_qh_maydropneighbor +static void qh_maydropneighbor(); +#define qh_merge_degenredundant gdal_qh_merge_degenredundant +static int qh_merge_degenredundant(); +#define qh_merge_nonconvex gdal_qh_merge_nonconvex +static void qh_merge_nonconvex(); +#define qh_mergecycle gdal_qh_mergecycle +static void qh_mergecycle(); +#define qh_mergecycle_all gdal_qh_mergecycle_all +static void qh_mergecycle_all(); +#define qh_mergecycle_facets gdal_qh_mergecycle_facets +static void qh_mergecycle_facets(); +#define qh_mergecycle_neighbors gdal_qh_mergecycle_neighbors +static void qh_mergecycle_neighbors(); +#define qh_mergecycle_ridges gdal_qh_mergecycle_ridges +static void qh_mergecycle_ridges(); +#define qh_mergecycle_vneighbors gdal_qh_mergecycle_vneighbors +static void qh_mergecycle_vneighbors(); +#define qh_mergefacet gdal_qh_mergefacet +static void qh_mergefacet(); +#define qh_mergefacet2d gdal_qh_mergefacet2d +static void qh_mergefacet2d(); +#define qh_mergeneighbors gdal_qh_mergeneighbors +static void qh_mergeneighbors(); +#define qh_mergeridges gdal_qh_mergeridges +static void qh_mergeridges(); +#define qh_mergesimplex gdal_qh_mergesimplex +static void qh_mergesimplex(); +#define qh_mergevertex_del gdal_qh_mergevertex_del +static void qh_mergevertex_del(); +#define qh_mergevertex_neighbors gdal_qh_mergevertex_neighbors +static void qh_mergevertex_neighbors(); +#define qh_mergevertices gdal_qh_mergevertices +static void qh_mergevertices(); +#define qh_neighbor_intersections gdal_qh_neighbor_intersections +static gdal_setT * qh_neighbor_intersections(); +#define qh_newvertices gdal_qh_newvertices +static void qh_newvertices(); +#define qh_reducevertices gdal_qh_reducevertices +static gdal_boolT qh_reducevertices(); +#define qh_redundant_vertex gdal_qh_redundant_vertex +static gdal_vertexT * qh_redundant_vertex(); +#define qh_remove_extravertices gdal_qh_remove_extravertices +static gdal_boolT qh_remove_extravertices(); +#define qh_rename_sharedvertex gdal_qh_rename_sharedvertex +static gdal_vertexT * qh_rename_sharedvertex(); +#define qh_renameridgevertex gdal_qh_renameridgevertex +static void qh_renameridgevertex(); +#define qh_renamevertex gdal_qh_renamevertex +static void qh_renamevertex(); +#define qh_test_appendmerge gdal_qh_test_appendmerge +static gdal_boolT qh_test_appendmerge(); +#define qh_test_vneighbors gdal_qh_test_vneighbors +static gdal_boolT qh_test_vneighbors(); +#define qh_tracemerge gdal_qh_tracemerge +static void qh_tracemerge(); +#define qh_tracemerging gdal_qh_tracemerging +static void qh_tracemerging(); +#define qh_updatetested gdal_qh_updatetested +static void qh_updatetested(); +#define qh_vertexridges gdal_qh_vertexridges +static gdal_setT * qh_vertexridges(); +#define qh_vertexridges_facet gdal_qh_vertexridges_facet +static void qh_vertexridges_facet(); +#define qh_willdelete gdal_qh_willdelete +static void qh_willdelete(); +#define qh_appendfacet gdal_qh_appendfacet +static void qh_appendfacet(); +#define qh_appendvertex gdal_qh_appendvertex +static void qh_appendvertex(); +#define qh_attachnewfacets gdal_qh_attachnewfacets +static void qh_attachnewfacets(); +#define qh_checkflipped gdal_qh_checkflipped +static gdal_boolT qh_checkflipped(); +#define qh_delfacet gdal_qh_delfacet +static void qh_delfacet(); +#define qh_deletevisible gdal_qh_deletevisible +static void qh_deletevisible(); +#define qh_facetintersect gdal_qh_facetintersect +static gdal_setT * qh_facetintersect(); +#define qh_gethash gdal_qh_gethash +static int qh_gethash(); +#define qh_makenewfacet gdal_qh_makenewfacet +static gdal_facetT * qh_makenewfacet(); +#define qh_makenewplanes gdal_qh_makenewplanes +static void qh_makenewplanes(); +#define qh_makenew_nonsimplicial gdal_qh_makenew_nonsimplicial +static gdal_facetT * qh_makenew_nonsimplicial(); +#define qh_makenew_simplicial gdal_qh_makenew_simplicial +static gdal_facetT * qh_makenew_simplicial(); +#define qh_matchneighbor gdal_qh_matchneighbor +static void qh_matchneighbor(); +#define qh_matchnewfacets gdal_qh_matchnewfacets +static void qh_matchnewfacets(); +#define qh_matchvertices gdal_qh_matchvertices +static gdal_boolT qh_matchvertices(); +#define qh_newfacet gdal_qh_newfacet +static gdal_facetT * qh_newfacet(); +#define qh_newridge gdal_qh_newridge +static gdal_ridgeT * qh_newridge(); +#define qh_pointid gdal_qh_pointid +static int qh_pointid(); +#define qh_removefacet gdal_qh_removefacet +static void qh_removefacet(); +#define qh_removevertex gdal_qh_removevertex +static void qh_removevertex(); +#define qh_updatevertices gdal_qh_updatevertices +static void qh_updatevertices(); +#define qh_addhash gdal_qh_addhash +static void qh_addhash(); +#define qh_check_bestdist gdal_qh_check_bestdist +static void qh_check_bestdist(); +#define qh_check_maxout gdal_qh_check_maxout +static void qh_check_maxout(); +#define qh_check_output gdal_qh_check_output +static void qh_check_output(); +#define qh_check_point gdal_qh_check_point +static void qh_check_point(); +#define qh_check_points gdal_qh_check_points +static void qh_check_points(); +#define qh_checkconvex gdal_qh_checkconvex +static void qh_checkconvex(); +#define qh_checkfacet gdal_qh_checkfacet +static void qh_checkfacet(); +#define qh_checkflipped_all gdal_qh_checkflipped_all +static void qh_checkflipped_all(); +#define qh_checkpolygon gdal_qh_checkpolygon +static void qh_checkpolygon(); +#define qh_checkvertex gdal_qh_checkvertex +static void qh_checkvertex(); +#define qh_clearcenters gdal_qh_clearcenters +static void qh_clearcenters(); +#define qh_createsimplex gdal_qh_createsimplex +static void qh_createsimplex(); +#define qh_delridge gdal_qh_delridge +static void qh_delridge(); +#define qh_delvertex gdal_qh_delvertex +static void qh_delvertex(); +#define qh_facet3vertex gdal_qh_facet3vertex +static gdal_setT * qh_facet3vertex(); +#define qh_findbestfacet gdal_qh_findbestfacet +static gdal_facetT * qh_findbestfacet(); +#define qh_findbestlower gdal_qh_findbestlower +static gdal_facetT * qh_findbestlower(); +#define qh_findfacet_all gdal_qh_findfacet_all +static gdal_facetT * qh_findfacet_all(); +#define qh_findgood gdal_qh_findgood +static int qh_findgood(); +#define qh_findgood_all gdal_qh_findgood_all +static void qh_findgood_all(); +#define qh_furthestnext gdal_qh_furthestnext +static void qh_furthestnext(); +#define qh_furthestout gdal_qh_furthestout +static void qh_furthestout(); +#define qh_infiniteloop gdal_qh_infiniteloop +static void qh_infiniteloop(); +#define qh_initbuild gdal_qh_initbuild +static void qh_initbuild(); +#define qh_initialhull gdal_qh_initialhull +static void qh_initialhull(); +#define qh_initialvertices gdal_qh_initialvertices +static gdal_setT * qh_initialvertices(); +#define qh_isvertex gdal_qh_isvertex +static gdal_vertexT * qh_isvertex(); +#define qh_makenewfacets gdal_qh_makenewfacets +static gdal_vertexT * qh_makenewfacets(); +#define qh_matchduplicates gdal_qh_matchduplicates +static void qh_matchduplicates(); +#define qh_nearcoplanar gdal_qh_nearcoplanar +static void qh_nearcoplanar(); +#define qh_nearvertex gdal_qh_nearvertex +static gdal_vertexT * qh_nearvertex(); +#define qh_newhashtable gdal_qh_newhashtable +static int qh_newhashtable(); +#define qh_newvertex gdal_qh_newvertex +static gdal_vertexT * qh_newvertex(); +#define qh_nextridge3d gdal_qh_nextridge3d +static gdal_ridgeT * qh_nextridge3d(); +#define qh_outcoplanar gdal_qh_outcoplanar +static void qh_outcoplanar(); +#define qh_point gdal_qh_point +static gdal_pointT * qh_point(); +#define qh_point_add gdal_qh_point_add +static void qh_point_add(); +#define qh_pointfacet gdal_qh_pointfacet +static gdal_setT * qh_pointfacet(); +#define qh_pointvertex gdal_qh_pointvertex +static gdal_setT * qh_pointvertex(); +#define qh_prependfacet gdal_qh_prependfacet +static void qh_prependfacet(); +#define qh_printhashtable gdal_qh_printhashtable +static void qh_printhashtable(); +#define qh_printlists gdal_qh_printlists +static void qh_printlists(); +#define qh_resetlists gdal_qh_resetlists +static void qh_resetlists(); +#define qh_setvoronoi_all gdal_qh_setvoronoi_all +static void qh_setvoronoi_all(); +#define qh_triangulate gdal_qh_triangulate +static void qh_triangulate(); +#define qh_triangulate_facet gdal_qh_triangulate_facet +static void qh_triangulate_facet(); +#define qh_triangulate_link gdal_qh_triangulate_link +static void qh_triangulate_link(); +#define qh_triangulate_mirror gdal_qh_triangulate_mirror +static void qh_triangulate_mirror(); +#define qh_triangulate_null gdal_qh_triangulate_null +static void qh_triangulate_null(); +#define qh_vertexintersect gdal_qh_vertexintersect +static void qh_vertexintersect(); +#define qh_vertexintersect_new gdal_qh_vertexintersect_new +static gdal_setT * qh_vertexintersect_new(); +#define qh_vertexneighbors gdal_qh_vertexneighbors +static void qh_vertexneighbors(); +#define qh_vertexsubset gdal_qh_vertexsubset +static gdal_boolT qh_vertexsubset(); +#define qh_qhull gdal_qh_qhull +static void qh_qhull(); +#define qh_addpoint gdal_qh_addpoint +static gdal_boolT qh_addpoint(); +#define qh_buildhull gdal_qh_buildhull +static void qh_buildhull(); +#define qh_buildtracing gdal_qh_buildtracing +static void qh_buildtracing(); +#define qh_build_withrestart gdal_qh_build_withrestart +static void qh_build_withrestart(); +#define qh_errexit2 gdal_qh_errexit2 +static void qh_errexit2(); +#define qh_findhorizon gdal_qh_findhorizon +static void qh_findhorizon(); +#define qh_nextfurthest gdal_qh_nextfurthest +static gdal_pointT * qh_nextfurthest(); +#define qh_partitionall gdal_qh_partitionall +static void qh_partitionall(); +#define qh_partitioncoplanar gdal_qh_partitioncoplanar +static void qh_partitioncoplanar(); +#define qh_partitionpoint gdal_qh_partitionpoint +static void qh_partitionpoint(); +#define qh_partitionvisible gdal_qh_partitionvisible +static void qh_partitionvisible(); +#define qh_precision gdal_qh_precision +static void qh_precision(); +#define qh_printsummary gdal_qh_printsummary +static void qh_printsummary(); +#define qh_appendprint gdal_qh_appendprint +static void qh_appendprint(); +#define qh_freebuild gdal_qh_freebuild +static void qh_freebuild(); +#define qh_freebuffers gdal_qh_freebuffers +static void qh_freebuffers(); +/*#define qh_initbuffers gdal_qh_initbuffers*/ +/*static void qh_initbuffers();*/ +#define qh_allstatA gdal_qh_allstatA +static void qh_allstatA(); +#define qh_allstatB gdal_qh_allstatB +static void qh_allstatB(); +#define qh_allstatC gdal_qh_allstatC +static void qh_allstatC(); +#define qh_allstatD gdal_qh_allstatD +static void qh_allstatD(); +#define qh_allstatE gdal_qh_allstatE +static void qh_allstatE(); +#define qh_allstatE2 gdal_qh_allstatE2 +static void qh_allstatE2(); +#define qh_allstatF gdal_qh_allstatF +static void qh_allstatF(); +#define qh_allstatG gdal_qh_allstatG +static void qh_allstatG(); +#define qh_allstatH gdal_qh_allstatH +static void qh_allstatH(); +#define qh_freebuffers gdal_qh_freebuffers +static void qh_freebuffers(); +/*#define qh_initbuffers gdal_qh_initbuffers*/ +/*static void qh_initbuffers();*/ +#define qh_setaddsorted gdal_qh_setaddsorted +static void qh_setaddsorted(); +#define qh_setaddnth gdal_qh_setaddnth +static void qh_setaddnth(); +#define qh_setappend gdal_qh_setappend +static void qh_setappend(); +#define qh_setappend_set gdal_qh_setappend_set +static void qh_setappend_set(); +#define qh_setappend2ndlast gdal_qh_setappend2ndlast +static void qh_setappend2ndlast(); +#define qh_setcheck gdal_qh_setcheck +static void qh_setcheck(); +#define qh_setcompact gdal_qh_setcompact +static void qh_setcompact(); +#define qh_setcopy gdal_qh_setcopy +static gdal_setT * qh_setcopy(); +#define qh_setdel gdal_qh_setdel +static void * qh_setdel(); +#define qh_setdellast gdal_qh_setdellast +static void * qh_setdellast(); +#define qh_setdelnth gdal_qh_setdelnth +static void * qh_setdelnth(); +#define qh_setdelnthsorted gdal_qh_setdelnthsorted +static void * qh_setdelnthsorted(); +#define qh_setdelsorted gdal_qh_setdelsorted +static void * qh_setdelsorted(); +#define qh_setduplicate gdal_qh_setduplicate +static gdal_setT * qh_setduplicate(); +#define qh_setequal gdal_qh_setequal +static int qh_setequal(); +#define qh_setequal_except gdal_qh_setequal_except +static int qh_setequal_except(); +#define qh_setequal_skip gdal_qh_setequal_skip +static int qh_setequal_skip(); +#define qh_setendpointer gdal_qh_setendpointer +static void ** qh_setendpointer(); +#define qh_setfree gdal_qh_setfree +static void qh_setfree(); +#define qh_setfree2 gdal_qh_setfree2 +static void qh_setfree2(); +#define qh_setfreelong gdal_qh_setfreelong +static void qh_setfreelong(); +#define qh_setin gdal_qh_setin +static int qh_setin(); +#define qh_setindex gdal_qh_setindex +static int qh_setindex(); +#define qh_setlarger gdal_qh_setlarger +static void qh_setlarger(); +#define qh_setlast gdal_qh_setlast +static void * qh_setlast(); +#define qh_setnew gdal_qh_setnew +static gdal_setT * qh_setnew(); +#define qh_setnew_delnthsorted gdal_qh_setnew_delnthsorted +static gdal_setT * qh_setnew_delnthsorted(); +#define qh_setprint gdal_qh_setprint +static void qh_setprint(); +#define qh_setreplace gdal_qh_setreplace +static void qh_setreplace(); +#define qh_setsize gdal_qh_setsize +static int qh_setsize(); +#define qh_settemp gdal_qh_settemp +static gdal_setT * qh_settemp(); +#define qh_settempfree gdal_qh_settempfree +static void qh_settempfree(); +#define qh_settempfree_all gdal_qh_settempfree_all +static void qh_settempfree_all(); +#define qh_settemppop gdal_qh_settemppop +static gdal_setT * qh_settemppop(); +#define qh_settemppush gdal_qh_settemppush +static void qh_settemppush(); +#define qh_settruncate gdal_qh_settruncate +static void qh_settruncate(); +#define qh_setunique gdal_qh_setunique +static int qh_setunique(); +#define qh_setzero gdal_qh_setzero +static void qh_setzero(); +#define qh_argv_to_command gdal_qh_argv_to_command +static int qh_argv_to_command(); +#define qh_argv_to_command_size gdal_qh_argv_to_command_size +static int qh_argv_to_command_size(); +#define qh_rand gdal_qh_rand +static int qh_rand(); +#define qh_srand gdal_qh_srand +static void qh_srand(); +#define qh_randomfactor gdal_qh_randomfactor +static gdal_realT qh_randomfactor(); +#define qh_randommatrix gdal_qh_randommatrix +static void qh_randommatrix(); +#define qh_strtol gdal_qh_strtol +static int qh_strtol(); +#define qh_strtod gdal_qh_strtod +static double qh_strtod(); +#define qh_allstatA gdal_qh_allstatA +static void qh_allstatA(); +#define qh_allstatB gdal_qh_allstatB +static void qh_allstatB(); +#define qh_allstatC gdal_qh_allstatC +static void qh_allstatC(); +#define qh_allstatD gdal_qh_allstatD +static void qh_allstatD(); +#define qh_allstatE gdal_qh_allstatE +static void qh_allstatE(); +#define qh_allstatE2 gdal_qh_allstatE2 +static void qh_allstatE2(); +#define qh_allstatF gdal_qh_allstatF +static void qh_allstatF(); +#define qh_allstatG gdal_qh_allstatG +static void qh_allstatG(); +#define qh_allstatH gdal_qh_allstatH +static void qh_allstatH(); +#define qh_allstatI gdal_qh_allstatI +static void qh_allstatI(); +#define qh_allstatistics gdal_qh_allstatistics +static void qh_allstatistics(); +#define qh_collectstatistics gdal_qh_collectstatistics +static void qh_collectstatistics(); +#define qh_freestatistics gdal_qh_freestatistics +static void qh_freestatistics(); +#define qh_initstatistics gdal_qh_initstatistics +static void qh_initstatistics(); +#define qh_newstats gdal_qh_newstats +static gdal_boolT qh_newstats(); +#define qh_nostatistic gdal_qh_nostatistic +static gdal_boolT qh_nostatistic(); +#define qh_printallstatistics gdal_qh_printallstatistics +static void qh_printallstatistics(); +#define qh_printstatistics gdal_qh_printstatistics +static void qh_printstatistics(); +#define qh_printstatlevel gdal_qh_printstatlevel +static void qh_printstatlevel(); +#define qh_printstats gdal_qh_printstats +static void qh_printstats(); +#define qh_stddev gdal_qh_stddev +static gdal_realT qh_stddev(); + +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable : 4324 ) +#pragma warning( disable : 4032 ) +#pragma warning( disable : 4306 ) /* e.g 'type cast' : conversion from 'long' to 'facetT *' of greater size */ +#endif + +#include "libqhull.h" +#include "libqhull.c" +#include "poly.c" +#include "poly2.c" +#include "mem.c" +#include "user.c" +#include "global.c" +/*#include "userprintf.c"*/ +#include "random.c" +#include "qset.c" +#include "io.c" +#include "usermem.c" +#include "geom.c" +#include "geom2.c" +#include "stat.c" +#include "merge.c" + +#ifdef _MSC_VER +#pragma warning( pop ) +#endif + +/* Replaces userprintf.c implementation */ +static void qh_fprintf(CPL_UNUSED FILE *fp, CPL_UNUSED int msgcode, const char *fmt, ... ) +{ + va_list args; + va_start(args, fmt); + CPLErrorV(CE_Warning, CPLE_AppDefined, fmt, args); + va_end(args); +} + +#endif diff --git a/modules/globebrowsing/ext/gdal/include/memdataset.h b/modules/globebrowsing/ext/gdal/include/memdataset.h new file mode 100644 index 0000000000..6a069f01bc --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/memdataset.h @@ -0,0 +1,184 @@ +/****************************************************************************** + * $Id$ + * + * Project: Memory Array Translator + * Purpose: Declaration of MEMDataset, and MEMRasterBand. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2000, 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. + ****************************************************************************/ + +#ifndef MEMDATASET_H_INCLUDED +#define MEMDATASET_H_INCLUDED + +#include "gdal_pam.h" +#include "gdal_priv.h" + +CPL_C_START +void GDALRegister_MEM(); +/* Caution: if changing this prototype, also change in swig/include/gdal_python.i + where it is redefined */ +GDALRasterBandH CPL_DLL MEMCreateRasterBand( GDALDataset *, int, GByte *, + GDALDataType, int, int, int ); +GDALRasterBandH CPL_DLL MEMCreateRasterBandEx( GDALDataset *, int, GByte *, + GDALDataType, GSpacing, GSpacing, + int ); +CPL_C_END + +/************************************************************************/ +/* MEMDataset */ +/************************************************************************/ + +class MEMRasterBand; + +class CPL_DLL MEMDataset : public GDALDataset +{ + int bGeoTransformSet; + double adfGeoTransform[6]; + + char *pszProjection; + + int nGCPCount; + GDAL_GCP *pasGCPs; + CPLString osGCPProjection; + +#if 0 + protected: + virtual int EnterReadWrite(GDALRWFlag eRWFlag); + virtual void LeaveReadWrite(); +#endif + + public: + MEMDataset(); + virtual ~MEMDataset(); + + virtual const char *GetProjectionRef(void); + virtual CPLErr SetProjection( const char * ); + + virtual CPLErr GetGeoTransform( double * ); + virtual CPLErr SetGeoTransform( double * ); + + virtual void *GetInternalHandle( const char * ); + + virtual int GetGCPCount(); + virtual const char *GetGCPProjection(); + virtual const GDAL_GCP *GetGCPs(); + virtual CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList, + const char *pszGCPProjection ); + + virtual CPLErr AddBand( GDALDataType eType, + char **papszOptions=NULL ); + virtual CPLErr IRasterIO( GDALRWFlag eRWFlag, + int nXOff, int nYOff, int nXSize, int nYSize, + void * pData, int nBufXSize, int nBufYSize, + GDALDataType eBufType, + int nBandCount, int *panBandMap, + GSpacing nPixelSpaceBuf, + GSpacing nLineSpaceBuf, + GSpacing nBandSpaceBuf, + GDALRasterIOExtraArg* psExtraArg); + + static GDALDataset *Open( GDALOpenInfo * ); + static GDALDataset *Create( const char * pszFilename, + int nXSize, int nYSize, int nBands, + GDALDataType eType, char ** papszParmList ); +}; + +/************************************************************************/ +/* MEMRasterBand */ +/************************************************************************/ + +class CPL_DLL MEMRasterBand : public GDALPamRasterBand +{ + protected: + friend class MEMDataset; + + GByte *pabyData; + GSpacing nPixelOffset; + GSpacing nLineOffset; + int bOwnData; + + int bNoDataSet; + double dfNoData; + + GDALColorTable *poColorTable; + GDALColorInterp eColorInterp; + + char *pszUnitType; + char **papszCategoryNames; + + double dfOffset; + double dfScale; + + CPLXMLNode *psSavedHistograms; + + public: + MEMRasterBand( GDALDataset *poDS, int nBand, + GByte *pabyData, GDALDataType eType, + GSpacing nPixelOffset, GSpacing nLineOffset, + int bAssumeOwnership, + const char * pszPixelType = NULL ); + virtual ~MEMRasterBand(); + + virtual CPLErr IReadBlock( int, int, void * ); + virtual CPLErr IWriteBlock( int, int, void * ); + virtual CPLErr IRasterIO( GDALRWFlag eRWFlag, + int nXOff, int nYOff, int nXSize, int nYSize, + void * pData, int nBufXSize, int nBufYSize, + GDALDataType eBufType, + GSpacing nPixelSpaceBuf, + GSpacing nLineSpaceBuf, + GDALRasterIOExtraArg* psExtraArg ); + virtual double GetNoDataValue( int *pbSuccess = NULL ); + virtual CPLErr SetNoDataValue( double ); + virtual CPLErr DeleteNoDataValue(); + + virtual GDALColorInterp GetColorInterpretation(); + virtual GDALColorTable *GetColorTable(); + virtual CPLErr SetColorTable( GDALColorTable * ); + + virtual CPLErr SetColorInterpretation( GDALColorInterp ); + + virtual const char *GetUnitType(); + CPLErr SetUnitType( const char * ); + + virtual char **GetCategoryNames(); + virtual CPLErr SetCategoryNames( char ** ); + + virtual double GetOffset( int *pbSuccess = NULL ); + CPLErr SetOffset( double ); + virtual double GetScale( int *pbSuccess = NULL ); + CPLErr SetScale( double ); + + virtual CPLErr SetDefaultHistogram( double dfMin, double dfMax, + int nBuckets, GUIntBig *panHistogram ); + virtual CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax, + int *pnBuckets, + GUIntBig ** ppanHistogram, + int bForce, + GDALProgressFunc, void *pProgressData); + + // Allow access to MEM driver's private internal memory buffer. + GByte *GetData(void) const { return(pabyData); } +}; + +#endif /* ndef MEMDATASET_H_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/ogr_api.h b/modules/globebrowsing/ext/gdal/include/ogr_api.h new file mode 100644 index 0000000000..29538cf067 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/ogr_api.h @@ -0,0 +1,655 @@ +/****************************************************************************** + * $Id$ + * + * Project: OpenGIS Simple Features Reference Implementation + * Purpose: C API for OGR Geometry, Feature, Layers, DataSource and drivers. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2002, Frank Warmerdam + * Copyright (c) 2008-2013, Even Rouault + * + * 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. + ****************************************************************************/ + +#ifndef OGR_API_H_INCLUDED +#define OGR_API_H_INCLUDED + +/** + * \file ogr_api.h + * + * C API and defines for OGRFeature, OGRGeometry, and OGRDataSource + * related classes. + * + * See also: ogr_geometry.h, ogr_feature.h, ogrsf_frmts.h, ogr_featurestyle.h + */ + +#include "cpl_progress.h" +#include "cpl_minixml.h" +#include "ogr_core.h" + +CPL_C_START + +/* -------------------------------------------------------------------- */ +/* Geometry related functions (ogr_geometry.h) */ +/* -------------------------------------------------------------------- */ +#ifdef DEBUG +typedef struct OGRGeometryHS *OGRGeometryH; +#else +typedef void *OGRGeometryH; +#endif + +#ifndef DEFINED_OGRSpatialReferenceH +#define DEFINED_OGRSpatialReferenceH + +#ifdef DEBUG +typedef struct OGRSpatialReferenceHS *OGRSpatialReferenceH; +typedef struct OGRCoordinateTransformationHS *OGRCoordinateTransformationH; +#else +typedef void *OGRSpatialReferenceH; +typedef void *OGRCoordinateTransformationH; +#endif + +#endif + +struct _CPLXMLNode; + +/* From base OGRGeometry class */ + +OGRErr CPL_DLL OGR_G_CreateFromWkb( unsigned char *, OGRSpatialReferenceH, + OGRGeometryH *, int ); +OGRErr CPL_DLL OGR_G_CreateFromWkt( char **, OGRSpatialReferenceH, + OGRGeometryH * ); +OGRErr CPL_DLL OGR_G_CreateFromFgf( unsigned char *, OGRSpatialReferenceH, + OGRGeometryH *, int, int * ); +void CPL_DLL OGR_G_DestroyGeometry( OGRGeometryH ); +OGRGeometryH CPL_DLL OGR_G_CreateGeometry( OGRwkbGeometryType ) CPL_WARN_UNUSED_RESULT; +OGRGeometryH CPL_DLL +OGR_G_ApproximateArcAngles( + double dfCenterX, double dfCenterY, double dfZ, + double dfPrimaryRadius, double dfSecondaryAxis, double dfRotation, + double dfStartAngle, double dfEndAngle, + double dfMaxAngleStepSizeDegrees ) CPL_WARN_UNUSED_RESULT; + +OGRGeometryH CPL_DLL OGR_G_ForceToPolygon( OGRGeometryH ) CPL_WARN_UNUSED_RESULT; +OGRGeometryH CPL_DLL OGR_G_ForceToLineString( OGRGeometryH ) CPL_WARN_UNUSED_RESULT; +OGRGeometryH CPL_DLL OGR_G_ForceToMultiPolygon( OGRGeometryH ) CPL_WARN_UNUSED_RESULT; +OGRGeometryH CPL_DLL OGR_G_ForceToMultiPoint( OGRGeometryH ) CPL_WARN_UNUSED_RESULT; +OGRGeometryH CPL_DLL OGR_G_ForceToMultiLineString( OGRGeometryH ) CPL_WARN_UNUSED_RESULT; +OGRGeometryH CPL_DLL OGR_G_ForceTo( OGRGeometryH hGeom, + OGRwkbGeometryType eTargetType, + char** papszOptions ) CPL_WARN_UNUSED_RESULT; + +int CPL_DLL OGR_G_GetDimension( OGRGeometryH ); +int CPL_DLL OGR_G_GetCoordinateDimension( OGRGeometryH ); +int CPL_DLL OGR_G_CoordinateDimension( OGRGeometryH ); +void CPL_DLL OGR_G_SetCoordinateDimension( OGRGeometryH, int ); +int CPL_DLL OGR_G_Is3D( OGRGeometryH ); +int CPL_DLL OGR_G_IsMeasured( OGRGeometryH ); +void CPL_DLL OGR_G_Set3D( OGRGeometryH, int ); +void CPL_DLL OGR_G_SetMeasured( OGRGeometryH, int ); +OGRGeometryH CPL_DLL OGR_G_Clone( OGRGeometryH ) CPL_WARN_UNUSED_RESULT; +void CPL_DLL OGR_G_GetEnvelope( OGRGeometryH, OGREnvelope * ); +void CPL_DLL OGR_G_GetEnvelope3D( OGRGeometryH, OGREnvelope3D * ); +OGRErr CPL_DLL OGR_G_ImportFromWkb( OGRGeometryH, unsigned char *, int ); +OGRErr CPL_DLL OGR_G_ExportToWkb( OGRGeometryH, OGRwkbByteOrder, unsigned char*); +OGRErr CPL_DLL OGR_G_ExportToIsoWkb( OGRGeometryH, OGRwkbByteOrder, unsigned char*); +int CPL_DLL OGR_G_WkbSize( OGRGeometryH hGeom ); +OGRErr CPL_DLL OGR_G_ImportFromWkt( OGRGeometryH, char ** ); +OGRErr CPL_DLL OGR_G_ExportToWkt( OGRGeometryH, char ** ); +OGRErr CPL_DLL OGR_G_ExportToIsoWkt( OGRGeometryH, char ** ); +OGRwkbGeometryType CPL_DLL OGR_G_GetGeometryType( OGRGeometryH ); +const char CPL_DLL *OGR_G_GetGeometryName( OGRGeometryH ); +void CPL_DLL OGR_G_DumpReadable( OGRGeometryH, FILE *, const char * ); +void CPL_DLL OGR_G_FlattenTo2D( OGRGeometryH ); +void CPL_DLL OGR_G_CloseRings( OGRGeometryH ); + +OGRGeometryH CPL_DLL OGR_G_CreateFromGML( const char * ) CPL_WARN_UNUSED_RESULT; +char CPL_DLL *OGR_G_ExportToGML( OGRGeometryH ) CPL_WARN_UNUSED_RESULT; +char CPL_DLL *OGR_G_ExportToGMLEx( OGRGeometryH, char** papszOptions ) CPL_WARN_UNUSED_RESULT; + +OGRGeometryH CPL_DLL OGR_G_CreateFromGMLTree( const CPLXMLNode * ) CPL_WARN_UNUSED_RESULT; +CPLXMLNode CPL_DLL *OGR_G_ExportToGMLTree( OGRGeometryH ) CPL_WARN_UNUSED_RESULT; +CPLXMLNode CPL_DLL *OGR_G_ExportEnvelopeToGMLTree( OGRGeometryH ) CPL_WARN_UNUSED_RESULT; + +char CPL_DLL *OGR_G_ExportToKML( OGRGeometryH, const char* pszAltitudeMode ) CPL_WARN_UNUSED_RESULT; + +char CPL_DLL *OGR_G_ExportToJson( OGRGeometryH ) CPL_WARN_UNUSED_RESULT; +char CPL_DLL *OGR_G_ExportToJsonEx( OGRGeometryH, char** papszOptions ) CPL_WARN_UNUSED_RESULT; +OGRGeometryH CPL_DLL OGR_G_CreateGeometryFromJson( const char* ) CPL_WARN_UNUSED_RESULT; + +void CPL_DLL OGR_G_AssignSpatialReference( OGRGeometryH, + OGRSpatialReferenceH ); +OGRSpatialReferenceH CPL_DLL OGR_G_GetSpatialReference( OGRGeometryH ); +OGRErr CPL_DLL OGR_G_Transform( OGRGeometryH, OGRCoordinateTransformationH ); +OGRErr CPL_DLL OGR_G_TransformTo( OGRGeometryH, OGRSpatialReferenceH ); + +OGRGeometryH CPL_DLL OGR_G_Simplify( OGRGeometryH hThis, double tolerance ) CPL_WARN_UNUSED_RESULT; +OGRGeometryH CPL_DLL OGR_G_SimplifyPreserveTopology( OGRGeometryH hThis, double tolerance ) CPL_WARN_UNUSED_RESULT; +OGRGeometryH CPL_DLL OGR_G_DelaunayTriangulation( OGRGeometryH hThis, double dfTolerance, int bOnlyEdges ) CPL_WARN_UNUSED_RESULT; + +void CPL_DLL OGR_G_Segmentize(OGRGeometryH hGeom, double dfMaxLength ); +int CPL_DLL OGR_G_Intersects( OGRGeometryH, OGRGeometryH ); +int CPL_DLL OGR_G_Equals( OGRGeometryH, OGRGeometryH ); +/*int CPL_DLL OGR_G_EqualsExact( OGRGeometryH, OGRGeometryH, double );*/ +int CPL_DLL OGR_G_Disjoint( OGRGeometryH, OGRGeometryH ); +int CPL_DLL OGR_G_Touches( OGRGeometryH, OGRGeometryH ); +int CPL_DLL OGR_G_Crosses( OGRGeometryH, OGRGeometryH ); +int CPL_DLL OGR_G_Within( OGRGeometryH, OGRGeometryH ); +int CPL_DLL OGR_G_Contains( OGRGeometryH, OGRGeometryH ); +int CPL_DLL OGR_G_Overlaps( OGRGeometryH, OGRGeometryH ); + +OGRGeometryH CPL_DLL OGR_G_Boundary( OGRGeometryH ) CPL_WARN_UNUSED_RESULT; +OGRGeometryH CPL_DLL OGR_G_ConvexHull( OGRGeometryH ) CPL_WARN_UNUSED_RESULT; +OGRGeometryH CPL_DLL OGR_G_Buffer( OGRGeometryH, double, int ) CPL_WARN_UNUSED_RESULT; +OGRGeometryH CPL_DLL OGR_G_Intersection( OGRGeometryH, OGRGeometryH ) CPL_WARN_UNUSED_RESULT; +OGRGeometryH CPL_DLL OGR_G_Union( OGRGeometryH, OGRGeometryH ) CPL_WARN_UNUSED_RESULT; +OGRGeometryH CPL_DLL OGR_G_UnionCascaded( OGRGeometryH ) CPL_WARN_UNUSED_RESULT; +OGRGeometryH CPL_DLL OGR_G_PointOnSurface( OGRGeometryH ) CPL_WARN_UNUSED_RESULT; +/*OGRGeometryH CPL_DLL OGR_G_Polygonize( OGRGeometryH *, int);*/ +/*OGRGeometryH CPL_DLL OGR_G_Polygonizer_getCutEdges( OGRGeometryH *, int);*/ +/*OGRGeometryH CPL_DLL OGR_G_LineMerge( OGRGeometryH );*/ + +OGRGeometryH CPL_DLL OGR_G_Difference( OGRGeometryH, OGRGeometryH ) CPL_WARN_UNUSED_RESULT; +OGRGeometryH CPL_DLL OGR_G_SymDifference( OGRGeometryH, OGRGeometryH ) CPL_WARN_UNUSED_RESULT; +double CPL_DLL OGR_G_Distance( OGRGeometryH, OGRGeometryH ); +double CPL_DLL OGR_G_Length( OGRGeometryH ); +double CPL_DLL OGR_G_Area( OGRGeometryH ); +int CPL_DLL OGR_G_Centroid( OGRGeometryH, OGRGeometryH ); +OGRGeometryH CPL_DLL OGR_G_Value( OGRGeometryH, double dfDistance ) CPL_WARN_UNUSED_RESULT; + +void CPL_DLL OGR_G_Empty( OGRGeometryH ); +int CPL_DLL OGR_G_IsEmpty( OGRGeometryH ); +int CPL_DLL OGR_G_IsValid( OGRGeometryH ); +/*char CPL_DLL *OGR_G_IsValidReason( OGRGeometryH );*/ +int CPL_DLL OGR_G_IsSimple( OGRGeometryH ); +int CPL_DLL OGR_G_IsRing( OGRGeometryH ); + +OGRGeometryH CPL_DLL OGR_G_Polygonize( OGRGeometryH ) CPL_WARN_UNUSED_RESULT; + +/* backward compatibility (non-standard methods) */ +int CPL_DLL OGR_G_Intersect( OGRGeometryH, OGRGeometryH ) CPL_WARN_DEPRECATED("Non standard method. Use OGR_G_Intersects() instead"); +int CPL_DLL OGR_G_Equal( OGRGeometryH, OGRGeometryH ) CPL_WARN_DEPRECATED("Non standard method. Use OGR_G_Equals() instead"); +OGRGeometryH CPL_DLL OGR_G_SymmetricDifference( OGRGeometryH, OGRGeometryH ) CPL_WARN_DEPRECATED("Non standard method. Use OGR_G_SymDifference() instead"); +double CPL_DLL OGR_G_GetArea( OGRGeometryH ) CPL_WARN_DEPRECATED("Non standard method. Use OGR_G_Area() instead"); +OGRGeometryH CPL_DLL OGR_G_GetBoundary( OGRGeometryH ) CPL_WARN_DEPRECATED("Non standard method. Use OGR_G_Boundary() instead"); + +/* Methods for getting/setting vertices in points, line strings and rings */ +int CPL_DLL OGR_G_GetPointCount( OGRGeometryH ); +int CPL_DLL OGR_G_GetPoints( OGRGeometryH hGeom, + void* pabyX, int nXStride, + void* pabyY, int nYStride, + void* pabyZ, int nZStride); +int CPL_DLL OGR_G_GetPointsZM( OGRGeometryH hGeom, + void* pabyX, int nXStride, + void* pabyY, int nYStride, + void* pabyZ, int nZStride, + void* pabyM, int nMStride); +double CPL_DLL OGR_G_GetX( OGRGeometryH, int ); +double CPL_DLL OGR_G_GetY( OGRGeometryH, int ); +double CPL_DLL OGR_G_GetZ( OGRGeometryH, int ); +double CPL_DLL OGR_G_GetM( OGRGeometryH, int ); +void CPL_DLL OGR_G_GetPoint( OGRGeometryH, int iPoint, + double *, double *, double * ); +void CPL_DLL OGR_G_GetPointZM( OGRGeometryH, int iPoint, + double *, double *, double *, double * ); +void CPL_DLL OGR_G_SetPointCount( OGRGeometryH hGeom, int nNewPointCount ); +void CPL_DLL OGR_G_SetPoint( OGRGeometryH, int iPoint, + double, double, double ); +void CPL_DLL OGR_G_SetPoint_2D( OGRGeometryH, int iPoint, + double, double ); +void CPL_DLL OGR_G_SetPointM( OGRGeometryH, int iPoint, + double, double, double ); +void CPL_DLL OGR_G_SetPointZM( OGRGeometryH, int iPoint, + double, double, double, double ); +void CPL_DLL OGR_G_AddPoint( OGRGeometryH, double, double, double ); +void CPL_DLL OGR_G_AddPoint_2D( OGRGeometryH, double, double ); +void CPL_DLL OGR_G_AddPointM( OGRGeometryH, double, double, double ); +void CPL_DLL OGR_G_AddPointZM( OGRGeometryH, double, double, double, double ); +void CPL_DLL OGR_G_SetPoints( OGRGeometryH hGeom, int nPointsIn, + void* pabyX, int nXStride, + void* pabyY, int nYStride, + void* pabyZ, int nZStride ); +void CPL_DLL OGR_G_SetPointsZM( OGRGeometryH hGeom, int nPointsIn, + void* pabyX, int nXStride, + void* pabyY, int nYStride, + void* pabyZ, int nZStride, + void* pabyM, int nMStride ); + +/* Methods for getting/setting rings and members collections */ + +int CPL_DLL OGR_G_GetGeometryCount( OGRGeometryH ); +OGRGeometryH CPL_DLL OGR_G_GetGeometryRef( OGRGeometryH, int ); +OGRErr CPL_DLL OGR_G_AddGeometry( OGRGeometryH, OGRGeometryH ); +OGRErr CPL_DLL OGR_G_AddGeometryDirectly( OGRGeometryH, OGRGeometryH ); +OGRErr CPL_DLL OGR_G_RemoveGeometry( OGRGeometryH, int, int ); + +int CPL_DLL OGR_G_HasCurveGeometry( OGRGeometryH, int bLookForNonLinear ); +OGRGeometryH CPL_DLL OGR_G_GetLinearGeometry( OGRGeometryH hGeom, + double dfMaxAngleStepSizeDegrees, + char** papszOptions) CPL_WARN_UNUSED_RESULT; +OGRGeometryH CPL_DLL OGR_G_GetCurveGeometry( OGRGeometryH hGeom, + char** papszOptions ) CPL_WARN_UNUSED_RESULT; + +OGRGeometryH CPL_DLL OGRBuildPolygonFromEdges( OGRGeometryH hLinesAsCollection, + int bBestEffort, + int bAutoClose, + double dfTolerance, + OGRErr * peErr ) CPL_WARN_UNUSED_RESULT; + +OGRErr CPL_DLL OGRSetGenerate_DB2_V72_BYTE_ORDER( + int bGenerate_DB2_V72_BYTE_ORDER ); + +int CPL_DLL OGRGetGenerate_DB2_V72_BYTE_ORDER(void); + +void CPL_DLL OGRSetNonLinearGeometriesEnabledFlag(int bFlag); +int CPL_DLL OGRGetNonLinearGeometriesEnabledFlag(void); + +/* -------------------------------------------------------------------- */ +/* Feature related (ogr_feature.h) */ +/* -------------------------------------------------------------------- */ + +#ifdef DEBUG +typedef struct OGRFieldDefnHS *OGRFieldDefnH; +typedef struct OGRFeatureDefnHS *OGRFeatureDefnH; +typedef struct OGRFeatureHS *OGRFeatureH; +typedef struct OGRStyleTableHS *OGRStyleTableH; +#else +typedef void *OGRFieldDefnH; +typedef void *OGRFeatureDefnH; +typedef void *OGRFeatureH; +typedef void *OGRStyleTableH; +#endif +typedef struct OGRGeomFieldDefnHS *OGRGeomFieldDefnH; + +/* OGRFieldDefn */ + +OGRFieldDefnH CPL_DLL OGR_Fld_Create( const char *, OGRFieldType ) CPL_WARN_UNUSED_RESULT; +void CPL_DLL OGR_Fld_Destroy( OGRFieldDefnH ); + +void CPL_DLL OGR_Fld_SetName( OGRFieldDefnH, const char * ); +const char CPL_DLL *OGR_Fld_GetNameRef( OGRFieldDefnH ); +OGRFieldType CPL_DLL OGR_Fld_GetType( OGRFieldDefnH ); +void CPL_DLL OGR_Fld_SetType( OGRFieldDefnH, OGRFieldType ); +OGRFieldSubType CPL_DLL OGR_Fld_GetSubType( OGRFieldDefnH ); +void CPL_DLL OGR_Fld_SetSubType( OGRFieldDefnH, OGRFieldSubType ); +OGRJustification CPL_DLL OGR_Fld_GetJustify( OGRFieldDefnH ); +void CPL_DLL OGR_Fld_SetJustify( OGRFieldDefnH, OGRJustification ); +int CPL_DLL OGR_Fld_GetWidth( OGRFieldDefnH ); +void CPL_DLL OGR_Fld_SetWidth( OGRFieldDefnH, int ); +int CPL_DLL OGR_Fld_GetPrecision( OGRFieldDefnH ); +void CPL_DLL OGR_Fld_SetPrecision( OGRFieldDefnH, int ); +void CPL_DLL OGR_Fld_Set( OGRFieldDefnH, const char *, OGRFieldType, + int, int, OGRJustification ); +int CPL_DLL OGR_Fld_IsIgnored( OGRFieldDefnH hDefn ); +void CPL_DLL OGR_Fld_SetIgnored( OGRFieldDefnH hDefn, int ); +int CPL_DLL OGR_Fld_IsNullable( OGRFieldDefnH hDefn ); +void CPL_DLL OGR_Fld_SetNullable( OGRFieldDefnH hDefn, int ); +const char CPL_DLL *OGR_Fld_GetDefault( OGRFieldDefnH hDefn ); +void CPL_DLL OGR_Fld_SetDefault( OGRFieldDefnH hDefn, const char* ); +int CPL_DLL OGR_Fld_IsDefaultDriverSpecific( OGRFieldDefnH hDefn ); + +const char CPL_DLL *OGR_GetFieldTypeName( OGRFieldType ); +const char CPL_DLL *OGR_GetFieldSubTypeName( OGRFieldSubType ); +int CPL_DLL OGR_AreTypeSubTypeCompatible( OGRFieldType eType, + OGRFieldSubType eSubType ); + +/* OGRGeomFieldDefnH */ + +OGRGeomFieldDefnH CPL_DLL OGR_GFld_Create( const char *, OGRwkbGeometryType ) CPL_WARN_UNUSED_RESULT; +void CPL_DLL OGR_GFld_Destroy( OGRGeomFieldDefnH ); + +void CPL_DLL OGR_GFld_SetName( OGRGeomFieldDefnH, const char * ); +const char CPL_DLL *OGR_GFld_GetNameRef( OGRGeomFieldDefnH ); + +OGRwkbGeometryType CPL_DLL OGR_GFld_GetType( OGRGeomFieldDefnH ); +void CPL_DLL OGR_GFld_SetType( OGRGeomFieldDefnH, OGRwkbGeometryType ); + +OGRSpatialReferenceH CPL_DLL OGR_GFld_GetSpatialRef( OGRGeomFieldDefnH ); +void CPL_DLL OGR_GFld_SetSpatialRef( OGRGeomFieldDefnH, + OGRSpatialReferenceH hSRS ); + +int CPL_DLL OGR_GFld_IsNullable( OGRGeomFieldDefnH hDefn ); +void CPL_DLL OGR_GFld_SetNullable( OGRGeomFieldDefnH hDefn, int ); + +int CPL_DLL OGR_GFld_IsIgnored( OGRGeomFieldDefnH hDefn ); +void CPL_DLL OGR_GFld_SetIgnored( OGRGeomFieldDefnH hDefn, int ); + +/* OGRFeatureDefn */ + +OGRFeatureDefnH CPL_DLL OGR_FD_Create( const char * ) CPL_WARN_UNUSED_RESULT; +void CPL_DLL OGR_FD_Destroy( OGRFeatureDefnH ); +void CPL_DLL OGR_FD_Release( OGRFeatureDefnH ); +const char CPL_DLL *OGR_FD_GetName( OGRFeatureDefnH ); +int CPL_DLL OGR_FD_GetFieldCount( OGRFeatureDefnH ); +OGRFieldDefnH CPL_DLL OGR_FD_GetFieldDefn( OGRFeatureDefnH, int ); +int CPL_DLL OGR_FD_GetFieldIndex( OGRFeatureDefnH, const char * ); +void CPL_DLL OGR_FD_AddFieldDefn( OGRFeatureDefnH, OGRFieldDefnH ); +OGRErr CPL_DLL OGR_FD_DeleteFieldDefn( OGRFeatureDefnH hDefn, int iField ); +OGRErr CPL_DLL OGR_FD_ReorderFieldDefns( OGRFeatureDefnH hDefn, int* panMap ); +OGRwkbGeometryType CPL_DLL OGR_FD_GetGeomType( OGRFeatureDefnH ); +void CPL_DLL OGR_FD_SetGeomType( OGRFeatureDefnH, OGRwkbGeometryType ); +int CPL_DLL OGR_FD_IsGeometryIgnored( OGRFeatureDefnH ); +void CPL_DLL OGR_FD_SetGeometryIgnored( OGRFeatureDefnH, int ); +int CPL_DLL OGR_FD_IsStyleIgnored( OGRFeatureDefnH ); +void CPL_DLL OGR_FD_SetStyleIgnored( OGRFeatureDefnH, int ); +int CPL_DLL OGR_FD_Reference( OGRFeatureDefnH ); +int CPL_DLL OGR_FD_Dereference( OGRFeatureDefnH ); +int CPL_DLL OGR_FD_GetReferenceCount( OGRFeatureDefnH ); + +int CPL_DLL OGR_FD_GetGeomFieldCount( OGRFeatureDefnH hFDefn ); +OGRGeomFieldDefnH CPL_DLL OGR_FD_GetGeomFieldDefn( OGRFeatureDefnH hFDefn, + int i ); +int CPL_DLL OGR_FD_GetGeomFieldIndex( OGRFeatureDefnH hFDefn, + const char *pszName); + +void CPL_DLL OGR_FD_AddGeomFieldDefn( OGRFeatureDefnH hFDefn, + OGRGeomFieldDefnH hGFldDefn); +OGRErr CPL_DLL OGR_FD_DeleteGeomFieldDefn( OGRFeatureDefnH hFDefn, + int iGeomField ); +int CPL_DLL OGR_FD_IsSame( OGRFeatureDefnH hFDefn, + OGRFeatureDefnH hOtherFDefn ); +/* OGRFeature */ + +OGRFeatureH CPL_DLL OGR_F_Create( OGRFeatureDefnH ) CPL_WARN_UNUSED_RESULT; +void CPL_DLL OGR_F_Destroy( OGRFeatureH ); +OGRFeatureDefnH CPL_DLL OGR_F_GetDefnRef( OGRFeatureH ); + +OGRErr CPL_DLL OGR_F_SetGeometryDirectly( OGRFeatureH, OGRGeometryH ); +OGRErr CPL_DLL OGR_F_SetGeometry( OGRFeatureH, OGRGeometryH ); +OGRGeometryH CPL_DLL OGR_F_GetGeometryRef( OGRFeatureH ); +OGRGeometryH CPL_DLL OGR_F_StealGeometry( OGRFeatureH ) CPL_WARN_UNUSED_RESULT; +OGRFeatureH CPL_DLL OGR_F_Clone( OGRFeatureH ) CPL_WARN_UNUSED_RESULT; +int CPL_DLL OGR_F_Equal( OGRFeatureH, OGRFeatureH ); + +int CPL_DLL OGR_F_GetFieldCount( OGRFeatureH ); +OGRFieldDefnH CPL_DLL OGR_F_GetFieldDefnRef( OGRFeatureH, int ); +int CPL_DLL OGR_F_GetFieldIndex( OGRFeatureH, const char * ); + +int CPL_DLL OGR_F_IsFieldSet( OGRFeatureH, int ); +void CPL_DLL OGR_F_UnsetField( OGRFeatureH, int ); +OGRField CPL_DLL *OGR_F_GetRawFieldRef( OGRFeatureH, int ); + +int CPL_DLL OGR_F_GetFieldAsInteger( OGRFeatureH, int ); +GIntBig CPL_DLL OGR_F_GetFieldAsInteger64( OGRFeatureH, int ); +double CPL_DLL OGR_F_GetFieldAsDouble( OGRFeatureH, int ); +const char CPL_DLL *OGR_F_GetFieldAsString( OGRFeatureH, int ); +const int CPL_DLL *OGR_F_GetFieldAsIntegerList( OGRFeatureH, int, int * ); +const GIntBig CPL_DLL *OGR_F_GetFieldAsInteger64List( OGRFeatureH, int, int * ); +const double CPL_DLL *OGR_F_GetFieldAsDoubleList( OGRFeatureH, int, int * ); +char CPL_DLL **OGR_F_GetFieldAsStringList( OGRFeatureH, int ); +GByte CPL_DLL *OGR_F_GetFieldAsBinary( OGRFeatureH, int, int * ); +int CPL_DLL OGR_F_GetFieldAsDateTime( OGRFeatureH, int, int *, int *, int *, + int *, int *, int *, int * ); +int CPL_DLL OGR_F_GetFieldAsDateTimeEx( OGRFeatureH hFeat, int iField, + int *pnYear, int *pnMonth, int *pnDay, + int *pnHour, int *pnMinute, float *pfSecond, + int *pnTZFlag ); + +void CPL_DLL OGR_F_SetFieldInteger( OGRFeatureH, int, int ); +void CPL_DLL OGR_F_SetFieldInteger64( OGRFeatureH, int, GIntBig ); +void CPL_DLL OGR_F_SetFieldDouble( OGRFeatureH, int, double ); +void CPL_DLL OGR_F_SetFieldString( OGRFeatureH, int, const char * ); +void CPL_DLL OGR_F_SetFieldIntegerList( OGRFeatureH, int, int, int * ); +void CPL_DLL OGR_F_SetFieldInteger64List( OGRFeatureH, int, int, const GIntBig * ); +void CPL_DLL OGR_F_SetFieldDoubleList( OGRFeatureH, int, int, double * ); +void CPL_DLL OGR_F_SetFieldStringList( OGRFeatureH, int, char ** ); +void CPL_DLL OGR_F_SetFieldRaw( OGRFeatureH, int, OGRField * ); +void CPL_DLL OGR_F_SetFieldBinary( OGRFeatureH, int, int, GByte * ); +void CPL_DLL OGR_F_SetFieldDateTime( OGRFeatureH, int, + int, int, int, int, int, int, int ); +void CPL_DLL OGR_F_SetFieldDateTimeEx( OGRFeatureH, int, + int, int, int, int, int, float, int ); + +int CPL_DLL OGR_F_GetGeomFieldCount( OGRFeatureH hFeat ); +OGRGeomFieldDefnH CPL_DLL OGR_F_GetGeomFieldDefnRef( OGRFeatureH hFeat, + int iField ); +int CPL_DLL OGR_F_GetGeomFieldIndex( OGRFeatureH hFeat, + const char *pszName); + +OGRGeometryH CPL_DLL OGR_F_GetGeomFieldRef( OGRFeatureH hFeat, + int iField ); +OGRErr CPL_DLL OGR_F_SetGeomFieldDirectly( OGRFeatureH hFeat, + int iField, + OGRGeometryH hGeom ); +OGRErr CPL_DLL OGR_F_SetGeomField( OGRFeatureH hFeat, + int iField, OGRGeometryH hGeom ); + +GIntBig CPL_DLL OGR_F_GetFID( OGRFeatureH ); +OGRErr CPL_DLL OGR_F_SetFID( OGRFeatureH, GIntBig ); +void CPL_DLL OGR_F_DumpReadable( OGRFeatureH, FILE * ); +OGRErr CPL_DLL OGR_F_SetFrom( OGRFeatureH, OGRFeatureH, int ); +OGRErr CPL_DLL OGR_F_SetFromWithMap( OGRFeatureH, OGRFeatureH, int , int * ); + +const char CPL_DLL *OGR_F_GetStyleString( OGRFeatureH ); +void CPL_DLL OGR_F_SetStyleString( OGRFeatureH, const char * ); +void CPL_DLL OGR_F_SetStyleStringDirectly( OGRFeatureH, char * ); +OGRStyleTableH CPL_DLL OGR_F_GetStyleTable( OGRFeatureH ); +void CPL_DLL OGR_F_SetStyleTableDirectly( OGRFeatureH, OGRStyleTableH ); +void CPL_DLL OGR_F_SetStyleTable( OGRFeatureH, OGRStyleTableH ); + +const char CPL_DLL *OGR_F_GetNativeData( OGRFeatureH ); +void CPL_DLL OGR_F_SetNativeData( OGRFeatureH, const char* ); +const char CPL_DLL *OGR_F_GetNativeMediaType( OGRFeatureH ); +void CPL_DLL OGR_F_SetNativeMediaType( OGRFeatureH, const char* ); + +void CPL_DLL OGR_F_FillUnsetWithDefault( OGRFeatureH hFeat, + int bNotNullableOnly, + char** papszOptions ); +int CPL_DLL OGR_F_Validate( OGRFeatureH, int nValidateFlags, int bEmitError ); + +/* -------------------------------------------------------------------- */ +/* ogrsf_frmts.h */ +/* -------------------------------------------------------------------- */ + +#ifdef DEBUG +typedef struct OGRLayerHS *OGRLayerH; +typedef struct OGRDataSourceHS *OGRDataSourceH; +typedef struct OGRDriverHS *OGRSFDriverH; +#else +typedef void *OGRLayerH; +typedef void *OGRDataSourceH; +typedef void *OGRSFDriverH; +#endif + +/* OGRLayer */ + +const char CPL_DLL* OGR_L_GetName( OGRLayerH ); +OGRwkbGeometryType CPL_DLL OGR_L_GetGeomType( OGRLayerH ); +OGRGeometryH CPL_DLL OGR_L_GetSpatialFilter( OGRLayerH ); +void CPL_DLL OGR_L_SetSpatialFilter( OGRLayerH, OGRGeometryH ); +void CPL_DLL OGR_L_SetSpatialFilterRect( OGRLayerH, + double, double, double, double ); +void CPL_DLL OGR_L_SetSpatialFilterEx( OGRLayerH, int iGeomField, + OGRGeometryH hGeom ); +void CPL_DLL OGR_L_SetSpatialFilterRectEx( OGRLayerH, int iGeomField, + double dfMinX, double dfMinY, + double dfMaxX, double dfMaxY ); +OGRErr CPL_DLL OGR_L_SetAttributeFilter( OGRLayerH, const char * ); +void CPL_DLL OGR_L_ResetReading( OGRLayerH ); +OGRFeatureH CPL_DLL OGR_L_GetNextFeature( OGRLayerH ) CPL_WARN_UNUSED_RESULT; +OGRErr CPL_DLL OGR_L_SetNextByIndex( OGRLayerH, GIntBig ); +OGRFeatureH CPL_DLL OGR_L_GetFeature( OGRLayerH, GIntBig ) CPL_WARN_UNUSED_RESULT; +OGRErr CPL_DLL OGR_L_SetFeature( OGRLayerH, OGRFeatureH ) CPL_WARN_UNUSED_RESULT; +OGRErr CPL_DLL OGR_L_CreateFeature( OGRLayerH, OGRFeatureH ) CPL_WARN_UNUSED_RESULT; +OGRErr CPL_DLL OGR_L_DeleteFeature( OGRLayerH, GIntBig ) CPL_WARN_UNUSED_RESULT; +OGRFeatureDefnH CPL_DLL OGR_L_GetLayerDefn( OGRLayerH ); +OGRSpatialReferenceH CPL_DLL OGR_L_GetSpatialRef( OGRLayerH ); +int CPL_DLL OGR_L_FindFieldIndex( OGRLayerH, const char *, int bExactMatch ); +GIntBig CPL_DLL OGR_L_GetFeatureCount( OGRLayerH, int ); +OGRErr CPL_DLL OGR_L_GetExtent( OGRLayerH, OGREnvelope *, int ); +OGRErr CPL_DLL OGR_L_GetExtentEx( OGRLayerH, int iGeomField, + OGREnvelope *psExtent, int bForce ); +int CPL_DLL OGR_L_TestCapability( OGRLayerH, const char * ); +OGRErr CPL_DLL OGR_L_CreateField( OGRLayerH, OGRFieldDefnH, int ); +OGRErr CPL_DLL OGR_L_CreateGeomField( OGRLayerH hLayer, + OGRGeomFieldDefnH hFieldDefn, int bForce ); +OGRErr CPL_DLL OGR_L_DeleteField( OGRLayerH, int iField ); +OGRErr CPL_DLL OGR_L_ReorderFields( OGRLayerH, int* panMap ); +OGRErr CPL_DLL OGR_L_ReorderField( OGRLayerH, int iOldFieldPos, int iNewFieldPos ); +OGRErr CPL_DLL OGR_L_AlterFieldDefn( OGRLayerH, int iField, OGRFieldDefnH hNewFieldDefn, int nFlags ); +OGRErr CPL_DLL OGR_L_StartTransaction( OGRLayerH ) CPL_WARN_UNUSED_RESULT; +OGRErr CPL_DLL OGR_L_CommitTransaction( OGRLayerH ) CPL_WARN_UNUSED_RESULT; +OGRErr CPL_DLL OGR_L_RollbackTransaction( OGRLayerH ); +int CPL_DLL OGR_L_Reference( OGRLayerH ); +int CPL_DLL OGR_L_Dereference( OGRLayerH ); +int CPL_DLL OGR_L_GetRefCount( OGRLayerH ); +OGRErr CPL_DLL OGR_L_SyncToDisk( OGRLayerH ); +GIntBig CPL_DLL OGR_L_GetFeaturesRead( OGRLayerH ); +const char CPL_DLL *OGR_L_GetFIDColumn( OGRLayerH ); +const char CPL_DLL *OGR_L_GetGeometryColumn( OGRLayerH ); +OGRStyleTableH CPL_DLL OGR_L_GetStyleTable( OGRLayerH ); +void CPL_DLL OGR_L_SetStyleTableDirectly( OGRLayerH, OGRStyleTableH ); +void CPL_DLL OGR_L_SetStyleTable( OGRLayerH, OGRStyleTableH ); +OGRErr CPL_DLL OGR_L_SetIgnoredFields( OGRLayerH, const char** ); +OGRErr CPL_DLL OGR_L_Intersection( OGRLayerH, OGRLayerH, OGRLayerH, char**, GDALProgressFunc, void * ); +OGRErr CPL_DLL OGR_L_Union( OGRLayerH, OGRLayerH, OGRLayerH, char**, GDALProgressFunc, void * ); +OGRErr CPL_DLL OGR_L_SymDifference( OGRLayerH, OGRLayerH, OGRLayerH, char**, GDALProgressFunc, void * ); +OGRErr CPL_DLL OGR_L_Identity( OGRLayerH, OGRLayerH, OGRLayerH, char**, GDALProgressFunc, void * ); +OGRErr CPL_DLL OGR_L_Update( OGRLayerH, OGRLayerH, OGRLayerH, char**, GDALProgressFunc, void * ); +OGRErr CPL_DLL OGR_L_Clip( OGRLayerH, OGRLayerH, OGRLayerH, char**, GDALProgressFunc, void * ); +OGRErr CPL_DLL OGR_L_Erase( OGRLayerH, OGRLayerH, OGRLayerH, char**, GDALProgressFunc, void * ); + +/* OGRDataSource */ + +void CPL_DLL OGR_DS_Destroy( OGRDataSourceH ); +const char CPL_DLL *OGR_DS_GetName( OGRDataSourceH ); +int CPL_DLL OGR_DS_GetLayerCount( OGRDataSourceH ); +OGRLayerH CPL_DLL OGR_DS_GetLayer( OGRDataSourceH, int ); +OGRLayerH CPL_DLL OGR_DS_GetLayerByName( OGRDataSourceH, const char * ); +OGRErr CPL_DLL OGR_DS_DeleteLayer( OGRDataSourceH, int ); +OGRSFDriverH CPL_DLL OGR_DS_GetDriver( OGRDataSourceH ); +OGRLayerH CPL_DLL OGR_DS_CreateLayer( OGRDataSourceH, const char *, + OGRSpatialReferenceH, OGRwkbGeometryType, + char ** ); +OGRLayerH CPL_DLL OGR_DS_CopyLayer( OGRDataSourceH, OGRLayerH, const char *, + char ** ); +int CPL_DLL OGR_DS_TestCapability( OGRDataSourceH, const char * ); +OGRLayerH CPL_DLL OGR_DS_ExecuteSQL( OGRDataSourceH, const char *, + OGRGeometryH, const char * ); +void CPL_DLL OGR_DS_ReleaseResultSet( OGRDataSourceH, OGRLayerH ); +int CPL_DLL OGR_DS_Reference( OGRDataSourceH ); +int CPL_DLL OGR_DS_Dereference( OGRDataSourceH ); +int CPL_DLL OGR_DS_GetRefCount( OGRDataSourceH ); +int CPL_DLL OGR_DS_GetSummaryRefCount( OGRDataSourceH ); +OGRErr CPL_DLL OGR_DS_SyncToDisk( OGRDataSourceH ); +OGRStyleTableH CPL_DLL OGR_DS_GetStyleTable( OGRDataSourceH ); +void CPL_DLL OGR_DS_SetStyleTableDirectly( OGRDataSourceH, OGRStyleTableH ); +void CPL_DLL OGR_DS_SetStyleTable( OGRDataSourceH, OGRStyleTableH ); + +/* OGRSFDriver */ + +const char CPL_DLL *OGR_Dr_GetName( OGRSFDriverH ); +OGRDataSourceH CPL_DLL OGR_Dr_Open( OGRSFDriverH, const char *, int ) CPL_WARN_UNUSED_RESULT; +int CPL_DLL OGR_Dr_TestCapability( OGRSFDriverH, const char * ); +OGRDataSourceH CPL_DLL OGR_Dr_CreateDataSource( OGRSFDriverH, const char *, + char ** ) CPL_WARN_UNUSED_RESULT; +OGRDataSourceH CPL_DLL OGR_Dr_CopyDataSource( OGRSFDriverH, OGRDataSourceH, + const char *, char ** ) CPL_WARN_UNUSED_RESULT; +OGRErr CPL_DLL OGR_Dr_DeleteDataSource( OGRSFDriverH, const char * ); + +/* OGRSFDriverRegistrar */ + +OGRDataSourceH CPL_DLL OGROpen( const char *, int, OGRSFDriverH * ) CPL_WARN_UNUSED_RESULT; +OGRDataSourceH CPL_DLL OGROpenShared( const char *, int, OGRSFDriverH * ) CPL_WARN_UNUSED_RESULT; +OGRErr CPL_DLL OGRReleaseDataSource( OGRDataSourceH ); +void CPL_DLL OGRRegisterDriver( OGRSFDriverH ); +void CPL_DLL OGRDeregisterDriver( OGRSFDriverH ); +int CPL_DLL OGRGetDriverCount(void); +OGRSFDriverH CPL_DLL OGRGetDriver( int ); +OGRSFDriverH CPL_DLL OGRGetDriverByName( const char * ); +int CPL_DLL OGRGetOpenDSCount(void); +OGRDataSourceH CPL_DLL OGRGetOpenDS( int iDS ); + + +/* note: this is also declared in ogrsf_frmts.h */ +void CPL_DLL OGRRegisterAll(void); +void CPL_DLL OGRCleanupAll(void); + +/* -------------------------------------------------------------------- */ +/* ogrsf_featurestyle.h */ +/* -------------------------------------------------------------------- */ + +#ifdef DEBUG +typedef struct OGRStyleMgrHS *OGRStyleMgrH; +typedef struct OGRStyleToolHS *OGRStyleToolH; +#else +typedef void *OGRStyleMgrH; +typedef void *OGRStyleToolH; +#endif + +/* OGRStyleMgr */ + +OGRStyleMgrH CPL_DLL OGR_SM_Create(OGRStyleTableH hStyleTable) CPL_WARN_UNUSED_RESULT; +void CPL_DLL OGR_SM_Destroy(OGRStyleMgrH hSM); + +const char CPL_DLL *OGR_SM_InitFromFeature(OGRStyleMgrH hSM, + OGRFeatureH hFeat); +int CPL_DLL OGR_SM_InitStyleString(OGRStyleMgrH hSM, + const char *pszStyleString); +int CPL_DLL OGR_SM_GetPartCount(OGRStyleMgrH hSM, + const char *pszStyleString); +OGRStyleToolH CPL_DLL OGR_SM_GetPart(OGRStyleMgrH hSM, int nPartId, + const char *pszStyleString); +int CPL_DLL OGR_SM_AddPart(OGRStyleMgrH hSM, OGRStyleToolH hST); +int CPL_DLL OGR_SM_AddStyle(OGRStyleMgrH hSM, const char *pszStyleName, + const char *pszStyleString); + +/* OGRStyleTool */ + +OGRStyleToolH CPL_DLL OGR_ST_Create(OGRSTClassId eClassId) CPL_WARN_UNUSED_RESULT; +void CPL_DLL OGR_ST_Destroy(OGRStyleToolH hST); + +OGRSTClassId CPL_DLL OGR_ST_GetType(OGRStyleToolH hST); + +OGRSTUnitId CPL_DLL OGR_ST_GetUnit(OGRStyleToolH hST); +void CPL_DLL OGR_ST_SetUnit(OGRStyleToolH hST, OGRSTUnitId eUnit, + double dfGroundPaperScale); + +const char CPL_DLL *OGR_ST_GetParamStr(OGRStyleToolH hST, int eParam, int *bValueIsNull); +int CPL_DLL OGR_ST_GetParamNum(OGRStyleToolH hST, int eParam, int *bValueIsNull); +double CPL_DLL OGR_ST_GetParamDbl(OGRStyleToolH hST, int eParam, int *bValueIsNull); +void CPL_DLL OGR_ST_SetParamStr(OGRStyleToolH hST, int eParam, const char *pszValue); +void CPL_DLL OGR_ST_SetParamNum(OGRStyleToolH hST, int eParam, int nValue); +void CPL_DLL OGR_ST_SetParamDbl(OGRStyleToolH hST, int eParam, double dfValue); +const char CPL_DLL *OGR_ST_GetStyleString(OGRStyleToolH hST); + +int CPL_DLL OGR_ST_GetRGBFromString(OGRStyleToolH hST, const char *pszColor, + int *pnRed, int *pnGreen, int *pnBlue, + int *pnAlpha); + +/* OGRStyleTable */ + +OGRStyleTableH CPL_DLL OGR_STBL_Create( void ) CPL_WARN_UNUSED_RESULT; +void CPL_DLL OGR_STBL_Destroy( OGRStyleTableH hSTBL ); +int CPL_DLL OGR_STBL_AddStyle( OGRStyleTableH hStyleTable, + const char *pszName, + const char *pszStyleString); +int CPL_DLL OGR_STBL_SaveStyleTable( OGRStyleTableH hStyleTable, + const char *pszFilename ); +int CPL_DLL OGR_STBL_LoadStyleTable( OGRStyleTableH hStyleTable, + const char *pszFilename ); +const char CPL_DLL *OGR_STBL_Find( OGRStyleTableH hStyleTable, const char *pszName ); +void CPL_DLL OGR_STBL_ResetStyleStringReading( OGRStyleTableH hStyleTable ); +const char CPL_DLL *OGR_STBL_GetNextStyle( OGRStyleTableH hStyleTable); +const char CPL_DLL *OGR_STBL_GetLastStyleName( OGRStyleTableH hStyleTable); + +CPL_C_END + +#endif /* ndef OGR_API_H_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/ogr_attrind.h b/modules/globebrowsing/ext/gdal/include/ogr_attrind.h new file mode 100644 index 0000000000..29a7c7a2f1 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/ogr_attrind.h @@ -0,0 +1,93 @@ +/****************************************************************************** + * $Id$ + * + * Project: OpenGIS Simple Features Reference Implementation + * Purpose: Classes related to generic implementation of attribute indexing. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2003, 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. + ****************************************************************************/ + +#ifndef OGR_ATTRIND_H_INCLUDED +#define OGR_ATTRIND_H_INCLUDED + +#include "ogrsf_frmts.h" + +/************************************************************************/ +/* OGRAttrIndex */ +/* */ +/* Base class for accessing the indexing info about one field. */ +/************************************************************************/ + +class CPL_DLL OGRAttrIndex +{ +protected: + OGRAttrIndex(); + +public: + virtual ~OGRAttrIndex(); + + virtual GIntBig GetFirstMatch( OGRField *psKey ) = 0; + virtual GIntBig *GetAllMatches( OGRField *psKey ) = 0; + virtual GIntBig *GetAllMatches( OGRField *psKey, GIntBig* panFIDList, int* nFIDCount, int* nLength ) = 0; + + virtual OGRErr AddEntry( OGRField *psKey, GIntBig nFID ) = 0; + virtual OGRErr RemoveEntry( OGRField *psKey, GIntBig nFID ) = 0; + + virtual OGRErr Clear() = 0; +}; + +/************************************************************************/ +/* OGRLayerAttrIndex */ +/* */ +/* Base class representing attribute indexes for all indexed */ +/* fields in a layer. */ +/************************************************************************/ + +class CPL_DLL OGRLayerAttrIndex +{ +protected: + OGRLayer *poLayer; + char *pszIndexPath; + + OGRLayerAttrIndex(); + +public: + virtual ~OGRLayerAttrIndex(); + + virtual OGRErr Initialize( const char *pszIndexPath, OGRLayer * ) = 0; + + virtual OGRErr CreateIndex( int iField ) = 0; + virtual OGRErr DropIndex( int iField ) = 0; + virtual OGRErr IndexAllFeatures( int iField = -1 ) = 0; + + virtual OGRErr AddToIndex( OGRFeature *poFeature, int iField = -1 ) = 0; + virtual OGRErr RemoveFromIndex( OGRFeature *poFeature ) = 0; + + virtual OGRAttrIndex *GetFieldIndex( int iField ) = 0; +}; + +OGRLayerAttrIndex CPL_DLL *OGRCreateDefaultLayerIndex(); + + +#endif /* ndef OGR_ATTRIND_H_INCLUDED */ + diff --git a/modules/globebrowsing/ext/gdal/include/ogr_core.h b/modules/globebrowsing/ext/gdal/include/ogr_core.h new file mode 100644 index 0000000000..ba206658f8 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/ogr_core.h @@ -0,0 +1,910 @@ +/****************************************************************************** + * $Id$ + * + * Project: OpenGIS Simple Features Reference Implementation + * Purpose: Define some core portability services for cross-platform OGR code. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, Frank Warmerdam + * Copyright (c) 2007-2014, Even Rouault + * + * 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. + ****************************************************************************/ + +#ifndef OGR_CORE_H_INCLUDED +#define OGR_CORE_H_INCLUDED + +#include "cpl_port.h" +#include "gdal_version.h" + +/** + * \file + * + * Core portability services for cross-platform OGR code. + */ + +/** + * Simple container for a bounding region. + */ + +#if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS) +class CPL_DLL OGREnvelope +{ + public: + OGREnvelope() : MinX(0.0), MaxX(0.0), MinY(0.0), MaxY(0.0) + { + } + + OGREnvelope(const OGREnvelope& oOther) : + MinX(oOther.MinX),MaxX(oOther.MaxX), MinY(oOther.MinY), MaxY(oOther.MaxY) + { + } + + double MinX; + double MaxX; + double MinY; + double MaxY; + +#ifdef HAVE_GCC_DIAGNOSTIC_PUSH +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wfloat-equal" +#endif + int IsInit() const { return MinX != 0 || MinY != 0 || MaxX != 0 || MaxY != 0; } + +#ifdef HAVE_GCC_DIAGNOSTIC_PUSH +#pragma GCC diagnostic pop +#endif + + void Merge( OGREnvelope const& sOther ) { + if( IsInit() ) + { + MinX = MIN(MinX,sOther.MinX); + MaxX = MAX(MaxX,sOther.MaxX); + MinY = MIN(MinY,sOther.MinY); + MaxY = MAX(MaxY,sOther.MaxY); + } + else + { + MinX = sOther.MinX; + MaxX = sOther.MaxX; + MinY = sOther.MinY; + MaxY = sOther.MaxY; + } + } + void Merge( double dfX, double dfY ) { + if( IsInit() ) + { + MinX = MIN(MinX,dfX); + MaxX = MAX(MaxX,dfX); + MinY = MIN(MinY,dfY); + MaxY = MAX(MaxY,dfY); + } + else + { + MinX = MaxX = dfX; + MinY = MaxY = dfY; + } + } + + void Intersect( OGREnvelope const& sOther ) { + if(Intersects(sOther)) + { + if( IsInit() ) + { + MinX = MAX(MinX,sOther.MinX); + MaxX = MIN(MaxX,sOther.MaxX); + MinY = MAX(MinY,sOther.MinY); + MaxY = MIN(MaxY,sOther.MaxY); + } + else + { + MinX = sOther.MinX; + MaxX = sOther.MaxX; + MinY = sOther.MinY; + MaxY = sOther.MaxY; + } + } + else + { + MinX = 0; + MaxX = 0; + MinY = 0; + MaxY = 0; + } + } + + int Intersects(OGREnvelope const& other) const + { + return MinX <= other.MaxX && MaxX >= other.MinX && + MinY <= other.MaxY && MaxY >= other.MinY; + } + + int Contains(OGREnvelope const& other) const + { + return MinX <= other.MinX && MinY <= other.MinY && + MaxX >= other.MaxX && MaxY >= other.MaxY; + } +}; +#else +typedef struct +{ + double MinX; + double MaxX; + double MinY; + double MaxY; +} OGREnvelope; +#endif + + +/** + * Simple container for a bounding region in 3D. + */ + +#if defined(__cplusplus) && !defined(CPL_SURESS_CPLUSPLUS) +class CPL_DLL OGREnvelope3D : public OGREnvelope +{ + public: + OGREnvelope3D() : OGREnvelope(), MinZ(0.0), MaxZ(0.0) + { + } + + OGREnvelope3D(const OGREnvelope3D& oOther) : + OGREnvelope(oOther), + MinZ(oOther.MinZ), MaxZ(oOther.MaxZ) + { + } + + double MinZ; + double MaxZ; + +#ifdef HAVE_GCC_DIAGNOSTIC_PUSH +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wfloat-equal" +#endif + int IsInit() const { return MinX != 0 || MinY != 0 || MaxX != 0 || MaxY != 0 || MinZ != 0 || MaxZ != 0; } +#ifdef HAVE_GCC_DIAGNOSTIC_PUSH +#pragma GCC diagnostic pop +#endif + + void Merge( OGREnvelope3D const& sOther ) { + if( IsInit() ) + { + MinX = MIN(MinX,sOther.MinX); + MaxX = MAX(MaxX,sOther.MaxX); + MinY = MIN(MinY,sOther.MinY); + MaxY = MAX(MaxY,sOther.MaxY); + MinZ = MIN(MinZ,sOther.MinZ); + MaxZ = MAX(MaxZ,sOther.MaxZ); + } + else + { + MinX = sOther.MinX; + MaxX = sOther.MaxX; + MinY = sOther.MinY; + MaxY = sOther.MaxY; + MinZ = sOther.MinZ; + MaxZ = sOther.MaxZ; + } + } + void Merge( double dfX, double dfY, double dfZ ) { + if( IsInit() ) + { + MinX = MIN(MinX,dfX); + MaxX = MAX(MaxX,dfX); + MinY = MIN(MinY,dfY); + MaxY = MAX(MaxY,dfY); + MinZ = MIN(MinZ,dfZ); + MaxZ = MAX(MaxZ,dfZ); + } + else + { + MinX = MaxX = dfX; + MinY = MaxY = dfY; + MinZ = MaxZ = dfZ; + } + } + + void Intersect( OGREnvelope3D const& sOther ) { + if(Intersects(sOther)) + { + if( IsInit() ) + { + MinX = MAX(MinX,sOther.MinX); + MaxX = MIN(MaxX,sOther.MaxX); + MinY = MAX(MinY,sOther.MinY); + MaxY = MIN(MaxY,sOther.MaxY); + MinZ = MAX(MinZ,sOther.MinZ); + MaxZ = MIN(MaxZ,sOther.MaxZ); + } + else + { + MinX = sOther.MinX; + MaxX = sOther.MaxX; + MinY = sOther.MinY; + MaxY = sOther.MaxY; + MinZ = sOther.MinZ; + MaxZ = sOther.MaxZ; + } + } + else + { + MinX = 0; + MaxX = 0; + MinY = 0; + MaxY = 0; + MinZ = 0; + MaxZ = 0; + } + } + + int Intersects(OGREnvelope3D const& other) const + { + return MinX <= other.MaxX && MaxX >= other.MinX && + MinY <= other.MaxY && MaxY >= other.MinY && + MinZ <= other.MaxZ && MaxZ >= other.MinZ; + } + + int Contains(OGREnvelope3D const& other) const + { + return MinX <= other.MinX && MinY <= other.MinY && + MaxX >= other.MaxX && MaxY >= other.MaxY && + MinZ <= other.MinZ && MaxZ >= other.MaxZ; + } +}; +#else +typedef struct +{ + double MinX; + double MaxX; + double MinY; + double MaxY; + double MinZ; + double MaxZ; +} OGREnvelope3D; +#endif + + +CPL_C_START + +void CPL_DLL *OGRMalloc( size_t ); +void CPL_DLL *OGRCalloc( size_t, size_t ); +void CPL_DLL *OGRRealloc( void *, size_t ); +char CPL_DLL *OGRStrdup( const char * ); +void CPL_DLL OGRFree( void * ); + +#ifdef STRICT_OGRERR_TYPE +typedef enum +{ + OGRERR_NONE, + OGRERR_NOT_ENOUGH_DATA, + OGRERR_NOT_ENOUGH_MEMORY, + OGRERR_UNSUPPORTED_GEOMETRY_TYPE, + OGRERR_UNSUPPORTED_OPERATION, + OGRERR_CORRUPT_DATA, + OGRERR_FAILURE, + OGRERR_UNSUPPORTED_SRS, + OGRERR_INVALID_HANDLE, + OGRERR_NON_EXISTING_FEATURE +} OGRErr; +#else +typedef int OGRErr; + +#define OGRERR_NONE 0 +#define OGRERR_NOT_ENOUGH_DATA 1 /* not enough data to deserialize */ +#define OGRERR_NOT_ENOUGH_MEMORY 2 +#define OGRERR_UNSUPPORTED_GEOMETRY_TYPE 3 +#define OGRERR_UNSUPPORTED_OPERATION 4 +#define OGRERR_CORRUPT_DATA 5 +#define OGRERR_FAILURE 6 +#define OGRERR_UNSUPPORTED_SRS 7 +#define OGRERR_INVALID_HANDLE 8 +#define OGRERR_NON_EXISTING_FEATURE 9 /* added in GDAL 2.0 */ + +#endif + +typedef int OGRBoolean; + +/* -------------------------------------------------------------------- */ +/* ogr_geometry.h related definitions. */ +/* -------------------------------------------------------------------- */ + +/** + * List of well known binary geometry types. These are used within the BLOBs + * but are also returned from OGRGeometry::getGeometryType() to identify the + * type of a geometry object. + */ +typedef enum +{ + wkbUnknown = 0, /**< unknown type, non-standard */ + + wkbPoint = 1, /**< 0-dimensional geometric object, standard WKB */ + wkbLineString = 2, /**< 1-dimensional geometric object with linear + * interpolation between Points, standard WKB */ + wkbPolygon = 3, /**< planar 2-dimensional geometric object defined + * by 1 exterior boundary and 0 or more interior + * boundaries, standard WKB */ + wkbMultiPoint = 4, /**< GeometryCollection of Points, standard WKB */ + wkbMultiLineString = 5, /**< GeometryCollection of LineStrings, standard WKB */ + wkbMultiPolygon = 6, /**< GeometryCollection of Polygons, standard WKB */ + wkbGeometryCollection = 7, /**< geometric object that is a collection of 1 + or more geometric objects, standard WKB */ + + wkbCircularString = 8, /**< one or more circular arc segments connected end to end, + * ISO SQL/MM Part 3. GDAL >= 2.0 */ + wkbCompoundCurve = 9, /**< sequence of contiguous curves, ISO SQL/MM Part 3. GDAL >= 2.0 */ + wkbCurvePolygon = 10, /**< planar surface, defined by 1 exterior boundary + * and zero or more interior boundaries, that are curves. + * ISO SQL/MM Part 3. GDAL >= 2.0 */ + wkbMultiCurve = 11, /**< GeometryCollection of Curves, ISO SQL/MM Part 3. GDAL >= 2.0 */ + wkbMultiSurface = 12, /**< GeometryCollection of Surfaces, ISO SQL/MM Part 3. GDAL >= 2.0 */ + wkbCurve = 13, /**< Curve (abstract type). ISO SQL/MM Part 3. GDAL >= 2.1 */ + wkbSurface = 14, /**< Surface (abstract type). ISO SQL/MM Part 3. GDAL >= 2.1 */ + wkbPolyhedralSurface = 15,/**< a contiguous collection of polygons, which share common boundary segments, + * ISO SQL/MM Part 3. Reserved in GDAL >= 2.1 but not yet implemented */ + wkbTIN = 16, /**< a PolyhedralSurface consisting only of Triangle patches + * ISO SQL/MM Part 3. Reserved in GDAL >= 2.1 but not yet implemented */ + wkbTriangle = 17, /** < a Triangle. ISO SQL/MM Part 3. Reserved in GDAL >= 2.1 but not yet implemented */ + + wkbNone = 100, /**< non-standard, for pure attribute records */ + wkbLinearRing = 101, /**< non-standard, just for createGeometry() */ + + wkbCircularStringZ = 1008, /**< wkbCircularString with Z component. ISO SQL/MM Part 3. GDAL >= 2.0 */ + wkbCompoundCurveZ = 1009, /**< wkbCompoundCurve with Z component. ISO SQL/MM Part 3. GDAL >= 2.0 */ + wkbCurvePolygonZ = 1010, /**< wkbCurvePolygon with Z component. ISO SQL/MM Part 3. GDAL >= 2.0 */ + wkbMultiCurveZ = 1011, /**< wkbMultiCurve with Z component. ISO SQL/MM Part 3. GDAL >= 2.0 */ + wkbMultiSurfaceZ = 1012, /**< wkbMultiSurface with Z component. ISO SQL/MM Part 3. GDAL >= 2.0 */ + wkbCurveZ = 1013, /**< wkbCurve with Z component. ISO SQL/MM Part 3. GDAL >= 2.1 */ + wkbSurfaceZ = 1014, /**< wkbSurface with Z component. ISO SQL/MM Part 3. GDAL >= 2.1 */ + wkbPolyhedralSurfaceZ = 1015, /**< ISO SQL/MM Part 3. Reserved in GDAL >= 2.1 but not yet implemented */ + wkbTINZ = 1016, /**< ISO SQL/MM Part 3. Reserved in GDAL >= 2.1 but not yet implemented */ + wkbTriangleZ = 1017, /**< ISO SQL/MM Part 3. Reserved in GDAL >= 2.1 but not yet implemented */ + + wkbPointM = 2001, /**< ISO SQL/MM Part 3. GDAL >= 2.1 */ + wkbLineStringM = 2002, /**< ISO SQL/MM Part 3. GDAL >= 2.1 */ + wkbPolygonM = 2003, /**< ISO SQL/MM Part 3. GDAL >= 2.1 */ + wkbMultiPointM = 2004, /**< ISO SQL/MM Part 3. GDAL >= 2.1 */ + wkbMultiLineStringM = 2005, /**< ISO SQL/MM Part 3. GDAL >= 2.1 */ + wkbMultiPolygonM = 2006, /**< ISO SQL/MM Part 3. GDAL >= 2.1 */ + wkbGeometryCollectionM = 2007, /**< ISO SQL/MM Part 3. GDAL >= 2.1 */ + wkbCircularStringM = 2008, /**< ISO SQL/MM Part 3. GDAL >= 2.1 */ + wkbCompoundCurveM = 2009, /**< ISO SQL/MM Part 3. GDAL >= 2.1 */ + wkbCurvePolygonM = 2010, /**< ISO SQL/MM Part 3. GDAL >= 2.1 */ + wkbMultiCurveM = 2011, /**< ISO SQL/MM Part 3. GDAL >= 2.1 */ + wkbMultiSurfaceM = 2012, /**< ISO SQL/MM Part 3. GDAL >= 2.1 */ + wkbCurveM = 2013, /**< ISO SQL/MM Part 3. GDAL >= 2.1 */ + wkbSurfaceM = 2014, /**< ISO SQL/MM Part 3. GDAL >= 2.1 */ + wkbPolyhedralSurfaceM = 2015, /**< ISO SQL/MM Part 3. Reserved in GDAL >= 2.1 but not yet implemented */ + wkbTINM = 2016, /**< ISO SQL/MM Part 3. Reserved in GDAL >= 2.1 but not yet implemented */ + wkbTriangleM = 2017, /**< ISO SQL/MM Part 3. Reserved in GDAL >= 2.1 but not yet implemented */ + + wkbPointZM = 3001, /**< ISO SQL/MM Part 3. GDAL >= 2.1 */ + wkbLineStringZM = 3002, /**< ISO SQL/MM Part 3. GDAL >= 2.1 */ + wkbPolygonZM = 3003, /**< ISO SQL/MM Part 3. GDAL >= 2.1 */ + wkbMultiPointZM = 3004, /**< ISO SQL/MM Part 3. GDAL >= 2.1 */ + wkbMultiLineStringZM = 3005, /**< ISO SQL/MM Part 3. GDAL >= 2.1 */ + wkbMultiPolygonZM = 3006, /**< ISO SQL/MM Part 3. GDAL >= 2.1 */ + wkbGeometryCollectionZM = 3007, /**< ISO SQL/MM Part 3. GDAL >= 2.1 */ + wkbCircularStringZM = 3008, /**< ISO SQL/MM Part 3. GDAL >= 2.1 */ + wkbCompoundCurveZM = 3009, /**< ISO SQL/MM Part 3. GDAL >= 2.1 */ + wkbCurvePolygonZM = 3010, /**< ISO SQL/MM Part 3. GDAL >= 2.1 */ + wkbMultiCurveZM = 3011, /**< ISO SQL/MM Part 3. GDAL >= 2.1 */ + wkbMultiSurfaceZM = 3012, /**< ISO SQL/MM Part 3. GDAL >= 2.1 */ + wkbCurveZM = 3013, /**< ISO SQL/MM Part 3. GDAL >= 2.1 */ + wkbSurfaceZM = 3014, /**< ISO SQL/MM Part 3. GDAL >= 2.1 */ + wkbPolyhedralSurfaceZM = 3015, /**< ISO SQL/MM Part 3. Reserved in GDAL >= 2.1 but not yet implemented */ + wkbTINZM = 3016, /**< ISO SQL/MM Part 3. Reserved in GDAL >= 2.1 but not yet implemented */ + wkbTriangleZM = 3017, /**< ISO SQL/MM Part 3. Reserved in GDAL >= 2.1 but not yet implemented */ + + wkbPoint25D = 0x80000001, /**< 2.5D extension as per 99-402 */ + wkbLineString25D = 0x80000002, /**< 2.5D extension as per 99-402 */ + wkbPolygon25D = 0x80000003, /**< 2.5D extension as per 99-402 */ + wkbMultiPoint25D = 0x80000004, /**< 2.5D extension as per 99-402 */ + wkbMultiLineString25D = 0x80000005, /**< 2.5D extension as per 99-402 */ + wkbMultiPolygon25D = 0x80000006, /**< 2.5D extension as per 99-402 */ + wkbGeometryCollection25D = 0x80000007 /**< 2.5D extension as per 99-402 */ + +} OGRwkbGeometryType; + +/** + * Output variants of WKB we support. + * + * 99-402 was a short-lived extension to SFSQL 1.1 that used a high-bit flag + * to indicate the presence of Z coordinates in a WKB geometry. + * + * SQL/MM Part 3 and SFSQL 1.2 use offsets of 1000 (Z), 2000 (M) and 3000 (ZM) + * to indicate the present of higher dimensional coordinates in a WKB geometry. + * Reference: + * 09-009_Committee_Draft_ISOIEC_CD_13249-3_SQLMM_Spatial.pdf, + * ISO/IEC JTC 1/SC 32 N 1820, ISO/IEC CD 13249-3:201x(E), Date: 2009-01-16. + * The codes are also found in §8.2.3 of + * OGC 06-103r4 "OpenGIS® Implementation Standard for Geographic information - Simple feature access - Part 1: Common architecture", v1.2.1 + */ +typedef enum +{ + wkbVariantOldOgc, /**< Old-style 99-402 extended dimension (Z) WKB types */ + wkbVariantIso, /**< SFSQL 1.2 and ISO SQL/MM Part 3 extended dimension (Z&M) WKB types */ + wkbVariantPostGIS1 /**< PostGIS 1.X has different codes for CurvePolygon, MultiCurve and MultiSurface */ +} OGRwkbVariant; + + +/** @deprecated in GDAL 2.0. Use wkbHasZ() or wkbSetZ() instead */ +#ifndef GDAL_COMPILATION +#define wkb25DBit 0x80000000 +#endif + +/** Return the 2D geometry type corresponding to the specified geometry type */ +#define wkbFlatten(x) OGR_GT_Flatten((OGRwkbGeometryType)(x)) + +/** Return if the geometry type is a 3D geometry type + * @since GDAL 2.0 + */ +#define wkbHasZ(x) (OGR_GT_HasZ(x) != 0) + +/** Return the 3D geometry type corresponding to the specified geometry type. + * @since GDAL 2.0 + */ +#define wkbSetZ(x) OGR_GT_SetZ(x) + +/** Return if the geometry type is a measured geometry type + * @since GDAL 2.1 + */ +#define wkbHasM(x) (OGR_GT_HasM(x) != 0) + +/** Return the measured geometry type corresponding to the specified geometry type. + * @since GDAL 2.1 + */ +#define wkbSetM(x) OGR_GT_SetM(x) + +#define ogrZMarker 0x21125711 + +const char CPL_DLL * OGRGeometryTypeToName( OGRwkbGeometryType eType ); +OGRwkbGeometryType CPL_DLL OGRMergeGeometryTypes( OGRwkbGeometryType eMain, + OGRwkbGeometryType eExtra ); +OGRwkbGeometryType CPL_DLL OGRMergeGeometryTypesEx( OGRwkbGeometryType eMain, + OGRwkbGeometryType eExtra, + int bAllowPromotingToCurves ); +OGRwkbGeometryType CPL_DLL OGR_GT_Flatten( OGRwkbGeometryType eType ); +OGRwkbGeometryType CPL_DLL OGR_GT_SetZ( OGRwkbGeometryType eType ); +OGRwkbGeometryType CPL_DLL OGR_GT_SetM( OGRwkbGeometryType eType ); +OGRwkbGeometryType CPL_DLL OGR_GT_SetModifier( OGRwkbGeometryType eType, int bSetZ, int bSetM ); +int CPL_DLL OGR_GT_HasZ( OGRwkbGeometryType eType ); +int CPL_DLL OGR_GT_HasM( OGRwkbGeometryType eType ); +int CPL_DLL OGR_GT_IsSubClassOf( OGRwkbGeometryType eType, + OGRwkbGeometryType eSuperType ); +int CPL_DLL OGR_GT_IsCurve( OGRwkbGeometryType ); +int CPL_DLL OGR_GT_IsSurface( OGRwkbGeometryType ); +int CPL_DLL OGR_GT_IsNonLinear( OGRwkbGeometryType ); +OGRwkbGeometryType CPL_DLL OGR_GT_GetCollection( OGRwkbGeometryType eType ); +OGRwkbGeometryType CPL_DLL OGR_GT_GetCurve( OGRwkbGeometryType eType ); +OGRwkbGeometryType CPL_DLL OGR_GT_GetLinear( OGRwkbGeometryType eType ); + +typedef enum +{ + wkbXDR = 0, /* MSB/Sun/Motoroloa: Most Significant Byte First */ + wkbNDR = 1 /* LSB/Intel/Vax: Least Significant Byte First */ +} OGRwkbByteOrder; + +#ifndef NO_HACK_FOR_IBM_DB2_V72 +# define HACK_FOR_IBM_DB2_V72 +#endif + +#ifdef HACK_FOR_IBM_DB2_V72 +# define DB2_V72_FIX_BYTE_ORDER(x) ((((x) & 0x31) == (x)) ? ((x) & 0x1) : (x)) +# define DB2_V72_UNFIX_BYTE_ORDER(x) ((unsigned char) (OGRGeometry::bGenerate_DB2_V72_BYTE_ORDER ? ((x) | 0x30) : (x))) +#else +# define DB2_V72_FIX_BYTE_ORDER(x) (x) +# define DB2_V72_UNFIX_BYTE_ORDER(x) (x) +#endif + +/** Alter field name. + * Used by OGR_L_AlterFieldDefn(). + */ +#define ALTER_NAME_FLAG 0x1 + +/** Alter field type. + * Used by OGR_L_AlterFieldDefn(). + */ +#define ALTER_TYPE_FLAG 0x2 + +/** Alter field width and precision. + * Used by OGR_L_AlterFieldDefn(). + */ +#define ALTER_WIDTH_PRECISION_FLAG 0x4 + +/** Alter field NOT NULL constraint. + * Used by OGR_L_AlterFieldDefn(). + * @since GDAL 2.0 + */ +#define ALTER_NULLABLE_FLAG 0x8 + +/** Alter field DEFAULT value. + * Used by OGR_L_AlterFieldDefn(). + * @since GDAL 2.0 + */ +#define ALTER_DEFAULT_FLAG 0x10 + +/** Alter all parameters of field definition. + * Used by OGR_L_AlterFieldDefn(). + */ +#define ALTER_ALL_FLAG (ALTER_NAME_FLAG | ALTER_TYPE_FLAG | ALTER_WIDTH_PRECISION_FLAG | ALTER_NULLABLE_FLAG | ALTER_DEFAULT_FLAG) + + +/** Validate that fields respect not-null constraints. + * Used by OGR_F_Validate(). + * @since GDAL 2.0 + */ +#define OGR_F_VAL_NULL 0x00000001 + +/** Validate that geometries respect geometry column type. + * Used by OGR_F_Validate(). + * @since GDAL 2.0 + */ +#define OGR_F_VAL_GEOM_TYPE 0x00000002 + +/** Validate that (string) fields respect field width. + * Used by OGR_F_Validate(). + * @since GDAL 2.0 + */ +#define OGR_F_VAL_WIDTH 0x00000004 + +/** Allow fields that are null when there's an associated default value. + * This can be used for drivers where the low-level layers will automatically set the + * field value to the associated default value. + * This flag only makes sense if OGR_F_VAL_NULL is set too. + * Used by OGR_F_Validate(). + * @since GDAL 2.0 + */ +#define OGR_F_VAL_ALLOW_NULL_WHEN_DEFAULT 0x00000008 + +/** Allow geometry fields to have a different coordinate dimension that their + * geometry column type. + * This flag only makes sense if OGR_F_VAL_GEOM_TYPE is set too. + * Used by OGR_F_Validate(). + * @since GDAL 2.1 + */ +#define OGR_F_VAL_ALLOW_DIFFERENT_GEOM_DIM 0x00000010 + +/** Enable all validation tests (except OGR_F_VAL_ALLOW_DIFFERENT_GEOM_DIM) + * Used by OGR_F_Validate(). + * @since GDAL 2.0 + */ +#define OGR_F_VAL_ALL (0x7FFFFFFF & ~OGR_F_VAL_ALLOW_DIFFERENT_GEOM_DIM) + +/************************************************************************/ +/* ogr_feature.h related definitions. */ +/************************************************************************/ + +/** + * List of feature field types. This list is likely to be extended in the + * future ... avoid coding applications based on the assumption that all + * field types can be known. + */ + +typedef enum +{ + /** Simple 32bit integer */ OFTInteger = 0, + /** List of 32bit integers */ OFTIntegerList = 1, + /** Double Precision floating point */ OFTReal = 2, + /** List of doubles */ OFTRealList = 3, + /** String of ASCII chars */ OFTString = 4, + /** Array of strings */ OFTStringList = 5, + /** deprecated */ OFTWideString = 6, + /** deprecated */ OFTWideStringList = 7, + /** Raw Binary data */ OFTBinary = 8, + /** Date */ OFTDate = 9, + /** Time */ OFTTime = 10, + /** Date and Time */ OFTDateTime = 11, + /** Single 64bit integer */ OFTInteger64 = 12, + /** List of 64bit integers */ OFTInteger64List = 13, + OFTMaxType = 13 +} OGRFieldType; + +/** + * List of field subtypes. A subtype represents a hint, a restriction of the + * main type, that is not strictly necessary to consult. + * This list is likely to be extended in the + * future ... avoid coding applications based on the assumption that all + * field types can be known. + * Most subtypes only make sense for a restricted set of main types. + * @since GDAL 2.0 + */ +typedef enum +{ + /** No subtype. This is the default value */ OFSTNone = 0, + /** Boolean integer. Only valid for OFTInteger and OFTIntegerList.*/ + OFSTBoolean = 1, + /** Signed 16-bit integer. Only valid for OFTInteger and OFTIntegerList. */ + OFSTInt16 = 2, + /** Single precision (32 bit) floating point. Only valid for OFTReal and OFTRealList. */ + OFSTFloat32 = 3, + OFSTMaxSubType = 3 +} OGRFieldSubType; + +/** + * Display justification for field values. + */ + +typedef enum +{ + OJUndefined = 0, + OJLeft = 1, + OJRight = 2 +} OGRJustification; + +#define OGRNullFID -1 +#define OGRUnsetMarker -21121 + +/************************************************************************/ +/* OGRField */ +/************************************************************************/ + +/** + * OGRFeature field attribute value union. + */ + +typedef union { + int Integer; + GIntBig Integer64; + double Real; + char *String; + + struct { + int nCount; + int *paList; + } IntegerList; + + struct { + int nCount; + GIntBig *paList; + } Integer64List; + + struct { + int nCount; + double *paList; + } RealList; + + struct { + int nCount; + char **paList; + } StringList; + + struct { + int nCount; + GByte *paData; + } Binary; + + struct { + int nMarker1; + int nMarker2; + } Set; + + struct { + GInt16 Year; + GByte Month; + GByte Day; + GByte Hour; + GByte Minute; + GByte TZFlag; /* 0=unknown, 1=localtime(ambiguous), + 100=GMT, 104=GMT+1, 80=GMT-5, etc */ + GByte Reserved; /* must be set to 0 */ + float Second; /* with millisecond accuracy. at the end of the structure, so as to keep it 12 bytes on 32 bit */ + } Date; +} OGRField; + +#define OGR_GET_MS(floatingpoint_sec) (int)(((floatingpoint_sec) - (int)(floatingpoint_sec)) * 1000 + 0.5) + +int CPL_DLL OGRParseDate( const char *pszInput, OGRField *psOutput, + int nOptions ); + +/* -------------------------------------------------------------------- */ +/* Constants from ogrsf_frmts.h for capabilities. */ +/* -------------------------------------------------------------------- */ +#define OLCRandomRead "RandomRead" +#define OLCSequentialWrite "SequentialWrite" +#define OLCRandomWrite "RandomWrite" +#define OLCFastSpatialFilter "FastSpatialFilter" +#define OLCFastFeatureCount "FastFeatureCount" +#define OLCFastGetExtent "FastGetExtent" +#define OLCCreateField "CreateField" +#define OLCDeleteField "DeleteField" +#define OLCReorderFields "ReorderFields" +#define OLCAlterFieldDefn "AlterFieldDefn" +#define OLCTransactions "Transactions" +#define OLCDeleteFeature "DeleteFeature" +#define OLCFastSetNextByIndex "FastSetNextByIndex" +#define OLCStringsAsUTF8 "StringsAsUTF8" +#define OLCIgnoreFields "IgnoreFields" +#define OLCCreateGeomField "CreateGeomField" +#define OLCCurveGeometries "CurveGeometries" +#define OLCMeasuredGeometries "MeasuredGeometries" + +#define ODsCCreateLayer "CreateLayer" +#define ODsCDeleteLayer "DeleteLayer" +#define ODsCCreateGeomFieldAfterCreateLayer "CreateGeomFieldAfterCreateLayer" +#define ODsCCurveGeometries "CurveGeometries" +#define ODsCTransactions "Transactions" +#define ODsCEmulatedTransactions "EmulatedTransactions" +#define ODsCMeasuredGeometries "MeasuredGeometries" + +#define ODrCCreateDataSource "CreateDataSource" +#define ODrCDeleteDataSource "DeleteDataSource" + +/* -------------------------------------------------------------------- */ +/* Layer metadata items. */ +/* -------------------------------------------------------------------- */ +/** Capability set to YES as metadata on a layer that has features with + * 64 bit identifiers. + @since GDAL 2.0 + */ +#define OLMD_FID64 "OLMD_FID64" + +/************************************************************************/ +/* ogr_featurestyle.h related definitions. */ +/************************************************************************/ + +/** + * OGRStyleTool derived class types (returned by GetType()). + */ + +typedef enum ogr_style_tool_class_id +{ + OGRSTCNone = 0, + OGRSTCPen = 1, + OGRSTCBrush = 2, + OGRSTCSymbol = 3, + OGRSTCLabel = 4, + OGRSTCVector = 5 +} OGRSTClassId; + +/** + * List of units supported by OGRStyleTools. + */ +typedef enum ogr_style_tool_units_id +{ + OGRSTUGround = 0, + OGRSTUPixel = 1, + OGRSTUPoints = 2, + OGRSTUMM = 3, + OGRSTUCM = 4, + OGRSTUInches = 5 +} OGRSTUnitId; + +/** + * List of parameters for use with OGRStylePen. + */ +typedef enum ogr_style_tool_param_pen_id +{ + OGRSTPenColor = 0, + OGRSTPenWidth = 1, + OGRSTPenPattern = 2, + OGRSTPenId = 3, + OGRSTPenPerOffset = 4, + OGRSTPenCap = 5, + OGRSTPenJoin = 6, + OGRSTPenPriority = 7, + OGRSTPenLast = 8 + +} OGRSTPenParam; + +/** + * List of parameters for use with OGRStyleBrush. + */ +typedef enum ogr_style_tool_param_brush_id +{ + OGRSTBrushFColor = 0, + OGRSTBrushBColor = 1, + OGRSTBrushId = 2, + OGRSTBrushAngle = 3, + OGRSTBrushSize = 4, + OGRSTBrushDx = 5, + OGRSTBrushDy = 6, + OGRSTBrushPriority = 7, + OGRSTBrushLast = 8 + +} OGRSTBrushParam; + + +/** + * List of parameters for use with OGRStyleSymbol. + */ +typedef enum ogr_style_tool_param_symbol_id +{ + OGRSTSymbolId = 0, + OGRSTSymbolAngle = 1, + OGRSTSymbolColor = 2, + OGRSTSymbolSize = 3, + OGRSTSymbolDx = 4, + OGRSTSymbolDy = 5, + OGRSTSymbolStep = 6, + OGRSTSymbolPerp = 7, + OGRSTSymbolOffset = 8, + OGRSTSymbolPriority = 9, + OGRSTSymbolFontName = 10, + OGRSTSymbolOColor = 11, + OGRSTSymbolLast = 12 + +} OGRSTSymbolParam; + +/** + * List of parameters for use with OGRStyleLabel. + */ +typedef enum ogr_style_tool_param_label_id +{ + OGRSTLabelFontName = 0, + OGRSTLabelSize = 1, + OGRSTLabelTextString = 2, + OGRSTLabelAngle = 3, + OGRSTLabelFColor = 4, + OGRSTLabelBColor = 5, + OGRSTLabelPlacement = 6, + OGRSTLabelAnchor = 7, + OGRSTLabelDx = 8, + OGRSTLabelDy = 9, + OGRSTLabelPerp = 10, + OGRSTLabelBold = 11, + OGRSTLabelItalic = 12, + OGRSTLabelUnderline = 13, + OGRSTLabelPriority = 14, + OGRSTLabelStrikeout = 15, + OGRSTLabelStretch = 16, + OGRSTLabelAdjHor = 17, + OGRSTLabelAdjVert = 18, + OGRSTLabelHColor = 19, + OGRSTLabelOColor = 20, + OGRSTLabelLast = 21 + +} OGRSTLabelParam; + +/* ------------------------------------------------------------------- */ +/* Version checking */ +/* -------------------------------------------------------------------- */ + +/* Note to developers : please keep this section in sync with gdal.h */ + +#ifndef GDAL_VERSION_INFO_DEFINED +#define GDAL_VERSION_INFO_DEFINED +const char CPL_DLL * CPL_STDCALL GDALVersionInfo( const char * ); +#endif + +#ifndef GDAL_CHECK_VERSION + +/** Return TRUE if GDAL library version at runtime matches nVersionMajor.nVersionMinor. + + The purpose of this method is to ensure that calling code will run with the GDAL + version it is compiled for. It is primarily indented for external plugins. + + @param nVersionMajor Major version to be tested against + @param nVersionMinor Minor version to be tested against + @param pszCallingComponentName If not NULL, in case of version mismatch, the method + will issue a failure mentioning the name of + the calling component. + */ +int CPL_DLL CPL_STDCALL GDALCheckVersion( int nVersionMajor, int nVersionMinor, + const char* pszCallingComponentName); + +/** Helper macro for GDALCheckVersion */ +#define GDAL_CHECK_VERSION(pszCallingComponentName) \ + GDALCheckVersion(GDAL_VERSION_MAJOR, GDAL_VERSION_MINOR, pszCallingComponentName) + +#endif + +CPL_C_END + +#endif /* ndef OGR_CORE_H_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/ogr_expat.h b/modules/globebrowsing/ext/gdal/include/ogr_expat.h new file mode 100644 index 0000000000..bc19366191 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/ogr_expat.h @@ -0,0 +1,58 @@ +/****************************************************************************** + * $Id$ + * + * Project: OGR + * Purpose: Convenience function for parsing with Expat library + * Author: Even Rouault, even dot rouault at mines dash paris dot org + * + ****************************************************************************** + * Copyright (c) 2009, Even Rouault + * + * 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. + ****************************************************************************/ + +#ifndef OGR_EXPATH_INCLUDED +#define OGR_EXPATH_INCLUDED + +#ifdef HAVE_EXPAT + +#include "cpl_port.h" +#include + +/* Compatibility stuff for expat >= 1.95.0 and < 1.95.7 */ +#ifndef XMLCALL +#define XMLCALL +#endif +#ifndef XML_STATUS_OK +#define XML_STATUS_OK 1 +#define XML_STATUS_ERROR 0 +#endif + +/* XML_StopParser only available for expat >= 1.95.8 */ +#if !defined(XML_MAJOR_VERSION) || (XML_MAJOR_VERSION * 10000 + XML_MINOR_VERSION * 100 + XML_MICRO_VERSION) < 19508 +#define XML_StopParser(parser, resumable) +#warning "Expat version is too old and does not have XML_StopParser. Corrupted files could hang OGR" +#endif + +/* Only for internal use ! */ +XML_Parser CPL_DLL OGRCreateExpatXMLParser(void); + +#endif /* HAVE_EXPAT */ + +#endif /* OGR_EXPATH_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/ogr_feature.h b/modules/globebrowsing/ext/gdal/include/ogr_feature.h new file mode 100644 index 0000000000..cd01ffb482 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/ogr_feature.h @@ -0,0 +1,490 @@ +/****************************************************************************** + * $Id$ + * + * Project: OpenGIS Simple Features Reference Implementation + * Purpose: Class for representing a whole feature, and layer schemas. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, Les Technologies SoftMap Inc. + * Copyright (c) 2008-2013, Even Rouault + * + * 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. + ****************************************************************************/ + +#ifndef OGR_FEATURE_H_INCLUDED +#define OGR_FEATURE_H_INCLUDED + +#include "ogr_geometry.h" +#include "ogr_featurestyle.h" +#include "cpl_atomic_ops.h" + +/** + * \file ogr_feature.h + * + * Simple feature classes. + */ + +/************************************************************************/ +/* OGRFieldDefn */ +/************************************************************************/ + +/** + * Definition of an attribute of an OGRFeatureDefn. A field is described by : + *
    + *
  • a name. See SetName() / GetNameRef()
  • + *
  • a type: OFTString, OFTInteger, OFTReal, ... See SetType() / GetType()
  • + *
  • a subtype (optional): OFSTBoolean, ... See SetSubType() / GetSubType()
  • + *
  • a width (optional): maximal number of characters. See SetWidth() / GetWidth()
  • + *
  • a precision (optional): number of digits after decimal point. See SetPrecision() / GetPrecision()
  • + *
  • a NOT NULL constraint (optional). See SetNullable() / IsNullable()
  • + *
  • a default value (optional). See SetDefault() / GetDefault()
  • + *
  • a boolean to indicate whether it should be ignored when retrieving features. See SetIgnored() / IsIgnored()
  • + *
+ */ + +class CPL_DLL OGRFieldDefn +{ + private: + char *pszName; + OGRFieldType eType; + OGRJustification eJustify; + int nWidth; /* zero is variable */ + int nPrecision; + char *pszDefault; + + int bIgnore; + OGRFieldSubType eSubType; + + int bNullable; + + void Initialize( const char *, OGRFieldType ); + + public: + OGRFieldDefn( const char *, OGRFieldType ); + OGRFieldDefn( OGRFieldDefn * ); + ~OGRFieldDefn(); + + void SetName( const char * ); + const char *GetNameRef() { return pszName; } + + OGRFieldType GetType() { return eType; } + void SetType( OGRFieldType eTypeIn ); + static const char *GetFieldTypeName( OGRFieldType ); + + OGRFieldSubType GetSubType() { return eSubType; } + void SetSubType( OGRFieldSubType eSubTypeIn ); + static const char *GetFieldSubTypeName( OGRFieldSubType ); + + OGRJustification GetJustify() { return eJustify; } + void SetJustify( OGRJustification eJustifyIn ) + { eJustify = eJustifyIn; } + + int GetWidth() { return nWidth; } + void SetWidth( int nWidthIn ) { nWidth = MAX(0,nWidthIn); } + + int GetPrecision() { return nPrecision; } + void SetPrecision( int nPrecisionIn ) + { nPrecision = nPrecisionIn; } + + void Set( const char *, OGRFieldType, int = 0, int = 0, + OGRJustification = OJUndefined ); + + void SetDefault( const char* ); + const char *GetDefault() const; + int IsDefaultDriverSpecific() const; + + int IsIgnored() { return bIgnore; } + void SetIgnored( int bIgnoreIn ) { bIgnore = bIgnoreIn; } + + int IsNullable() const { return bNullable; } + void SetNullable( int bNullableIn ) { bNullable = bNullableIn; } + + int IsSame( const OGRFieldDefn * ) const; + + private: + CPL_DISALLOW_COPY_ASSIGN(OGRFieldDefn); +}; + +/************************************************************************/ +/* OGRGeomFieldDefn */ +/************************************************************************/ + +/** + * Definition of a geometry field of an OGRFeatureDefn. A geometry field is + * described by : + *
    + *
  • a name. See SetName() / GetNameRef()
  • + *
  • a type: wkbPoint, wkbLineString, ... See SetType() / GetType()
  • + *
  • a spatial reference system (optional). See SetSpatialRef() / GetSpatialRef()
  • + *
  • a NOT NULL constraint (optional). See SetNullable() / IsNullable()
  • + *
  • a boolean to indicate whether it should be ignored when retrieving features. See SetIgnored() / IsIgnored()
  • + *
+ * + * @since OGR 1.11 + */ + +class CPL_DLL OGRGeomFieldDefn +{ +protected: + char *pszName; + OGRwkbGeometryType eGeomType; /* all values possible except wkbNone */ + OGRSpatialReference* poSRS; + + int bIgnore; + int bNullable; + + void Initialize( const char *, OGRwkbGeometryType ); + +public: + OGRGeomFieldDefn(const char *pszNameIn, + OGRwkbGeometryType eGeomTypeIn); + OGRGeomFieldDefn( OGRGeomFieldDefn * ); + virtual ~OGRGeomFieldDefn(); + + void SetName( const char * ); + const char *GetNameRef() { return pszName; } + + OGRwkbGeometryType GetType() { return eGeomType; } + void SetType( OGRwkbGeometryType eTypeIn ); + + virtual OGRSpatialReference* GetSpatialRef(); + void SetSpatialRef(OGRSpatialReference* poSRSIn); + + int IsIgnored() { return bIgnore; } + void SetIgnored( int bIgnoreIn ) { bIgnore = bIgnoreIn; } + + int IsNullable() const { return bNullable; } + void SetNullable( int bNullableIn ) { bNullable = bNullableIn; } + + int IsSame( OGRGeomFieldDefn * ); + + private: + CPL_DISALLOW_COPY_ASSIGN(OGRGeomFieldDefn); +}; + +/************************************************************************/ +/* OGRFeatureDefn */ +/************************************************************************/ + +/** + * Definition of a feature class or feature layer. + * + * This object contains schema information for a set of OGRFeatures. In + * table based systems, an OGRFeatureDefn is essentially a layer. In more + * object oriented approaches (such as SF CORBA) this can represent a class + * of features but doesn't necessarily relate to all of a layer, or just one + * layer. + * + * This object also can contain some other information such as a name and + * potentially other metadata. + * + * It is essentially a collection of field descriptions (OGRFieldDefn class). + * Starting with GDAL 1.11, in addition to attribute fields, it can also + * contain multiple geometry fields (OGRGeomFieldDefn class). + * + * It is reasonable for different translators to derive classes from + * OGRFeatureDefn with additional translator specific information. + */ + +class CPL_DLL OGRFeatureDefn +{ + protected: + volatile int nRefCount; + + int nFieldCount; + OGRFieldDefn **papoFieldDefn; + + int nGeomFieldCount; + OGRGeomFieldDefn **papoGeomFieldDefn; + + char *pszFeatureClassName; + + int bIgnoreStyle; + + public: + OGRFeatureDefn( const char * pszName = NULL ); + virtual ~OGRFeatureDefn(); + + virtual const char *GetName(); + + virtual int GetFieldCount(); + virtual OGRFieldDefn *GetFieldDefn( int i ); + virtual int GetFieldIndex( const char * ); + + virtual void AddFieldDefn( OGRFieldDefn * ); + virtual OGRErr DeleteFieldDefn( int iField ); + virtual OGRErr ReorderFieldDefns( int* panMap ); + + virtual int GetGeomFieldCount(); + virtual OGRGeomFieldDefn *GetGeomFieldDefn( int i ); + virtual int GetGeomFieldIndex( const char * ); + + virtual void AddGeomFieldDefn( OGRGeomFieldDefn *, int bCopy = TRUE ); + virtual OGRErr DeleteGeomFieldDefn( int iGeomField ); + + virtual OGRwkbGeometryType GetGeomType(); + virtual void SetGeomType( OGRwkbGeometryType ); + + virtual OGRFeatureDefn *Clone(); + + int Reference() { return CPLAtomicInc(&nRefCount); } + int Dereference() { return CPLAtomicDec(&nRefCount); } + int GetReferenceCount() { return nRefCount; } + void Release(); + + virtual int IsGeometryIgnored(); + virtual void SetGeometryIgnored( int bIgnore ); + virtual int IsStyleIgnored() { return bIgnoreStyle; } + virtual void SetStyleIgnored( int bIgnore ) { bIgnoreStyle = bIgnore; } + + virtual int IsSame( OGRFeatureDefn * poOtherFeatureDefn ); + + static OGRFeatureDefn *CreateFeatureDefn( const char *pszName = NULL ); + static void DestroyFeatureDefn( OGRFeatureDefn * ); + + private: + CPL_DISALLOW_COPY_ASSIGN(OGRFeatureDefn); +}; + +/************************************************************************/ +/* OGRFeature */ +/************************************************************************/ + +/** + * A simple feature, including geometry and attributes. + */ + +class CPL_DLL OGRFeature +{ + private: + + GIntBig nFID; + OGRFeatureDefn *poDefn; + OGRGeometry **papoGeometries; + OGRField *pauFields; + char *m_pszNativeData; + char *m_pszNativeMediaType; + + bool SetFieldInternal( int i, OGRField * puValue ); + + protected: + char * m_pszStyleString; + OGRStyleTable *m_poStyleTable; + char * m_pszTmpFieldValue; + + public: + OGRFeature( OGRFeatureDefn * ); + virtual ~OGRFeature(); + + OGRFeatureDefn *GetDefnRef() { return poDefn; } + + OGRErr SetGeometryDirectly( OGRGeometry * ); + OGRErr SetGeometry( OGRGeometry * ); + OGRGeometry *GetGeometryRef(); + OGRGeometry *StealGeometry() CPL_WARN_UNUSED_RESULT; + + int GetGeomFieldCount() + { return poDefn->GetGeomFieldCount(); } + OGRGeomFieldDefn *GetGeomFieldDefnRef( int iField ) + { return poDefn->GetGeomFieldDefn(iField); } + int GetGeomFieldIndex( const char * pszName) + { return poDefn->GetGeomFieldIndex(pszName); } + + OGRGeometry* GetGeomFieldRef(int iField); + OGRGeometry* StealGeometry(int iField); + OGRGeometry* GetGeomFieldRef(const char* pszFName); + OGRErr SetGeomFieldDirectly( int iField, OGRGeometry * ); + OGRErr SetGeomField( int iField, OGRGeometry * ); + + OGRFeature *Clone() CPL_WARN_UNUSED_RESULT; + virtual OGRBoolean Equal( OGRFeature * poFeature ); + + int GetFieldCount() { return poDefn->GetFieldCount(); } + OGRFieldDefn *GetFieldDefnRef( int iField ) + { return poDefn->GetFieldDefn(iField); } + int GetFieldIndex( const char * pszName) + { return poDefn->GetFieldIndex(pszName);} + + int IsFieldSet( int iField ); + + void UnsetField( int iField ); + + OGRField *GetRawFieldRef( int i ) { return pauFields + i; } + + int GetFieldAsInteger( int i ); + GIntBig GetFieldAsInteger64( int i ); + double GetFieldAsDouble( int i ); + const char *GetFieldAsString( int i ); + const int *GetFieldAsIntegerList( int i, int *pnCount ); + const GIntBig *GetFieldAsInteger64List( int i, int *pnCount ); + const double *GetFieldAsDoubleList( int i, int *pnCount ); + char **GetFieldAsStringList( int i ); + GByte *GetFieldAsBinary( int i, int *pnCount ); + int GetFieldAsDateTime( int i, + int *pnYear, int *pnMonth, int *pnDay, + int *pnHour, int *pnMinute, int *pnSecond, + int *pnTZFlag ); + int GetFieldAsDateTime( int i, + int *pnYear, int *pnMonth, int *pnDay, + int *pnHour, int *pnMinute, float *pfSecond, + int *pnTZFlag ); + + int GetFieldAsInteger( const char *pszFName ) + { return GetFieldAsInteger( GetFieldIndex(pszFName) ); } + GIntBig GetFieldAsInteger64( const char *pszFName ) + { return GetFieldAsInteger64( GetFieldIndex(pszFName) ); } + double GetFieldAsDouble( const char *pszFName ) + { return GetFieldAsDouble( GetFieldIndex(pszFName) ); } + const char *GetFieldAsString( const char *pszFName ) + { return GetFieldAsString( GetFieldIndex(pszFName) ); } + const int *GetFieldAsIntegerList( const char *pszFName, + int *pnCount ) + { return GetFieldAsIntegerList( GetFieldIndex(pszFName), + pnCount ); } + const GIntBig *GetFieldAsInteger64List( const char *pszFName, + int *pnCount ) + { return GetFieldAsInteger64List( GetFieldIndex(pszFName), + pnCount ); } + const double *GetFieldAsDoubleList( const char *pszFName, + int *pnCount ) + { return GetFieldAsDoubleList( GetFieldIndex(pszFName), + pnCount ); } + char **GetFieldAsStringList( const char *pszFName ) + { return GetFieldAsStringList(GetFieldIndex(pszFName)); } + + void SetField( int i, int nValue ); + void SetField( int i, GIntBig nValue ); + void SetField( int i, double dfValue ); + void SetField( int i, const char * pszValue ); + void SetField( int i, int nCount, int * panValues ); + void SetField( int i, int nCount, const GIntBig * panValues ); + void SetField( int i, int nCount, double * padfValues ); + void SetField( int i, char ** papszValues ); + void SetField( int i, OGRField * puValue ); + void SetField( int i, int nCount, GByte * pabyBinary ); + void SetField( int i, int nYear, int nMonth, int nDay, + int nHour=0, int nMinute=0, float fSecond=0.f, + int nTZFlag = 0 ); + + void SetField( const char *pszFName, int nValue ) + { SetField( GetFieldIndex(pszFName), nValue ); } + void SetField( const char *pszFName, GIntBig nValue ) + { SetField( GetFieldIndex(pszFName), nValue ); } + void SetField( const char *pszFName, double dfValue ) + { SetField( GetFieldIndex(pszFName), dfValue ); } + void SetField( const char *pszFName, const char * pszValue) + { SetField( GetFieldIndex(pszFName), pszValue ); } + void SetField( const char *pszFName, int nCount, + int * panValues ) + { SetField(GetFieldIndex(pszFName),nCount,panValues);} + void SetField( const char *pszFName, int nCount, + const GIntBig * panValues ) + { SetField(GetFieldIndex(pszFName),nCount,panValues);} + void SetField( const char *pszFName, int nCount, + double * padfValues ) + {SetField(GetFieldIndex(pszFName),nCount,padfValues);} + void SetField( const char *pszFName, char ** papszValues ) + { SetField( GetFieldIndex(pszFName), papszValues); } + void SetField( const char *pszFName, OGRField * puValue ) + { SetField( GetFieldIndex(pszFName), puValue ); } + void SetField( const char *pszFName, + int nYear, int nMonth, int nDay, + int nHour=0, int nMinute=0, float fSecond=0.f, + int nTZFlag = 0 ) + { SetField( GetFieldIndex(pszFName), + nYear, nMonth, nDay, + nHour, nMinute, fSecond, nTZFlag ); } + + GIntBig GetFID() { return nFID; } + virtual OGRErr SetFID( GIntBig nFIDIn ); + + void DumpReadable( FILE *, char** papszOptions = NULL ); + + OGRErr SetFrom( OGRFeature *, int = TRUE); + OGRErr SetFrom( OGRFeature *, int *, int = TRUE ); + OGRErr SetFieldsFrom( OGRFeature *, int *, int = TRUE ); + + OGRErr RemapFields( OGRFeatureDefn *poNewDefn, + int *panRemapSource ); + OGRErr RemapGeomFields( OGRFeatureDefn *poNewDefn, + int *panRemapSource ); + + int Validate( int nValidateFlags, + int bEmitError ); + void FillUnsetWithDefault(int bNotNullableOnly, + char** papszOptions ); + + virtual const char *GetStyleString(); + virtual void SetStyleString( const char * ); + virtual void SetStyleStringDirectly( char * ); + virtual OGRStyleTable *GetStyleTable() { return m_poStyleTable; } + virtual void SetStyleTable(OGRStyleTable *poStyleTable); + virtual void SetStyleTableDirectly(OGRStyleTable *poStyleTable); + + const char *GetNativeData() const { return m_pszNativeData; } + const char *GetNativeMediaType() const { return m_pszNativeMediaType; } + void SetNativeData( const char* pszNativeData ); + void SetNativeMediaType( const char* pszNativeMediaType ); + + static OGRFeature *CreateFeature( OGRFeatureDefn * ); + static void DestroyFeature( OGRFeature * ); + + private: + CPL_DISALLOW_COPY_ASSIGN(OGRFeature); +}; + +/************************************************************************/ +/* OGRFeatureQuery */ +/************************************************************************/ + +class OGRLayer; +class swq_expr_node; +class swq_custom_func_registrar; + +class CPL_DLL OGRFeatureQuery +{ + private: + OGRFeatureDefn *poTargetDefn; + void *pSWQExpr; + + char **FieldCollector( void *, char ** ); + + GIntBig *EvaluateAgainstIndices( swq_expr_node*, OGRLayer *, GIntBig& nFIDCount); + + int CanUseIndex( swq_expr_node*, OGRLayer * ); + + public: + OGRFeatureQuery(); + ~OGRFeatureQuery(); + + OGRErr Compile( OGRFeatureDefn *, const char *, + int bCheck = TRUE, swq_custom_func_registrar* poCustomFuncRegistrar = NULL ); + int Evaluate( OGRFeature * ); + + GIntBig *EvaluateAgainstIndices( OGRLayer *, OGRErr * ); + + int CanUseIndex( OGRLayer * ); + + char **GetUsedFields(); + + void *GetSWQExpr() { return pSWQExpr; } +}; + +#endif /* ndef OGR_FEATURE_H_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/ogr_featurestyle.h b/modules/globebrowsing/ext/gdal/include/ogr_featurestyle.h new file mode 100644 index 0000000000..6230ef1cce --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/ogr_featurestyle.h @@ -0,0 +1,466 @@ +/****************************************************************************** + * $Id$ + * + * Project: OpenGIS Simple Features Reference Implementation + * Purpose: Define of Feature Representation + * Author: Stephane Villeneuve, stephane.v@videtron.ca + * + ****************************************************************************** + * 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. + ****************************************************************************/ + +#ifndef OGR_FEATURESTYLE_INCLUDE +#define OGR_FEATURESTYLE_INCLUDE + +#include "cpl_conv.h" +#include "cpl_string.h" +#include "ogr_core.h" + +class OGRFeature; + +/** + * \file ogr_featurestyle.h + * + * Simple feature style classes. + */ + +/* + * All OGRStyleTool param lists are defined in ogr_core.h. + */ + +typedef enum ogr_style_type +{ + OGRSTypeString, + OGRSTypeDouble, + OGRSTypeInteger, + OGRSTypeBoolean +} OGRSType; + +typedef struct ogr_style_param +{ + int eParam; + const char *pszToken; + GBool bGeoref; + OGRSType eType; +} OGRStyleParamId; + + +typedef struct ogr_style_value +{ + char *pszValue; + double dfValue; + int nValue; // Used for both integer and boolean types + GBool bValid; + OGRSTUnitId eUnit; +} OGRStyleValue; + + +// Every time a pszStyleString given in parameter is NULL, +// the StyleString defined in the Mgr will be use. + +/** + * This class represents a style table + */ +class CPL_DLL OGRStyleTable +{ + private: + char **m_papszStyleTable; + + CPLString osLastRequestedStyleName; + int iNextStyle; + + public: + OGRStyleTable(); + ~OGRStyleTable(); + GBool AddStyle(const char *pszName,const char *pszStyleString); + GBool RemoveStyle(const char *pszName); + GBool ModifyStyle(const char *pszName, const char *pszStyleString); + + GBool SaveStyleTable(const char *pszFilename); + GBool LoadStyleTable(const char *pszFilename); + const char *Find(const char *pszStyleString); + GBool IsExist(const char *pszName); + const char *GetStyleName(const char *pszName); + void Print(FILE *fpOut); + void Clear(); + OGRStyleTable *Clone(); + void ResetStyleStringReading(); + const char *GetNextStyle(); + const char *GetLastStyleName(); +}; + + +class OGRStyleTool; + +/** + * This class represents a style manager + */ +class CPL_DLL OGRStyleMgr +{ + private: + OGRStyleTable *m_poDataSetStyleTable; + char *m_pszStyleString; + + public: + OGRStyleMgr(OGRStyleTable *poDataSetStyleTable = NULL); + ~OGRStyleMgr(); + + GBool SetFeatureStyleString(OGRFeature *,const char *pszStyleString=NULL, + GBool bNoMatching = FALSE); + /* It will set in the given feature the pszStyleString with + the style or will set the style name found in + dataset StyleTable (if bNoMatching == FALSE). */ + + const char *InitFromFeature(OGRFeature *); + GBool InitStyleString(const char *pszStyleString = NULL); + + const char *GetStyleName(const char *pszStyleString= NULL); + const char *GetStyleByName(const char *pszStyleName); + + GBool AddStyle(const char *pszStyleName, const char *pszStyleString=NULL); + + const char *GetStyleString(OGRFeature * = NULL); + + GBool AddPart(OGRStyleTool *); + GBool AddPart(const char *); + + int GetPartCount(const char *pszStyleString = NULL); + OGRStyleTool *GetPart(int hPartId, const char *pszStyleString = NULL); + + /* It could have a reference counting process us for the OGRStyleTable, if + needed. */ + + OGRStyleTable *GetDataSetStyleTable(){return m_poDataSetStyleTable;} + + OGRStyleTool *CreateStyleToolFromStyleString(const char *pszStyleString); + +}; + +/** + * This class represents a style tool + */ +class CPL_DLL OGRStyleTool +{ + private: + GBool m_bModified; + GBool m_bParsed; + double m_dfScale; + OGRSTUnitId m_eUnit; + OGRSTClassId m_eClassId; + char *m_pszStyleString; + + virtual GBool Parse() = 0; + + protected: + GBool Parse(const OGRStyleParamId* pasStyle, + OGRStyleValue* pasValue, + int nCount); + + public: + + OGRStyleTool(){} + OGRStyleTool(OGRSTClassId eClassId); + virtual ~OGRStyleTool(); + + GBool GetRGBFromString(const char *pszColor, int &nRed, int &nGreen, + int &nBlue, int &nTransparence); + int GetSpecificId(const char *pszId, const char *pszWanted); + + GBool IsStyleModified() {return m_bModified;} + void StyleModified() {m_bModified = TRUE;} + + GBool IsStyleParsed() {return m_bParsed;} + void StyleParsed() {m_bParsed = TRUE;} + + OGRSTClassId GetType(); + + void SetInternalInputUnitFromParam(char *pszString); + + void SetUnit(OGRSTUnitId,double dfScale = 1.0); //the dfScale will be + //used if we are working with Ground Unit ( ground = paper * scale); + + OGRSTUnitId GetUnit(){return m_eUnit;} + + // There are two way to set the parameters in the Style, with generic + // methods (using a defined enumeration) or with the reel method specific + // for Each style tools. + + virtual const char *GetStyleString() = 0; + void SetStyleString(const char *pszStyleString); + const char *GetStyleString(const OGRStyleParamId *pasStyleParam , + OGRStyleValue *pasStyleValue, int nSize); + + const char *GetParamStr(const OGRStyleParamId &sStyleParam , + OGRStyleValue &sStyleValue, + GBool &bValueIsNull); + + int GetParamNum(const OGRStyleParamId &sStyleParam , + OGRStyleValue &sStyleValue, + GBool &bValueIsNull); + + double GetParamDbl(const OGRStyleParamId &sStyleParam , + OGRStyleValue &sStyleValue, + GBool &bValueIsNull); + + void SetParamStr(const OGRStyleParamId &sStyleParam , + OGRStyleValue &sStyleValue, + const char *pszParamString); + + void SetParamNum(const OGRStyleParamId &sStyleParam , + OGRStyleValue &sStyleValue, + int nParam); + + void SetParamDbl(const OGRStyleParamId &sStyleParam , + OGRStyleValue &sStyleValue, + double dfParam); + + double ComputeWithUnit(double, OGRSTUnitId); + int ComputeWithUnit(int , OGRSTUnitId); + +}; + +/** + * This class represents a style pen + */ +class CPL_DLL OGRStylePen : public OGRStyleTool +{ + private: + + OGRStyleValue *m_pasStyleValue; + + GBool Parse(); + + public: + + OGRStylePen(); + virtual ~OGRStylePen(); + + /**********************************************************************/ + /* Explicit fct for all parameters defined in the Drawing tools Pen */ + /**********************************************************************/ + + const char *Color(GBool &bDefault){return GetParamStr(OGRSTPenColor,bDefault);} + void SetColor(const char *pszColor){SetParamStr(OGRSTPenColor,pszColor);} + double Width(GBool &bDefault){return GetParamDbl(OGRSTPenWidth,bDefault);} + void SetWidth(double dfWidth){SetParamDbl(OGRSTPenWidth,dfWidth);} + const char *Pattern(GBool &bDefault){return (const char *)GetParamStr(OGRSTPenPattern,bDefault);} + void SetPattern(const char *pszPattern){SetParamStr(OGRSTPenPattern,pszPattern);} + const char *Id(GBool &bDefault){return GetParamStr(OGRSTPenId,bDefault);} + void SetId(const char *pszId){SetParamStr(OGRSTPenId,pszId);} + double PerpendicularOffset(GBool &bDefault){return GetParamDbl(OGRSTPenPerOffset,bDefault);} + void SetPerpendicularOffset(double dfPerp){SetParamDbl(OGRSTPenPerOffset,dfPerp);} + const char *Cap(GBool &bDefault){return GetParamStr(OGRSTPenCap,bDefault);} + void SetCap(const char *pszCap){SetParamStr(OGRSTPenCap,pszCap);} + const char *Join(GBool &bDefault){return GetParamStr(OGRSTPenJoin,bDefault);} + void SetJoin(const char *pszJoin){SetParamStr(OGRSTPenJoin,pszJoin);} + int Priority(GBool &bDefault){return GetParamNum(OGRSTPenPriority,bDefault);} + void SetPriority(int nPriority){SetParamNum(OGRSTPenPriority,nPriority);} + + /*****************************************************************/ + + const char *GetParamStr(OGRSTPenParam eParam, GBool &bValueIsNull); + int GetParamNum(OGRSTPenParam eParam,GBool &bValueIsNull); + double GetParamDbl(OGRSTPenParam eParam,GBool &bValueIsNull); + void SetParamStr(OGRSTPenParam eParam, const char *pszParamString); + void SetParamNum(OGRSTPenParam eParam, int nParam); + void SetParamDbl(OGRSTPenParam eParam, double dfParam); + const char *GetStyleString(); +}; + +/** + * This class represents a style brush + */ +class CPL_DLL OGRStyleBrush : public OGRStyleTool +{ + private: + + OGRStyleValue *m_pasStyleValue; + + GBool Parse(); + + public: + + OGRStyleBrush(); + virtual ~OGRStyleBrush(); + + /* Explicit fct for all parameters defined in the Drawing tools Brush */ + + const char *ForeColor(GBool &bDefault){return GetParamStr(OGRSTBrushFColor,bDefault);} + void SetForeColor(const char *pszColor){SetParamStr(OGRSTBrushFColor,pszColor);} + const char *BackColor(GBool &bDefault){return GetParamStr(OGRSTBrushBColor,bDefault);} + void SetBackColor(const char *pszColor){SetParamStr(OGRSTBrushBColor,pszColor);} + const char *Id(GBool &bDefault){ return GetParamStr(OGRSTBrushId,bDefault);} + void SetId(const char *pszId){SetParamStr(OGRSTBrushId,pszId);} + double Angle(GBool &bDefault){return GetParamDbl(OGRSTBrushAngle,bDefault);} + void SetAngle(double dfAngle){SetParamDbl(OGRSTBrushAngle,dfAngle );} + double Size(GBool &bDefault){return GetParamDbl(OGRSTBrushSize,bDefault);} + void SetSize(double dfSize){SetParamDbl(OGRSTBrushSize,dfSize );} + double SpacingX(GBool &bDefault){return GetParamDbl(OGRSTBrushDx,bDefault);} + void SetSpacingX(double dfX){SetParamDbl(OGRSTBrushDx,dfX );} + double SpacingY(GBool &bDefault){return GetParamDbl(OGRSTBrushDy,bDefault);} + void SetSpacingY(double dfY){SetParamDbl(OGRSTBrushDy,dfY );} + int Priority(GBool &bDefault){ return GetParamNum(OGRSTBrushPriority,bDefault);} + void SetPriority(int nPriority){ SetParamNum(OGRSTBrushPriority,nPriority);} + + /*****************************************************************/ + + const char *GetParamStr(OGRSTBrushParam eParam, GBool &bValueIsNull); + int GetParamNum(OGRSTBrushParam eParam,GBool &bValueIsNull); + double GetParamDbl(OGRSTBrushParam eParam,GBool &bValueIsNull); + void SetParamStr(OGRSTBrushParam eParam, const char *pszParamString); + void SetParamNum(OGRSTBrushParam eParam, int nParam); + void SetParamDbl(OGRSTBrushParam eParam, double dfParam); + const char *GetStyleString(); +}; + +/** + * This class represents a style symbol + */ +class CPL_DLL OGRStyleSymbol : public OGRStyleTool +{ + private: + + OGRStyleValue *m_pasStyleValue; + + GBool Parse(); + + public: + + OGRStyleSymbol(); + virtual ~OGRStyleSymbol(); + + /*****************************************************************/ + /* Explicit fct for all parameters defined in the Drawing tools */ + /*****************************************************************/ + + const char *Id(GBool &bDefault){return GetParamStr(OGRSTSymbolId,bDefault);} + void SetId(const char *pszId){ SetParamStr(OGRSTSymbolId,pszId);} + double Angle(GBool &bDefault){ return GetParamDbl(OGRSTSymbolAngle,bDefault);} + void SetAngle(double dfAngle){SetParamDbl(OGRSTSymbolAngle,dfAngle );} + const char *Color(GBool &bDefault){return GetParamStr(OGRSTSymbolColor,bDefault);} + void SetColor(const char *pszColor){SetParamStr(OGRSTSymbolColor,pszColor);} + double Size(GBool &bDefault){ return GetParamDbl(OGRSTSymbolSize,bDefault);} + void SetSize(double dfSize){ SetParamDbl(OGRSTSymbolSize,dfSize );} + double SpacingX(GBool &bDefault){return GetParamDbl(OGRSTSymbolDx,bDefault);} + void SetSpacingX(double dfX){SetParamDbl(OGRSTSymbolDx,dfX );} + double SpacingY(GBool &bDefault){return GetParamDbl(OGRSTSymbolDy,bDefault);} + void SetSpacingY(double dfY){SetParamDbl(OGRSTSymbolDy,dfY );} + double Step(GBool &bDefault){return GetParamDbl(OGRSTSymbolStep,bDefault);} + void SetStep(double dfStep){SetParamDbl(OGRSTSymbolStep,dfStep );} + double Offset(GBool &bDefault){return GetParamDbl(OGRSTSymbolOffset,bDefault);} + void SetOffset(double dfOffset){SetParamDbl(OGRSTSymbolOffset,dfOffset );} + double Perp(GBool &bDefault){return GetParamDbl(OGRSTSymbolPerp,bDefault);} + void SetPerp(double dfPerp){SetParamDbl(OGRSTSymbolPerp,dfPerp );} + int Priority(GBool &bDefault){return GetParamNum(OGRSTSymbolPriority,bDefault);} + void SetPriority(int nPriority){SetParamNum(OGRSTSymbolPriority,nPriority);} + const char *FontName(GBool &bDefault) + {return GetParamStr(OGRSTSymbolFontName,bDefault);} + void SetFontName(const char *pszFontName) + {SetParamStr(OGRSTSymbolFontName,pszFontName);} + const char *OColor(GBool &bDefault){return GetParamStr(OGRSTSymbolOColor,bDefault);} + void SetOColor(const char *pszColor){SetParamStr(OGRSTSymbolOColor,pszColor);} + + /*****************************************************************/ + + const char *GetParamStr(OGRSTSymbolParam eParam, GBool &bValueIsNull); + int GetParamNum(OGRSTSymbolParam eParam,GBool &bValueIsNull); + double GetParamDbl(OGRSTSymbolParam eParam,GBool &bValueIsNull); + void SetParamStr(OGRSTSymbolParam eParam, const char *pszParamString); + void SetParamNum(OGRSTSymbolParam eParam, int nParam); + void SetParamDbl(OGRSTSymbolParam eParam, double dfParam); + const char *GetStyleString(); +}; + +/** + * This class represents a style label + */ +class CPL_DLL OGRStyleLabel : public OGRStyleTool +{ + private: + + OGRStyleValue *m_pasStyleValue; + + GBool Parse(); + + public: + + OGRStyleLabel(); + virtual ~OGRStyleLabel(); + + /*****************************************************************/ + /* Explicit fct for all parameters defined in the Drawing tools */ + /*****************************************************************/ + + const char *FontName(GBool &bDefault){return GetParamStr(OGRSTLabelFontName,bDefault);} + void SetFontName(const char *pszFontName){SetParamStr(OGRSTLabelFontName,pszFontName);} + double Size(GBool &bDefault){return GetParamDbl(OGRSTLabelSize,bDefault);} + void SetSize(double dfSize){SetParamDbl(OGRSTLabelSize,dfSize);} + const char *TextString(GBool &bDefault){return GetParamStr(OGRSTLabelTextString,bDefault);} + void SetTextString(const char *pszTextString){SetParamStr(OGRSTLabelTextString,pszTextString);} + double Angle(GBool &bDefault){return GetParamDbl(OGRSTLabelAngle,bDefault);} + void SetAngle(double dfAngle){SetParamDbl(OGRSTLabelAngle,dfAngle);} + const char *ForeColor(GBool &bDefault){return GetParamStr(OGRSTLabelFColor,bDefault);} + void SetForColor(const char *pszForColor){SetParamStr(OGRSTLabelFColor,pszForColor);} + const char *BackColor(GBool &bDefault){return GetParamStr(OGRSTLabelBColor,bDefault);} + void SetBackColor(const char *pszBackColor){SetParamStr(OGRSTLabelBColor,pszBackColor);} + const char *Placement(GBool &bDefault){return GetParamStr(OGRSTLabelPlacement,bDefault);} + void SetPlacement(const char *pszPlacement){SetParamStr(OGRSTLabelPlacement,pszPlacement);} + int Anchor(GBool &bDefault){return GetParamNum(OGRSTLabelAnchor,bDefault);} + void SetAnchor(int nAnchor){SetParamNum(OGRSTLabelAnchor,nAnchor);} + double SpacingX(GBool &bDefault){return GetParamDbl(OGRSTLabelDx,bDefault);} + void SetSpacingX(double dfX){SetParamDbl(OGRSTLabelDx,dfX);} + double SpacingY(GBool &bDefault){return GetParamDbl(OGRSTLabelDy,bDefault);} + void SetSpacingY(double dfY){SetParamDbl(OGRSTLabelDy,dfY);} + double Perp(GBool &bDefault){return GetParamDbl(OGRSTLabelPerp,bDefault);} + void SetPerp(double dfPerp){SetParamDbl(OGRSTLabelPerp,dfPerp);} + GBool Bold(GBool &bDefault){return GetParamNum(OGRSTLabelBold,bDefault);} + void SetBold(GBool bBold){SetParamNum(OGRSTLabelBold,bBold);} + GBool Italic(GBool &bDefault){return GetParamNum(OGRSTLabelItalic,bDefault);} + void SetItalic(GBool bItalic){SetParamNum(OGRSTLabelItalic,bItalic);} + GBool Underline(GBool &bDefault){return GetParamNum(OGRSTLabelUnderline,bDefault);} + void SetUnderline(GBool bUnderline){SetParamNum(OGRSTLabelUnderline,bUnderline);} + int Priority(GBool &bDefault){return GetParamNum(OGRSTLabelPriority,bDefault);} + void SetPriority(int nPriority){SetParamNum(OGRSTLabelPriority,nPriority);} + GBool Strikeout(GBool &bDefault){return GetParamNum(OGRSTLabelStrikeout,bDefault);} + void SetStrikeout(GBool bStrikeout){SetParamNum(OGRSTLabelStrikeout,bStrikeout);} + double Stretch(GBool &bDefault){return GetParamDbl(OGRSTLabelStretch,bDefault);} + void SetStretch(double dfStretch){SetParamDbl(OGRSTLabelStretch,dfStretch);} + const char *AdjustmentHor(GBool &bDefault){return GetParamStr(OGRSTLabelAdjHor,bDefault);} + void SetAdjustmentHor(const char *pszAdjustmentHor){SetParamStr(OGRSTLabelAdjHor,pszAdjustmentHor);} + const char *AdjustmentVert(GBool &bDefault){return GetParamStr(OGRSTLabelAdjVert,bDefault);} + void SetAdjustmentVert(const char *pszAdjustmentVert){SetParamStr(OGRSTLabelAdjHor,pszAdjustmentVert);} + const char *ShadowColor(GBool &bDefault){return GetParamStr(OGRSTLabelHColor,bDefault);} + void SetShadowColor(const char *pszShadowColor){SetParamStr(OGRSTLabelHColor,pszShadowColor);} + const char *OutlineColor(GBool &bDefault){return GetParamStr(OGRSTLabelOColor,bDefault);} + void SetOutlineColor(const char *pszOutlineColor){SetParamStr(OGRSTLabelOColor,pszOutlineColor);} + + /*****************************************************************/ + + const char *GetParamStr(OGRSTLabelParam eParam, GBool &bValueIsNull); + int GetParamNum(OGRSTLabelParam eParam,GBool &bValueIsNull); + double GetParamDbl(OGRSTLabelParam eParam,GBool &bValueIsNull); + void SetParamStr(OGRSTLabelParam eParam, const char *pszParamString); + void SetParamNum(OGRSTLabelParam eParam, int nParam); + void SetParamDbl(OGRSTLabelParam eParam, double dfParam); + const char *GetStyleString(); +}; + +#endif /* OGR_FEATURESTYLE_INCLUDE */ diff --git a/modules/globebrowsing/ext/gdal/include/ogr_geocoding.h b/modules/globebrowsing/ext/gdal/include/ogr_geocoding.h new file mode 100644 index 0000000000..0817776768 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/ogr_geocoding.h @@ -0,0 +1,63 @@ +/****************************************************************************** + * $Id$ + * + * Project: OpenGIS Simple Features Reference Implementation + * Purpose: Client of geocoding service. + * Author: Even Rouault, + * + ****************************************************************************** + * Copyright (c) 2012, Even Rouault + * + * 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. + ****************************************************************************/ + +#ifndef OGR_GEOCODING_H_INCLUDED +#define OGR_GEOCODING_H_INCLUDED + +#include "cpl_port.h" +#include "ogr_api.h" + +/** + * \file ogr_geocoding.h + * + * C API for geocoding client. + */ + +CPL_C_START + +typedef struct _OGRGeocodingSessionHS *OGRGeocodingSessionH; + +OGRGeocodingSessionH CPL_DLL OGRGeocodeCreateSession(char** papszOptions); + +void CPL_DLL OGRGeocodeDestroySession(OGRGeocodingSessionH hSession); + +OGRLayerH CPL_DLL OGRGeocode(OGRGeocodingSessionH hSession, + const char* pszQuery, + char** papszStructuredQuery, + char** papszOptions); + +OGRLayerH CPL_DLL OGRGeocodeReverse(OGRGeocodingSessionH hSession, + double dfLon, double dfLat, + char** papszOptions); + +void CPL_DLL OGRGeocodeFreeResult(OGRLayerH hLayer); + +CPL_C_END + +#endif // OGR_GEOCODING_H_INCLUDED diff --git a/modules/globebrowsing/ext/gdal/include/ogr_geometry.h b/modules/globebrowsing/ext/gdal/include/ogr_geometry.h new file mode 100644 index 0000000000..4406051e80 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/ogr_geometry.h @@ -0,0 +1,1400 @@ +/****************************************************************************** + * $Id$ + * + * Project: OpenGIS Simple Features Reference Implementation + * Purpose: Classes for manipulating simple features that is not specific + * to a particular interface technology. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, Frank Warmerdam + * Copyright (c) 2008-2014, Even Rouault + * + * 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. + ****************************************************************************/ + +#ifndef OGR_GEOMETRY_H_INCLUDED +#define OGR_GEOMETRY_H_INCLUDED + +#include "ogr_core.h" +#include "ogr_spatialref.h" + +/** + * \file ogr_geometry.h + * + * Simple feature geometry classes. + */ + +/** + * Simple container for a position. + */ +class OGRRawPoint +{ + public: + OGRRawPoint() + { + x = y = 0.0; + } + + OGRRawPoint(double xIn, double yIn) : x(xIn), y(yIn) {} + double x; + double y; +}; + +typedef struct GEOSGeom_t *GEOSGeom; +typedef struct GEOSContextHandle_HS *GEOSContextHandle_t; + +class OGRPoint; +class OGRCurve; +class OGRCompoundCurve; +class OGRLinearRing; +class OGRLineString; +class OGRSurface; +class OGRCurvePolygon; +class OGRPolygon; +class OGRMultiSurface; +class OGRMultiPolygon; +class OGRMultiCurve; +class OGRMultiLineString; + +typedef OGRLineString* (*OGRCurveCasterToLineString)(OGRCurve*); +typedef OGRLinearRing* (*OGRCurveCasterToLinearRing)(OGRCurve*); + +typedef OGRPolygon* (*OGRSurfaceCasterToPolygon)(OGRSurface*); +typedef OGRCurvePolygon* (*OGRSurfaceCasterToCurvePolygon)(OGRSurface*); + +/************************************************************************/ +/* OGRGeometry */ +/************************************************************************/ + +/** + * Abstract base class for all geometry classes. + * + * Some spatial analysis methods require that OGR is built on the GEOS library + * to work properly. The precise meaning of methods that describe spatial relationships + * between geometries is described in the SFCOM, or other simple features interface + * specifications, like "OpenGIS® Implementation Specification for + * Geographic information - Simple feature access - Part 1: Common architecture" + * (OGC 06-103r4) + * + * In GDAL 2.0, the hierarchy of classes has been extended with + * + * (working draft) ISO SQL/MM Part 3 (ISO/IEC 13249-3) curve geometries : + * CIRCULARSTRING (OGRCircularString), COMPOUNDCURVE (OGRCompoundCurve), + * CURVEPOLYGON (OGRCurvePolygon), MULTICURVE (OGRMultiCurve) and MULTISURFACE (OGRMultiSurface). + * + */ + +class CPL_DLL OGRGeometry +{ + private: + OGRSpatialReference * poSRS; // may be NULL + + protected: + friend class OGRCurveCollection; + + unsigned int flags; + + OGRErr importPreambuleFromWkt( char ** ppszInput, + int* pbHasZ, int* pbHasM, + bool* pbIsEmpty ); + OGRErr importCurveCollectionFromWkt( char ** ppszInput, + int bAllowEmptyComponent, + int bAllowLineString, + int bAllowCurve, + int bAllowCompoundCurve, + OGRErr (*pfnAddCurveDirectly)(OGRGeometry* poSelf, OGRCurve* poCurve) ); + OGRErr importPreambuleFromWkb( unsigned char * pabyData, + int nSize, + OGRwkbByteOrder& eByteOrder, + OGRwkbVariant eWkbVariant ); + OGRErr importPreambuleOfCollectionFromWkb( + unsigned char * pabyData, + int& nSize, + int& nDataOffset, + OGRwkbByteOrder& eByteOrder, + int nMinSubGeomSize, + int& nGeomCount, + OGRwkbVariant eWkbVariant ); + OGRErr PointOnSurfaceInternal( OGRPoint * poPoint ) const; + + public: + +/************************************************************************/ +/* Bit flags for OGRGeometry */ +/* The OGR_G_NOT_EMPTY_POINT is used *only* for points. */ +/* Do not use these outside of the core. */ +/* Use Is3D, IsMeasured, set3D, and setMeasured instead */ +/************************************************************************/ + + static const unsigned int OGR_G_NOT_EMPTY_POINT = 0x1; + static const unsigned int OGR_G_3D = 0x2; + static const unsigned int OGR_G_MEASURED = 0x4; + + OGRGeometry(); + OGRGeometry( const OGRGeometry& other ); + virtual ~OGRGeometry(); + + OGRGeometry& operator=( const OGRGeometry& other ); + + // standard IGeometry + virtual int getDimension() const = 0; + virtual int getCoordinateDimension() const; + int CoordinateDimension() const; + virtual OGRBoolean IsEmpty() const; + virtual OGRBoolean IsValid() const; + virtual OGRBoolean IsSimple() const; + OGRBoolean Is3D() const { return flags & OGR_G_3D; } + OGRBoolean IsMeasured() const { return flags & OGR_G_MEASURED; } + virtual OGRBoolean IsRing() const; + virtual void empty() = 0; + virtual OGRGeometry *clone() const CPL_WARN_UNUSED_RESULT = 0; + virtual void getEnvelope( OGREnvelope * psEnvelope ) const = 0; + virtual void getEnvelope( OGREnvelope3D * psEnvelope ) const = 0; + + // IWks Interface + virtual int WkbSize() const = 0; + virtual OGRErr importFromWkb( unsigned char *, int=-1, OGRwkbVariant=wkbVariantOldOgc )=0; + virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char *, OGRwkbVariant=wkbVariantOldOgc ) const = 0; + virtual OGRErr importFromWkt( char ** ppszInput ) = 0; + virtual OGRErr exportToWkt( char ** ppszDstText, OGRwkbVariant=wkbVariantOldOgc ) const = 0; + + // non-standard + virtual OGRwkbGeometryType getGeometryType() const = 0; + OGRwkbGeometryType getIsoGeometryType() const; + virtual const char *getGeometryName() const = 0; + virtual void dumpReadable( FILE *, const char * = NULL, char** papszOptions = NULL ) const; + virtual void flattenTo2D() = 0; + virtual char * exportToGML( const char* const * papszOptions = NULL ) const; + virtual char * exportToKML() const; + virtual char * exportToJson() const; + + static GEOSContextHandle_t createGEOSContext(); + static void freeGEOSContext(GEOSContextHandle_t hGEOSCtxt); + virtual GEOSGeom exportToGEOS(GEOSContextHandle_t hGEOSCtxt) const CPL_WARN_UNUSED_RESULT; + virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear = FALSE) const; + virtual OGRGeometry* getCurveGeometry(const char* const* papszOptions = NULL) const CPL_WARN_UNUSED_RESULT; + virtual OGRGeometry* getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0, + const char* const* papszOptions = NULL) const CPL_WARN_UNUSED_RESULT; + + virtual void closeRings(); + + virtual void setCoordinateDimension( int nDimension ); + virtual void set3D( OGRBoolean bIs3D ); + virtual void setMeasured( OGRBoolean bIsMeasured ); + + void assignSpatialReference( OGRSpatialReference * poSR ); + OGRSpatialReference *getSpatialReference( void ) const { return poSRS; } + + virtual OGRErr transform( OGRCoordinateTransformation *poCT ) = 0; + OGRErr transformTo( OGRSpatialReference *poSR ); + + virtual void segmentize(double dfMaxLength); + + // ISpatialRelation + virtual OGRBoolean Intersects( const OGRGeometry * ) const; + virtual OGRBoolean Equals( OGRGeometry * ) const = 0; + virtual OGRBoolean Disjoint( const OGRGeometry * ) const; + virtual OGRBoolean Touches( const OGRGeometry * ) const; + virtual OGRBoolean Crosses( const OGRGeometry * ) const; + virtual OGRBoolean Within( const OGRGeometry * ) const; + virtual OGRBoolean Contains( const OGRGeometry * ) const; + virtual OGRBoolean Overlaps( const OGRGeometry * ) const; +// virtual OGRBoolean Relate( const OGRGeometry *, const char * ) const; +// virtual OGRGeometry *LocateAlong( double mValue ) const; +// virtual OGRGeometry *LocateBetween( double mStart, double mEnd ) const; + + virtual OGRGeometry *Boundary() const CPL_WARN_UNUSED_RESULT; + virtual double Distance( const OGRGeometry * ) const ; + virtual OGRGeometry *ConvexHull() const CPL_WARN_UNUSED_RESULT; + virtual OGRGeometry *Buffer( double dfDist, int nQuadSegs = 30 ) const CPL_WARN_UNUSED_RESULT; + virtual OGRGeometry *Intersection( const OGRGeometry *) const CPL_WARN_UNUSED_RESULT; + virtual OGRGeometry *Union( const OGRGeometry * ) const CPL_WARN_UNUSED_RESULT; + virtual OGRGeometry *UnionCascaded() const CPL_WARN_UNUSED_RESULT; + virtual OGRGeometry *Difference( const OGRGeometry * ) const CPL_WARN_UNUSED_RESULT; + virtual OGRGeometry *SymDifference( const OGRGeometry * ) const CPL_WARN_UNUSED_RESULT; + virtual OGRErr Centroid( OGRPoint * poPoint ) const; + virtual OGRGeometry *Simplify(double dTolerance) const CPL_WARN_UNUSED_RESULT; + OGRGeometry *SimplifyPreserveTopology(double dTolerance) const CPL_WARN_UNUSED_RESULT; + virtual OGRGeometry *DelaunayTriangulation(double dfTolerance, int bOnlyEdges) const CPL_WARN_UNUSED_RESULT; + + virtual OGRGeometry *Polygonize() const CPL_WARN_UNUSED_RESULT; + + // backward compatibility to non-standard method names. + OGRBoolean Intersect( OGRGeometry * ) const CPL_WARN_DEPRECATED("Non standard method. Use Intersects() instead"); + OGRBoolean Equal( OGRGeometry * ) const CPL_WARN_DEPRECATED("Non standard method. Use Equals() instead"); + OGRGeometry *SymmetricDifference( const OGRGeometry * ) const CPL_WARN_DEPRECATED("Non standard method. Use SymDifference() instead"); + OGRGeometry *getBoundary() const CPL_WARN_DEPRECATED("Non standard method. Use Boundary() instead"); + + // Special HACK for DB2 7.2 support + static int bGenerate_DB2_V72_BYTE_ORDER; + + virtual void swapXY(); + + static OGRGeometry* CastToIdentity(OGRGeometry* poGeom) { return poGeom; } + static OGRGeometry* CastToError(OGRGeometry* poGeom); +}; + +/************************************************************************/ +/* OGRPoint */ +/************************************************************************/ + +/** + * Point class. + * + * Implements SFCOM IPoint methods. + */ + +class CPL_DLL OGRPoint : public OGRGeometry +{ + double x; + double y; + double z; + double m; + + public: + OGRPoint(); + OGRPoint( double x, double y ); + OGRPoint( double x, double y, double z ); + OGRPoint( double x, double y, double z, double m ); + OGRPoint( const OGRPoint& other ); + virtual ~OGRPoint(); + + OGRPoint& operator=( const OGRPoint& other ); + + // IWks Interface + virtual int WkbSize() const; + virtual OGRErr importFromWkb( unsigned char *, int=-1, OGRwkbVariant=wkbVariantOldOgc ); + virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char *, OGRwkbVariant=wkbVariantOldOgc ) const; + virtual OGRErr importFromWkt( char ** ); + virtual OGRErr exportToWkt( char ** ppszDstText, OGRwkbVariant=wkbVariantOldOgc ) const; + + // IGeometry + virtual int getDimension() const; + virtual OGRGeometry *clone() const; + virtual void empty(); + virtual void getEnvelope( OGREnvelope * psEnvelope ) const; + virtual void getEnvelope( OGREnvelope3D * psEnvelope ) const; + virtual OGRBoolean IsEmpty() const { return !(flags & OGR_G_NOT_EMPTY_POINT); } + + // IPoint + double getX() const { return x; } + double getY() const { return y; } + double getZ() const { return z; } + double getM() const { return m; } + + // Non standard + virtual void setCoordinateDimension( int nDimension ); + void setX( double xIn ) { x = xIn; flags |= OGR_G_NOT_EMPTY_POINT; } + void setY( double yIn ) { y = yIn; flags |= OGR_G_NOT_EMPTY_POINT; } + void setZ( double zIn ) { z = zIn; flags |= (OGR_G_NOT_EMPTY_POINT | OGR_G_3D); } + void setM( double mIn ) { m = mIn; flags |= (OGR_G_NOT_EMPTY_POINT | OGR_G_MEASURED); } + + // ISpatialRelation + virtual OGRBoolean Equals( OGRGeometry * ) const; + virtual OGRBoolean Intersects( const OGRGeometry * ) const; + virtual OGRBoolean Within( const OGRGeometry * ) const; + + // Non standard from OGRGeometry + virtual const char *getGeometryName() const; + virtual OGRwkbGeometryType getGeometryType() const; + virtual OGRErr transform( OGRCoordinateTransformation *poCT ); + virtual void flattenTo2D(); + + virtual void swapXY(); +}; + +/************************************************************************/ +/* OGRPointIterator */ +/************************************************************************/ + +/** + * Interface for a point iterator. + * + * @since GDAL 2.0 + */ + +class CPL_DLL OGRPointIterator +{ + public: + virtual ~OGRPointIterator(); + virtual OGRBoolean getNextPoint(OGRPoint* p) = 0; + + static void destroy(OGRPointIterator*); +}; + +/************************************************************************/ +/* OGRCurve */ +/************************************************************************/ + +/** + * Abstract curve base class for OGRLineString, OGRCircularString and + * OGRCompoundCurve + */ + +class CPL_DLL OGRCurve : public OGRGeometry +{ + protected: + OGRCurve(); + OGRCurve( const OGRCurve& other ); + + virtual OGRCurveCasterToLineString GetCasterToLineString() const = 0; + virtual OGRCurveCasterToLinearRing GetCasterToLinearRing() const = 0; + + friend class OGRCurvePolygon; + friend class OGRCompoundCurve; + virtual int ContainsPoint( const OGRPoint* p ) const; + virtual double get_AreaOfCurveSegments() const = 0; + + public: + virtual ~OGRCurve(); + + OGRCurve& operator=( const OGRCurve& other ); + + // ICurve methods + virtual double get_Length() const = 0; + virtual void StartPoint(OGRPoint *) const = 0; + virtual void EndPoint(OGRPoint *) const = 0; + virtual int get_IsClosed() const; + virtual void Value( double, OGRPoint * ) const = 0; + virtual OGRLineString* CurveToLine(double dfMaxAngleStepSizeDegrees = 0, + const char* const* papszOptions = NULL) const = 0; + virtual int getDimension() const; + + // non standard + virtual int getNumPoints() const = 0; + virtual OGRPointIterator* getPointIterator() const = 0; + virtual OGRBoolean IsConvex() const; + virtual double get_Area() const = 0; + + static OGRCompoundCurve* CastToCompoundCurve(OGRCurve* puCurve); + static OGRLineString* CastToLineString(OGRCurve* poCurve); + static OGRLinearRing* CastToLinearRing(OGRCurve* poCurve); +}; + +/************************************************************************/ +/* OGRSimpleCurve */ +/************************************************************************/ + +/** + * Abstract curve base class for OGRLineString and OGRCircularString + * + * Note: this class does not exist in SQL/MM standard and exists for + * implementation convenience. + * + * @since GDAL 2.0 + */ + +class CPL_DLL OGRSimpleCurve: public OGRCurve +{ + protected: + friend class OGRGeometry; + + int nPointCount; + OGRRawPoint *paoPoints; + double *padfZ; + double *padfM; + + void Make3D(); + void Make2D(); + void RemoveM(); + void AddM(); + + OGRErr importFromWKTListOnly( char ** ppszInput, int bHasZ, int bHasM, + OGRRawPoint*& paoPointsIn, int& nMaxPoints, + double*& padfZIn ); + + virtual double get_LinearArea() const; + + OGRSimpleCurve(); + OGRSimpleCurve( const OGRSimpleCurve& other ); + + public: + virtual ~OGRSimpleCurve(); + + OGRSimpleCurve& operator=( const OGRSimpleCurve& other ); + + // IWks Interface + virtual int WkbSize() const; + virtual OGRErr importFromWkb( unsigned char *, int = -1, OGRwkbVariant=wkbVariantOldOgc ); + virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char *, OGRwkbVariant=wkbVariantOldOgc ) const; + virtual OGRErr importFromWkt( char ** ); + virtual OGRErr exportToWkt( char ** ppszDstText, OGRwkbVariant=wkbVariantOldOgc ) const; + + // IGeometry interface + virtual OGRGeometry *clone() const; + virtual void empty(); + virtual void getEnvelope( OGREnvelope * psEnvelope ) const; + virtual void getEnvelope( OGREnvelope3D * psEnvelope ) const; + virtual OGRBoolean IsEmpty() const; + + // ICurve methods + virtual double get_Length() const; + virtual void StartPoint(OGRPoint *) const; + virtual void EndPoint(OGRPoint *) const; + virtual void Value( double, OGRPoint * ) const; + virtual double Project(const OGRPoint *) const; + virtual OGRLineString* getSubLine(double, double, int) const; + + // ILineString methods + virtual int getNumPoints() const { return nPointCount; } + void getPoint( int, OGRPoint * ) const; + double getX( int i ) const { return paoPoints[i].x; } + double getY( int i ) const { return paoPoints[i].y; } + double getZ( int i ) const; + double getM( int i ) const; + + // ISpatialRelation + virtual OGRBoolean Equals( OGRGeometry * ) const; + + // non standard. + virtual void setCoordinateDimension( int nDimension ); + virtual void set3D( OGRBoolean bIs3D ); + virtual void setMeasured( OGRBoolean bIsMeasured ); + void setNumPoints( int nNewPointCount, int bZeroizeNewContent = TRUE ); + void setPoint( int, OGRPoint * ); + void setPoint( int, double, double ); + void setZ( int, double ); + void setM( int, double ); + void setPoint( int, double, double, double ); + void setPointM( int, double, double, double ); + void setPoint( int, double, double, double, double ); + void setPoints( int, OGRRawPoint *, double * = NULL ); + void setPointsM( int, OGRRawPoint *, double * ); + void setPoints( int, OGRRawPoint *, double *, double * ); + void setPoints( int, double * padfX, double * padfY, + double *padfZIn = NULL ); + void setPointsM( int, double * padfX, double * padfY, + double *padfMIn = NULL ); + void setPoints( int, double * padfX, double * padfY, + double *padfZIn, double *padfMIn ); + void addPoint( OGRPoint * ); + void addPoint( double, double ); + void addPoint( double, double, double ); + void addPointM( double, double, double ); + void addPoint( double, double, double, double ); + + void getPoints( OGRRawPoint *, double * = NULL ) const; + void getPoints( OGRRawPoint *, double *, double * ) const; + void getPoints( void* pabyX, int nXStride, + void* pabyY, int nYStride, + void* pabyZ = NULL, int nZStride = 0 ) const; + void getPoints( void* pabyX, int nXStride, + void* pabyY, int nYStride, + void* pabyZ, int nZStride, + void* pabyM, int nMStride ) const; + + void addSubLineString( const OGRLineString *, + int nStartVertex = 0, int nEndVertex = -1 ); + void reversePoints( void ); + virtual OGRPointIterator* getPointIterator() const; + + // non-standard from OGRGeometry + virtual OGRErr transform( OGRCoordinateTransformation *poCT ); + virtual void flattenTo2D(); + virtual void segmentize(double dfMaxLength); + + virtual void swapXY(); +}; + +/************************************************************************/ +/* OGRLineString */ +/************************************************************************/ + +/** + * Concrete representation of a multi-vertex line. + * + * Note: for implementation convenience, we make it inherit from OGRSimpleCurve whereas + * SFSQL and SQL/MM only make it inherits from OGRCurve. + */ + +class CPL_DLL OGRLineString : public OGRSimpleCurve +{ + protected: + static OGRLineString* TransferMembersAndDestroy( + OGRLineString* poSrc, + OGRLineString* poDst); + + static OGRLinearRing* CastToLinearRing(OGRLineString* poLS); + + virtual OGRCurveCasterToLineString GetCasterToLineString() const; + virtual OGRCurveCasterToLinearRing GetCasterToLinearRing() const; + + virtual double get_AreaOfCurveSegments() const; + + public: + OGRLineString(); + OGRLineString(const OGRLineString& other); + virtual ~OGRLineString(); + + OGRLineString& operator=(const OGRLineString& other); + + virtual OGRLineString* CurveToLine(double dfMaxAngleStepSizeDegrees = 0, + const char* const* papszOptions = NULL) const; + virtual OGRGeometry* getCurveGeometry(const char* const* papszOptions = NULL) const; + virtual double get_Area() const; + + // non-standard from OGRGeometry + virtual OGRwkbGeometryType getGeometryType() const; + virtual const char *getGeometryName() const; +}; + +/************************************************************************/ +/* OGRLinearRing */ +/************************************************************************/ + +/** + * Concrete representation of a closed ring. + * + * This class is functionally equivalent to an OGRLineString, but has a + * separate identity to maintain alignment with the OpenGIS simple feature + * data model. It exists to serve as a component of an OGRPolygon. + * + * The OGRLinearRing has no corresponding free standing well known binary + * representation, so importFromWkb() and exportToWkb() will not actually + * work. There is a non-standard GDAL WKT representation though. + * + * Because OGRLinearRing is not a "proper" free standing simple features + * object, it cannot be directly used on a feature via SetGeometry(), and + * cannot generally be used with GEOS for operations like Intersects(). + * Instead the polygon should be used, or the OGRLinearRing should be + * converted to an OGRLineString for such operations. + * + * Note: this class exists in SFSQL 1.2, but not in ISO SQL/MM Part 3. + */ + +class CPL_DLL OGRLinearRing : public OGRLineString +{ + protected: + friend class OGRPolygon; + + // These are not IWks compatible ... just a convenience for OGRPolygon. + virtual int _WkbSize( int _flags ) const; + virtual OGRErr _importFromWkb( OGRwkbByteOrder, int _flags, + unsigned char *, int=-1 ); + virtual OGRErr _exportToWkb( OGRwkbByteOrder, int _flags, + unsigned char * ) const; + + static OGRLineString* CastToLineString(OGRLinearRing* poLR); + + virtual OGRCurveCasterToLineString GetCasterToLineString() const; + virtual OGRCurveCasterToLinearRing GetCasterToLinearRing() const; + + public: + OGRLinearRing(); + OGRLinearRing(const OGRLinearRing& other); + OGRLinearRing( OGRLinearRing * ); + virtual ~OGRLinearRing(); + + OGRLinearRing& operator=(const OGRLinearRing& other); + + // Non standard. + virtual const char *getGeometryName() const; + virtual OGRGeometry *clone() const; + virtual int isClockwise() const; + virtual void reverseWindingOrder(); + virtual void closeRings(); + OGRBoolean isPointInRing(const OGRPoint* pt, int bTestEnvelope = TRUE) const; + OGRBoolean isPointOnRingBoundary(const OGRPoint* pt, int bTestEnvelope = TRUE) const; + + // IWks Interface - Note this isn't really a first class object + // for the purposes of WKB form. These methods always fail since this + // object can't be serialized on its own. + virtual int WkbSize() const; + virtual OGRErr importFromWkb( unsigned char *, int=-1, OGRwkbVariant=wkbVariantOldOgc ); + virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char *, OGRwkbVariant=wkbVariantOldOgc ) const; +}; + +/************************************************************************/ +/* OGRCircularString */ +/************************************************************************/ + +/** + * Concrete representation of a circular string, that is to say a curve made + * of one or several arc circles. + * + * Note: for implementation convenience, we make it inherit from OGRSimpleCurve whereas + * SQL/MM only makes it inherits from OGRCurve. + * + * Compatibility: ISO SQL/MM Part 3. + * + * @since GDAL 2.0 + */ + +class CPL_DLL OGRCircularString : public OGRSimpleCurve +{ + private: + void ExtendEnvelopeWithCircular( OGREnvelope * psEnvelope ) const; + OGRBoolean IsValidFast() const; + int IsFullCircle( double& cx, double& cy, double& square_R ) const; + + protected: + virtual OGRCurveCasterToLineString GetCasterToLineString() const; + virtual OGRCurveCasterToLinearRing GetCasterToLinearRing() const; + virtual int ContainsPoint( const OGRPoint* p ) const; + virtual double get_AreaOfCurveSegments() const; + + public: + OGRCircularString(); + OGRCircularString(const OGRCircularString& other); + virtual ~OGRCircularString(); + + OGRCircularString& operator=(const OGRCircularString& other); + + // IWks Interface + virtual OGRErr importFromWkb( unsigned char *, int = -1, OGRwkbVariant=wkbVariantOldOgc ); + virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char *, OGRwkbVariant=wkbVariantOldOgc ) const; + virtual OGRErr importFromWkt( char ** ); + virtual OGRErr exportToWkt( char ** ppszDstText, OGRwkbVariant=wkbVariantOldOgc ) const; + + // IGeometry interface + virtual OGRBoolean IsValid() const; + virtual void getEnvelope( OGREnvelope * psEnvelope ) const; + virtual void getEnvelope( OGREnvelope3D * psEnvelope ) const; + + // ICurve methods + virtual double get_Length() const; + virtual OGRLineString* CurveToLine(double dfMaxAngleStepSizeDegrees = 0, + const char* const* papszOptions = NULL) const; + virtual void Value( double, OGRPoint * ) const; + virtual double get_Area() const; + + // non-standard from OGRGeometry + virtual OGRwkbGeometryType getGeometryType() const; + virtual const char *getGeometryName() const; + virtual void segmentize(double dfMaxLength); + virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear = FALSE) const; + virtual OGRGeometry* getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0, + const char* const* papszOptions = NULL) const; +}; + +/************************************************************************/ +/* OGRCurveCollection */ +/************************************************************************/ + +/** + * Utility class to store a collection of curves. Used as a member of + * OGRCompoundCurve and OGRCurvePolygon. + * + * This class is only exported because of linking issues. It should never + * be directly used. + * + * @since GDAL 2.0 + */ + +class CPL_DLL OGRCurveCollection +{ + protected: + friend class OGRCompoundCurve; + friend class OGRCurvePolygon; + friend class OGRPolygon; + + int nCurveCount; + OGRCurve **papoCurves; + + public: + OGRCurveCollection(); + OGRCurveCollection(const OGRCurveCollection& other); + ~OGRCurveCollection(); + + OGRCurveCollection& operator=(const OGRCurveCollection& other); + + void empty(OGRGeometry* poGeom); + OGRBoolean IsEmpty() const; + void getEnvelope( OGREnvelope * psEnvelope ) const; + void getEnvelope( OGREnvelope3D * psEnvelope ) const; + + OGRErr addCurveDirectly( OGRGeometry* poGeom, OGRCurve* poCurve, + int bNeedRealloc ); + int WkbSize() const; + OGRErr importPreambuleFromWkb( OGRGeometry* poGeom, + unsigned char * pabyData, + int& nSize, + int& nDataOffset, + OGRwkbByteOrder& eByteOrder, + int nMinSubGeomSize, + OGRwkbVariant eWkVariant ); + OGRErr importBodyFromWkb( OGRGeometry* poGeom, + unsigned char * pabyData, + int nSize, + int nDataOffset, + int bAcceptCompoundCurve, + OGRErr (*pfnAddCurveDirectlyFromWkb)(OGRGeometry* poGeom, OGRCurve* poCurve), + OGRwkbVariant eWkVariant ); + OGRErr exportToWkt( const OGRGeometry* poGeom, char ** ppszDstText ) const; + OGRErr exportToWkb( const OGRGeometry* poGeom, OGRwkbByteOrder, + unsigned char *, OGRwkbVariant eWkbVariant ) const; + OGRBoolean Equals(OGRCurveCollection *poOCC) const; + void setCoordinateDimension( OGRGeometry* poGeom, int nNewDimension ); + void set3D( OGRGeometry* poGeom, OGRBoolean bIs3D ); + void setMeasured( OGRGeometry* poGeom, OGRBoolean bIsMeasured ); + int getNumCurves() const; + OGRCurve *getCurve( int ); + const OGRCurve *getCurve( int ) const; + OGRCurve *stealCurve( int ); + OGRErr transform( OGRGeometry* poGeom, + OGRCoordinateTransformation *poCT ); + void flattenTo2D(OGRGeometry* poGeom); + void segmentize(double dfMaxLength); + void swapXY(); + OGRBoolean hasCurveGeometry(int bLookForNonLinear) const; +}; + +/************************************************************************/ +/* OGRCompoundCurve */ +/************************************************************************/ + +/** + * Concrete representation of a compound curve, made of curves: OGRLineString + * and OGRCircularString. Each curve is connected by its first point to + * the last point of the previous curve. + * + * Compatibility: ISO SQL/MM Part 3. + * + * @since GDAL 2.0 + */ + +class CPL_DLL OGRCompoundCurve : public OGRCurve +{ + private: + OGRCurveCollection oCC; + + OGRErr addCurveDirectlyInternal( OGRCurve* poCurve, + double dfToleranceEps, + int bNeedRealloc ); + static OGRErr addCurveDirectlyFromWkt( OGRGeometry* poSelf, OGRCurve* poCurve ); + static OGRErr addCurveDirectlyFromWkb( OGRGeometry* poSelf, OGRCurve* poCurve ); + OGRLineString* CurveToLineInternal(double dfMaxAngleStepSizeDegrees, + const char* const* papszOptions, + int bIsLinearRing) const; + + protected: + static OGRLineString* CastToLineString(OGRCompoundCurve* poCC); + static OGRLinearRing* CastToLinearRing(OGRCompoundCurve* poCC); + + virtual OGRCurveCasterToLineString GetCasterToLineString() const; + virtual OGRCurveCasterToLinearRing GetCasterToLinearRing() const; + + public: + OGRCompoundCurve(); + OGRCompoundCurve(const OGRCompoundCurve& other); + virtual ~OGRCompoundCurve(); + + OGRCompoundCurve& operator=(const OGRCompoundCurve& other); + + // IWks Interface + virtual int WkbSize() const; + virtual OGRErr importFromWkb( unsigned char *, int = -1, OGRwkbVariant=wkbVariantOldOgc ); + virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char *, OGRwkbVariant=wkbVariantOldOgc ) const; + virtual OGRErr importFromWkt( char ** ); + virtual OGRErr exportToWkt( char ** ppszDstText, OGRwkbVariant=wkbVariantOldOgc ) const; + + // IGeometry interface + virtual OGRGeometry *clone() const; + virtual void empty(); + virtual void getEnvelope( OGREnvelope * psEnvelope ) const; + virtual void getEnvelope( OGREnvelope3D * psEnvelope ) const; + virtual OGRBoolean IsEmpty() const; + + // ICurve methods + virtual double get_Length() const; + virtual void StartPoint(OGRPoint *) const; + virtual void EndPoint(OGRPoint *) const; + virtual void Value( double, OGRPoint * ) const; + virtual OGRLineString* CurveToLine(double dfMaxAngleStepSizeDegrees = 0, + const char* const* papszOptions = NULL) const; + + virtual int getNumPoints() const; + virtual double get_AreaOfCurveSegments() const; + virtual double get_Area() const; + + // ISpatialRelation + virtual OGRBoolean Equals( OGRGeometry * ) const; + + // ICompoundCurve method + int getNumCurves() const; + OGRCurve *getCurve( int ); + const OGRCurve *getCurve( int ) const; + + // non standard. + virtual void setCoordinateDimension( int nDimension ); + virtual void set3D( OGRBoolean bIs3D ); + virtual void setMeasured( OGRBoolean bIsMeasured ); + + OGRErr addCurve( OGRCurve*, double dfToleranceEps = 1e-14 ); + OGRErr addCurveDirectly( OGRCurve*, double dfToleranceEps = 1e-14 ); + OGRCurve *stealCurve( int ); + virtual OGRPointIterator* getPointIterator() const; + + // non-standard from OGRGeometry + virtual OGRwkbGeometryType getGeometryType() const; + virtual const char *getGeometryName() const; + virtual OGRErr transform( OGRCoordinateTransformation *poCT ); + virtual void flattenTo2D(); + virtual void segmentize(double dfMaxLength); + virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear = FALSE) const; + virtual OGRGeometry* getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0, + const char* const* papszOptions = NULL) const; + + virtual void swapXY(); +}; + +/************************************************************************/ +/* OGRSurface */ +/************************************************************************/ + +/** + * Abstract base class for 2 dimensional objects like polygons or curve polygons. + */ + +class CPL_DLL OGRSurface : public OGRGeometry +{ + protected: + + virtual OGRSurfaceCasterToPolygon GetCasterToPolygon() const = 0; + virtual OGRSurfaceCasterToCurvePolygon GetCasterToCurvePolygon() const = 0; + + public: + virtual double get_Area() const = 0; + virtual OGRErr PointOnSurface( OGRPoint * poPoint ) const = 0; + + static OGRPolygon* CastToPolygon(OGRSurface* poSurface); + static OGRCurvePolygon* CastToCurvePolygon(OGRSurface* poSurface); +}; + + +/************************************************************************/ +/* OGRCurvePolygon */ +/************************************************************************/ + +/** + * Concrete class representing curve polygons. + * + * Note that curve polygons consist of one outer (curve) ring, and zero or + * more inner rings. A curve polygon cannot represent disconnected + * regions (such as multiple islands in a political body). The + * OGRMultiSurface must be used for this. + * + * Compatibility: ISO SQL/MM Part 3. + * + * @since GDAL 2.0 + */ + +class CPL_DLL OGRCurvePolygon : public OGRSurface +{ + private: + OGRBoolean ContainsPoint( const OGRPoint* p ) const; + virtual int checkRing( OGRCurve * poNewRing ) const; + OGRErr addRingDirectlyInternal( OGRCurve* poCurve, int bNeedRealloc ); + static OGRErr addCurveDirectlyFromWkt( OGRGeometry* poSelf, OGRCurve* poCurve ); + static OGRErr addCurveDirectlyFromWkb( OGRGeometry* poSelf, OGRCurve* poCurve ); + + protected: + friend class OGRPolygon; + OGRCurveCollection oCC; + + static OGRPolygon* CastToPolygon(OGRCurvePolygon* poCP); + + virtual OGRSurfaceCasterToPolygon GetCasterToPolygon() const; + virtual OGRSurfaceCasterToCurvePolygon GetCasterToCurvePolygon() const; + + public: + OGRCurvePolygon(); + OGRCurvePolygon(const OGRCurvePolygon&); + virtual ~OGRCurvePolygon(); + + OGRCurvePolygon& operator=(const OGRCurvePolygon& other); + + // Non standard (OGRGeometry). + virtual const char *getGeometryName() const; + virtual OGRwkbGeometryType getGeometryType() const; + virtual OGRGeometry *clone() const; + virtual void empty(); + virtual OGRErr transform( OGRCoordinateTransformation *poCT ); + virtual void flattenTo2D(); + virtual OGRBoolean IsEmpty() const; + virtual void segmentize(double dfMaxLength); + virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear = FALSE) const; + virtual OGRGeometry* getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0, + const char* const* papszOptions = NULL) const; + + // ISurface Interface + virtual double get_Area() const; + virtual OGRErr PointOnSurface( OGRPoint * poPoint ) const; + + // IWks Interface + virtual int WkbSize() const; + virtual OGRErr importFromWkb( unsigned char *, int = -1, OGRwkbVariant=wkbVariantOldOgc ); + virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char *, OGRwkbVariant=wkbVariantOldOgc ) const; + virtual OGRErr importFromWkt( char ** ); + virtual OGRErr exportToWkt( char ** ppszDstText, OGRwkbVariant eWkbVariant = wkbVariantOldOgc ) const; + + // IGeometry + virtual int getDimension() const; + virtual void getEnvelope( OGREnvelope * psEnvelope ) const; + virtual void getEnvelope( OGREnvelope3D * psEnvelope ) const; + + // ICurvePolygon + virtual OGRPolygon* CurvePolyToPoly(double dfMaxAngleStepSizeDegrees = 0, + const char* const* papszOptions = NULL) const; + + // ISpatialRelation + virtual OGRBoolean Equals( OGRGeometry * ) const; + virtual OGRBoolean Intersects( const OGRGeometry * ) const; + virtual OGRBoolean Contains( const OGRGeometry * ) const; + + // Non standard + virtual void setCoordinateDimension( int nDimension ); + virtual void set3D( OGRBoolean bIs3D ); + virtual void setMeasured( OGRBoolean bIsMeasured ); + + OGRErr addRing( OGRCurve * ); + OGRErr addRingDirectly( OGRCurve * ); + + OGRCurve *getExteriorRingCurve(); + const OGRCurve *getExteriorRingCurve() const; + int getNumInteriorRings() const; + OGRCurve *getInteriorRingCurve( int ); + const OGRCurve *getInteriorRingCurve( int ) const; + + OGRCurve *stealExteriorRingCurve(); + + virtual void swapXY(); +}; + +/************************************************************************/ +/* OGRPolygon */ +/************************************************************************/ + +/** + * Concrete class representing polygons. + * + * Note that the OpenGIS simple features polygons consist of one outer + * ring (linearring), and zero or more inner rings. A polygon cannot represent disconnected + * regions (such as multiple islands in a political body). The + * OGRMultiPolygon must be used for this. + */ + +class CPL_DLL OGRPolygon : public OGRCurvePolygon +{ + protected: + friend class OGRMultiSurface; + + virtual int checkRing( OGRCurve * poNewRing ) const; + OGRErr importFromWKTListOnly( char ** ppszInput, int bHasZ, int bHasM, + OGRRawPoint*& paoPoints, int& nMaxPoints, + double*& padfZ ); + + static OGRCurvePolygon* CastToCurvePolygon(OGRPolygon* poPoly); + + virtual OGRSurfaceCasterToPolygon GetCasterToPolygon() const; + virtual OGRSurfaceCasterToCurvePolygon GetCasterToCurvePolygon() const; + + public: + OGRPolygon(); + OGRPolygon(const OGRPolygon& other); + virtual ~OGRPolygon(); + + OGRPolygon& operator=(const OGRPolygon& other); + + // Non standard (OGRGeometry). + virtual const char *getGeometryName() const; + virtual OGRwkbGeometryType getGeometryType() const; + virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear = FALSE) const; + virtual OGRGeometry* getCurveGeometry(const char* const* papszOptions = NULL) const; + virtual OGRGeometry* getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0, + const char* const* papszOptions = NULL) const; + + // ISurface Interface + virtual OGRErr PointOnSurface( OGRPoint * poPoint ) const; + + // IWks Interface + virtual int WkbSize() const; + virtual OGRErr importFromWkb( unsigned char *, int = -1, OGRwkbVariant=wkbVariantOldOgc ); + virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char *, OGRwkbVariant=wkbVariantOldOgc ) const; + virtual OGRErr importFromWkt( char ** ); + virtual OGRErr exportToWkt( char ** ppszDstText, OGRwkbVariant=wkbVariantOldOgc ) const; + + // ICurvePolygon + virtual OGRPolygon* CurvePolyToPoly(double dfMaxAngleStepSizeDegrees = 0, + const char* const* papszOptions = NULL) const; + + OGRLinearRing *getExteriorRing(); + const OGRLinearRing *getExteriorRing() const; + OGRLinearRing *getInteriorRing( int ); + const OGRLinearRing *getInteriorRing( int ) const; + + OGRLinearRing *stealExteriorRing(); + OGRLinearRing *stealInteriorRing(int); + + OGRBoolean IsPointOnSurface( const OGRPoint * ) const; + + virtual void closeRings(); +}; + +/************************************************************************/ +/* OGRGeometryCollection */ +/************************************************************************/ + +/** + * A collection of 1 or more geometry objects. + * + * All geometries must share a common spatial reference system, and + * Subclasses may impose additional restrictions on the contents. + */ + +class CPL_DLL OGRGeometryCollection : public OGRGeometry +{ + OGRErr importFromWkbInternal( unsigned char * pabyData, int nSize, int nRecLevel, + OGRwkbVariant ); + OGRErr importFromWktInternal( char **ppszInput, int nRecLevel ); + + protected: + int nGeomCount; + OGRGeometry **papoGeoms; + + OGRErr exportToWktInternal( char ** ppszDstText, + OGRwkbVariant eWkbVariant, + const char* pszSkipPrefix ) const; + virtual OGRBoolean isCompatibleSubType( OGRwkbGeometryType ) const; + + static OGRGeometryCollection* TransferMembersAndDestroy(OGRGeometryCollection* poSrc, + OGRGeometryCollection* poDst); + + public: + OGRGeometryCollection(); + OGRGeometryCollection(const OGRGeometryCollection& other); + virtual ~OGRGeometryCollection(); + + OGRGeometryCollection& operator=(const OGRGeometryCollection& other); + + // Non standard (OGRGeometry). + virtual const char *getGeometryName() const; + virtual OGRwkbGeometryType getGeometryType() const; + virtual OGRGeometry *clone() const; + virtual void empty(); + virtual OGRErr transform( OGRCoordinateTransformation *poCT ); + virtual void flattenTo2D(); + virtual OGRBoolean IsEmpty() const; + virtual void segmentize(double dfMaxLength); + virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear = FALSE) const; + virtual OGRGeometry* getCurveGeometry(const char* const* papszOptions = NULL) const; + virtual OGRGeometry* getLinearGeometry(double dfMaxAngleStepSizeDegrees = 0, const char* const* papszOptions = NULL) const; + + // IWks Interface + virtual int WkbSize() const; + virtual OGRErr importFromWkb( unsigned char *, int = -1, OGRwkbVariant=wkbVariantOldOgc ); + virtual OGRErr exportToWkb( OGRwkbByteOrder, unsigned char *, OGRwkbVariant=wkbVariantOldOgc ) const; + virtual OGRErr importFromWkt( char ** ); + virtual OGRErr exportToWkt( char ** ppszDstText, OGRwkbVariant=wkbVariantOldOgc ) const; + + virtual double get_Length() const; + virtual double get_Area() const; + + // IGeometry methods + virtual int getDimension() const; + virtual void getEnvelope( OGREnvelope * psEnvelope ) const; + virtual void getEnvelope( OGREnvelope3D * psEnvelope ) const; + + // IGeometryCollection + int getNumGeometries() const; + OGRGeometry *getGeometryRef( int ); + const OGRGeometry *getGeometryRef( int ) const; + + // ISpatialRelation + virtual OGRBoolean Equals( OGRGeometry * ) const; + + // Non standard + virtual void setCoordinateDimension( int nDimension ); + virtual void set3D( OGRBoolean bIs3D ); + virtual void setMeasured( OGRBoolean bIsMeasured ); + virtual OGRErr addGeometry( const OGRGeometry * ); + virtual OGRErr addGeometryDirectly( OGRGeometry * ); + virtual OGRErr removeGeometry( int iIndex, int bDelete = TRUE ); + + void closeRings(); + + virtual void swapXY(); +}; + +/************************************************************************/ +/* OGRMultiSurface */ +/************************************************************************/ + +/** + * A collection of non-overlapping OGRSurface. + * + * @since GDAL 2.0 + */ + +class CPL_DLL OGRMultiSurface : public OGRGeometryCollection +{ + protected: + virtual OGRBoolean isCompatibleSubType( OGRwkbGeometryType ) const; + + public: + OGRMultiSurface(); + OGRMultiSurface(const OGRMultiSurface& other); + virtual ~OGRMultiSurface(); + + OGRMultiSurface& operator=(const OGRMultiSurface& other); + + // Non standard (OGRGeometry). + virtual const char *getGeometryName() const; + virtual OGRwkbGeometryType getGeometryType() const; + virtual OGRErr importFromWkt( char ** ); + virtual OGRErr exportToWkt( char **, OGRwkbVariant=wkbVariantOldOgc ) const; + + // IMultiSurface methods + virtual OGRErr PointOnSurface( OGRPoint * poPoint ) const; + + // IGeometry methods + virtual int getDimension() const; + + // Non standard + virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear = FALSE) const; + + static OGRMultiPolygon* CastToMultiPolygon(OGRMultiSurface* poMS); +}; + +/************************************************************************/ +/* OGRMultiPolygon */ +/************************************************************************/ + +/** + * A collection of non-overlapping OGRPolygon. + */ + +class CPL_DLL OGRMultiPolygon : public OGRMultiSurface +{ + protected: + virtual OGRBoolean isCompatibleSubType( OGRwkbGeometryType ) const; + + public: + OGRMultiPolygon(); + OGRMultiPolygon(const OGRMultiPolygon& other); + virtual ~OGRMultiPolygon(); + + OGRMultiPolygon& operator=(const OGRMultiPolygon& other); + + // Non standard (OGRGeometry). + virtual const char *getGeometryName() const; + virtual OGRwkbGeometryType getGeometryType() const; + virtual OGRErr exportToWkt( char **, OGRwkbVariant=wkbVariantOldOgc ) const; + + // IMultiSurface methods + virtual OGRErr PointOnSurface( OGRPoint * poPoint ) const; + + // Non standard + virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear = FALSE) const; + + static OGRMultiSurface* CastToMultiSurface(OGRMultiPolygon* poMP); +}; + +/************************************************************************/ +/* OGRMultiPoint */ +/************************************************************************/ + +/** + * A collection of OGRPoint. + */ + +class CPL_DLL OGRMultiPoint : public OGRGeometryCollection +{ + private: + OGRErr importFromWkt_Bracketed( char **, int bHasM, int bHasZ ); + + protected: + virtual OGRBoolean isCompatibleSubType( OGRwkbGeometryType ) const; + + public: + OGRMultiPoint(); + OGRMultiPoint(const OGRMultiPoint& other); + virtual ~OGRMultiPoint(); + + OGRMultiPoint& operator=(const OGRMultiPoint& other); + + // Non standard (OGRGeometry). + virtual const char *getGeometryName() const; + virtual OGRwkbGeometryType getGeometryType() const; + virtual OGRErr importFromWkt( char ** ); + virtual OGRErr exportToWkt( char **, OGRwkbVariant=wkbVariantOldOgc ) const; + + // IGeometry methods + virtual int getDimension() const; + + // Non standard + virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear = FALSE) const; +}; + +/************************************************************************/ +/* OGRMultiCurve */ +/************************************************************************/ + +/** + * A collection of OGRCurve. + * + * @since GDAL 2.0 + */ + +class CPL_DLL OGRMultiCurve : public OGRGeometryCollection +{ + protected: + static OGRErr addCurveDirectlyFromWkt( OGRGeometry* poSelf, OGRCurve* poCurve ); + virtual OGRBoolean isCompatibleSubType( OGRwkbGeometryType ) const; + + public: + OGRMultiCurve(); + OGRMultiCurve(const OGRMultiCurve& other); + virtual ~OGRMultiCurve(); + + OGRMultiCurve& operator=(const OGRMultiCurve& other); + + // Non standard (OGRGeometry). + virtual const char *getGeometryName() const; + virtual OGRwkbGeometryType getGeometryType() const; + virtual OGRErr importFromWkt( char ** ); + virtual OGRErr exportToWkt( char **, OGRwkbVariant=wkbVariantOldOgc ) const; + + // IGeometry methods + virtual int getDimension() const; + + // Non standard + virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear = FALSE) const; + + static OGRMultiLineString* CastToMultiLineString(OGRMultiCurve* poMC); +}; + +/************************************************************************/ +/* OGRMultiLineString */ +/************************************************************************/ + +/** + * A collection of OGRLineString. + */ + +class CPL_DLL OGRMultiLineString : public OGRMultiCurve +{ + protected: + virtual OGRBoolean isCompatibleSubType( OGRwkbGeometryType ) const; + + public: + OGRMultiLineString(); + OGRMultiLineString(const OGRMultiLineString& other); + virtual ~OGRMultiLineString(); + + OGRMultiLineString& operator=(const OGRMultiLineString& other); + + // Non standard (OGRGeometry). + virtual const char *getGeometryName() const; + virtual OGRwkbGeometryType getGeometryType() const; + virtual OGRErr exportToWkt( char **, OGRwkbVariant=wkbVariantOldOgc ) const; + + // Non standard + virtual OGRBoolean hasCurveGeometry(int bLookForNonLinear = FALSE) const; + + static OGRMultiCurve* CastToMultiCurve(OGRMultiLineString* poMLS); +}; + + +/************************************************************************/ +/* OGRGeometryFactory */ +/************************************************************************/ + +/** + * Create geometry objects from well known text/binary. + */ + +class CPL_DLL OGRGeometryFactory +{ + static OGRErr createFromFgfInternal( unsigned char *pabyData, + OGRSpatialReference * poSR, + OGRGeometry **ppoReturn, + int nBytes, + int *pnBytesConsumed, + int nRecLevel ); + public: + static OGRErr createFromWkb( unsigned char *, OGRSpatialReference *, + OGRGeometry **, int = -1, OGRwkbVariant=wkbVariantOldOgc ); + static OGRErr createFromWkt( char **, OGRSpatialReference *, + OGRGeometry ** ); + static OGRErr createFromFgf( unsigned char *, OGRSpatialReference *, + OGRGeometry **, int = -1, int * = NULL ); + static OGRGeometry *createFromGML( const char * ); + static OGRGeometry *createFromGEOS( GEOSContextHandle_t hGEOSCtxt, GEOSGeom ); + + static void destroyGeometry( OGRGeometry * ); + static OGRGeometry *createGeometry( OGRwkbGeometryType ); + + static OGRGeometry * forceToPolygon( OGRGeometry * ); + static OGRGeometry * forceToLineString( OGRGeometry *, bool bOnlyInOrder = true ); + static OGRGeometry * forceToMultiPolygon( OGRGeometry * ); + static OGRGeometry * forceToMultiPoint( OGRGeometry * ); + static OGRGeometry * forceToMultiLineString( OGRGeometry * ); + + static OGRGeometry * forceTo( OGRGeometry* poGeom, + OGRwkbGeometryType eTargetType, + const char*const* papszOptions = NULL ); + + static OGRGeometry * organizePolygons( OGRGeometry **papoPolygons, + int nPolygonCount, + int *pbResultValidGeometry, + const char **papszOptions = NULL); + static int haveGEOS(); + + static OGRGeometry* transformWithOptions( const OGRGeometry* poSrcGeom, + OGRCoordinateTransformation *poCT, + char** papszOptions ); + + static OGRGeometry* + approximateArcAngles( double dfX, double dfY, double dfZ, + double dfPrimaryRadius, double dfSecondaryAxis, + double dfRotation, + double dfStartAngle, double dfEndAngle, + double dfMaxAngleStepSizeDegrees ); + + static int GetCurveParmeters(double x0, double y0, + double x1, double y1, + double x2, double y2, + double& R, double& cx, double& cy, + double& alpha0, double& alpha1, double& alpha2 ); + static OGRLineString* curveToLineString( double x0, double y0, double z0, + double x1, double y1, double z1, + double x2, double y2, double z2, + int bHasZ, + double dfMaxAngleStepSizeDegrees, + const char*const* papszOptions = NULL ); + static OGRCurve* curveFromLineString(const OGRLineString* poLS, + const char*const* papszOptions = NULL); +}; + +OGRwkbGeometryType CPL_DLL OGRFromOGCGeomType( const char *pszGeomType ); +const char CPL_DLL * OGRToOGCGeomType( OGRwkbGeometryType eGeomType ); + +/* Prepared geometry API (needs GEOS >= 3.1.0) */ +typedef struct _OGRPreparedGeometry OGRPreparedGeometry; +int OGRHasPreparedGeometrySupport(); +OGRPreparedGeometry* OGRCreatePreparedGeometry( const OGRGeometry* poGeom ); +void OGRDestroyPreparedGeometry( OGRPreparedGeometry* poPreparedGeom ); +int OGRPreparedGeometryIntersects( const OGRPreparedGeometry* poPreparedGeom, + const OGRGeometry* poOtherGeom ); +int OGRPreparedGeometryContains( const OGRPreparedGeometry* poPreparedGeom, + const OGRGeometry* poOtherGeom ); + +#endif /* ndef OGR_GEOMETRY_H_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/ogr_geos.h b/modules/globebrowsing/ext/gdal/include/ogr_geos.h new file mode 100644 index 0000000000..079a9355a6 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/ogr_geos.h @@ -0,0 +1,49 @@ +/****************************************************************************** + * $Id$ + * + * Project: OpenGIS Simple Features Reference Implementation + * Purpose: Definitions related to support for use of GEOS in OGR. + * This file is only intended to be pulled in by OGR implementation + * code directly accessing GEOS. + * Author: Frank Warmerdam + * + ****************************************************************************** + * Copyright (c) 2004, 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. + ****************************************************************************/ + +#ifndef OGR_GEOS_H_INCLUDED +#define OGR_GEOS_H_INCLUDED + +#ifdef HAVE_GEOS +// To avoid accidental use of non reentrant GEOS API. +// (check only effective in GEOS >= 3.5) +# define GEOS_USE_ONLY_R_API + +# include +#else + +namespace geos { + class Geometry; +}; + +#endif + +#endif /* ndef OGR_GEOS_H_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/ogr_p.h b/modules/globebrowsing/ext/gdal/include/ogr_p.h new file mode 100644 index 0000000000..7d11d26dbe --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/ogr_p.h @@ -0,0 +1,182 @@ +/****************************************************************************** + * $Id$ + * + * Project: OpenGIS Simple Features Reference Implementation + * Purpose: Some private helper functions and stuff for OGR implementation. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, Frank Warmerdam + * Copyright (c) 2008-2014, Even Rouault + * + * 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. + ****************************************************************************/ + +#ifndef OGR_P_H_INCLUDED +#define OGR_P_H_INCLUDED + +/* -------------------------------------------------------------------- */ +/* Include the common portability library ... lets us do lots */ +/* of stuff easily. */ +/* -------------------------------------------------------------------- */ + +#include "cpl_string.h" +#include "cpl_conv.h" +#include "cpl_minixml.h" + +#include "ogr_core.h" +#include "ogr_geometry.h" +#include "ogr_feature.h" + +/* A default name for the default geometry column, instead of '' */ +#define OGR_GEOMETRY_DEFAULT_NON_EMPTY_NAME "_ogr_geometry_" + +#ifdef CPL_MSB +# define OGR_SWAP(x) (x == wkbNDR) +#else +# define OGR_SWAP(x) (x == wkbXDR) +#endif + +/* PostGIS 1.X has non standard codes for the following geometry types */ +#define POSTGIS15_CURVEPOLYGON 13 /* instead of 10 */ +#define POSTGIS15_MULTICURVE 14 /* instead of 11 */ +#define POSTGIS15_MULTISURFACE 15 /* instead of 12 */ + +/* Has been deprecated. Can only be used in very specific circumstances */ +#ifdef GDAL_COMPILATION +#define wkb25DBitInternalUse 0x80000000 +#endif + +/* -------------------------------------------------------------------- */ +/* helper function for parsing well known text format vector objects.*/ +/* -------------------------------------------------------------------- */ + +#ifdef OGR_GEOMETRY_H_INCLUDED +#define OGR_WKT_TOKEN_MAX 64 + +const char CPL_DLL * OGRWktReadToken( const char * pszInput, char * pszToken ); + +const char CPL_DLL * OGRWktReadPoints( const char * pszInput, + OGRRawPoint **ppaoPoints, + double **ppadfZ, + int * pnMaxPoints, + int * pnReadPoints ); + +const char CPL_DLL * OGRWktReadPointsM( const char * pszInput, + OGRRawPoint **ppaoPoints, + double **ppadfZ, + double **ppadfM, + int * flags, /* geometry flags, are we expecting Z, M, or both; may change due to input */ + int * pnMaxPoints, + int * pnReadPoints ); + +void CPL_DLL OGRMakeWktCoordinate( char *, double, double, double, int ); +void CPL_DLL OGRMakeWktCoordinateM( char *, double, double, double, double, OGRBoolean, OGRBoolean ); + +#endif + +void OGRFormatDouble( char *pszBuffer, int nBufferLen, double dfVal, + char chDecimalSep, int nPrecision = 15, char chConversionSpecifier = 'f' ); + +/* -------------------------------------------------------------------- */ +/* Date-time parsing and processing functions */ +/* -------------------------------------------------------------------- */ + +/* Internal use by OGR drivers only, CPL_DLL is just there in case */ +/* they are compiled as plugins */ +int CPL_DLL OGRGetDayOfWeek(int day, int month, int year); +int CPL_DLL OGRParseXMLDateTime( const char* pszXMLDateTime, + OGRField* psField ); +int CPL_DLL OGRParseRFC822DateTime( const char* pszRFC822DateTime, + OGRField* psField ); +char CPL_DLL * OGRGetRFC822DateTime(const OGRField* psField); +char CPL_DLL * OGRGetXMLDateTime(const OGRField* psField); +char CPL_DLL * OGRGetXML_UTF8_EscapedString(const char* pszString); + +int OGRCompareDate( OGRField *psFirstTuple, + OGRField *psSecondTuple ); /* used by ogr_gensql.cpp and ogrfeaturequery.cpp */ + +/* General utility option processing. */ +int CPL_DLL OGRGeneralCmdLineProcessor( int nArgc, char ***ppapszArgv, int nOptions ); + +/************************************************************************/ +/* Support for special attributes (feature query and selection) */ +/************************************************************************/ +#define SPF_FID 0 +#define SPF_OGR_GEOMETRY 1 +#define SPF_OGR_STYLE 2 +#define SPF_OGR_GEOM_WKT 3 +#define SPF_OGR_GEOM_AREA 4 +#define SPECIAL_FIELD_COUNT 5 + +extern const char* const SpecialFieldNames[SPECIAL_FIELD_COUNT]; + +#ifdef SWQ_H_INCLUDED_ +extern const swq_field_type SpecialFieldTypes[SPECIAL_FIELD_COUNT]; +#endif + +/************************************************************************/ +/* Some SRS related stuff, search in SRS data files. */ +/************************************************************************/ + +OGRErr CPL_DLL OSRGetEllipsoidInfo( int, char **, double *, double *); + +/* Fast atof function */ +double OGRFastAtof(const char* pszStr); + +OGRErr CPL_DLL OGRCheckPermutation(int* panPermutation, int nSize); + +/* GML related */ + +OGRGeometry *GML2OGRGeometry_XMLNode( const CPLXMLNode *psNode, + int nPseudoBoolGetSecondaryGeometryOption, + int nRecLevel = 0, + int nSRSDimension = 0, + bool bIgnoreGSG = false, + bool bOrientation = true, + bool bFaceHoleNegative = false); + +/************************************************************************/ +/* PostGIS EWKB encoding */ +/************************************************************************/ + +OGRGeometry CPL_DLL *OGRGeometryFromEWKB( GByte *pabyWKB, int nLength, int* pnSRID, + int bIsPostGIS1_EWKB ); +OGRGeometry CPL_DLL *OGRGeometryFromHexEWKB( const char *pszBytea, int* pnSRID, + int bIsPostGIS1_EWKB ); +char CPL_DLL * OGRGeometryToHexEWKB( OGRGeometry * poGeometry, int nSRSId, + int nPostGISMajor, int nPostGISMinor ); + +/************************************************************************/ +/* WKB Type Handling encoding */ +/************************************************************************/ + +OGRErr OGRReadWKBGeometryType( unsigned char * pabyData, + OGRwkbVariant wkbVariant, + OGRwkbGeometryType *eGeometryType ); + +/************************************************************************/ +/* Other */ +/************************************************************************/ + +void CPL_DLL OGRUpdateFieldType( OGRFieldDefn* poFDefn, + OGRFieldType eNewType, + OGRFieldSubType eNewSubType ); + +#endif /* ndef OGR_P_H_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/ogr_spatialref.h b/modules/globebrowsing/ext/gdal/include/ogr_spatialref.h new file mode 100644 index 0000000000..12c1a39dfd --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/ogr_spatialref.h @@ -0,0 +1,636 @@ +/****************************************************************************** + * $Id$ + * + * Project: OpenGIS Simple Features Reference Implementation + * Purpose: Classes for manipulating spatial reference systems in a + * platform non-specific manner. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, Les Technologies SoftMap Inc. + * Copyright (c) 2008-2013, Even Rouault + * + * 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. + ****************************************************************************/ + +#ifndef OGR_SPATIALREF_H_INCLUDED +#define OGR_SPATIALREF_H_INCLUDED + +#include "ogr_srs_api.h" + +/** + * \file ogr_spatialref.h + * + * Coordinate systems services. + */ + +/************************************************************************/ +/* OGR_SRSNode */ +/************************************************************************/ + +/** + * Objects of this class are used to represent value nodes in the parsed + * representation of the WKT SRS format. For instance UNIT["METER",1] + * would be rendered into three OGR_SRSNodes. The root node would have a + * value of UNIT, and two children, the first with a value of METER, and the + * second with a value of 1. + * + * Normally application code just interacts with the OGRSpatialReference + * object, which uses the OGR_SRSNode to implement it's data structure; + * however, this class is user accessible for detailed access to components + * of an SRS definition. + */ + +class CPL_DLL OGR_SRSNode +{ + char *pszValue; + + OGR_SRSNode **papoChildNodes; + OGR_SRSNode *poParent; + + int nChildren; + + int NeedsQuoting() const; + OGRErr importFromWkt( char **, int nRecLevel, int* pnNodes ); + + public: + OGR_SRSNode(const char * = NULL); + ~OGR_SRSNode(); + + int IsLeafNode() const { return nChildren == 0; } + + int GetChildCount() const { return nChildren; } + OGR_SRSNode *GetChild( int ); + const OGR_SRSNode *GetChild( int ) const; + + OGR_SRSNode *GetNode( const char * ); + const OGR_SRSNode *GetNode( const char * ) const; + + void InsertChild( OGR_SRSNode *, int ); + void AddChild( OGR_SRSNode * ); + int FindChild( const char * ) const; + void DestroyChild( int ); + void ClearChildren(); + void StripNodes( const char * ); + + const char *GetValue() const { return pszValue; } + void SetValue( const char * ); + + void MakeValueSafe(); + OGRErr FixupOrdering(); + + OGR_SRSNode *Clone() const; + + OGRErr importFromWkt( char ** ); + OGRErr exportToWkt( char ** ) const; + OGRErr exportToPrettyWkt( char **, int = 1) const; + + OGRErr applyRemapper( const char *pszNode, + char **papszSrcValues, + char **papszDstValues, + int nStepSize = 1, + int bChildOfHit = FALSE ); +}; + +/************************************************************************/ +/* OGRSpatialReference */ +/************************************************************************/ + +/** + * This class represents an OpenGIS Spatial Reference System, and contains + * methods for converting between this object organization and well known + * text (WKT) format. This object is reference counted as one instance of + * the object is normally shared between many OGRGeometry objects. + * + * Normally application code can fetch needed parameter values for this + * SRS using GetAttrValue(), but in special cases the underlying parse tree + * (or OGR_SRSNode objects) can be accessed more directly. + * + * See the tutorial for more information on + * how to use this class. + */ + +class CPL_DLL OGRSpatialReference +{ + double dfFromGreenwich; + double dfToMeter; + double dfToDegrees; + + OGR_SRSNode *poRoot; + + int nRefCount; + int bNormInfoSet; + + static OGRErr Validate(OGR_SRSNode *poRoot); + static OGRErr ValidateAuthority(OGR_SRSNode *poRoot); + static OGRErr ValidateAxis(OGR_SRSNode *poRoot); + static OGRErr ValidateUnit(OGR_SRSNode *poRoot); + static OGRErr ValidateVertDatum(OGR_SRSNode *poRoot); + static OGRErr ValidateProjection( OGR_SRSNode* poRoot ); + static int IsAliasFor( const char *, const char * ); + void GetNormInfo() const; + + OGRErr importFromURNPart(const char* pszAuthority, + const char* pszCode, + const char* pszURN); + public: + OGRSpatialReference(const OGRSpatialReference&); + OGRSpatialReference(const char * = NULL); + + virtual ~OGRSpatialReference(); + + static void DestroySpatialReference(OGRSpatialReference* poSRS); + + OGRSpatialReference &operator=(const OGRSpatialReference&); + + int Reference(); + int Dereference(); + int GetReferenceCount() const { return nRefCount; } + void Release(); + + OGRSpatialReference *Clone() const; + OGRSpatialReference *CloneGeogCS() const; + + void dumpReadable(); + OGRErr exportToWkt( char ** ) const; + OGRErr exportToPrettyWkt( char **, int = FALSE) const; + OGRErr exportToProj4( char ** ) const; + OGRErr exportToPCI( char **, char **, double ** ) const; + OGRErr exportToUSGS( long *, long *, double **, long * ) const; + OGRErr exportToXML( char **, const char * = NULL ) const; + OGRErr exportToPanorama( long *, long *, long *, long *, + double * ) const; + OGRErr exportToERM( char *pszProj, char *pszDatum, char *pszUnits ); + OGRErr exportToMICoordSys( char ** ) const; + + OGRErr importFromWkt( char ** ); + OGRErr importFromProj4( const char * ); + OGRErr importFromEPSG( int ); + OGRErr importFromEPSGA( int ); + OGRErr importFromESRI( char ** ); + OGRErr importFromPCI( const char *, const char * = NULL, + double * = NULL ); +#define USGS_ANGLE_DECIMALDEGREES 0 +#define USGS_ANGLE_PACKEDDMS TRUE /* 1 */ +#define USGS_ANGLE_RADIANS 2 + OGRErr importFromUSGS( long iProjSys, long iZone, + double *padfPrjParams, long iDatum, + int nUSGSAngleFormat = USGS_ANGLE_PACKEDDMS ); + OGRErr importFromPanorama( long, long, long, double* ); + OGRErr importFromOzi( const char * const* papszLines ); + OGRErr importFromWMSAUTO( const char *pszAutoDef ); + OGRErr importFromXML( const char * ); + OGRErr importFromDict( const char *pszDict, const char *pszCode ); + OGRErr importFromURN( const char * ); + OGRErr importFromCRSURL( const char * ); + OGRErr importFromERM( const char *pszProj, const char *pszDatum, + const char *pszUnits ); + OGRErr importFromUrl( const char * ); + OGRErr importFromMICoordSys( const char * ); + + OGRErr morphToESRI(); + OGRErr morphFromESRI(); + + OGRErr Validate(); + OGRErr StripCTParms( OGR_SRSNode * = NULL ); + OGRErr StripVertical(); + OGRErr FixupOrdering(); + OGRErr Fixup(); + + int EPSGTreatsAsLatLong(); + int EPSGTreatsAsNorthingEasting(); + const char *GetAxis( const char *pszTargetKey, int iAxis, + OGRAxisOrientation *peOrientation ) const; + OGRErr SetAxes( const char *pszTargetKey, + const char *pszXAxisName, + OGRAxisOrientation eXAxisOrientation, + const char *pszYAxisName, + OGRAxisOrientation eYAxisOrientation ); + + // Machinery for accessing parse nodes + OGR_SRSNode *GetRoot() { return poRoot; } + const OGR_SRSNode *GetRoot() const { return poRoot; } + void SetRoot( OGR_SRSNode * ); + + OGR_SRSNode *GetAttrNode(const char *); + const OGR_SRSNode *GetAttrNode(const char *) const; + const char *GetAttrValue(const char *, int = 0) const; + + OGRErr SetNode( const char *, const char * ); + OGRErr SetNode( const char *, double ); + + OGRErr SetLinearUnitsAndUpdateParameters( const char *pszName, + double dfInMeters ); + OGRErr SetLinearUnits( const char *pszName, double dfInMeters ); + OGRErr SetTargetLinearUnits( const char *pszTargetKey, + const char *pszName, double dfInMeters ); + double GetLinearUnits( char ** = NULL ) const; + double GetTargetLinearUnits( const char *pszTargetKey, + char ** ppszRetName = NULL ) const; + + OGRErr SetAngularUnits( const char *pszName, double dfInRadians ); + double GetAngularUnits( char ** = NULL ) const; + + double GetPrimeMeridian( char ** = NULL ) const; + + int IsGeographic() const; + int IsProjected() const; + int IsGeocentric() const; + int IsLocal() const; + int IsVertical() const; + int IsCompound() const; + int IsSameGeogCS( const OGRSpatialReference * ) const; + int IsSameVertCS( const OGRSpatialReference * ) const; + int IsSame( const OGRSpatialReference * ) const; + + void Clear(); + OGRErr SetLocalCS( const char * ); + OGRErr SetProjCS( const char * ); + OGRErr SetProjection( const char * ); + OGRErr SetGeocCS( const char * pszGeocName ); + OGRErr SetGeogCS( const char * pszGeogName, + const char * pszDatumName, + const char * pszEllipsoidName, + double dfSemiMajor, double dfInvFlattening, + const char * pszPMName = NULL, + double dfPMOffset = 0.0, + const char * pszUnits = NULL, + double dfConvertToRadians = 0.0 ); + OGRErr SetWellKnownGeogCS( const char * ); + OGRErr CopyGeogCSFrom( const OGRSpatialReference * poSrcSRS ); + OGRErr SetVertCS( const char *pszVertCSName, + const char *pszVertDatumName, + int nVertDatumClass = 2005 ); + OGRErr SetCompoundCS( const char *pszName, + const OGRSpatialReference *poHorizSRS, + const OGRSpatialReference *poVertSRS ); + + OGRErr SetFromUserInput( const char * ); + + OGRErr SetTOWGS84( double, double, double, + double = 0.0, double = 0.0, double = 0.0, + double = 0.0 ); + OGRErr GetTOWGS84( double *padfCoef, int nCoeff = 7 ) const; + + double GetSemiMajor( OGRErr * = NULL ) const; + double GetSemiMinor( OGRErr * = NULL ) const; + double GetInvFlattening( OGRErr * = NULL ) const; + + OGRErr SetAuthority( const char * pszTargetKey, + const char * pszAuthority, + int nCode ); + + OGRErr AutoIdentifyEPSG(); + int GetEPSGGeogCS(); + + const char *GetAuthorityCode( const char * pszTargetKey ) const; + const char *GetAuthorityName( const char * pszTargetKey ) const; + + const char *GetExtension( const char *pszTargetKey, + const char *pszName, + const char *pszDefault = NULL ) const; + OGRErr SetExtension( const char *pszTargetKey, + const char *pszName, + const char *pszValue ); + + int FindProjParm( const char *pszParameter, + const OGR_SRSNode *poPROJCS=NULL ) const; + OGRErr SetProjParm( const char *, double ); + double GetProjParm( const char *, double =0.0, OGRErr* = NULL ) const; + + OGRErr SetNormProjParm( const char *, double ); + double GetNormProjParm( const char *, double=0.0, OGRErr* =NULL)const; + + static int IsAngularParameter( const char * ); + static int IsLongitudeParameter( const char * ); + static int IsLinearParameter( const char * ); + + /** Albers Conic Equal Area */ + OGRErr SetACEA( double dfStdP1, double dfStdP2, + double dfCenterLat, double dfCenterLong, + double dfFalseEasting, double dfFalseNorthing ); + + /** Azimuthal Equidistant */ + OGRErr SetAE( double dfCenterLat, double dfCenterLong, + double dfFalseEasting, double dfFalseNorthing ); + + /** Bonne */ + OGRErr SetBonne( double dfStdP1, double dfCentralMeridian, + double dfFalseEasting, double dfFalseNorthing ); + + /** Cylindrical Equal Area */ + OGRErr SetCEA( double dfStdP1, double dfCentralMeridian, + double dfFalseEasting, double dfFalseNorthing ); + + /** Cassini-Soldner */ + OGRErr SetCS( double dfCenterLat, double dfCenterLong, + double dfFalseEasting, double dfFalseNorthing ); + + /** Equidistant Conic */ + OGRErr SetEC( double dfStdP1, double dfStdP2, + double dfCenterLat, double dfCenterLong, + double dfFalseEasting, double dfFalseNorthing ); + + /** Eckert I-VI */ + OGRErr SetEckert( int nVariation, double dfCentralMeridian, + double dfFalseEasting, double dfFalseNorthing ); + + OGRErr SetEckertIV( double dfCentralMeridian, + double dfFalseEasting, double dfFalseNorthing ); + + OGRErr SetEckertVI( double dfCentralMeridian, + double dfFalseEasting, double dfFalseNorthing ); + + /** Equirectangular */ + OGRErr SetEquirectangular(double dfCenterLat, double dfCenterLong, + double dfFalseEasting, double dfFalseNorthing ); + /** Equirectangular generalized form : */ + OGRErr SetEquirectangular2( double dfCenterLat, double dfCenterLong, + double dfPseudoStdParallel1, + double dfFalseEasting, double dfFalseNorthing ); + + /** Geostationary Satellite */ + OGRErr SetGEOS( double dfCentralMeridian, double dfSatelliteHeight, + double dfFalseEasting, double dfFalseNorthing ); + + /** Goode Homolosine */ + OGRErr SetGH( double dfCentralMeridian, + double dfFalseEasting, double dfFalseNorthing ); + + /** Interrupted Goode Homolosine */ + OGRErr SetIGH(); + + /** Gall Stereograpic */ + OGRErr SetGS( double dfCentralMeridian, + double dfFalseEasting, double dfFalseNorthing ); + + /** Gauss Schreiber Transverse Mercator */ + OGRErr SetGaussSchreiberTMercator(double dfCenterLat, double dfCenterLong, + double dfScale, + double dfFalseEasting, double dfFalseNorthing ); + + /** Gnomonic */ + OGRErr SetGnomonic(double dfCenterLat, double dfCenterLong, + double dfFalseEasting, double dfFalseNorthing ); + + /** Hotine Oblique Mercator */ + OGRErr SetHOM( double dfCenterLat, double dfCenterLong, + double dfAzimuth, double dfRectToSkew, + double dfScale, + double dfFalseEasting, double dfFalseNorthing ); + + OGRErr SetHOM2PNO( double dfCenterLat, + double dfLat1, double dfLong1, + double dfLat2, double dfLong2, + double dfScale, + double dfFalseEasting, double dfFalseNorthing ); + + OGRErr SetOM( double dfCenterLat, double dfCenterLong, + double dfAzimuth, double dfRectToSkew, + double dfScale, + double dfFalseEasting, double dfFalseNorthing ); + + /** Hotine Oblique Mercator Azimuth Center / Variant B */ + OGRErr SetHOMAC( double dfCenterLat, double dfCenterLong, + double dfAzimuth, double dfRectToSkew, + double dfScale, + double dfFalseEasting, double dfFalseNorthing ); + + /** International Map of the World Polyconic */ + OGRErr SetIWMPolyconic( double dfLat1, double dfLat2, + double dfCenterLong, + double dfFalseEasting, + double dfFalseNorthing ); + + /** Krovak Oblique Conic Conformal */ + OGRErr SetKrovak( double dfCenterLat, double dfCenterLong, + double dfAzimuth, double dfPseudoStdParallelLat, + double dfScale, + double dfFalseEasting, double dfFalseNorthing ); + + /** Lambert Azimuthal Equal-Area */ + OGRErr SetLAEA( double dfCenterLat, double dfCenterLong, + double dfFalseEasting, double dfFalseNorthing ); + + /** Lambert Conformal Conic */ + OGRErr SetLCC( double dfStdP1, double dfStdP2, + double dfCenterLat, double dfCenterLong, + double dfFalseEasting, double dfFalseNorthing ); + + /** Lambert Conformal Conic 1SP */ + OGRErr SetLCC1SP( double dfCenterLat, double dfCenterLong, + double dfScale, + double dfFalseEasting, double dfFalseNorthing ); + + /** Lambert Conformal Conic (Belgium) */ + OGRErr SetLCCB( double dfStdP1, double dfStdP2, + double dfCenterLat, double dfCenterLong, + double dfFalseEasting, double dfFalseNorthing ); + + /** Miller Cylindrical */ + OGRErr SetMC( double dfCenterLat, double dfCenterLong, + double dfFalseEasting, double dfFalseNorthing ); + + /** Mercator */ + OGRErr SetMercator( double dfCenterLat, double dfCenterLong, + double dfScale, + double dfFalseEasting, double dfFalseNorthing ); + + OGRErr SetMercator2SP( double dfStdP1, + double dfCenterLat, double dfCenterLong, + double dfFalseEasting, double dfFalseNorthing ); + + /** Mollweide */ + OGRErr SetMollweide( double dfCentralMeridian, + double dfFalseEasting, double dfFalseNorthing ); + + /** New Zealand Map Grid */ + OGRErr SetNZMG( double dfCenterLat, double dfCenterLong, + double dfFalseEasting, double dfFalseNorthing ); + + /** Oblique Stereographic */ + OGRErr SetOS( double dfOriginLat, double dfCMeridian, + double dfScale, + double dfFalseEasting,double dfFalseNorthing); + + /** Orthographic */ + OGRErr SetOrthographic( double dfCenterLat, double dfCenterLong, + double dfFalseEasting,double dfFalseNorthing); + + /** Polyconic */ + OGRErr SetPolyconic( double dfCenterLat, double dfCenterLong, + double dfFalseEasting, double dfFalseNorthing ); + + /** Polar Stereographic */ + OGRErr SetPS( double dfCenterLat, double dfCenterLong, + double dfScale, + double dfFalseEasting, double dfFalseNorthing); + + /** Robinson */ + OGRErr SetRobinson( double dfCenterLong, + double dfFalseEasting, double dfFalseNorthing ); + + /** Sinusoidal */ + OGRErr SetSinusoidal( double dfCenterLong, + double dfFalseEasting, double dfFalseNorthing ); + + /** Stereographic */ + OGRErr SetStereographic( double dfCenterLat, double dfCenterLong, + double dfScale, + double dfFalseEasting,double dfFalseNorthing); + + /** Swiss Oblique Cylindrical */ + OGRErr SetSOC( double dfLatitudeOfOrigin, double dfCentralMeridian, + double dfFalseEasting, double dfFalseNorthing ); + + /** Transverse Mercator */ + OGRErr SetTM( double dfCenterLat, double dfCenterLong, + double dfScale, + double dfFalseEasting, double dfFalseNorthing ); + + /** Transverse Mercator variants. */ + OGRErr SetTMVariant( const char *pszVariantName, + double dfCenterLat, double dfCenterLong, + double dfScale, + double dfFalseEasting, double dfFalseNorthing ); + + /** Tunesia Mining Grid */ + OGRErr SetTMG( double dfCenterLat, double dfCenterLong, + double dfFalseEasting, double dfFalseNorthing ); + + /** Transverse Mercator (South Oriented) */ + OGRErr SetTMSO( double dfCenterLat, double dfCenterLong, + double dfScale, + double dfFalseEasting, double dfFalseNorthing ); + + /** Two Point Equidistant */ + OGRErr SetTPED( double dfLat1, double dfLong1, + double dfLat2, double dfLong2, + double dfFalseEasting, double dfFalseNorthing ); + + /** VanDerGrinten */ + OGRErr SetVDG( double dfCenterLong, + double dfFalseEasting, double dfFalseNorthing ); + + /** Universal Transverse Mercator */ + OGRErr SetUTM( int nZone, int bNorth = TRUE ); + int GetUTMZone( int *pbNorth = NULL ) const; + + /** Wagner I -- VII */ + OGRErr SetWagner( int nVariation, double dfCenterLat, + double dfFalseEasting, double dfFalseNorthing ); + + /** Quadrilateralized Spherical Cube */ + OGRErr SetQSC(double dfCenterLat, double dfCenterLong); + + /** Spherical, Cross-track, Height */ + OGRErr SetSCH( double dfPegLat, double dfPegLong, + double dfPegHeading, double dfPegHgt); + /** State Plane */ + OGRErr SetStatePlane( int nZone, int bNAD83 = TRUE, + const char *pszOverrideUnitName = NULL, + double dfOverrideUnit = 0.0 ); + + OGRErr ImportFromESRIStatePlaneWKT( + int nCode, const char* pszDatumName, const char* pszUnitsName, + int nPCSCode, const char* pszCSName = NULL ); + OGRErr ImportFromESRIWisconsinWKT( + const char* pszPrjName, double dfCentralMeridian, double dfLatOfOrigin, + const char* pszUnitsName, const char* pszCSName = NULL ); + + static OGRSpatialReference* GetWGS84SRS(); +}; + +/************************************************************************/ +/* OGRCoordinateTransformation */ +/* */ +/* This is really just used as a base class for a private */ +/* implementation. */ +/************************************************************************/ + +/** + * Interface for transforming between coordinate systems. + * + * Currently, the only implementation within OGR is OGRProj4CT, which + * requires the PROJ.4 library to be available at run-time. + * + * Also, see OGRCreateCoordinateTransformation() for creating transformations. + */ + +class CPL_DLL OGRCoordinateTransformation +{ +public: + virtual ~OGRCoordinateTransformation() {} + + static void DestroyCT(OGRCoordinateTransformation* poCT); + + // From CT_CoordinateTransformation + + /** Fetch internal source coordinate system. */ + virtual OGRSpatialReference *GetSourceCS() = 0; + + /** Fetch internal target coordinate system. */ + virtual OGRSpatialReference *GetTargetCS() = 0; + + // From CT_MathTransform + + /** + * Transform points from source to destination space. + * + * This method is the same as the C function OCTTransform(). + * + * The method TransformEx() allows extended success information to + * be captured indicating which points failed to transform. + * + * @param nCount number of points to transform. + * @param x array of nCount X vertices, modified in place. + * @param y array of nCount Y vertices, modified in place. + * @param z array of nCount Z vertices, modified in place. + * @return TRUE on success, or FALSE if some or all points fail to + * transform. + */ + virtual int Transform( int nCount, + double *x, double *y, double *z = NULL ) = 0; + + /** + * Transform points from source to destination space. + * + * This method is the same as the C function OCTTransformEx(). + * + * @param nCount number of points to transform. + * @param x array of nCount X vertices, modified in place. + * @param y array of nCount Y vertices, modified in place. + * @param z array of nCount Z vertices, modified in place. + * @param pabSuccess array of per-point flags set to TRUE if that point + * transforms, or FALSE if it does not. + * + * @return TRUE if some or all points transform successfully, or FALSE if + * if none transform. + */ + virtual int TransformEx( int nCount, + double *x, double *y, double *z = NULL, + int *pabSuccess = NULL ) = 0; + +}; + +OGRCoordinateTransformation CPL_DLL * +OGRCreateCoordinateTransformation( OGRSpatialReference *poSource, + OGRSpatialReference *poTarget ); + +#endif /* ndef OGR_SPATIALREF_H_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/ogr_srs_api.h b/modules/globebrowsing/ext/gdal/include/ogr_srs_api.h new file mode 100644 index 0000000000..abaa72184c --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/ogr_srs_api.h @@ -0,0 +1,791 @@ +/****************************************************************************** + * $Id$ + * + * Project: OpenGIS Simple Features Reference Implementation + * Purpose: C API and constant declarations for OGR Spatial References. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2000, Frank Warmerdam + * Copyright (c) 2008-2013, Even Rouault + * + * 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. + ****************************************************************************/ + +#ifndef OGR_SRS_API_H_INCLUDED +#define OGR_SRS_API_H_INCLUDED + +#ifndef SWIG +#include "ogr_core.h" + +CPL_C_START + +/** + * \file ogr_srs_api.h + * + * C spatial reference system services and defines. + * + * See also: ogr_spatialref.h + */ + +/* -------------------------------------------------------------------- */ +/* Axis orientations (corresponds to CS_AxisOrientationEnum). */ +/* -------------------------------------------------------------------- */ +typedef enum { + OAO_Other=0, + OAO_North=1, + OAO_South=2, + OAO_East=3, + OAO_West=4, + OAO_Up=5, + OAO_Down=6 +} OGRAxisOrientation; + +const char CPL_DLL *OSRAxisEnumToName( OGRAxisOrientation eOrientation ); + +/* -------------------------------------------------------------------- */ +/* Datum types (corresponds to CS_DatumType). */ +/* -------------------------------------------------------------------- */ + +typedef enum { + ODT_HD_Min=1000, + ODT_HD_Other=1000, + ODT_HD_Classic=1001, + ODT_HD_Geocentric=1002, + ODT_HD_Max=1999, + ODT_VD_Min=2000, + ODT_VD_Other=2000, + ODT_VD_Orthometric=2001, + ODT_VD_Ellipsoidal=2002, + ODT_VD_AltitudeBarometric=2003, + ODT_VD_Normal=2004, + ODT_VD_GeoidModelDerived=2005, + ODT_VD_Depth=2006, + ODT_VD_Max=2999, + ODT_LD_Min=10000, + ODT_LD_Max=32767 +} OGRDatumType; + +#endif // ndef SWIG + +/* ==================================================================== */ +/* Some standard WKT geographic coordinate systems. */ +/* ==================================================================== */ + +#define SRS_WKT_WGS84 "GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4326\"]]" + +/* ==================================================================== */ +/* Some "standard" strings. */ +/* ==================================================================== */ + +#define SRS_PT_ALBERS_CONIC_EQUAL_AREA \ + "Albers_Conic_Equal_Area" +#define SRS_PT_AZIMUTHAL_EQUIDISTANT "Azimuthal_Equidistant" +#define SRS_PT_CASSINI_SOLDNER "Cassini_Soldner" +#define SRS_PT_CYLINDRICAL_EQUAL_AREA "Cylindrical_Equal_Area" +#define SRS_PT_BONNE "Bonne" +#define SRS_PT_ECKERT_I "Eckert_I" +#define SRS_PT_ECKERT_II "Eckert_II" +#define SRS_PT_ECKERT_III "Eckert_III" +#define SRS_PT_ECKERT_IV "Eckert_IV" +#define SRS_PT_ECKERT_V "Eckert_V" +#define SRS_PT_ECKERT_VI "Eckert_VI" +#define SRS_PT_EQUIDISTANT_CONIC \ + "Equidistant_Conic" +#define SRS_PT_EQUIRECTANGULAR "Equirectangular" +#define SRS_PT_GALL_STEREOGRAPHIC \ + "Gall_Stereographic" +#define SRS_PT_GAUSSSCHREIBERTMERCATOR \ + "Gauss_Schreiber_Transverse_Mercator" +#define SRS_PT_GEOSTATIONARY_SATELLITE \ + "Geostationary_Satellite" +#define SRS_PT_GOODE_HOMOLOSINE "Goode_Homolosine" +#define SRS_PT_IGH "Interrupted_Goode_Homolosine" +#define SRS_PT_GNOMONIC "Gnomonic" +#define SRS_PT_HOTINE_OBLIQUE_MERCATOR_AZIMUTH_CENTER \ + "Hotine_Oblique_Mercator_Azimuth_Center" +#define SRS_PT_HOTINE_OBLIQUE_MERCATOR \ + "Hotine_Oblique_Mercator" +#define SRS_PT_HOTINE_OBLIQUE_MERCATOR_TWO_POINT_NATURAL_ORIGIN \ + "Hotine_Oblique_Mercator_Two_Point_Natural_Origin" +#define SRS_PT_LABORDE_OBLIQUE_MERCATOR \ + "Laborde_Oblique_Mercator" +#define SRS_PT_LAMBERT_CONFORMAL_CONIC_1SP \ + "Lambert_Conformal_Conic_1SP" +#define SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP \ + "Lambert_Conformal_Conic_2SP" +#define SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP_BELGIUM \ + "Lambert_Conformal_Conic_2SP_Belgium" +#define SRS_PT_LAMBERT_AZIMUTHAL_EQUAL_AREA \ + "Lambert_Azimuthal_Equal_Area" +#define SRS_PT_MERCATOR_1SP "Mercator_1SP" +#define SRS_PT_MERCATOR_2SP "Mercator_2SP" +// Mercator_Auxiliary_Sphere is used used by ESRI to mean EPSG:3875 +#define SRS_PT_MERCATOR_AUXILIARY_SPHERE \ + "Mercator_Auxiliary_Sphere" +#define SRS_PT_MILLER_CYLINDRICAL "Miller_Cylindrical" +#define SRS_PT_MOLLWEIDE "Mollweide" +#define SRS_PT_NEW_ZEALAND_MAP_GRID \ + "New_Zealand_Map_Grid" +#define SRS_PT_OBLIQUE_STEREOGRAPHIC \ + "Oblique_Stereographic" +#define SRS_PT_ORTHOGRAPHIC "Orthographic" +#define SRS_PT_POLAR_STEREOGRAPHIC \ + "Polar_Stereographic" +#define SRS_PT_POLYCONIC "Polyconic" +#define SRS_PT_ROBINSON "Robinson" +#define SRS_PT_SINUSOIDAL "Sinusoidal" +#define SRS_PT_STEREOGRAPHIC "Stereographic" +#define SRS_PT_SWISS_OBLIQUE_CYLINDRICAL \ + "Swiss_Oblique_Cylindrical" +#define SRS_PT_TRANSVERSE_MERCATOR \ + "Transverse_Mercator" +#define SRS_PT_TRANSVERSE_MERCATOR_SOUTH_ORIENTED \ + "Transverse_Mercator_South_Orientated" + +/* special mapinfo variants on Transverse Mercator */ +#define SRS_PT_TRANSVERSE_MERCATOR_MI_21 \ + "Transverse_Mercator_MapInfo_21" +#define SRS_PT_TRANSVERSE_MERCATOR_MI_22 \ + "Transverse_Mercator_MapInfo_22" +#define SRS_PT_TRANSVERSE_MERCATOR_MI_23 \ + "Transverse_Mercator_MapInfo_23" +#define SRS_PT_TRANSVERSE_MERCATOR_MI_24 \ + "Transverse_Mercator_MapInfo_24" +#define SRS_PT_TRANSVERSE_MERCATOR_MI_25 \ + "Transverse_Mercator_MapInfo_25" + +#define SRS_PT_TUNISIA_MINING_GRID \ + "Tunisia_Mining_Grid" +#define SRS_PT_TWO_POINT_EQUIDISTANT \ + "Two_Point_Equidistant" +#define SRS_PT_VANDERGRINTEN "VanDerGrinten" +#define SRS_PT_KROVAK "Krovak" +#define SRS_PT_IMW_POLYCONIC "International_Map_of_the_World_Polyconic" +#define SRS_PT_WAGNER_I "Wagner_I" +#define SRS_PT_WAGNER_II "Wagner_II" +#define SRS_PT_WAGNER_III "Wagner_III" +#define SRS_PT_WAGNER_IV "Wagner_IV" +#define SRS_PT_WAGNER_V "Wagner_V" +#define SRS_PT_WAGNER_VI "Wagner_VI" +#define SRS_PT_WAGNER_VII "Wagner_VII" +#define SRS_PT_QSC "Quadrilateralized_Spherical_Cube" +#define SRS_PT_AITOFF "Aitoff" +#define SRS_PT_WINKEL_I "Winkel_I" +#define SRS_PT_WINKEL_II "Winkel_II" +#define SRS_PT_WINKEL_TRIPEL "Winkel_Tripel" +#define SRS_PT_CRASTER_PARABOLIC "Craster_Parabolic" +#define SRS_PT_LOXIMUTHAL "Loximuthal" +#define SRS_PT_QUARTIC_AUTHALIC "Quartic_Authalic" +#define SRS_PT_SCH "Spherical_Cross_Track_Height" + +#define SRS_PP_CENTRAL_MERIDIAN "central_meridian" +#define SRS_PP_SCALE_FACTOR "scale_factor" +#define SRS_PP_STANDARD_PARALLEL_1 "standard_parallel_1" +#define SRS_PP_STANDARD_PARALLEL_2 "standard_parallel_2" +#define SRS_PP_PSEUDO_STD_PARALLEL_1 "pseudo_standard_parallel_1" +#define SRS_PP_LONGITUDE_OF_CENTER "longitude_of_center" +#define SRS_PP_LATITUDE_OF_CENTER "latitude_of_center" +#define SRS_PP_LONGITUDE_OF_ORIGIN "longitude_of_origin" +#define SRS_PP_LATITUDE_OF_ORIGIN "latitude_of_origin" +#define SRS_PP_FALSE_EASTING "false_easting" +#define SRS_PP_FALSE_NORTHING "false_northing" +#define SRS_PP_AZIMUTH "azimuth" +#define SRS_PP_LONGITUDE_OF_POINT_1 "longitude_of_point_1" +#define SRS_PP_LATITUDE_OF_POINT_1 "latitude_of_point_1" +#define SRS_PP_LONGITUDE_OF_POINT_2 "longitude_of_point_2" +#define SRS_PP_LATITUDE_OF_POINT_2 "latitude_of_point_2" +#define SRS_PP_LONGITUDE_OF_POINT_3 "longitude_of_point_3" +#define SRS_PP_LATITUDE_OF_POINT_3 "latitude_of_point_3" +#define SRS_PP_RECTIFIED_GRID_ANGLE "rectified_grid_angle" +#define SRS_PP_LANDSAT_NUMBER "landsat_number" +#define SRS_PP_PATH_NUMBER "path_number" +#define SRS_PP_PERSPECTIVE_POINT_HEIGHT "perspective_point_height" +#define SRS_PP_SATELLITE_HEIGHT "satellite_height" +#define SRS_PP_FIPSZONE "fipszone" +#define SRS_PP_ZONE "zone" +#define SRS_PP_LATITUDE_OF_1ST_POINT "Latitude_Of_1st_Point" +#define SRS_PP_LONGITUDE_OF_1ST_POINT "Longitude_Of_1st_Point" +#define SRS_PP_LATITUDE_OF_2ND_POINT "Latitude_Of_2nd_Point" +#define SRS_PP_LONGITUDE_OF_2ND_POINT "Longitude_Of_2nd_Point" +#define SRS_PP_PEG_POINT_LATITUDE "peg_point_latitude" +#define SRS_PP_PEG_POINT_LONGITUDE "peg_point_longitude" +#define SRS_PP_PEG_POINT_HEADING "peg_point_heading" +#define SRS_PP_PEG_POINT_HEIGHT "peg_point_height" + +#define SRS_UL_METER "Meter" +#define SRS_UL_FOOT "Foot (International)" /* or just "FOOT"? */ +#define SRS_UL_FOOT_CONV "0.3048" +#define SRS_UL_US_FOOT "Foot_US" /* or "US survey foot" from EPSG */ +#define SRS_UL_US_FOOT_CONV "0.3048006096012192" +#define SRS_UL_NAUTICAL_MILE "Nautical Mile" +#define SRS_UL_NAUTICAL_MILE_CONV "1852.0" +#define SRS_UL_LINK "Link" /* Based on US Foot */ +#define SRS_UL_LINK_CONV "0.20116684023368047" +#define SRS_UL_CHAIN "Chain" /* based on US Foot */ +#define SRS_UL_CHAIN_CONV "20.116684023368047" +#define SRS_UL_ROD "Rod" /* based on US Foot */ +#define SRS_UL_ROD_CONV "5.02921005842012" +#define SRS_UL_LINK_Clarke "Link_Clarke" +#define SRS_UL_LINK_Clarke_CONV "0.2011661949" + +#define SRS_UL_KILOMETER "Kilometer" +#define SRS_UL_KILOMETER_CONV "1000." +#define SRS_UL_DECIMETER "Decimeter" +#define SRS_UL_DECIMETER_CONV "0.1" +#define SRS_UL_CENTIMETER "Centimeter" +#define SRS_UL_CENTIMETER_CONV "0.01" +#define SRS_UL_MILLIMETER "Millimeter" +#define SRS_UL_MILLIMETER_CONV "0.001" +#define SRS_UL_INTL_NAUT_MILE "Nautical_Mile_International" +#define SRS_UL_INTL_NAUT_MILE_CONV "1852.0" +#define SRS_UL_INTL_INCH "Inch_International" +#define SRS_UL_INTL_INCH_CONV "0.0254" +#define SRS_UL_INTL_FOOT "Foot_International" +#define SRS_UL_INTL_FOOT_CONV "0.3048" +#define SRS_UL_INTL_YARD "Yard_International" +#define SRS_UL_INTL_YARD_CONV "0.9144" +#define SRS_UL_INTL_STAT_MILE "Statute_Mile_International" +#define SRS_UL_INTL_STAT_MILE_CONV "1609.344" +#define SRS_UL_INTL_FATHOM "Fathom_International" +#define SRS_UL_INTL_FATHOM_CONV "1.8288" +#define SRS_UL_INTL_CHAIN "Chain_International" +#define SRS_UL_INTL_CHAIN_CONV "20.1168" +#define SRS_UL_INTL_LINK "Link_International" +#define SRS_UL_INTL_LINK_CONV "0.201168" +#define SRS_UL_US_INCH "Inch_US_Surveyor" +#define SRS_UL_US_INCH_CONV "0.025400050800101603" +#define SRS_UL_US_YARD "Yard_US_Surveyor" +#define SRS_UL_US_YARD_CONV "0.914401828803658" +#define SRS_UL_US_CHAIN "Chain_US_Surveyor" +#define SRS_UL_US_CHAIN_CONV "20.11684023368047" +#define SRS_UL_US_STAT_MILE "Statute_Mile_US_Surveyor" +#define SRS_UL_US_STAT_MILE_CONV "1609.347218694437" +#define SRS_UL_INDIAN_YARD "Yard_Indian" +#define SRS_UL_INDIAN_YARD_CONV "0.91439523" +#define SRS_UL_INDIAN_FOOT "Foot_Indian" +#define SRS_UL_INDIAN_FOOT_CONV "0.30479841" +#define SRS_UL_INDIAN_CHAIN "Chain_Indian" +#define SRS_UL_INDIAN_CHAIN_CONV "20.11669506" + +#define SRS_UA_DEGREE "degree" +#define SRS_UA_DEGREE_CONV "0.0174532925199433" +#define SRS_UA_RADIAN "radian" + +#define SRS_PM_GREENWICH "Greenwich" + +#define SRS_DN_NAD27 "North_American_Datum_1927" +#define SRS_DN_NAD83 "North_American_Datum_1983" +#define SRS_DN_WGS72 "WGS_1972" +#define SRS_DN_WGS84 "WGS_1984" + +#define SRS_WGS84_SEMIMAJOR 6378137.0 +#define SRS_WGS84_INVFLATTENING 298.257223563 + +#ifndef SWIG +/* -------------------------------------------------------------------- */ +/* C Wrappers for C++ objects and methods. */ +/* -------------------------------------------------------------------- */ +#ifndef DEFINED_OGRSpatialReferenceH +#define DEFINED_OGRSpatialReferenceH + +#ifdef DEBUG +typedef struct OGRSpatialReferenceHS *OGRSpatialReferenceH; +typedef struct OGRCoordinateTransformationHS *OGRCoordinateTransformationH; +#else +typedef void *OGRSpatialReferenceH; +typedef void *OGRCoordinateTransformationH; +#endif + +#endif + + +OGRSpatialReferenceH CPL_DLL CPL_STDCALL + OSRNewSpatialReference( const char * /* = NULL */); +OGRSpatialReferenceH CPL_DLL CPL_STDCALL OSRCloneGeogCS( OGRSpatialReferenceH ); +OGRSpatialReferenceH CPL_DLL CPL_STDCALL OSRClone( OGRSpatialReferenceH ); +void CPL_DLL CPL_STDCALL OSRDestroySpatialReference( OGRSpatialReferenceH ); + +int CPL_DLL OSRReference( OGRSpatialReferenceH ); +int CPL_DLL OSRDereference( OGRSpatialReferenceH ); +void CPL_DLL OSRRelease( OGRSpatialReferenceH ); + +OGRErr CPL_DLL OSRValidate( OGRSpatialReferenceH ); +OGRErr CPL_DLL OSRFixupOrdering( OGRSpatialReferenceH ); +OGRErr CPL_DLL OSRFixup( OGRSpatialReferenceH ); +OGRErr CPL_DLL OSRStripCTParms( OGRSpatialReferenceH ); + +OGRErr CPL_DLL CPL_STDCALL OSRImportFromEPSG( OGRSpatialReferenceH, int ); +OGRErr CPL_DLL CPL_STDCALL OSRImportFromEPSGA( OGRSpatialReferenceH, int ); +OGRErr CPL_DLL OSRImportFromWkt( OGRSpatialReferenceH, char ** ); +OGRErr CPL_DLL OSRImportFromProj4( OGRSpatialReferenceH, const char *); +OGRErr CPL_DLL OSRImportFromESRI( OGRSpatialReferenceH, char **); +OGRErr CPL_DLL OSRImportFromPCI( OGRSpatialReferenceH hSRS, const char *, + const char *, double * ); +OGRErr CPL_DLL OSRImportFromUSGS( OGRSpatialReferenceH, + long, long, double *, long); +OGRErr CPL_DLL OSRImportFromXML( OGRSpatialReferenceH, const char * ); +OGRErr CPL_DLL OSRImportFromDict( OGRSpatialReferenceH, const char *, + const char * ); +OGRErr CPL_DLL OSRImportFromPanorama( OGRSpatialReferenceH, long, long, long, + double * ); +OGRErr CPL_DLL OSRImportFromOzi( OGRSpatialReferenceH , const char * const *); +OGRErr CPL_DLL OSRImportFromMICoordSys( OGRSpatialReferenceH, const char *); +OGRErr CPL_DLL OSRImportFromERM( OGRSpatialReferenceH, + const char *, const char *, const char * ); +OGRErr CPL_DLL OSRImportFromUrl( OGRSpatialReferenceH, const char * ); + +OGRErr CPL_DLL CPL_STDCALL OSRExportToWkt( OGRSpatialReferenceH, char ** ); +OGRErr CPL_DLL CPL_STDCALL OSRExportToPrettyWkt( OGRSpatialReferenceH, char **, int); +OGRErr CPL_DLL CPL_STDCALL OSRExportToProj4( OGRSpatialReferenceH, char **); +OGRErr CPL_DLL OSRExportToPCI( OGRSpatialReferenceH, char **, char **, + double ** ); +OGRErr CPL_DLL OSRExportToUSGS( OGRSpatialReferenceH, long *, long *, + double **, long * ); +OGRErr CPL_DLL OSRExportToXML( OGRSpatialReferenceH, char **, const char * ); +OGRErr CPL_DLL OSRExportToPanorama( OGRSpatialReferenceH, long *, long *, + long *, long *, double * ); +OGRErr CPL_DLL OSRExportToMICoordSys( OGRSpatialReferenceH, char ** ); +OGRErr CPL_DLL OSRExportToERM( OGRSpatialReferenceH, char *, char *, char * ); + +OGRErr CPL_DLL OSRMorphToESRI( OGRSpatialReferenceH ); +OGRErr CPL_DLL OSRMorphFromESRI( OGRSpatialReferenceH ); + +OGRErr CPL_DLL CPL_STDCALL OSRSetAttrValue( OGRSpatialReferenceH hSRS, + const char * pszNodePath, + const char * pszNewNodeValue ); +const char CPL_DLL * CPL_STDCALL OSRGetAttrValue( OGRSpatialReferenceH hSRS, + const char * pszName, int iChild /* = 0 */ ); + +OGRErr CPL_DLL OSRSetAngularUnits( OGRSpatialReferenceH, const char *, double ); +double CPL_DLL OSRGetAngularUnits( OGRSpatialReferenceH, char ** ); +OGRErr CPL_DLL OSRSetLinearUnits( OGRSpatialReferenceH, const char *, double ); +OGRErr CPL_DLL OSRSetTargetLinearUnits( OGRSpatialReferenceH, const char *, const char *, double ); +OGRErr CPL_DLL OSRSetLinearUnitsAndUpdateParameters( + OGRSpatialReferenceH, const char *, double ); +double CPL_DLL OSRGetLinearUnits( OGRSpatialReferenceH, char ** ); +double CPL_DLL OSRGetTargetLinearUnits( OGRSpatialReferenceH, const char *, char ** ); + +double CPL_DLL OSRGetPrimeMeridian( OGRSpatialReferenceH, char ** ); + +int CPL_DLL OSRIsGeographic( OGRSpatialReferenceH ); +int CPL_DLL OSRIsLocal( OGRSpatialReferenceH ); +int CPL_DLL OSRIsProjected( OGRSpatialReferenceH ); +int CPL_DLL OSRIsCompound( OGRSpatialReferenceH ); +int CPL_DLL OSRIsGeocentric( OGRSpatialReferenceH ); +int CPL_DLL OSRIsVertical( OGRSpatialReferenceH ); +int CPL_DLL OSRIsSameGeogCS( OGRSpatialReferenceH, OGRSpatialReferenceH ); +int CPL_DLL OSRIsSameVertCS( OGRSpatialReferenceH, OGRSpatialReferenceH ); +int CPL_DLL OSRIsSame( OGRSpatialReferenceH, OGRSpatialReferenceH ); + +OGRErr CPL_DLL OSRSetLocalCS( OGRSpatialReferenceH hSRS, const char *pszName ); +OGRErr CPL_DLL OSRSetProjCS( OGRSpatialReferenceH hSRS, const char * pszName ); +OGRErr CPL_DLL OSRSetGeocCS( OGRSpatialReferenceH hSRS, const char * pszName ); +OGRErr CPL_DLL OSRSetWellKnownGeogCS( OGRSpatialReferenceH hSRS, + const char * pszName ); +OGRErr CPL_DLL CPL_STDCALL OSRSetFromUserInput( OGRSpatialReferenceH hSRS, + const char * ); +OGRErr CPL_DLL OSRCopyGeogCSFrom( OGRSpatialReferenceH hSRS, + const OGRSpatialReferenceH hSrcSRS ); +OGRErr CPL_DLL OSRSetTOWGS84( OGRSpatialReferenceH hSRS, + double, double, double, + double, double, double, double ); +OGRErr CPL_DLL OSRGetTOWGS84( OGRSpatialReferenceH hSRS, double *, int ); + +OGRErr CPL_DLL OSRSetCompoundCS( OGRSpatialReferenceH hSRS, + const char *pszName, + OGRSpatialReferenceH hHorizSRS, + OGRSpatialReferenceH hVertSRS ); +OGRErr CPL_DLL OSRSetGeogCS( OGRSpatialReferenceH hSRS, + const char * pszGeogName, + const char * pszDatumName, + const char * pszEllipsoidName, + double dfSemiMajor, double dfInvFlattening, + const char * pszPMName /* = NULL */, + double dfPMOffset /* = 0.0 */, + const char * pszUnits /* = NULL */, + double dfConvertToRadians /* = 0.0 */ ); + +OGRErr CPL_DLL OSRSetVertCS( OGRSpatialReferenceH hSRS, + const char * pszVertCSName, + const char * pszVertDatumName, + int nVertDatumType ); + +double CPL_DLL OSRGetSemiMajor( OGRSpatialReferenceH, OGRErr * /* = NULL */ ); +double CPL_DLL OSRGetSemiMinor( OGRSpatialReferenceH, OGRErr * /* = NULL */ ); +double CPL_DLL OSRGetInvFlattening( OGRSpatialReferenceH, OGRErr * /*=NULL*/); + +OGRErr CPL_DLL OSRSetAuthority( OGRSpatialReferenceH hSRS, + const char * pszTargetKey, + const char * pszAuthority, + int nCode ); +const char CPL_DLL *OSRGetAuthorityCode( OGRSpatialReferenceH hSRS, + const char * pszTargetKey ); +const char CPL_DLL *OSRGetAuthorityName( OGRSpatialReferenceH hSRS, + const char * pszTargetKey ); +OGRErr CPL_DLL OSRSetProjection( OGRSpatialReferenceH, const char * ); +OGRErr CPL_DLL OSRSetProjParm( OGRSpatialReferenceH, const char *, double ); +double CPL_DLL OSRGetProjParm( OGRSpatialReferenceH hSRS, + const char * pszParmName, + double dfDefault /* = 0.0 */, + OGRErr * /* = NULL */ ); +OGRErr CPL_DLL OSRSetNormProjParm( OGRSpatialReferenceH, const char *, double); +double CPL_DLL OSRGetNormProjParm( OGRSpatialReferenceH hSRS, + const char * pszParmName, + double dfDefault /* = 0.0 */, + OGRErr * /* = NULL */ ); + +OGRErr CPL_DLL OSRSetUTM( OGRSpatialReferenceH hSRS, int nZone, int bNorth ); +int CPL_DLL OSRGetUTMZone( OGRSpatialReferenceH hSRS, int *pbNorth ); +OGRErr CPL_DLL OSRSetStatePlane( OGRSpatialReferenceH hSRS, + int nZone, int bNAD83 ); +OGRErr CPL_DLL OSRSetStatePlaneWithUnits( OGRSpatialReferenceH hSRS, + int nZone, int bNAD83, + const char *pszOverrideUnitName, + double dfOverrideUnit ); +OGRErr CPL_DLL OSRAutoIdentifyEPSG( OGRSpatialReferenceH hSRS ); + +int CPL_DLL OSREPSGTreatsAsLatLong( OGRSpatialReferenceH hSRS ); +int CPL_DLL OSREPSGTreatsAsNorthingEasting( OGRSpatialReferenceH hSRS ); +const char CPL_DLL *OSRGetAxis( OGRSpatialReferenceH hSRS, + const char *pszTargetKey, int iAxis, + OGRAxisOrientation *peOrientation ); +OGRErr CPL_DLL OSRSetAxes( OGRSpatialReferenceH hSRS, + const char *pszTargetKey, + const char *pszXAxisName, + OGRAxisOrientation eXAxisOrientation, + const char *pszYAxisName, + OGRAxisOrientation eYAxisOrientation ); +/** Albers Conic Equal Area */ +OGRErr CPL_DLL OSRSetACEA( OGRSpatialReferenceH hSRS, double dfStdP1, double dfStdP2, + double dfCenterLat, double dfCenterLong, + double dfFalseEasting, double dfFalseNorthing ); + +/** Azimuthal Equidistant */ +OGRErr CPL_DLL OSRSetAE( OGRSpatialReferenceH hSRS, double dfCenterLat, double dfCenterLong, + double dfFalseEasting, double dfFalseNorthing ); + +/** Bonne */ +OGRErr CPL_DLL OSRSetBonne(OGRSpatialReferenceH hSRS, + double dfStandardParallel, double dfCentralMeridian, + double dfFalseEasting, double dfFalseNorthing ); + +/** Cylindrical Equal Area */ +OGRErr CPL_DLL OSRSetCEA( OGRSpatialReferenceH hSRS, double dfStdP1, double dfCentralMeridian, + double dfFalseEasting, double dfFalseNorthing ); + +/** Cassini-Soldner */ +OGRErr CPL_DLL OSRSetCS( OGRSpatialReferenceH hSRS, double dfCenterLat, double dfCenterLong, + double dfFalseEasting, double dfFalseNorthing ); + +/** Equidistant Conic */ +OGRErr CPL_DLL OSRSetEC( OGRSpatialReferenceH hSRS, double dfStdP1, double dfStdP2, + double dfCenterLat, double dfCenterLong, + double dfFalseEasting, double dfFalseNorthing ); + +/** Eckert I-VI */ +OGRErr CPL_DLL OSRSetEckert( OGRSpatialReferenceH hSRS, int nVariation, + double dfCentralMeridian, + double dfFalseEasting, double dfFalseNorthing ); + +/** Eckert IV */ +OGRErr CPL_DLL OSRSetEckertIV( OGRSpatialReferenceH hSRS, double dfCentralMeridian, + double dfFalseEasting, double dfFalseNorthing ); + +/** Eckert VI */ +OGRErr CPL_DLL OSRSetEckertVI( OGRSpatialReferenceH hSRS, double dfCentralMeridian, + double dfFalseEasting, double dfFalseNorthing ); + +/** Equirectangular */ +OGRErr CPL_DLL OSRSetEquirectangular(OGRSpatialReferenceH hSRS, + double dfCenterLat, double dfCenterLong, + double dfFalseEasting, double dfFalseNorthing ); + +/** Equirectangular generalized form */ +OGRErr CPL_DLL OSRSetEquirectangular2( OGRSpatialReferenceH hSRS, + double dfCenterLat, double dfCenterLong, + double dfPseudoStdParallel1, + double dfFalseEasting, + double dfFalseNorthing ); + +/** Gall Stereograpic */ +OGRErr CPL_DLL OSRSetGS( OGRSpatialReferenceH hSRS, double dfCentralMeridian, + double dfFalseEasting, double dfFalseNorthing ); + +/** Goode Homolosine */ +OGRErr CPL_DLL OSRSetGH( OGRSpatialReferenceH hSRS, double dfCentralMeridian, + double dfFalseEasting, double dfFalseNorthing ); + +/** Interrupted Goode Homolosine */ +OGRErr CPL_DLL OSRSetIGH( OGRSpatialReferenceH hSRS ); + +/** GEOS - Geostationary Satellite View */ +OGRErr CPL_DLL OSRSetGEOS( OGRSpatialReferenceH hSRS, + double dfCentralMeridian, double dfSatelliteHeight, + double dfFalseEasting, double dfFalseNorthing ); + +/** Gauss Schreiber Transverse Mercator */ +OGRErr CPL_DLL OSRSetGaussSchreiberTMercator( OGRSpatialReferenceH hSRS, + double dfCenterLat, double dfCenterLong, + double dfScale, + double dfFalseEasting, + double dfFalseNorthing ); +/** Gnomonic */ +OGRErr CPL_DLL OSRSetGnomonic(OGRSpatialReferenceH hSRS, + double dfCenterLat, double dfCenterLong, + double dfFalseEasting, double dfFalseNorthing ); + +/** Oblique Mercator (aka HOM (variant B) */ +OGRErr CPL_DLL OSRSetOM( OGRSpatialReferenceH hSRS, + double dfCenterLat, double dfCenterLong, + double dfAzimuth, double dfRectToSkew, + double dfScale, + double dfFalseEasting, double dfFalseNorthing ); + +/** Hotine Oblique Mercator using azimuth angle */ +OGRErr CPL_DLL OSRSetHOM( OGRSpatialReferenceH hSRS, + double dfCenterLat, double dfCenterLong, + double dfAzimuth, double dfRectToSkew, + double dfScale, + double dfFalseEasting, double dfFalseNorthing ); + +OGRErr CPL_DLL OSRSetHOMAC( OGRSpatialReferenceH hSRS, + double dfCenterLat, double dfCenterLong, + double dfAzimuth, double dfRectToSkew, + double dfScale, + double dfFalseEasting, + double dfFalseNorthing ); + +/** Hotine Oblique Mercator using two points on centerline */ +OGRErr CPL_DLL OSRSetHOM2PNO( OGRSpatialReferenceH hSRS, double dfCenterLat, + double dfLat1, double dfLong1, + double dfLat2, double dfLong2, + double dfScale, + double dfFalseEasting, double dfFalseNorthing ); + +/** International Map of the World Polyconic */ +OGRErr CPL_DLL OSRSetIWMPolyconic( OGRSpatialReferenceH hSRS, + double dfLat1, double dfLat2, + double dfCenterLong, + double dfFalseEasting, + double dfFalseNorthing ); + +/** Krovak Oblique Conic Conformal */ +OGRErr CPL_DLL OSRSetKrovak( OGRSpatialReferenceH hSRS, + double dfCenterLat, double dfCenterLong, + double dfAzimuth, double dfPseudoStdParallelLat, + double dfScale, + double dfFalseEasting, double dfFalseNorthing ); + +/** Lambert Azimuthal Equal-Area */ +OGRErr CPL_DLL OSRSetLAEA( OGRSpatialReferenceH hSRS, + double dfCenterLat, double dfCenterLong, + double dfFalseEasting, double dfFalseNorthing ); + +/** Lambert Conformal Conic */ +OGRErr CPL_DLL OSRSetLCC( OGRSpatialReferenceH hSRS, + double dfStdP1, double dfStdP2, + double dfCenterLat, double dfCenterLong, + double dfFalseEasting, double dfFalseNorthing ); + +/** Lambert Conformal Conic 1SP */ +OGRErr CPL_DLL OSRSetLCC1SP( OGRSpatialReferenceH hSRS, + double dfCenterLat, double dfCenterLong, + double dfScale, + double dfFalseEasting, double dfFalseNorthing ); + +/** Lambert Conformal Conic (Belgium) */ +OGRErr CPL_DLL OSRSetLCCB( OGRSpatialReferenceH hSRS, + double dfStdP1, double dfStdP2, + double dfCenterLat, double dfCenterLong, + double dfFalseEasting, double dfFalseNorthing ); + +/** Miller Cylindrical */ +OGRErr CPL_DLL OSRSetMC( OGRSpatialReferenceH hSRS, + double dfCenterLat, double dfCenterLong, + double dfFalseEasting, double dfFalseNorthing ); + +/** Mercator */ +OGRErr CPL_DLL OSRSetMercator( OGRSpatialReferenceH hSRS, + double dfCenterLat, double dfCenterLong, + double dfScale, + double dfFalseEasting, double dfFalseNorthing ); +OGRErr CPL_DLL OSRSetMercator2SP( OGRSpatialReferenceH hSRS, + double dfStdP1, + double dfCenterLat, double dfCenterLong, + double dfFalseEasting, double dfFalseNorthing ); + +/** Mollweide */ +OGRErr CPL_DLL OSRSetMollweide( OGRSpatialReferenceH hSRS, + double dfCentralMeridian, + double dfFalseEasting, + double dfFalseNorthing ); + +/** New Zealand Map Grid */ +OGRErr CPL_DLL OSRSetNZMG( OGRSpatialReferenceH hSRS, + double dfCenterLat, double dfCenterLong, + double dfFalseEasting, double dfFalseNorthing ); + +/** Oblique Stereographic */ +OGRErr CPL_DLL OSRSetOS( OGRSpatialReferenceH hSRS, + double dfOriginLat, double dfCMeridian, + double dfScale, + double dfFalseEasting,double dfFalseNorthing); + +/** Orthographic */ +OGRErr CPL_DLL OSRSetOrthographic( OGRSpatialReferenceH hSRS, + double dfCenterLat, double dfCenterLong, + double dfFalseEasting, + double dfFalseNorthing); + +/** Polyconic */ +OGRErr CPL_DLL OSRSetPolyconic( OGRSpatialReferenceH hSRS, + double dfCenterLat, double dfCenterLong, + double dfFalseEasting, double dfFalseNorthing ); + +/** Polar Stereographic */ +OGRErr CPL_DLL OSRSetPS( OGRSpatialReferenceH hSRS, + double dfCenterLat, double dfCenterLong, + double dfScale, + double dfFalseEasting, double dfFalseNorthing); + +/** Robinson */ +OGRErr CPL_DLL OSRSetRobinson( OGRSpatialReferenceH hSRS, + double dfCenterLong, + double dfFalseEasting, double dfFalseNorthing ); + +/** Sinusoidal */ +OGRErr CPL_DLL OSRSetSinusoidal( OGRSpatialReferenceH hSRS, + double dfCenterLong, + double dfFalseEasting, + double dfFalseNorthing ); + +/** Stereographic */ +OGRErr CPL_DLL OSRSetStereographic( OGRSpatialReferenceH hSRS, + double dfCenterLat, double dfCenterLong, + double dfScale, + double dfFalseEasting, + double dfFalseNorthing); + +/** Swiss Oblique Cylindrical */ +OGRErr CPL_DLL OSRSetSOC( OGRSpatialReferenceH hSRS, + double dfLatitudeOfOrigin, double dfCentralMeridian, + double dfFalseEasting, double dfFalseNorthing ); + +/** Transverse Mercator + * + * Special processing available for Transverse Mercator with GDAL >= 1.10 and PROJ >= 4.8 : + * see OGRSpatialReference::exportToProj4(). + */ + +OGRErr CPL_DLL OSRSetTM( OGRSpatialReferenceH hSRS, + double dfCenterLat, double dfCenterLong, + double dfScale, + double dfFalseEasting, double dfFalseNorthing ); + +/** Transverse Mercator variant */ +OGRErr CPL_DLL OSRSetTMVariant( + OGRSpatialReferenceH hSRS, const char *pszVariantName, + double dfCenterLat, double dfCenterLong, + double dfScale, + double dfFalseEasting, double dfFalseNorthing ); + +/** Tunesia Mining Grid */ +OGRErr CPL_DLL OSRSetTMG( OGRSpatialReferenceH hSRS, + double dfCenterLat, double dfCenterLong, + double dfFalseEasting, double dfFalseNorthing ); + +/** Transverse Mercator (South Oriented) */ +OGRErr CPL_DLL OSRSetTMSO( OGRSpatialReferenceH hSRS, + double dfCenterLat, double dfCenterLong, + double dfScale, + double dfFalseEasting, double dfFalseNorthing ); + +OGRErr CPL_DLL OSRSetTPED( OGRSpatialReferenceH hSRS, + double dfLat1, double dfLong1, + double dfLat2, double dfLong2, + double dfFalseEasting, double dfFalseNorthing ); + +/** VanDerGrinten */ +OGRErr CPL_DLL OSRSetVDG( OGRSpatialReferenceH hSRS, + double dfCenterLong, + double dfFalseEasting, double dfFalseNorthing ); + +/** Wagner I -- VII */ +OGRErr CPL_DLL OSRSetWagner( OGRSpatialReferenceH hSRS, int nVariation, + double dfCenterLat, + double dfFalseEasting, + double dfFalseNorthing ); + +/** Quadrilateralized Spherical Cube */ +OGRErr CPL_DLL OSRSetQSC( OGRSpatialReferenceH hSRS, + double dfCenterLat, double dfCenterLong ); + +/** Spherical, Cross-track, Height */ +OGRErr CPL_DLL OSRSetSCH( OGRSpatialReferenceH hSRS, + double dfPegLat, double dfPegLong, + double dfPegHeading, double dfPegHgt); + + +double CPL_DLL OSRCalcInvFlattening( double dfSemiMajor, double dfSemiMinor ); +double CPL_DLL OSRCalcSemiMinorFromInvFlattening( double dfSemiMajor, double dfInvFlattening ); + +void CPL_DLL OSRCleanup( void ); + +/* -------------------------------------------------------------------- */ +/* OGRCoordinateTransform C API. */ +/* -------------------------------------------------------------------- */ +OGRCoordinateTransformationH CPL_DLL CPL_STDCALL +OCTNewCoordinateTransformation( OGRSpatialReferenceH hSourceSRS, + OGRSpatialReferenceH hTargetSRS ); +void CPL_DLL CPL_STDCALL + OCTDestroyCoordinateTransformation( OGRCoordinateTransformationH ); + +int CPL_DLL CPL_STDCALL +OCTTransform( OGRCoordinateTransformationH hCT, + int nCount, double *x, double *y, double *z ); + +int CPL_DLL CPL_STDCALL +OCTTransformEx( OGRCoordinateTransformationH hCT, + int nCount, double *x, double *y, double *z, + int *pabSuccess ); + +/* this is really private to OGR. */ +char *OCTProj4Normalize( const char *pszProj4Src ); + +void OCTCleanupProjMutex( void ); + +/* -------------------------------------------------------------------- */ +/* Projection transform dictionary query. */ +/* -------------------------------------------------------------------- */ + +char CPL_DLL ** OPTGetProjectionMethods( void ); +char CPL_DLL ** OPTGetParameterList( const char * pszProjectionMethod, + char ** ppszUserName ); +int CPL_DLL OPTGetParameterInfo( const char * pszProjectionMethod, + const char * pszParameterName, + char ** ppszUserName, + char ** ppszType, + double *pdfDefaultValue ); + +CPL_C_END + +#endif /* ndef SWIG */ + +#endif /* ndef OGR_SRS_API_H_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/ogr_srs_esri_names.h b/modules/globebrowsing/ext/gdal/include/ogr_srs_esri_names.h new file mode 100644 index 0000000000..2a7181bd0e --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/ogr_srs_esri_names.h @@ -0,0 +1,717 @@ +static const char * const apszGcsNameMapping[] = { +"North_American_Datum_1983", "GCS_North_American_1983", +"North_American_Datum_1927", "GCS_North_American_1927", +"NAD27_CONUS", "GCS_North_American_1927", +"Reseau_Geodesique_de_Nouvelle_Caledonie_1991-93", "GCS_RGNC_1991-93", +"Reseau_Geodesique_de_la_Polynesie_Francaise", "GCS_RGPF", +"Rauenberg_1983", "GCS_RD/83", +"Phillipine_Reference_System_1992", "GCS_PRS_1992", +"Potsdam_1983", "GCS_PD/83", +"Datum_Geodesi_Nasional_1995", "GCS_DGN_1995", +"Islands_Network_1993", "GCS_ISN_1993", +"Institut_Geographique_du_Congo_Belge_1955", "GCS_IGCB_1955", +"IGC_1962_Arc_of_the_6th_Parallel_South", "GCS_IGC_1962_6th_Parallel_South", +"Jamaica_2001", "GCS_JAD_2001", +"European_Libyan_1979", "GCS_European_Libyan_Datum_1979", +"Madrid_1870", "GCS_Madrid_1870_Madrid", +"Azores_Occidental_Islands_1939", "GCS_Azores_Occidental_1939", +"Azores_Central_Islands_1948", "GCS_Azores_Central_1948", +"Azores_Oriental_Islands_1940", "GCS_Azores_Oriental_1940", +"Lithuania_1994", "GCS_LKS_1994", +"Libyan_Geodetic_Datum_2006", "GCS_LGD2006", +//"Lisbon", "GCS_Lisbon_Lisbon", +"Stockholm_1938", "GCS_RT38", +"Latvia_1992", "GCS_LKS_1992", +"Azores_Oriental_Islands_1995", "GCS_Azores_Oriental_1995", +"Azores_Central_Islands_1948", "GCS_Azores_Central_1948", +"Azores_Central_Islands_1995", "GCS_Azores_Central_1995", +"ATF", "GCS_ATF_Paris", +//"ITRF_2000", "GCS_MONREF_1997", +"Faroe_Datum_1954", "GCS_FD_1954", +"Vietnam_2000", "GCS_VN_2000", +//"Belge_1950", "GCS_Belge_1950_Brussels", +"Qatar_1948", "GCS_Qatar_1948", +"Qatar", "GCS_Qatar_1974", +"Kuwait_Utility", "GCS_KUDAMS", +"ED_1950_16", "GCS_European_1950", +"SAD_1969_Mean", "GCS_South_American_1969", +"Sphere_of_Radius_6370997m", "GCS_Sphere_ARC_INFO", +"Australian_Geodetic_1966", "GCS_Australian_1966", +"Australian_Geodetic_1984", "GCS_Australian_1984", +"AGD84", "GCS_Australian_1984", +"AGD66", "GCS_Australian_1966", +"Rome_1940", "GCS_Monte_Mario", +"Tokyo_Japan", "GCS_Tokyo", +"Graciosa_Base_SW_1948_1", "GCS_Graciosa_Base_SW_1948", +"Datum_Lisboa_Bessel_1", "GCS_Datum_Lisboa_Bessel", +"Datum_Lisboa_Hayford_1", "GCS_Datum_Lisboa_Hayford", +"Observatorio_Metereo_1939_Grupo_Ocidental", "GCS_Observ_Meteorologico_1939", +"Porto_Santo_1936_1", "GCS_Porto_Santo_1936", +"Sao_Braz_1", "GCS_Sao_Braz", +"GDA94", "GCS_GDA_1994", +"HARN", "GCS_North_American_1983_HARN", +"NAD83_HARN", "GCS_North_American_1983_HARN", +"Voirol_1875", "GCS_Voirol_1875", +"Voirol_1960", "GCS_Voirol_Unifie_1960", +"Ain_el_Abd_1970_Bahrain", "GCS_Ain_el_Abd_1970", +"ED_1950_ED77", "GCS_European_1950_ED77", +"Naparima_1955_2", "GCS_Naparima_1955", +"Aratu_Brazil_Campos_Espirito_Santo_and_Santos_basins", "GCS_Aratu", +"Camacupa_Angola_1", "GCS_Camacupa", +"Cape_1", "GCS_Cape", +"Carthage_Tunisia", "GCS_Carthage", +"Deir_ez_Zor_2", "GCS_Deir_ez_Zor", +"Old_Egyptian_1907", "GCS_Egypt_1907", +"PSAD56", "GCS_Provisional_S_American_1956", +"Indian 1975", "GCS_Indian_1975", +"Indian_1960_1", "GCS_Indian_1960", +"Kalianpur_1937_1", "GCS_Kalianpur_1937", +"Kertau_1948", "GCS_Kertau", +"Kertau_1968", "GCS_Kertau", +"Luzon", "GCS_Luzon_1911", +"Malongo_1987_1", "GCS_Malongo_1987", +"Minna_Cameroon", "GCS_Minna", +"Mporaloko_1", "GCS_Mporaloko", +"Nahrwan_Oman", "GCS_Nahrwan_1967", +"Naparima_BWI", "GCS_Naparima_1972", +"Geodetic_Datum_1949", "GCS_New_Zealand_1949", +"Qatar_National", "GCS_Qatar_1974", +"SAD_1969_Mean", "GCS_South_American_1969", +"Tananarive_Observatory_1925", "GCS_Tananarive_1925", +"Tananarive", "GCS_Tananarive_1925", +"Ireland_1965", "GCS_TM65", +"DE_DHDN_whole_country_2001_to_ETRS89", "GCS_Deutsches_Hauptdreiecksnetz", +"Belge_1972_1", "GCS_Belge_1972", +"WGS_72", "GCS_WGS_1972", +"JGD2000", "GCS_JGD_2000", +"NZGD49", "GCS_New_Zealand_1949", +"CH1903_1", "GCS_CH1903", +"DE_42/83_to_ETRS89", "GCS_Pulkovo_1942", +"DE_42_83_to_ETRS89", "GCS_Pulkovo_1942", +"Amersfoort_1", "GCS_Amersfoort", +"CH1903+_L+T1997", "GCS_CH1903+", +"Ord_Survey_G_Britain_1936", "GCS_OSGB_1936", +"European_Datum_1950", "GCS_European_1950", +"Geocentric_Datum_of_Australia_1994", "GCS_GDA_1994", +"NAD83_High_Accuracy_Regional_Network", "GCS_North_American_1983_HARN", +"Bogota_1975", "GCS_Bogota", +"North_American_Datum_1927_CGQ77", "GCS_NAD_1927_CGQ77", +"North_American_Datum_1927_1976", "GCS_NAD_1927_Definition_1976", +"European_Datum_1950_1977", "GCS_European_1950_ED77", +"WGS_1972_Transit_Broadcast_Ephemeris", "GCS_WGS_1972_BE", +"Greek_Geodetic_Reference_System_1987", "GCS_GGRS_1987", +"Militar_Geographische_Institute", "GCS_MGI", +"ED50", "GCS_European_1950", +"ETRS89", "GCS_ETRS_1989", +NULL, NULL}; + +static const char * const apszGcsNameMappingBasedOnProjCS[] = { +"EUREF_FIN_TM35FIN", "GCS_ETRS_1989", "GCS_EUREF_FIN", +"Nord_Maroc_Degree", "GCS_Merchich", "GCS_Merchich_Degree", +"Sahara_Degree", "GCS_Merchich", "GCS_Merchich_Degree", +"Sud_Maroc_Degree", "GCS_Merchich", "GCS_Merchich_Degree", +"Merchich_Degree_UTM_Zone_28N", "GCS_Merchich", "GCS_Merchich_Degree", +"Lambert_Conformal_Conic", "GCS_Merchich", "GCS_Merchich_Degree", +"UTM", "GCS_Merchich", "GCS_Merchich_Degree", +"UTM_Zone_28_Northern_Hemisphere", "GCS_Merchich", "GCS_Merchich_Degree", +"Portuguese_National_Grid", "GCS_Lisbon", "GCS_Lisbon_Lisbon", +"Belge_Lambert_1950", "GCS_Belge_1950", "GCS_Belge_1950_Brussels", +"MONREF_1997_UTM_Zone_46N", "GCS_ITRF_2000", "GCS_MONREF_1997", +"MONREF_1997_UTM_Zone_47N", "GCS_ITRF_2000", "GCS_MONREF_1997", +NULL, NULL, NULL}; + + + +static const char * const apszGcsNameMappingBasedOnUnit[] = { +"Voirol_Unifie_1960", "Degree", "GCS_Voirol_Unifie_1960_Degree", +"Voirol_1960", "Degree", "GCS_Voirol_Unifie_1960_Degree", +"Voirol 1960", "Degree", "GCS_Voirol_Unifie_1960_Degree", +"Voirol_1875", "Degree", "GCS_Voirol_1875_Degree", +"Voirol 1875", "Degree", "GCS_Voirol_1875_Degree", +"NTF", "Grad", "GCS_NTF_Paris", +NULL, NULL, NULL}; + +static const char * const apszGcsNameMappingBasedPrime[] = { +"Bern_1898", "Bern", "GCS_Bern_1898_Bern", +"Madrid_1870", "Madrid", "GCS_Madrid_1870_Madrid", +"MGI", "Ferro", "GCS_MGI_Ferro", +"MGI", "Stockholm", "GCS_RT38_Stockholm", +"Monte_Mario", "Rome", "GCS_Monte_Mario_Rome", +"NGO_1948", "Oslo", "GCS_NGO_1948_Oslo", +"S_JTSK", "Ferro", "GCS_S_JTSK_Ferro", +"Stockholm_1938", "Stockholm", "GCS_RT38_Stockholm", +NULL, NULL, NULL}; + +static const char * const apszInvFlatteningMapping[] = { +"293.464999999", "293.465", +"293.465000003", "293.465", +"293.465073361", "293.465", +"293.466020000", "293.46602", +"293.466021293", "293.46602", +"293.4663077168286", "293.466307656", +"293.4664236085404", "293.466307656", +"294.2606763690", "294.260676369", +"294.9786981999", "294.9786982", +"294.978698213", "294.9786982", +"295.9999999999", "296.0", +"297.0000000000", "297.0", +"297.0000000284", "297.0", +"297.0000535480", "297.0", +"298.2499972761", "298.25", +"298.2500000654", "298.25", +"298.2500112226", "298.25", +"298.256999999", "298.257", +"298.2600000000", "298.26", +"298.2571643544962", "298.257223563", +"298.25716435449", "298.257222101", +"298.257222096042", "298.257222101", +"298.25722210100", "298.257222101", +"298.25722356299", "298.257223563", +"298.25722356300", "298.257223563", +"298.25999858999", "298.26", +"298.2684109950054", "298.268410995005", +"298.2999", "298.3", +"298.3000", "298.3", +"299.1527033239203", "299.1528128", +"299.15281280000", "299.1528128", +"299.15281283", "299.1528128", +"299.15281310607", "299.1528128", +"299.15281327254", "299.1528128", +"299.32496460000", "299.3249646", +"299.32496405862", "299.3249646", +"299.32497531503", "299.3249646", +"300.80158474106", "300.8017", +"300.80169943849", "300.8017", +"300.80169999999", "300.8017", +"300.80170000000", "300.8017", +"300.80170009712", "300.8017", +NULL, NULL}; + +static const char * const apszParamValueMapping[] = { +"Cassini", "false_easting", "283799.9999", "283800.0", +"Cassini", "false_easting", "132033.9199", "132033.92", +"Cassini", "false_northing", "214499.9999", "214500.0", +"Cassini", "false_northing", "62565.9599", "62565.95", +"Transverse_Mercator", "false_easting", "499999.1331", "500000.0", +"Transverse_Mercator", "false_easting", "299999.4798609", "300000.0", +"Transverse_Mercator", "false_northing", "399999.30648", "400000.0", +"Transverse_Mercator", "false_northing", "499999.1331", "500000.0", +"Transverse_Mercator", "central_meridian","51.21666666666668", "51.21666666666667", +"Transverse_Mercator", "Scale_Factor", "0.999601272", "0.9996012717", +"Lambert_Conformal_Conic", "central_meridian", "-90.33333333333334", "-90.33333333333333", +"Lambert_Conformal_Conic", "central_meridian", "-76.83333333333334", "-76.83333333333333", +"Krovak", "longitude_of_center", "24.83333333333334", "24.83333333333333", +"Hotine_Oblique_Mercator_Azimuth_Center", "longitude_of_center", "7.439583333333334", "7.439583333333333", +"Hotine_Oblique_Mercator_Azimuth_Center", "latitude_of_center", "46.95240555555557", "46.95240555555556", +NULL, NULL, NULL, NULL}; + +static const char * const apszParamNameMapping[] = { +"Lambert_Azimuthal_Equal_Area", "longitude_of_center", "Central_Meridian", +"Lambert_Azimuthal_Equal_Area", "Latitude_Of_Center", "Latitude_Of_Origin", +"Miller_Cylindrical", "longitude_of_center", "Central_Meridian", +"Gnomonic", "central_meridian", "Longitude_Of_Center", +"Gnomonic", "latitude_of_origin", "Latitude_Of_Center", +"Orthographic", "central_meridian", "Longitude_Of_Center", +"Orthographic", "latitude_of_origin", "Latitude_Of_Center", +"New_Zealand_Map_Grid", "central_meridian", "Longitude_Of_Origin", +"Hotine_Oblique_Mercator_Two_Point_Natural_Origin", "latitude_of_point_1", "Latitude_Of_1st_Point", +"Hotine_Oblique_Mercator_Two_Point_Natural_Origin", "longitude_of_point_1", "Longitude_Of_1st_Point", +"Hotine_Oblique_Mercator_Two_Point_Natural_Origin", "latitude_of_point_2", "Latitude_Of_2nd_Point", +"Hotine_Oblique_Mercator_Two_Point_Natural_Origin", "longitude_of_point_2", "Longitude_Of_2nd_Point", +NULL, NULL, NULL}; + +static const char * const apszDeleteParametersBasedOnProjection[] = { +"Stereographic_South_Pole", "scale_factor", +"Stereographic_North_Pole", "scale_factor", +"Mercator", "scale_factor", +"Miller_Cylindrical", "latitude_of_center", +"Equidistant_Cylindrical", "pseudo_standard_parallel_1", +"Equidistant_Cylindrical", "latitude_of_origin", +"Plate_Carree", "latitude_of_origin", +"Plate_Carree", "pseudo_standard_parallel_1", +"Plate_Carree", "standard_parallel_1", +"Hotine_Oblique_Mercator_Azimuth_Center", "rectified_grid_angle", +"Hotine_Oblique_Mercator_Azimuth_Natural_Origin", "rectified_grid_angle", +NULL, NULL}; + +static const char * const apszAddParametersBasedOnProjection[] = { +"Cassini", "scale_factor", "1.0", +"Mercator", "standard_parallel_1", "0.0", +NULL, NULL, NULL}; + +static const int statePlaneZoneMapping[] = { +/* old zone code, prj code, new zone code */ + 3126, -1, 101, + 3151, -1, 102, + 3176, -1, 202, + 3201, -1, 203, + 3226, -1, 301, + 3251, -1, 302, + 3326, -1, 403, + 3351, -1, 404, + 3376, 26945, 405, + 3426, -1, 407, + 3451, -1, 501, + 3476, -1, 502, + 3526, -1, 600, + 3551, -1, 700, + 3576, -1, 903, + 3626, -1, 902, + 3651, -1, 1001, + 3676, -1, 1002, + 3726, -1, 1102, + 3751, -1, 1103, + 3776, -1, 1201, + 3801, -1, 1202, + 3826, -1, 1301, + 3851, -1, 1302, + 3876, -1, 1401, + 3926, -1, 1501, + 3951, -1, 1502, + 3976, -1, 1601, + 4026, -1, 1701, + 6426, -1, 1703, + 4076, -1, 1801, + 4101, -1, 1802, + 4126, -1, 1900, + 4151, -1, 2001, + 4176, -1, 2002, + 4226, -1, 2102, + 4251, -1, 2103, + 6351, -1, 2111, + 6376, -1, 2112, + 6401, -1, 2113, + 4276, -1, 2201, + 4326, -1, 2203, + 4351, -1, 2301, + 4376, -1, 2302, + 4400, 32045, 3400, + 4401, -1, 2401, + 4426, -1, 2402, + 4451, -1, 2403, + 4476, 32100, 2500, + 4476, -1, 2501, + 4701, 32111, 2900, + 4801, 2260, 3101, + 4801, 32115, 3101, + 4526, -1, 2503, + 4551, -1, 2601, + 4576, -1, 2602, + 4626, -1, 2702, + 4651, -1, 2703, + 4676, -1, 2800, + 4726, -1, 3001, + 4751, -1, 3002, + 4776, -1, 3003, + 4826, -1, 3102, + 4851, -1, 3103, + 4876, -1, 3104, + 4926, -1, 3301, + 4951, -1, 3302, + 4976, -1, 3401, + 5026, -1, 3501, + 5051, -1, 3502, + 5076, -1, 3601, + 5126, -1, 3701, + 5151, -1, 3702, + 5176, -1, 3800, + 5226, -1, 3902, + 5251, -1, 4001, + 5276, -1, 4002, + 5301, -1, 4100, + 5326, -1, 4201, + 5351, -1, 4202, + 5376, -1, 4203, + 5401, -1, 4204, + 5426, -1, 4205, + 5451, -1, 4301, + 5476, -1, 4302, + 5501, -1, 4303, + 5526, -1, 4400, + 5551, -1, 4501, + 5576, -1, 4502, + 5601, -1, 4601, + 5626, -1, 4602, + 5651, -1, 4701, + 5676, -1, 4702, + 5701, -1, 4801, + 5726, -1, 4802, + 5751, -1, 4803, + 5776, -1, 4901, + 5801, -1, 4902, + 5826, -1, 4903, + 5851, -1, 4904, + 6101, -1, 5001, + 6126, -1, 5002, + 6151, -1, 5003, + 6176, -1, 5004, + 6201, -1, 5005, + 6226, -1, 5006, + 6251, -1, 5007, + 6276, -1, 5008, + 6301, -1, 5009, + 6326, -1, 5010, + 5876, -1, 5101, + 5901, -1, 5102, + 5926, -1, 5103, + 5951, -1, 5104, + 5976, -1, 5105, + 6001, -1, 5201, + 6026, -1, 5200, + 6076, -1, 5200, + 6051, -1, 5202, + 0, 0, 0 + }; + +/* This is not a complete mapping. Need to add more. */ +static const int statePlanePcsCodeToZoneCode[] = { +/* pcs code, state plane prj str index*/ +2222, 2016, +2223, 2026, +2224, 2036, +2225, 4012, +2226, 4022, +2227, 4032, +2228, 4042, +2229, 4052, +2230, 4062, +2231, 5012, +2232, 5022, +2233, 5032, +2234, 6002, +2235, 7002, +2236, 9012, +2237, 9022, +2238, 9032, +2239, 10012, +2240, 10022, +2241, 11012, +2242, 11022, +2243, 11032, +2251, 21116, +2252, 21126, +2253, 21136, +2256, 25006, +2265, 33016, +2266, 33026, +2965, 13012, +2966, 13022, +2246, 16012, +2247, 16022, +2248, 19002, +2249, 20012, +2250, 20022, +2254, 23012, +2255, 23022, +2257, 30012, +2258, 30022, +2259, 30032, +2260, 31012, +2261, 31022, +2262, 31032, +2263, 31042, +2264, 32002, +2267, 35012, +2268, 35022, +2269, 36016, +2270, 36026, +2271, 37012, +2272, 37022, +2273, 39006, +2274, 41002, +2275, 42012, +2276, 42022, +2277, 42032, +2278, 42042, +2279, 42052, +2280, 43016, +2281, 43026, +2282, 43036, +2283, 45012, +2284, 45022, +2285, 46012, +2286, 46022, +2287, 48012, +2288, 48022, +2289, 48032, +2867, 2015, +2868, 2025, +2869, 2035, +2896, 21115, +2897, 21125, +2898, 21135, +2901, 25005, +2909, 33015, +2910, 33025, +2913, 36015, +2914, 36025, +2921, 43015, +2922, 43025, +2923, 43035, +2870, 4013, +2871, 4023, +2872, 4033, +2873, 4043, +2874, 4053, +2875, 4063, +2876, 5013, +2877, 5023, +2878, 5033, +2879, 6003, +2880, 7003, +2881, 9013, +2882, 9023, +2883, 9033, +2884, 10013, +2885, 10023, +2886, 11013, +2887, 11023, +2888, 11033, +2967, 13013, +2968, 13023, +2891, 16013, +2892, 16023, +2893, 19003, +2894, 20013, +2895, 20023, +2899, 23013, +2900, 23023, +2902, 30013, +2903, 30023, +2904, 30033, +2905, 31013, +2906, 31023, +2907, 31033, +2908, 31043, +2911, 35013, +2912, 35023, +2915, 41003, +2916, 42013, +2917, 42023, +2918, 42033, +2919, 42043, +2920, 42053, +2924, 45013, +2925, 45023, +2926, 46013, +2927, 46023, +2928, 48013, +2929, 48023, +2930, 48033, +// following are state systems (not complete) +2964, 102965, +2991, 102991, +2992, 102992, +2993, 102993, +2994, 102994, +// following are NAD 1983 SPCS Zone +26929, 1011, +26930, 1021, +26931, 50011, +26932, 50021, +26933, 50031, +26934, 50041, +26935, 50051, +26936, 50061, +26937, 50071, +26938, 50081, +26939, 50091, +26940, 50101, +26948, 2011, +26949, 2021, +26950, 2031, +26951, 3011, +26952, 3021, +26941, 4011, +26942, 4021, +26943, 4031, +26944, 4041, +26945, 4051, +26946, 4061, +26953, 5011, +26954, 5021, +26955, 5031, +26956, 6001, +26957, 7001, +26958, 9011, +26959, 9021, +26960, 9031, +26966, 10011, +26967, 10021, +26961, 51011, +26962, 51021, +26963, 51031, +26964, 51041, +26965, 51051, +26968, 11011, +26969, 11021, +26970, 11031, +26971, 12011, +26972, 12021, +26973, 13011, +26974, 13021, +26975, 14011, +26976, 14021, +26977, 15011, +26978, 15021, +26979, 16011, +26980, 16021, +26981, 17011, +26982, 17021, +26983, 18011, +26984, 18021, +26985, 19001, +26986, 20011, +26987, 20021, +26988, 21111, +26989, 21121, +26990, 21131, +26991, 22011, +26992, 22021, +26993, 22031, +26994, 23011, +26995, 23021, +26996, 24011, +26997, 24021, +26998, 24031, +32100, 25001, +32104, 26001, +32107, 27011, +32108, 27021, +32109, 27031, +32110, 28001, +32111, 29001, +32112, 30011, +32113, 30021, +32114, 30031, +32115, 31011, +32116, 31021, +32117, 31031, +32118, 31041, +32119, 32001, +32120, 33011, +32121, 33021, +32122, 34011, +32123, 34021, +32124, 35011, +32125, 35021, +32126, 36011, +32127, 36021, +32128, 37011, +32129, 37021, +32130, 38001, +32133, 39001, +32134, 40011, +32135, 40021, +32136, 41001, +32137, 42011, +32138, 42021, +32139, 42031, +32140, 42041, +32141, 42051, +32142, 43011, +32143, 43021, +32144, 43031, +32145, 44001, +32146, 45011, +32147, 45021, +32148, 46011, +32149, 46021, +32150, 47011, +32151, 47021, +32152, 48011, +32153, 48021, +32154, 48031, +32155, 49011, +32156, 49021, +32157, 49031, +32158, 49041, +32161, 52000, +65161, 54001, +0, 0 +}; + +/* ==================================================================== */ +/* WISCRS Table */ +/* ==================================================================== */ +static const double apszWISCRS_LCC_meter[] = { +// Central_Meridian, Latitude_Of_Origin, SR code + -91.1527777777, 46.6696483772, 103303.0, + -92.4577777777, 45.8987148658, 103306.0, + -91.2944444444, 44.9778568986, 103308.0, + -89.3944444444, 43.4625466458, 103310.0, + -90.9388888888, 43.2000556050, 103311.0, + -89.4222222222, 43.0695160375, 103312.0, + -91.2888888888, 45.8722811263, 103317.0, + -89.8388888888, 42.6375622769, 103322.0, + -89.2416666666, 43.8070001177, 103323.0, + -89.8388888888, 42.6375622769, 103332.0, + -89.0333333333, 45.1542371052, 103333.0, + -89.7700000000, 44.9009044236, 103336.0, + -89.2416666666, 43.8070001177, 103338.0, + -90.6416666666, 44.0000739286, 103341.0, + -89.5444444444, 45.7042237702, 103343.0, + -92.2277777777, 44.6361488719, 103346.0, + -92.2277777777, 44.6361488719, 103347.0, + -89.5000000000, 44.4168239752, 103349.0, + -90.4305555555, 43.3223129275, 103352.0, + -91.1166666666, 45.9000991313, 103356.0, + -90.4833333333, 45.1778220858, 103360.0, + -90.7833333333, 43.5750329397, 103362.0, + -89.4888888888, 46.0778440905, 103363.0, + -88.5416666667, 42.6694620969, 103364.0, + -91.7833333333, 45.9612198333, 103365.0, + -89.2416666666, 44.1139440458, 103369.0, + -90.0000000000, 44.3625954694, 103371.0, + 0.0, 0,0, 0,0 +}; + +static const double apszWISCRS_TM_meter[] = { +// Central_Meridian, Latitude_Of_Origin, SR code + -90.0000000000, 43.3666666666, 103300.0, + -90.6222222222, 45.7061111111, 103301.0, + -91.8500000000, 45.1333333333, 103302.0, + -88.0000000000, 43.0000000000, 103304.0, + -91.7972222222, 43.4813888888, 103305.0, + -88.5000000000, 42.7194444444, 103307.0, + -90.7083333333, 43.6000000000, 103309.0, + -88.7750000000, 41.4722222222, 103313.0, + -87.2722222222, 44.4000000000, 103314.0, + -91.9166666666, 45.8833333333, 103315.0, + -91.8944444444, 44.4083333333, 103316.0, + -88.1416666666, 45.4388888888, 103318.0, + -88.5000000000, 42.7194444444, 103319.0, + -88.6333333333, 44.0055555556, 103320.0, + -90.8000000000, 41.4111111111, 103321.0, + -90.1611111111, 42.5388888888, 103324.0, + -90.2555555555, 45.4333333333, 103325.0, + -90.8442965194, 44.2533351277, 103326.0, + -88.7750000000, 41.4722222222, 103327.0, + -90.0000000000, 43.3666666666, 103328.0, + -87.8944444444, 42.2166666666, 103329.0, + -87.5500000000, 43.2666666666, 103330.0, + -91.3166666666, 43.4511111111, 103331.0, + -89.7333333333, 44.8444444444, 103334.0, + -87.5500000000, 43.2666666666, 103335.0, + -87.7111111111, 44.6916666666, 103337.0, + -88.4166666666, 44.7166666666, 103339.0, + -87.8944444444, 42.2166666666, 103340.0, + -87.9083333333, 44.3972222222, 103342.0, + -88.5000000000, 42.7194444444, 103344.0, + -87.8944444444, 42.2166666666, 103345.0, + -92.6333333333, 44.6611111111, 103348.0, + -90.4888888889, 44.5555555556, 103350.0, + -87.8944444444, 42.2166666666, 103351.0, + -89.0722222222, 41.9444444444, 103353.0, + -91.0666666666, 43.9194444444, 103354.0, + -89.9000000000, 42.8194444444, 103355.0, + -88.6055555556, 44.0361111111, 103357.0, + -87.5500000000, 43.2666666666, 103358.0, + -92.6333333333, 44.0361111111, 103359.0, + -91.3666666666, 43.1611111111, 103361.0, + -88.0638888888, 42.9180555555, 103366.0, + -88.2250000000, 42.5694444444, 103367.0, + -88.8166666666, 43.4202777777, 103368.0, + -88.5000000000, 42.7194444444, 103370.0, + 0.0, 0,0, 0,0 +}; diff --git a/modules/globebrowsing/ext/gdal/include/ograpispy.h b/modules/globebrowsing/ext/gdal/include/ograpispy.h new file mode 100644 index 0000000000..b37340da72 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/ograpispy.h @@ -0,0 +1,173 @@ +/****************************************************************************** + * $Id$ + * + * Project: OpenGIS Simple Features Reference Implementation + * Purpose: OGR C API "Spy" + * Author: Even Rouault, even.rouault at spatialys.com + * + ****************************************************************************** + * Copyright (c) 2014, Even Rouault + * + * 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. + ****************************************************************************/ + +#ifndef OGRAPISPY_H_INCLUDED +#define OGRAPISPY_H_INCLUDED + +#include "gdal.h" + +/** + * \file ograpispy.h + * + * OGR C API spy. + * + * If GDAL is compiled with OGRAPISPY_ENABLED defined (which is the case for a + * DEBUG build), a mechanism to trace calls to the OGR *C* API is available + * (calls to the C++ API will not be traced) + * + * Provided there is compile-time support, the mechanism must also be enabled at + * runtime by setting the OGR_API_SPY_FILE configuration option + * to a file where the calls to the OGR C API will be dumped (stdout and stderr + * are recognized as special strings to name the standard output and error files). + * The traced calls are outputted as a OGR Python script. + * + * Only calls that may have side-effects to the behaviour of drivers are traced. + * + * If a file-based datasource is open in update mode, a snapshot of its initial + * state is stored in a 'snapshot' directory, and then a copy of it is made as + * the working datasource. That way, the generated script can be executed in a + * reproducible way. The path for snapshots is the current working directory by + * default, and can be changed by setting the OGR_API_SPY_SNAPSHOT_PATH + * configuration option. If it is set to NO, the snapshot feature will be disabled. + * The reliability of snapshoting relies on if the dataset correctly implements + * GetFileList() (for multi-file datasources) + * + * @since GDAL 2.0 + */ + + +#ifdef DEBUG +#define OGRAPISPY_ENABLED +#endif + +#ifdef OGRAPISPY_ENABLED + +CPL_C_START + +extern int bOGRAPISpyEnabled; + +int OGRAPISpyOpenTakeSnapshot(const char* pszName, int bUpdate); +void OGRAPISpyOpen(const char* pszName, int bUpdate, int iSnapshot, + GDALDatasetH* phDS); +void OGRAPISpyPreClose(OGRDataSourceH hDS); +void OGRAPISpyPostClose(); +void OGRAPISpyCreateDataSource(OGRSFDriverH hDriver, const char* pszName, + char** papszOptions, OGRDataSourceH hDS); +void OGRAPISpyDeleteDataSource(OGRSFDriverH hDriver, const char* pszName); + +void OGRAPISpy_DS_GetLayerCount( OGRDataSourceH hDS ); +void OGRAPISpy_DS_GetLayer( OGRDataSourceH hDS, int iLayer, OGRLayerH hLayer ); +void OGRAPISpy_DS_GetLayerByName( OGRDataSourceH hDS, const char* pszLayerName, + OGRLayerH hLayer ); +void OGRAPISpy_DS_ExecuteSQL( OGRDataSourceH hDS, + const char *pszStatement, + OGRGeometryH hSpatialFilter, + const char *pszDialect, + OGRLayerH hLayer); +void OGRAPISpy_DS_ReleaseResultSet( OGRDataSourceH hDS, OGRLayerH hLayer); + +void OGRAPISpy_DS_CreateLayer( OGRDataSourceH hDS, + const char * pszName, + OGRSpatialReferenceH hSpatialRef, + OGRwkbGeometryType eType, + char ** papszOptions, + OGRLayerH hLayer); +void OGRAPISpy_DS_DeleteLayer( OGRDataSourceH hDS, int iLayer ); + +void OGRAPISpy_Dataset_StartTransaction( GDALDatasetH hDS, int bForce ); +void OGRAPISpy_Dataset_CommitTransaction( GDALDatasetH hDS ); +void OGRAPISpy_Dataset_RollbackTransaction( GDALDatasetH hDS ); + +void OGRAPISpy_L_GetFeatureCount( OGRLayerH hLayer, int bForce ); +void OGRAPISpy_L_GetExtent( OGRLayerH hLayer, int bForce ); +void OGRAPISpy_L_GetExtentEx( OGRLayerH hLayer, int iGeomField, int bForce ); +void OGRAPISpy_L_SetAttributeFilter( OGRLayerH hLayer, const char* pszFilter ); +void OGRAPISpy_L_GetFeature( OGRLayerH hLayer, GIntBig nFeatureId ); +void OGRAPISpy_L_SetNextByIndex( OGRLayerH hLayer, GIntBig nIndex ); +void OGRAPISpy_L_GetNextFeature( OGRLayerH hLayer ); +void OGRAPISpy_L_SetFeature( OGRLayerH hLayer, OGRFeatureH hFeat ); +void OGRAPISpy_L_CreateFeature( OGRLayerH hLayer, OGRFeatureH hFeat ); +void OGRAPISpy_L_CreateField( OGRLayerH hLayer, OGRFieldDefnH hField, + int bApproxOK ); +void OGRAPISpy_L_DeleteField( OGRLayerH hLayer, int iField ); +void OGRAPISpy_L_ReorderFields( OGRLayerH hLayer, int* panMap ); +void OGRAPISpy_L_ReorderField( OGRLayerH hLayer, int iOldFieldPos, + int iNewFieldPos ); +void OGRAPISpy_L_AlterFieldDefn( OGRLayerH hLayer, int iField, + OGRFieldDefnH hNewFieldDefn, + int nFlags ); +void OGRAPISpy_L_CreateGeomField( OGRLayerH hLayer, OGRGeomFieldDefnH hField, + int bApproxOK ); +void OGRAPISpy_L_StartTransaction( OGRLayerH hLayer ); +void OGRAPISpy_L_CommitTransaction( OGRLayerH hLayer ); +void OGRAPISpy_L_RollbackTransaction( OGRLayerH hLayer ); +void OGRAPISpy_L_GetLayerDefn( OGRLayerH hLayer ); +void OGRAPISpy_L_FindFieldIndex( OGRLayerH hLayer, const char *pszFieldName, + int bExactMatch ); +void OGRAPISpy_L_GetSpatialRef( OGRLayerH hLayer ); +void OGRAPISpy_L_TestCapability( OGRLayerH hLayer, const char* pszCap ); +void OGRAPISpy_L_GetSpatialFilter( OGRLayerH hLayer ); +void OGRAPISpy_L_SetSpatialFilter( OGRLayerH hLayer, OGRGeometryH hGeom ); +void OGRAPISpy_L_SetSpatialFilterEx( OGRLayerH hLayer, int iGeomField, + OGRGeometryH hGeom ); +void OGRAPISpy_L_SetSpatialFilterRect( OGRLayerH hLayer, + double dfMinX, double dfMinY, + double dfMaxX, double dfMaxY); +void OGRAPISpy_L_SetSpatialFilterRectEx( OGRLayerH hLayer, int iGeomField, + double dfMinX, double dfMinY, + double dfMaxX, double dfMaxY); +void OGRAPISpy_L_ResetReading( OGRLayerH hLayer ); +void OGRAPISpy_L_SyncToDisk( OGRLayerH hLayer ); +void OGRAPISpy_L_DeleteFeature( OGRLayerH hLayer, GIntBig nFID ); +void OGRAPISpy_L_GetFIDColumn( OGRLayerH hLayer ); +void OGRAPISpy_L_GetGeometryColumn( OGRLayerH hLayer ); +void OGRAPISpy_L_GetName( OGRLayerH hLayer ); +void OGRAPISpy_L_GetGeomType( OGRLayerH hLayer ); +void OGRAPISpy_L_SetIgnoredFields( OGRLayerH hLayer, + const char** papszIgnoredFields ); + +void OGRAPISpy_FD_GetGeomType(OGRFeatureDefnH hDefn); +void OGRAPISpy_FD_GetFieldCount(OGRFeatureDefnH hDefn); +void OGRAPISpy_FD_GetFieldDefn(OGRFeatureDefnH hDefn, int iField, + OGRFieldDefnH hGeomField); +void OGRAPISpy_FD_GetFieldIndex(OGRFeatureDefnH hDefn, const char* pszFieldName); + +void OGRAPISpy_Fld_GetXXXX(OGRFieldDefnH hField, const char* pszOp); + +void OGRAPISpy_FD_GetGeomFieldCount(OGRFeatureDefnH hDefn); +void OGRAPISpy_FD_GetGeomFieldDefn(OGRFeatureDefnH hDefn, int iGeomField, + OGRGeomFieldDefnH hGeomField); +void OGRAPISpy_FD_GetGeomFieldIndex(OGRFeatureDefnH hDefn, const char* pszFieldName); +void OGRAPISpy_GFld_GetXXXX(OGRGeomFieldDefnH hGeomField, const char* pszOp); + +CPL_C_END + +#endif /* OGRAPISPY_ENABLED */ + +#endif /* OGRAPISPY_H_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/ogrgeomediageometry.h b/modules/globebrowsing/ext/gdal/include/ogrgeomediageometry.h new file mode 100644 index 0000000000..9cfa417497 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/ogrgeomediageometry.h @@ -0,0 +1,43 @@ +/****************************************************************************** + * $Id$ + * + * Project: OpenGIS Simple Features Reference Implementation + * Purpose: Implements decoder of geomedia geometry blobs + * Author: Even Rouault, + * + ****************************************************************************** + * Copyright (c) 2011, Even Rouault + * + * 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. + ****************************************************************************/ + +#ifndef OGR_GEOMEDIAGEOMETRY_H_INCLUDED +#define OGR_GEOMEDIAGEOMETRY_H_INCLUDED + +#include "ogr_geometry.h" +#include "ogr_spatialref.h" +#include "ogr_feature.h" + +OGRErr OGRCreateFromGeomedia( GByte *pabyGeom, + OGRGeometry **ppoGeom, + int nBytes ); + +OGRSpatialReference* OGRGetGeomediaSRS(OGRFeature* poFeature); + +#endif diff --git a/modules/globebrowsing/ext/gdal/include/ogrpgeogeometry.h b/modules/globebrowsing/ext/gdal/include/ogrpgeogeometry.h new file mode 100644 index 0000000000..60be647cc7 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/ogrpgeogeometry.h @@ -0,0 +1,96 @@ +/****************************************************************************** + * $Id$ + * + * Project: OpenGIS Simple Features Reference Implementation + * Purpose: Implements decoder of shapebin geometry for PGeo + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2005, Frank Warmerdam + * Copyright (c) 2011-2014, Even Rouault + * + * 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. + ****************************************************************************/ + +#ifndef OGR_PGEOGEOMETRY_H_INCLUDED +#define OGR_PGEOGEOMETRY_H_INCLUDED + +#include "ogr_geometry.h" + +#define SHPT_NULL 0 + +#define SHPT_POINT 1 +#define SHPT_POINTM 21 +#define SHPT_POINTZM 11 +#define SHPT_POINTZ 9 + +#define SHPT_MULTIPOINT 8 +#define SHPT_MULTIPOINTM 28 +#define SHPT_MULTIPOINTZM 18 +#define SHPT_MULTIPOINTZ 20 + +#define SHPT_ARC 3 +#define SHPT_ARCM 23 +#define SHPT_ARCZM 13 +#define SHPT_ARCZ 10 + +#define SHPT_POLYGON 5 +#define SHPT_POLYGONM 25 +#define SHPT_POLYGONZM 15 +#define SHPT_POLYGONZ 19 + +#define SHPT_MULTIPATCHM 31 +#define SHPT_MULTIPATCH 32 + +#define SHPT_GENERALPOLYLINE 50 +#define SHPT_GENERALPOLYGON 51 +#define SHPT_GENERALPOINT 52 +#define SHPT_GENERALMULTIPOINT 53 +#define SHPT_GENERALMULTIPATCH 54 + +/* The following are layers geometry type */ +/* They are different from the above shape types */ +#define ESRI_LAYERGEOMTYPE_NULL 0 +#define ESRI_LAYERGEOMTYPE_POINT 1 +#define ESRI_LAYERGEOMTYPE_MULTIPOINT 2 +#define ESRI_LAYERGEOMTYPE_POLYLINE 3 +#define ESRI_LAYERGEOMTYPE_POLYGON 4 +#define ESRI_LAYERGEOMTYPE_MULTIPATCH 9 + +void OGRCreateFromMultiPatchPart(OGRMultiPolygon *poMP, + OGRPolygon*& poLastPoly, + int nPartType, + int nPartPoints, + double* padfX, + double* padfY, + double* padfZ); + +OGRErr CPL_DLL OGRCreateFromShapeBin( GByte *pabyShape, + OGRGeometry **ppoGeom, + int nBytes ); + +OGRErr CPL_DLL OGRWriteToShapeBin( OGRGeometry *poGeom, + GByte **ppabyShape, + int *pnBytes ); + +OGRErr CPL_DLL OGRWriteMultiPatchToShapeBin( OGRGeometry *poGeom, + GByte **ppabyShape, + int *pnBytes ); + +#endif diff --git a/modules/globebrowsing/ext/gdal/include/ogrsf_frmts.h b/modules/globebrowsing/ext/gdal/include/ogrsf_frmts.h new file mode 100644 index 0000000000..72578701bd --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/ogrsf_frmts.h @@ -0,0 +1,427 @@ +/****************************************************************************** + * $Id$ + * + * Project: OpenGIS Simple Features Reference Implementation + * Purpose: Classes related to format registration, and file opening. + * Author: Frank Warmerdam, warmerda@home.com + * + ****************************************************************************** + * Copyright (c) 1999, Les Technologies SoftMap Inc. + * Copyright (c) 2007-2014, Even Rouault + * + * 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. + ****************************************************************************/ + +#ifndef OGRSF_FRMTS_H_INCLUDED +#define OGRSF_FRMTS_H_INCLUDED + +#include "cpl_progress.h" +#include "ogr_feature.h" +#include "ogr_featurestyle.h" +#include "gdal_priv.h" + +/** + * \file ogrsf_frmts.h + * + * Classes related to registration of format support, and opening datasets. + */ + +#if !defined(GDAL_COMPILATION) && !defined(SUPPRESS_DEPRECATION_WARNINGS) +#define OGR_DEPRECATED(x) CPL_WARN_DEPRECATED(x) +#else +#define OGR_DEPRECATED(x) +#endif + +class OGRLayerAttrIndex; +class OGRSFDriver; + +/************************************************************************/ +/* OGRLayer */ +/************************************************************************/ + +/** + * This class represents a layer of simple features, with access methods. + * + */ + +/* Note: any virtual method added to this class must also be added in the */ +/* OGRLayerDecorator and OGRMutexedLayer classes. */ + +class CPL_DLL OGRLayer : public GDALMajorObject +{ + private: + void ConvertGeomsIfNecessary( OGRFeature *poFeature ); + + protected: + int m_bFilterIsEnvelope; + OGRGeometry *m_poFilterGeom; + OGRPreparedGeometry *m_pPreparedFilterGeom; /* m_poFilterGeom compiled as a prepared geometry */ + OGREnvelope m_sFilterEnvelope; + int m_iGeomFieldFilter; // specify the index on which the spatial + // filter is active. + + int FilterGeometry( OGRGeometry * ); + //int FilterGeometry( OGRGeometry *, OGREnvelope* psGeometryEnvelope); + int InstallFilter( OGRGeometry * ); + + OGRErr GetExtentInternal(int iGeomField, OGREnvelope *psExtent, int bForce ); + + virtual OGRErr ISetFeature( OGRFeature *poFeature ) CPL_WARN_UNUSED_RESULT; + virtual OGRErr ICreateFeature( OGRFeature *poFeature ) CPL_WARN_UNUSED_RESULT; + + public: + OGRLayer(); + virtual ~OGRLayer(); + + virtual OGRGeometry *GetSpatialFilter(); + virtual void SetSpatialFilter( OGRGeometry * ); + virtual void SetSpatialFilterRect( double dfMinX, double dfMinY, + double dfMaxX, double dfMaxY ); + + virtual void SetSpatialFilter( int iGeomField, OGRGeometry * ); + virtual void SetSpatialFilterRect( int iGeomField, + double dfMinX, double dfMinY, + double dfMaxX, double dfMaxY ); + + virtual OGRErr SetAttributeFilter( const char * ); + + virtual void ResetReading() = 0; + virtual OGRFeature *GetNextFeature() CPL_WARN_UNUSED_RESULT = 0; + virtual OGRErr SetNextByIndex( GIntBig nIndex ); + virtual OGRFeature *GetFeature( GIntBig nFID ) CPL_WARN_UNUSED_RESULT; + + OGRErr SetFeature( OGRFeature *poFeature ) CPL_WARN_UNUSED_RESULT; + OGRErr CreateFeature( OGRFeature *poFeature ) CPL_WARN_UNUSED_RESULT; + + virtual OGRErr DeleteFeature( GIntBig nFID ) CPL_WARN_UNUSED_RESULT; + + virtual const char *GetName(); + virtual OGRwkbGeometryType GetGeomType(); + virtual OGRFeatureDefn *GetLayerDefn() = 0; + virtual int FindFieldIndex( const char *pszFieldName, int bExactMatch ); + + virtual OGRSpatialReference *GetSpatialRef(); + + virtual GIntBig GetFeatureCount( int bForce = TRUE ); + virtual OGRErr GetExtent(OGREnvelope *psExtent, int bForce = TRUE) CPL_WARN_UNUSED_RESULT; + virtual OGRErr GetExtent(int iGeomField, OGREnvelope *psExtent, + int bForce = TRUE) CPL_WARN_UNUSED_RESULT; + + virtual int TestCapability( const char * ) = 0; + + virtual OGRErr CreateField( OGRFieldDefn *poField, + int bApproxOK = TRUE ); + virtual OGRErr DeleteField( int iField ); + virtual OGRErr ReorderFields( int* panMap ); + virtual OGRErr AlterFieldDefn( int iField, OGRFieldDefn* poNewFieldDefn, int nFlagsIn ); + + virtual OGRErr CreateGeomField( OGRGeomFieldDefn *poField, + int bApproxOK = TRUE ); + + virtual OGRErr SyncToDisk(); + + virtual OGRStyleTable *GetStyleTable(); + virtual void SetStyleTableDirectly( OGRStyleTable *poStyleTable ); + + virtual void SetStyleTable(OGRStyleTable *poStyleTable); + + virtual OGRErr StartTransaction() CPL_WARN_UNUSED_RESULT; + virtual OGRErr CommitTransaction() CPL_WARN_UNUSED_RESULT; + virtual OGRErr RollbackTransaction(); + + virtual const char *GetFIDColumn(); + virtual const char *GetGeometryColumn(); + + virtual OGRErr SetIgnoredFields( const char **papszFields ); + + OGRErr Intersection( OGRLayer *pLayerMethod, + OGRLayer *pLayerResult, + char** papszOptions = NULL, + GDALProgressFunc pfnProgress = NULL, + void * pProgressArg = NULL ); + OGRErr Union( OGRLayer *pLayerMethod, + OGRLayer *pLayerResult, + char** papszOptions = NULL, + GDALProgressFunc pfnProgress = NULL, + void * pProgressArg = NULL ); + OGRErr SymDifference( OGRLayer *pLayerMethod, + OGRLayer *pLayerResult, + char** papszOptions, + GDALProgressFunc pfnProgress, + void * pProgressArg ); + OGRErr Identity( OGRLayer *pLayerMethod, + OGRLayer *pLayerResult, + char** papszOptions = NULL, + GDALProgressFunc pfnProgress = NULL, + void * pProgressArg = NULL ); + OGRErr Update( OGRLayer *pLayerMethod, + OGRLayer *pLayerResult, + char** papszOptions = NULL, + GDALProgressFunc pfnProgress = NULL, + void * pProgressArg = NULL ); + OGRErr Clip( OGRLayer *pLayerMethod, + OGRLayer *pLayerResult, + char** papszOptions = NULL, + GDALProgressFunc pfnProgress = NULL, + void * pProgressArg = NULL ); + OGRErr Erase( OGRLayer *pLayerMethod, + OGRLayer *pLayerResult, + char** papszOptions = NULL, + GDALProgressFunc pfnProgress = NULL, + void * pProgressArg = NULL ); + + int Reference(); + int Dereference(); + int GetRefCount() const; + + GIntBig GetFeaturesRead(); + + /* non virtual : convenience wrapper for ReorderFields() */ + OGRErr ReorderField( int iOldFieldPos, int iNewFieldPos ); + + int AttributeFilterEvaluationNeedsGeometry(); + + /* consider these private */ + OGRErr InitializeIndexSupport( const char * ); + OGRLayerAttrIndex *GetIndex() { return m_poAttrIndex; } + + protected: + OGRStyleTable *m_poStyleTable; + OGRFeatureQuery *m_poAttrQuery; + char *m_pszAttrQueryString; + OGRLayerAttrIndex *m_poAttrIndex; + + int m_nRefCount; + + GIntBig m_nFeaturesRead; +}; + +/************************************************************************/ +/* OGRDataSource */ +/************************************************************************/ + +/** + * LEGACY class. Use GDALDataset in your new code ! This class may be + * removed in a later release. + * + * This class represents a data source. A data source potentially + * consists of many layers (OGRLayer). A data source normally consists + * of one, or a related set of files, though the name doesn't have to be + * a real item in the file system. + * + * When an OGRDataSource is destroyed, all it's associated OGRLayers objects + * are also destroyed. + * + * NOTE: Starting with GDAL 2.0, it is *NOT* safe to cast the handle of + * a C function that returns a OGRDataSourceH to a OGRDataSource*. If a C++ object + * is needed, the handle should be cast to GDALDataset*. + * + * @deprecated + */ + +class CPL_DLL OGRDataSource : public GDALDataset +{ +public: + OGRDataSource(); + + virtual const char *GetName() OGR_DEPRECATED("Use GDALDataset class instead") = 0; + + static void DestroyDataSource( OGRDataSource * ) OGR_DEPRECATED("Use GDALDataset class instead"); +}; + +/************************************************************************/ +/* OGRSFDriver */ +/************************************************************************/ + +/** + * LEGACY class. Use GDALDriver in your new code ! This class may be + * removed in a later release. + * + * Represents an operational format driver. + * + * One OGRSFDriver derived class will normally exist for each file format + * registered for use, regardless of whether a file has or will be opened. + * The list of available drivers is normally managed by the + * OGRSFDriverRegistrar. + * + * NOTE: Starting with GDAL 2.0, it is *NOT* safe to cast the handle of + * a C function that returns a OGRSFDriverH to a OGRSFDriver*. If a C++ object + * is needed, the handle should be cast to GDALDriver*. + * + * @deprecated + */ + +class CPL_DLL OGRSFDriver : public GDALDriver +{ + public: + virtual ~OGRSFDriver(); + + virtual const char *GetName() OGR_DEPRECATED("Use GDALDriver class instead") = 0; + + virtual OGRDataSource *Open( const char *pszName, int bUpdate=FALSE ) OGR_DEPRECATED("Use GDALDriver class instead") = 0; + + virtual int TestCapability( const char *pszCap ) OGR_DEPRECATED("Use GDALDriver class instead") = 0; + + virtual OGRDataSource *CreateDataSource( const char *pszName, + char ** = NULL ) OGR_DEPRECATED("Use GDALDriver class instead"); + virtual OGRErr DeleteDataSource( const char *pszName ) OGR_DEPRECATED("Use GDALDriver class instead"); +}; + + +/************************************************************************/ +/* OGRSFDriverRegistrar */ +/************************************************************************/ + +/** + * LEGACY class. Use GDALDriverManager in your new code ! This class may be + * removed in a later release. + * + * Singleton manager for OGRSFDriver instances that will be used to try + * and open datasources. Normally the registrar is populated with + * standard drivers using the OGRRegisterAll() function and does not need + * to be directly accessed. The driver registrar and all registered drivers + * may be cleaned up on shutdown using OGRCleanupAll(). + * + * @deprecated + */ + +class CPL_DLL OGRSFDriverRegistrar +{ + + OGRSFDriverRegistrar(); + ~OGRSFDriverRegistrar(); + + static GDALDataset* OpenWithDriverArg(GDALDriver* poDriver, + GDALOpenInfo* poOpenInfo); + static GDALDataset* CreateVectorOnly( GDALDriver* poDriver, + const char * pszName, + char ** papszOptions ); + static CPLErr DeleteDataSource( GDALDriver* poDriver, + const char * pszName ); + + public: + + static OGRSFDriverRegistrar *GetRegistrar() OGR_DEPRECATED("Use GDALDriverManager class instead"); + + void RegisterDriver( OGRSFDriver * poDriver ) OGR_DEPRECATED("Use GDALDriverManager class instead"); + + int GetDriverCount( void ) OGR_DEPRECATED("Use GDALDriverManager class instead"); + GDALDriver *GetDriver( int iDriver ) OGR_DEPRECATED("Use GDALDriverManager class instead"); + GDALDriver *GetDriverByName( const char * ) OGR_DEPRECATED("Use GDALDriverManager class instead"); + + int GetOpenDSCount() OGR_DEPRECATED("Use GDALDriverManager class instead"); + OGRDataSource *GetOpenDS( int ) OGR_DEPRECATED("Use GDALDriverManager class instead"); +}; + +/* -------------------------------------------------------------------- */ +/* Various available registration methods. */ +/* -------------------------------------------------------------------- */ +CPL_C_START +void CPL_DLL OGRRegisterAll(); +void OGRRegisterAllInternal(); + +void CPL_DLL RegisterOGRFileGDB(); +void CPL_DLL RegisterOGRShape(); +void CPL_DLL RegisterOGRDB2(); +void CPL_DLL RegisterOGRNTF(); +void CPL_DLL RegisterOGRFME(); +void CPL_DLL RegisterOGRSDTS(); +void CPL_DLL RegisterOGRTiger(); +void CPL_DLL RegisterOGRS57(); +void CPL_DLL RegisterOGRTAB(); +void CPL_DLL RegisterOGRMIF(); +void CPL_DLL RegisterOGROGDI(); +void CPL_DLL RegisterOGRODBC(); +void CPL_DLL RegisterOGRWAsP(); +void CPL_DLL RegisterOGRPG(); +void CPL_DLL RegisterOGRMSSQLSpatial(); +void CPL_DLL RegisterOGRMySQL(); +void CPL_DLL RegisterOGROCI(); +void CPL_DLL RegisterOGRDGN(); +void CPL_DLL RegisterOGRGML(); +void CPL_DLL RegisterOGRLIBKML(); +void CPL_DLL RegisterOGRKML(); +void CPL_DLL RegisterOGRGeoJSON(); +void CPL_DLL RegisterOGRAVCBin(); +void CPL_DLL RegisterOGRAVCE00(); +void CPL_DLL RegisterOGRREC(); +void CPL_DLL RegisterOGRMEM(); +void CPL_DLL RegisterOGRVRT(); +void CPL_DLL RegisterOGRDODS(); +void CPL_DLL RegisterOGRSQLite(); +void CPL_DLL RegisterOGRCSV(); +void CPL_DLL RegisterOGRILI1(); +void CPL_DLL RegisterOGRILI2(); +void CPL_DLL RegisterOGRGRASS(); +void CPL_DLL RegisterOGRPGeo(); +void CPL_DLL RegisterOGRDXFDWG(); +void CPL_DLL RegisterOGRDXF(); +void CPL_DLL RegisterOGRDWG(); +void CPL_DLL RegisterOGRSDE(); +void CPL_DLL RegisterOGRIDB(); +void CPL_DLL RegisterOGRGMT(); +void CPL_DLL RegisterOGRBNA(); +void CPL_DLL RegisterOGRGPX(); +void CPL_DLL RegisterOGRGeoconcept(); +void CPL_DLL RegisterOGRIngres(); +void CPL_DLL RegisterOGRXPlane(); +void CPL_DLL RegisterOGRNAS(); +void CPL_DLL RegisterOGRGeoRSS(); +void CPL_DLL RegisterOGRGTM(); +void CPL_DLL RegisterOGRVFK(); +void CPL_DLL RegisterOGRPGDump(); +void CPL_DLL RegisterOGROSM(); +void CPL_DLL RegisterOGRGPSBabel(); +void CPL_DLL RegisterOGRSUA(); +void CPL_DLL RegisterOGROpenAir(); +void CPL_DLL RegisterOGRPDS(); +void CPL_DLL RegisterOGRWFS(); +void CPL_DLL RegisterOGRSOSI(); +void CPL_DLL RegisterOGRHTF(); +void CPL_DLL RegisterOGRAeronavFAA(); +void CPL_DLL RegisterOGRGeomedia(); +void CPL_DLL RegisterOGRMDB(); +void CPL_DLL RegisterOGREDIGEO(); +void CPL_DLL RegisterOGRGFT(); +void CPL_DLL RegisterOGRSVG(); +void CPL_DLL RegisterOGRCouchDB(); +void CPL_DLL RegisterOGRCloudant(); +void CPL_DLL RegisterOGRIdrisi(); +void CPL_DLL RegisterOGRARCGEN(); +void CPL_DLL RegisterOGRSEGUKOOA(); +void CPL_DLL RegisterOGRSEGY(); +void CPL_DLL RegisterOGRXLS(); +void CPL_DLL RegisterOGRODS(); +void CPL_DLL RegisterOGRXLSX(); +void CPL_DLL RegisterOGRElastic(); +void CPL_DLL RegisterOGRGeoPackage(); +void CPL_DLL RegisterOGRWalk(); +void CPL_DLL RegisterOGRCartoDB(); +void CPL_DLL RegisterOGRAmigoCloud(); +void CPL_DLL RegisterOGRSXF(); +void CPL_DLL RegisterOGROpenFileGDB(); +void CPL_DLL RegisterOGRSelafin(); +void CPL_DLL RegisterOGRJML(); +void CPL_DLL RegisterOGRPLSCENES(); +void CPL_DLL RegisterOGRCSW(); +void CPL_DLL RegisterOGRMongoDB(); +void CPL_DLL RegisterOGRVDV(); +CPL_C_END + +#endif /* ndef OGRSF_FRMTS_H_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/osr_cs_wkt.h b/modules/globebrowsing/ext/gdal/include/osr_cs_wkt.h new file mode 100644 index 0000000000..b08df31fc9 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/osr_cs_wkt.h @@ -0,0 +1,55 @@ +/****************************************************************************** + * $Id$ + * + * Project: OpenGIS Simple Features Reference Implementation + * Purpose: CS WKT parser + * Author: Even Rouault, + * + ****************************************************************************** + * Copyright (c) 2013, Even Rouault + * + * 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. + ****************************************************************************/ + +#ifndef OSR_CS_WKT_H_INCLUDED_ +#define OSR_CS_WKT_H_INCLUDED_ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct +{ + const char *pszInput; + const char *pszLastSuccess; + const char *pszNext; + char szErrorMsg[512]; +} osr_cs_wkt_parse_context; + +#include "osr_cs_wkt_parser.h" + +void osr_cs_wkt_error( osr_cs_wkt_parse_context *context, const char *msg ); +int osr_cs_wkt_lex(YYSTYPE* pNode, osr_cs_wkt_parse_context *context); +int osr_cs_wkt_parse(osr_cs_wkt_parse_context *context); + +#ifdef __cplusplus +} +#endif + +#endif /* OSR_CS_WKT_H_INCLUDED_ */ diff --git a/modules/globebrowsing/ext/gdal/include/osr_cs_wkt_parser.h b/modules/globebrowsing/ext/gdal/include/osr_cs_wkt_parser.h new file mode 100644 index 0000000000..c4678054c1 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/osr_cs_wkt_parser.h @@ -0,0 +1,89 @@ +/* A Bison parser, made by GNU Bison 3.0. */ + +/* Bison interface for Yacc-like parsers in C + + Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +#ifndef YY_OSR_CS_WKT_OSR_CS_WKT_PARSER_H_INCLUDED +# define YY_OSR_CS_WKT_OSR_CS_WKT_PARSER_H_INCLUDED +/* Debug traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif +#if YYDEBUG +extern int osr_cs_wkt_debug; +#endif + +/* Token type. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + enum yytokentype + { + END = 0, + T_PARAM_MT = 258, + T_CONCAT_MT = 259, + T_INVERSE_MT = 260, + T_PASSTHROUGH_MT = 261, + T_PROJCS = 262, + T_PROJECTION = 263, + T_GEOGCS = 264, + T_DATUM = 265, + T_SPHEROID = 266, + T_PRIMEM = 267, + T_UNIT = 268, + T_GEOCCS = 269, + T_AUTHORITY = 270, + T_VERT_CS = 271, + T_VERT_DATUM = 272, + T_COMPD_CS = 273, + T_AXIS = 274, + T_TOWGS84 = 275, + T_FITTED_CS = 276, + T_LOCAL_CS = 277, + T_LOCAL_DATUM = 278, + T_PARAMETER = 279, + T_EXTENSION = 280, + T_STRING = 281, + T_NUMBER = 282, + T_IDENTIFIER = 283 + }; +#endif + +/* Value type. */ +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef int YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 +# define YYSTYPE_IS_DECLARED 1 +#endif + + + +int osr_cs_wkt_parse (osr_cs_wkt_parse_context *context); + +#endif /* !YY_OSR_CS_WKT_OSR_CS_WKT_PARSER_H_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/include/rawdataset.h b/modules/globebrowsing/ext/gdal/include/rawdataset.h new file mode 100644 index 0000000000..68b923ab1a --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/rawdataset.h @@ -0,0 +1,179 @@ +/****************************************************************************** + * $Id$ + * + * Project: Raw Translator + * Purpose: Implementation of RawDataset class. Intended to be subclassed + * by other raw formats. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, Frank Warmerdam + * Copyright (c) 2008-2014, Even Rouault + * + * 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. + ****************************************************************************/ + +#ifndef GDAL_FRMTS_RAW_RAWDATASET_H_INCLUDED +#define GDAL_FRMTS_RAW_RAWDATASET_H_INCLUDED + +#include "gdal_pam.h" + +/************************************************************************/ +/* ==================================================================== */ +/* RawDataset */ +/* ==================================================================== */ +/************************************************************************/ + +class RawRasterBand; + +/** + * \brief Abstract Base Class dedicated to define new raw dataset types. + */ +class CPL_DLL RawDataset : public GDALPamDataset +{ + friend class RawRasterBand; + + protected: + virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int, + void *, int, int, GDALDataType, + int, int *, + GSpacing nPixelSpace, GSpacing nLineSpace, + GSpacing nBandSpace, + GDALRasterIOExtraArg* psExtraArg ); + public: + RawDataset(); + ~RawDataset() = 0; + + private: + CPL_DISALLOW_COPY_ASSIGN(RawDataset); +}; + +/************************************************************************/ +/* ==================================================================== */ +/* RawRasterBand */ +/* ==================================================================== */ +/************************************************************************/ + +/** + * \brief Abstract Base Class dedicated to define raw datasets. + * \note It is not defined an Abstract Base Class, but it's advised to + * consider it as such and not use it directly in client's code. + */ +class CPL_DLL RawRasterBand : public GDALPamRasterBand +{ +protected: + friend class RawDataset; + + FILE *fpRaw; + VSILFILE *fpRawL; + int bIsVSIL; + + vsi_l_offset nImgOffset; + int nPixelOffset; + int nLineOffset; + int nLineSize; + int bNativeOrder; + + int nLoadedScanline; + void *pLineBuffer; + void *pLineStart; + int bDirty; + + GDALColorTable *poCT; + GDALColorInterp eInterp; + + char **papszCategoryNames; + + int bOwnsFP; + + int Seek( vsi_l_offset, int ); + size_t Read( void *, size_t, size_t ); + size_t Write( void *, size_t, size_t ); + + CPLErr AccessBlock( vsi_l_offset nBlockOff, size_t nBlockSize, + void * pData ); + int IsSignificantNumberOfLinesLoaded( int nLineOff, int nLines ); + void Initialize(); + + virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int, + void *, int, int, GDALDataType, + GSpacing nPixelSpace, GSpacing nLineSpace, + GDALRasterIOExtraArg* psExtraArg ); + + int CanUseDirectIO(int nXOff, int nYOff, int nXSize, int nYSize, + GDALDataType eBufType); + +public: + + RawRasterBand( GDALDataset *poDS, int nBand, void * fpRaw, + vsi_l_offset nImgOffset, int nPixelOffset, + int nLineOffset, + GDALDataType eDataType, int bNativeOrder, + int bIsVSIL = FALSE, int bOwnsFP = FALSE ); + + RawRasterBand( void * fpRaw, + vsi_l_offset nImgOffset, int nPixelOffset, + int nLineOffset, + GDALDataType eDataType, int bNativeOrder, + int nXSize, int nYSize, int bIsVSIL = FALSE, int bOwnsFP = FALSE ); + + ~RawRasterBand() /* = 0 */ ; + + // should override RasterIO eventually. + + virtual CPLErr IReadBlock( int, int, void * ); + virtual CPLErr IWriteBlock( int, int, void * ); + + virtual GDALColorTable *GetColorTable(); + virtual GDALColorInterp GetColorInterpretation(); + virtual CPLErr SetColorTable( GDALColorTable * ); + virtual CPLErr SetColorInterpretation( GDALColorInterp ); + + virtual char **GetCategoryNames(); + virtual CPLErr SetCategoryNames( char ** ); + + virtual CPLErr FlushCache(); + + virtual CPLVirtualMem *GetVirtualMemAuto( GDALRWFlag eRWFlag, + int *pnPixelSpace, + GIntBig *pnLineSpace, + char **papszOptions ); + + CPLErr AccessLine( int iLine ); + + void SetAccess( GDALAccess eAccess ); + + // this is deprecated. + void StoreNoDataValue( double ); + + // Query methods for internal data. + vsi_l_offset GetImgOffset() { return nImgOffset; } + int GetPixelOffset() { return nPixelOffset; } + int GetLineOffset() { return nLineOffset; } + int GetNativeOrder() { return bNativeOrder; } + int GetIsVSIL() { return bIsVSIL; } + FILE *GetFP() { return (bIsVSIL) ? reinterpret_cast( fpRawL ) : fpRaw; } + VSILFILE *GetFPL() { CPLAssert(bIsVSIL); return fpRawL; } + int GetOwnsFP() { return bOwnsFP; } + + private: + CPL_DISALLOW_COPY_ASSIGN(RawRasterBand); +}; + +#endif // GDAL_FRMTS_RAW_RAWDATASET_H_INCLUDED diff --git a/modules/globebrowsing/ext/gdal/include/swq.h b/modules/globebrowsing/ext/gdal/include/swq.h new file mode 100644 index 0000000000..e95486594a --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/swq.h @@ -0,0 +1,389 @@ +/****************************************************************************** + * + * Component: OGDI Driver Support Library + * Purpose: Generic SQL WHERE Expression Evaluator Declarations. + * Author: Frank Warmerdam + * + ****************************************************************************** + * Copyright (C) 2001 Information Interoperability Institute (3i) + * Copyright (c) 2010-2013, Even Rouault + * Permission to use, copy, modify and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appear in all copies, that + * both the copyright notice and this permission notice appear in + * supporting documentation, and that the name of 3i not be used + * in advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. 3i makes no + * representations about the suitability of this software for any purpose. + * It is provided "as is" without express or implied warranty. + ****************************************************************************/ + +#ifndef SWQ_H_INCLUDED_ +#define SWQ_H_INCLUDED_ + +#include "cpl_conv.h" +#include "cpl_string.h" +#include "ogr_core.h" + +#if defined(_WIN32) && !defined(strcasecmp) +# define strcasecmp stricmp +#endif + +typedef enum { + SWQ_OR, + SWQ_AND, + SWQ_NOT, + SWQ_EQ, + SWQ_NE, + SWQ_GE, + SWQ_LE, + SWQ_LT, + SWQ_GT, + SWQ_LIKE, + SWQ_ISNULL, + SWQ_IN, + SWQ_BETWEEN, + SWQ_ADD, + SWQ_SUBTRACT, + SWQ_MULTIPLY, + SWQ_DIVIDE, + SWQ_MODULUS, + SWQ_CONCAT, + SWQ_SUBSTR, + SWQ_HSTORE_GET_VALUE, + SWQ_AVG, + SWQ_MIN, + SWQ_MAX, + SWQ_COUNT, + SWQ_SUM, + SWQ_CAST, + SWQ_CUSTOM_FUNC, /* only if parsing done in bAcceptCustomFuncs mode */ + SWQ_ARGUMENT_LIST /* temporary value only set during parsing and replaced by something else at the end */ +} swq_op; + +typedef enum { + SWQ_INTEGER, + SWQ_INTEGER64, + SWQ_FLOAT, + SWQ_STRING, + SWQ_BOOLEAN, // integer + SWQ_DATE, // string + SWQ_TIME, // string + SWQ_TIMESTAMP,// string + SWQ_GEOMETRY, + SWQ_NULL, + SWQ_OTHER, + SWQ_ERROR +} swq_field_type; + +#define SWQ_IS_INTEGER(x) ((x) == SWQ_INTEGER || (x) == SWQ_INTEGER64) + +typedef enum { + SNT_CONSTANT, + SNT_COLUMN, + SNT_OPERATION +} swq_node_type; + + +class swq_field_list; +class swq_expr_node; +class swq_select; +class OGRGeometry; + +typedef swq_expr_node *(*swq_field_fetcher)( swq_expr_node *op, + void *record_handle ); +typedef swq_expr_node *(*swq_op_evaluator)(swq_expr_node *op, + swq_expr_node **sub_field_values ); +typedef swq_field_type (*swq_op_checker)( swq_expr_node *op, + int bAllowMismatchTypeOnFieldComparison ); + +class swq_custom_func_registrar; + +class swq_expr_node { +public: + swq_expr_node(); + + explicit swq_expr_node( const char * ); + explicit swq_expr_node( int ); + explicit swq_expr_node( GIntBig ); + explicit swq_expr_node( double ); + explicit swq_expr_node( OGRGeometry* ); + explicit swq_expr_node( swq_op ); + + ~swq_expr_node(); + + void Initialize(); + CPLString UnparseOperationFromUnparsedSubExpr(char** apszSubExpr); + char *Unparse( swq_field_list *, char chColumnQuote ); + void Dump( FILE *fp, int depth ); + swq_field_type Check( swq_field_list *, int bAllowFieldsInSecondaryTables, + int bAllowMismatchTypeOnFieldComparison, + swq_custom_func_registrar* poCustomFuncRegistrar ); + swq_expr_node* Evaluate( swq_field_fetcher pfnFetcher, + void *record ); + swq_expr_node* Clone(); + + void ReplaceBetweenByGEAndLERecurse(); + + swq_node_type eNodeType; + swq_field_type field_type; + + /* only for SNT_OPERATION */ + void PushSubExpression( swq_expr_node * ); + void ReverseSubExpressions(); + int nOperation; + int nSubExprCount; + swq_expr_node **papoSubExpr; + + /* only for SNT_COLUMN */ + int field_index; + int table_index; + char *table_name; + + /* only for SNT_CONSTANT */ + int is_null; + GIntBig int_value; + double float_value; + OGRGeometry *geometry_value; + + /* shared by SNT_COLUMN, SNT_CONSTANT and also possibly SNT_OPERATION when */ + /* nOperation == SWQ_CUSTOM_FUNC */ + char *string_value; /* column name when SNT_COLUMN */ + + static CPLString QuoteIfNecessary( const CPLString &, char chQuote = '\'' ); + static CPLString Quote( const CPLString &, char chQuote = '\'' ); +}; + +typedef struct { + const char* pszName; + swq_op eOperation; + swq_op_evaluator pfnEvaluator; + swq_op_checker pfnChecker; +} swq_operation; + +class swq_op_registrar { +public: + static const swq_operation *GetOperator( const char * ); + static const swq_operation *GetOperator( swq_op eOperation ); +}; + +class swq_custom_func_registrar +{ + public: + virtual ~swq_custom_func_registrar() {} + virtual const swq_operation *GetOperator( const char * ) = 0; +}; + + +typedef struct { + char *data_source; + char *table_name; + char *table_alias; +} swq_table_def; + +class swq_field_list { +public: + int count; + char **names; + swq_field_type *types; + int *table_ids; + int *ids; + + int table_count; + swq_table_def *table_defs; +}; + +class swq_parse_context { +public: + swq_parse_context() : nStartToken(0), pszInput(NULL), pszNext(NULL), + pszLastValid(NULL), bAcceptCustomFuncs(FALSE), + poRoot(NULL), poCurSelect(NULL) {} + + int nStartToken; + const char *pszInput; + const char *pszNext; + const char *pszLastValid; + int bAcceptCustomFuncs; + + swq_expr_node *poRoot; + + swq_select *poCurSelect; +}; + +/* Compile an SQL WHERE clause into an internal form. The field_list is +** the list of fields in the target 'table', used to render where into +** field numbers instead of names. +*/ +int swqparse( swq_parse_context *context ); +int swqlex( swq_expr_node **ppNode, swq_parse_context *context ); +void swqerror( swq_parse_context *context, const char *msg ); + +int swq_identify_field( const char* table_name, + const char *token, swq_field_list *field_list, + swq_field_type *this_type, int *table_id ); + +CPLErr swq_expr_compile( const char *where_clause, + int field_count, + char **field_list, + swq_field_type *field_types, + int bCheck, + swq_custom_func_registrar* poCustomFuncRegistrar, + swq_expr_node **expr_root ); + +CPLErr swq_expr_compile2( const char *where_clause, + swq_field_list *field_list, + int bCheck, + swq_custom_func_registrar* poCustomFuncRegistrar, + swq_expr_node **expr_root ); + +/* +** Evaluation related. +*/ +int swq_test_like( const char *input, const char *pattern ); + +swq_expr_node *SWQGeneralEvaluator( swq_expr_node *, swq_expr_node **); +swq_field_type SWQGeneralChecker( swq_expr_node *node, int bAllowMismatchTypeOnFieldComparison ); +swq_expr_node *SWQCastEvaluator( swq_expr_node *, swq_expr_node **); +swq_field_type SWQCastChecker( swq_expr_node *node, int bAllowMismatchTypeOnFieldComparison ); +const char* SWQFieldTypeToString( swq_field_type field_type ); + +/****************************************************************************/ + +#define SWQP_ALLOW_UNDEFINED_COL_FUNCS 0x01 + +#define SWQM_SUMMARY_RECORD 1 +#define SWQM_RECORDSET 2 +#define SWQM_DISTINCT_LIST 3 + +typedef enum { + SWQCF_NONE = 0, + SWQCF_AVG = SWQ_AVG, + SWQCF_MIN = SWQ_MIN, + SWQCF_MAX = SWQ_MAX, + SWQCF_COUNT = SWQ_COUNT, + SWQCF_SUM = SWQ_SUM, + SWQCF_CUSTOM +} swq_col_func; + +typedef struct { + swq_col_func col_func; + char *table_name; + char *field_name; + char *field_alias; + int table_index; + int field_index; + swq_field_type field_type; + swq_field_type target_type; + OGRFieldSubType target_subtype; + int field_length; + int field_precision; + int distinct_flag; + OGRwkbGeometryType eGeomType; + int nSRID; + swq_expr_node *expr; +} swq_col_def; + +typedef struct { + GIntBig count; + + char **distinct_list; /* items of the list can be NULL */ + double sum; + double min; + double max; + char szMin[32]; + char szMax[32]; +} swq_summary; + +typedef struct { + char *table_name; + char *field_name; + int table_index; + int field_index; + int ascending_flag; +} swq_order_def; + +typedef struct { + int secondary_table; + swq_expr_node *poExpr; +} swq_join_def; + +class swq_select_parse_options +{ +public: + swq_custom_func_registrar* poCustomFuncRegistrar; + int bAllowFieldsInSecondaryTablesInWhere; + int bAddSecondaryTablesGeometryFields; + int bAlwaysPrefixWithTableName; + int bAllowDistinctOnGeometryField; + int bAllowDistinctOnMultipleFields; + + swq_select_parse_options(): poCustomFuncRegistrar(NULL), + bAllowFieldsInSecondaryTablesInWhere(FALSE), + bAddSecondaryTablesGeometryFields(FALSE), + bAlwaysPrefixWithTableName(FALSE), + bAllowDistinctOnGeometryField(FALSE), + bAllowDistinctOnMultipleFields(FALSE) {} +}; + +class swq_select +{ + void postpreparse(); + +public: + swq_select(); + ~swq_select(); + + int query_mode; + + char *raw_select; + + int PushField( swq_expr_node *poExpr, const char *pszAlias=NULL, + int distinct_flag = FALSE ); + int result_columns; + swq_col_def *column_defs; + swq_summary *column_summary; + + int PushTableDef( const char *pszDataSource, + const char *pszTableName, + const char *pszAlias ); + int table_count; + swq_table_def *table_defs; + + void PushJoin( int iSecondaryTable, swq_expr_node* poExpr ); + int join_count; + swq_join_def *join_defs; + + swq_expr_node *where_expr; + + void PushOrderBy( const char* pszTableName, const char *pszFieldName, int bAscending ); + int order_specs; + swq_order_def *order_defs; + + swq_select *poOtherSelect; + void PushUnionAll( swq_select* poOtherSelectIn ); + + CPLErr preparse( const char *select_statement, + int bAcceptCustomFuncs = FALSE ); + CPLErr expand_wildcard( swq_field_list *field_list, + int bAlwaysPrefixWithTableName ); + CPLErr parse( swq_field_list *field_list, + swq_select_parse_options* poParseOptions ); + + char *Unparse(); + void Dump( FILE * ); +}; + +CPLErr swq_select_parse( swq_select *select_info, + swq_field_list *field_list, + int parse_flags ); + +const char *swq_select_finish_summarize( swq_select *select_info ); +const char *swq_select_summarize( swq_select *select_info, + int dest_column, + const char *value ); + +int swq_is_reserved_keyword(const char* pszStr); + +char* OGRHStoreGetValue(const char* pszHStore, const char* pszSearchedKey); + +#endif /* def SWQ_H_INCLUDED_ */ diff --git a/modules/globebrowsing/ext/gdal/include/thinplatespline.h b/modules/globebrowsing/ext/gdal/include/thinplatespline.h new file mode 100644 index 0000000000..a597c4f9c4 --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/thinplatespline.h @@ -0,0 +1,188 @@ +/****************************************************************************** + * $Id$ + * + * Project: GDAL Warp API + * Purpose: Declarations for 2D Thin Plate Spline transformer. + * Author: VIZRT Development Team. + * + * This code was provided by Gilad Ronnen (gro at visrt dot com) with + * permission to reuse under the following license. + * + ****************************************************************************** + * Copyright (c) 2004, VIZRT Inc. + * + * 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. + ****************************************************************************/ + +#include "gdal_alg.h" +#include "cpl_conv.h" + +typedef enum +{ + VIZ_GEOREF_SPLINE_ZERO_POINTS, + VIZ_GEOREF_SPLINE_ONE_POINT, + VIZ_GEOREF_SPLINE_TWO_POINTS, + VIZ_GEOREF_SPLINE_ONE_DIMENSIONAL, + VIZ_GEOREF_SPLINE_FULL, + + VIZ_GEOREF_SPLINE_POINT_WAS_ADDED, + VIZ_GEOREF_SPLINE_POINT_WAS_DELETED + +} vizGeorefInterType; + +//#define VIZ_GEOREF_SPLINE_MAX_POINTS 40 +#define VIZGEOREF_MAX_VARS 2 + +class VizGeorefSpline2D +{ + bool grow_points(); + + public: + + VizGeorefSpline2D(int nof_vars = 1) : + type(VIZ_GEOREF_SPLINE_ZERO_POINTS), + _nof_vars(nof_vars), + _nof_points(0), + _max_nof_points(0), + _nof_eqs(0), +#if 0 + _tx(0.0), + _ty(0.0), + _ta(10.0), +#endif + _dx(0.0), + _dy(0.0), + x(NULL), + y(NULL), + u(NULL), + unused(NULL), + index(NULL) + { + for( int i = 0; i < VIZGEOREF_MAX_VARS; i++ ) + { + rhs[i] = NULL; + coef[i] = NULL; + } + + grow_points(); + } + + ~VizGeorefSpline2D() { + CPLFree( x ); + CPLFree( y ); + CPLFree( u ); + CPLFree( unused ); + CPLFree( index ); + for( int i = 0; i < _nof_vars; i++ ) + { + CPLFree( rhs[i] ); + CPLFree( coef[i] ); + } + } + +#if 0 + int get_nof_points(){ + return _nof_points; + } + + void set_toler( double tx, double ty ){ + _tx = tx; + _ty = ty; + } + + void get_toler( double& tx, double& ty) { + tx = _tx; + ty = _ty; + } + + vizGeorefInterType get_interpolation_type ( ){ + return type; + } + + void dump_data_points() + { + for ( int i = 0; i < _nof_points; i++ ) + { + fprintf(stderr, "X = %f Y = %f Vars = ", x[i], y[i]); + for ( int v = 0; v < _nof_vars; v++ ) + fprintf(stderr, "%f ", rhs[v][i+3]); + fprintf(stderr, "\n"); + } + } + + int delete_list() + { + _nof_points = 0; + type = VIZ_GEOREF_SPLINE_ZERO_POINTS; + if ( _AA ) + { + CPLFree(_AA); + _AA = NULL; + } + if ( _Ainv ) + { + CPLFree(_Ainv); + _Ainv = NULL; + } + return _nof_points; + } +#endif + + bool add_point( const double Px, const double Py, const double *Pvars ); + int get_point( const double Px, const double Py, double *Pvars ); +#if 0 + int delete_point(const double Px, const double Py ); + bool get_xy(int index, double& x, double& y); + bool change_point(int index, double x, double y, double* Pvars); + void reset(void) { _nof_points = 0; } +#endif + int solve(void); + + private: + + vizGeorefInterType type; + + const int _nof_vars; + int _nof_points; + int _max_nof_points; + int _nof_eqs; + +#if 0 + // Disabled because the methods that use there is disabled. + double _tx, _ty; + double _ta; +#endif + + double _dx, _dy; + + double *x; // [VIZ_GEOREF_SPLINE_MAX_POINTS+3]; + double *y; // [VIZ_GEOREF_SPLINE_MAX_POINTS+3]; + +// double rhs[VIZ_GEOREF_SPLINE_MAX_POINTS+3][VIZGEOREF_MAX_VARS]; +// double coef[VIZ_GEOREF_SPLINE_MAX_POINTS+3][VIZGEOREF_MAX_VARS]; + double *rhs[VIZGEOREF_MAX_VARS]; + double *coef[VIZGEOREF_MAX_VARS]; + + double *u; // [VIZ_GEOREF_SPLINE_MAX_POINTS]; + int *unused; // [VIZ_GEOREF_SPLINE_MAX_POINTS]; + int *index; // [VIZ_GEOREF_SPLINE_MAX_POINTS]; + + private: + CPL_DISALLOW_COPY_ASSIGN(VizGeorefSpline2D); +}; diff --git a/modules/globebrowsing/ext/gdal/include/vrtdataset.h b/modules/globebrowsing/ext/gdal/include/vrtdataset.h new file mode 100644 index 0000000000..44417ab94b --- /dev/null +++ b/modules/globebrowsing/ext/gdal/include/vrtdataset.h @@ -0,0 +1,1052 @@ +/****************************************************************************** + * $Id$ + * + * Project: Virtual GDAL Datasets + * Purpose: Declaration of virtual gdal dataset classes. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2001, Frank Warmerdam + * Copyright (c) 2007-2013, Even Rouault + * + * 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. + ****************************************************************************/ + +#ifndef VIRTUALDATASET_H_INCLUDED +#define VIRTUALDATASET_H_INCLUDED + +#include "cpl_hash_set.h" +#include "gdal_pam.h" +#include "gdal_priv.h" +#include "gdal_vrt.h" + +#include +#include + +int VRTApplyMetadata( CPLXMLNode *, GDALMajorObject * ); +CPLXMLNode *VRTSerializeMetadata( GDALMajorObject * ); + +#if 0 +int VRTWarpedOverviewTransform( void *pTransformArg, int bDstToSrc, + int nPointCount, + double *padfX, double *padfY, double *padfZ, + int *panSuccess ); +void* VRTDeserializeWarpedOverviewTransformer( CPLXMLNode *psTree ); +#endif + +/************************************************************************/ +/* VRTOverviewInfo() */ +/************************************************************************/ +class VRTOverviewInfo +{ +public: + CPLString osFilename; + int nBand; + GDALRasterBand *poBand; + int bTriedToOpen; + + VRTOverviewInfo() : nBand(0), poBand(NULL), bTriedToOpen(FALSE) {} + ~VRTOverviewInfo() { + if( poBand == NULL ) + /* do nothing */; + else if( poBand->GetDataset()->GetShared() ) + GDALClose( /* (GDALDatasetH) */ poBand->GetDataset() ); + else + poBand->GetDataset()->Dereference(); + } +}; + + +/************************************************************************/ +/* VRTSource */ +/************************************************************************/ + +class CPL_DLL VRTSource +{ +public: + virtual ~VRTSource(); + + virtual CPLErr RasterIO( int nXOff, int nYOff, int nXSize, int nYSize, + void *pData, int nBufXSize, int nBufYSize, + GDALDataType eBufType, + GSpacing nPixelSpace, GSpacing nLineSpace, + GDALRasterIOExtraArg* psExtraArg ) = 0; + + virtual double GetMinimum( int nXSize, int nYSize, int *pbSuccess ) = 0; + virtual double GetMaximum( int nXSize, int nYSize, int *pbSuccess ) = 0; + virtual CPLErr ComputeRasterMinMax( int nXSize, int nYSize, int bApproxOK, + double* adfMinMax ) = 0; + virtual CPLErr ComputeStatistics( int nXSize, int nYSize, + int bApproxOK, + double *pdfMin, double *pdfMax, + double *pdfMean, double *pdfStdDev, + GDALProgressFunc pfnProgress, + void *pProgressData ) = 0; + virtual CPLErr GetHistogram( int nXSize, int nYSize, + double dfMin, double dfMax, + int nBuckets, GUIntBig * panHistogram, + int bIncludeOutOfRange, int bApproxOK, + GDALProgressFunc pfnProgress, + void *pProgressData ) = 0; + + virtual CPLErr XMLInit( CPLXMLNode *psTree, const char * ) = 0; + virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath ) = 0; + + virtual void GetFileList(char*** ppapszFileList, int *pnSize, + int *pnMaxSize, CPLHashSet* hSetFiles); + + virtual int IsSimpleSource() { return FALSE; } +}; + +typedef VRTSource *(*VRTSourceParser)(CPLXMLNode *, const char *); + +VRTSource *VRTParseCoreSources( CPLXMLNode *psTree, const char * ); +VRTSource *VRTParseFilterSources( CPLXMLNode *psTree, const char * ); + +/************************************************************************/ +/* VRTDataset */ +/************************************************************************/ + +class VRTRasterBand; + +class CPL_DLL VRTDataset : public GDALDataset +{ + friend class VRTRasterBand; + + char *m_pszProjection; + + int m_bGeoTransformSet; + double m_adfGeoTransform[6]; + + int m_nGCPCount; + GDAL_GCP *m_pasGCPList; + char *m_pszGCPProjection; + + int m_bNeedsFlush; + int m_bWritable; + + char *m_pszVRTPath; + + VRTRasterBand *m_poMaskBand; + + int m_bCompatibleForDatasetIO; + int CheckCompatibleForDatasetIO(); + std::vector m_apoOverviews; + std::vector m_apoOverviewsBak; + + protected: + virtual int CloseDependentDatasets(); + + public: + VRTDataset(int nXSize, int nYSize); + virtual ~VRTDataset(); + + void SetNeedsFlush() { m_bNeedsFlush = TRUE; } + virtual void FlushCache(); + + void SetWritable(int bWritableIn) { m_bWritable = bWritableIn; } + + virtual CPLErr CreateMaskBand( int nFlags ); + void SetMaskBand(VRTRasterBand* poMaskBand); + + virtual const char *GetProjectionRef(void); + virtual CPLErr SetProjection( const char * ); + virtual CPLErr GetGeoTransform( double * ); + virtual CPLErr SetGeoTransform( double * ); + + virtual CPLErr SetMetadata( char **papszMD, const char *pszDomain = "" ); + virtual CPLErr SetMetadataItem( const char *pszName, const char *pszValue, + const char *pszDomain = "" ); + + virtual char** GetMetadata( const char *pszDomain = "" ); + + virtual int GetGCPCount(); + virtual const char *GetGCPProjection(); + virtual const GDAL_GCP *GetGCPs(); + virtual CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList, + const char *pszGCPProjection ); + + virtual CPLErr AddBand( GDALDataType eType, + char **papszOptions=NULL ); + + virtual char **GetFileList(); + + virtual CPLErr IRasterIO( GDALRWFlag eRWFlag, + int nXOff, int nYOff, int nXSize, int nYSize, + void * pData, int nBufXSize, int nBufYSize, + GDALDataType eBufType, + int nBandCount, int *panBandMap, + GSpacing nPixelSpace, GSpacing nLineSpace, + GSpacing nBandSpace, + GDALRasterIOExtraArg* psExtraArg); + + virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath); + virtual CPLErr XMLInit( CPLXMLNode *, const char * ); + + virtual CPLErr IBuildOverviews( const char *, int, int *, + int, int *, GDALProgressFunc, void * ); + + /* Used by PDF driver for example */ + GDALDataset* GetSingleSimpleSource(); + void BuildVirtualOverviews(); + + void UnsetPreservedRelativeFilenames(); + + static int Identify( GDALOpenInfo * ); + static GDALDataset *Open( GDALOpenInfo * ); + static GDALDataset *OpenXML( const char *, const char * = NULL, + GDALAccess eAccess = GA_ReadOnly ); + static GDALDataset *Create( const char * pszName, + int nXSize, int nYSize, int nBands, + GDALDataType eType, char ** papszOptions ); + static CPLErr Delete( const char * pszFilename ); +}; + +/************************************************************************/ +/* VRTWarpedDataset */ +/************************************************************************/ + +class GDALWarpOperation; +class VRTWarpedRasterBand; + +class CPL_DLL VRTWarpedDataset : public VRTDataset +{ + int m_nBlockXSize; + int m_nBlockYSize; + GDALWarpOperation *m_poWarper; + + int m_nOverviewCount; + VRTWarpedDataset **m_papoOverviews; + int m_nSrcOvrLevel; + + void CreateImplicitOverviews(); + + friend class VRTWarpedRasterBand; + + protected: + virtual int CloseDependentDatasets(); + +public: + VRTWarpedDataset( int nXSize, int nYSize ); + virtual ~VRTWarpedDataset(); + + CPLErr Initialize( /* GDALWarpOptions */ void * ); + + virtual CPLErr IBuildOverviews( const char *, int, int *, + int, int *, GDALProgressFunc, void * ); + + virtual CPLErr SetMetadataItem( const char *pszName, const char *pszValue, + const char *pszDomain = "" ); + + virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath ); + virtual CPLErr XMLInit( CPLXMLNode *, const char * ); + + virtual CPLErr AddBand( GDALDataType eType, + char **papszOptions=NULL ); + + virtual char **GetFileList(); + + CPLErr ProcessBlock( int iBlockX, int iBlockY ); + + void GetBlockSize( int *, int * ); +}; + +/************************************************************************/ +/* VRTPansharpenedDataset */ +/************************************************************************/ + +class GDALPansharpenOperation; + +typedef enum +{ + GTAdjust_Union, + GTAdjust_Intersection, + GTAdjust_None, + GTAdjust_NoneWithoutWarning +} GTAdjustment; + +class VRTPansharpenedDataset : public VRTDataset +{ + friend class VRTPansharpenedRasterBand; + + int m_nBlockXSize; + int m_nBlockYSize; + GDALPansharpenOperation* m_poPansharpener; + VRTPansharpenedDataset* m_poMainDataset; + std::vector m_apoOverviewDatasets; + // Map from absolute to relative. + std::map m_oMapToRelativeFilenames; + + int m_bLoadingOtherBands; + + GByte *m_pabyLastBufferBandRasterIO; + int m_nLastBandRasterIOXOff; + int m_nLastBandRasterIOYOff; + int m_nLastBandRasterIOXSize; + int m_nLastBandRasterIOYSize; + GDALDataType m_eLastBandRasterIODataType; + + GTAdjustment m_eGTAdjustment; + int m_bNoDataDisabled; + + std::vector m_apoDatasetsToClose; + + protected: + virtual int CloseDependentDatasets(); + +public: + VRTPansharpenedDataset( int nXSize, int nYSize ); + virtual ~VRTPansharpenedDataset(); + + virtual CPLErr XMLInit( CPLXMLNode *, const char * ); + virtual CPLXMLNode * SerializeToXML( const char *pszVRTPath ); + + CPLErr XMLInit( CPLXMLNode *psTree, const char *pszVRTPath, + GDALRasterBandH hPanchroBandIn, + int nInputSpectralBandsIn, + GDALRasterBandH* pahInputSpectralBandsIn ); + + virtual CPLErr AddBand( GDALDataType eType, + char **papszOptions=NULL ); + + virtual char **GetFileList(); + + virtual CPLErr IRasterIO( GDALRWFlag eRWFlag, + int nXOff, int nYOff, int nXSize, int nYSize, + void * pData, int nBufXSize, int nBufYSize, + GDALDataType eBufType, + int nBandCount, int *panBandMap, + GSpacing nPixelSpace, GSpacing nLineSpace, + GSpacing nBandSpace, + GDALRasterIOExtraArg* psExtraArg); + + void GetBlockSize( int *, int * ); + + GDALPansharpenOperation* GetPansharpener() { return m_poPansharpener; } +}; + +/************************************************************************/ +/* VRTRasterBand */ +/* */ +/* Provides support for all the various kinds of metadata but */ +/* no raster access. That is handled by derived classes. */ +/************************************************************************/ + +class CPL_DLL VRTRasterBand : public GDALRasterBand +{ + protected: + int m_bIsMaskBand; + + int m_bNoDataValueSet; + // If set to true, will not report the existence of nodata. + int m_bHideNoDataValue; + double m_dfNoDataValue; + + GDALColorTable *m_poColorTable; + + GDALColorInterp m_eColorInterp; + + char *m_pszUnitType; + char **m_papszCategoryNames; + + double m_dfOffset; + double m_dfScale; + + CPLXMLNode *m_psSavedHistograms; + + void Initialize( int nXSize, int nYSize ); + + std::vector m_apoOverviews; + + VRTRasterBand *m_poMaskBand; + + public: + + VRTRasterBand(); + virtual ~VRTRasterBand(); + + virtual CPLErr XMLInit( CPLXMLNode *, const char * ); + virtual CPLXMLNode * SerializeToXML( const char *pszVRTPath ); + + virtual CPLErr SetNoDataValue( double ); + virtual double GetNoDataValue( int *pbSuccess = NULL ); + virtual CPLErr DeleteNoDataValue(); + + virtual CPLErr SetColorTable( GDALColorTable * ); + virtual GDALColorTable *GetColorTable(); + + virtual CPLErr SetColorInterpretation( GDALColorInterp ); + virtual GDALColorInterp GetColorInterpretation(); + + virtual const char *GetUnitType(); + CPLErr SetUnitType( const char * ); + + virtual char **GetCategoryNames(); + virtual CPLErr SetCategoryNames( char ** ); + + virtual CPLErr SetMetadata( char **papszMD, const char *pszDomain = "" ); + virtual CPLErr SetMetadataItem( const char *pszName, const char *pszValue, + const char *pszDomain = "" ); + + virtual double GetOffset( int *pbSuccess = NULL ); + CPLErr SetOffset( double ); + virtual double GetScale( int *pbSuccess = NULL ); + CPLErr SetScale( double ); + + virtual int GetOverviewCount(); + virtual GDALRasterBand *GetOverview(int); + + virtual CPLErr GetHistogram( double dfMin, double dfMax, + int nBuckets, GUIntBig * panHistogram, + int bIncludeOutOfRange, int bApproxOK, + GDALProgressFunc, void *pProgressData ); + + virtual CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax, + int *pnBuckets, GUIntBig ** ppanHistogram, + int bForce, + GDALProgressFunc, void *pProgressData); + + virtual CPLErr SetDefaultHistogram( double dfMin, double dfMax, + int nBuckets, GUIntBig *panHistogram ); + + CPLErr CopyCommonInfoFrom( GDALRasterBand * ); + + virtual void GetFileList(char*** ppapszFileList, int *pnSize, + int *pnMaxSize, CPLHashSet* hSetFiles); + + virtual void SetDescription( const char * ); + + virtual GDALRasterBand *GetMaskBand(); + virtual int GetMaskFlags(); + + virtual CPLErr CreateMaskBand( int nFlags ); + + void SetMaskBand(VRTRasterBand* poMaskBand); + + void SetIsMaskBand(); + + CPLErr UnsetNoDataValue(); + + virtual int CloseDependentDatasets(); + + virtual int IsSourcedRasterBand() { return FALSE; } + virtual int IsPansharpenRasterBand() { return FALSE; } +}; + +/************************************************************************/ +/* VRTSourcedRasterBand */ +/************************************************************************/ + +class VRTSimpleSource; + +class CPL_DLL VRTSourcedRasterBand : public VRTRasterBand +{ + private: + int m_nRecursionCounter; + CPLString m_osLastLocationInfo; + char **m_papszSourceList; + + bool CanUseSourcesMinMaxImplementations(); + + public: + int nSources; + VRTSource **papoSources; + int bEqualAreas; + + VRTSourcedRasterBand( GDALDataset *poDS, int nBand ); + VRTSourcedRasterBand( GDALDataType eType, + int nXSize, int nYSize ); + VRTSourcedRasterBand( GDALDataset *poDS, int nBand, + GDALDataType eType, + int nXSize, int nYSize ); + virtual ~VRTSourcedRasterBand(); + + virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int, + void *, int, int, GDALDataType, + GSpacing nPixelSpace, GSpacing nLineSpace, + GDALRasterIOExtraArg* psExtraArg); + + virtual char **GetMetadataDomainList(); + virtual const char *GetMetadataItem( const char * pszName, + const char * pszDomain = "" ); + virtual char **GetMetadata( const char * pszDomain = "" ); + virtual CPLErr SetMetadata( char ** papszMetadata, + const char * pszDomain = "" ); + virtual CPLErr SetMetadataItem( const char * pszName, + const char * pszValue, + const char * pszDomain = "" ); + + virtual CPLErr XMLInit( CPLXMLNode *, const char * ); + virtual CPLXMLNode * SerializeToXML( const char *pszVRTPath ); + + virtual double GetMinimum( int *pbSuccess = NULL ); + virtual double GetMaximum(int *pbSuccess = NULL ); + virtual CPLErr ComputeRasterMinMax( int bApproxOK, double* adfMinMax ); + virtual CPLErr ComputeStatistics( int bApproxOK, + double *pdfMin, double *pdfMax, + double *pdfMean, double *pdfStdDev, + GDALProgressFunc pfnProgress, + void *pProgressData ); + virtual CPLErr GetHistogram( double dfMin, double dfMax, + int nBuckets, GUIntBig * panHistogram, + int bIncludeOutOfRange, int bApproxOK, + GDALProgressFunc pfnProgress, + void *pProgressData ); + + CPLErr AddSource( VRTSource * ); + CPLErr AddSimpleSource( GDALRasterBand *poSrcBand, + double dfSrcXOff=-1, double dfSrcYOff=-1, + double dfSrcXSize=-1, double dfSrcYSize=-1, + double dfDstXOff=-1, double dfDstYOff=-1, + double dfDstXSize=-1, double dfDstYSize=-1, + const char *pszResampling = "near", + double dfNoDataValue = VRT_NODATA_UNSET); + CPLErr AddComplexSource( GDALRasterBand *poSrcBand, + double dfSrcXOff=-1, double dfSrcYOff=-1, + double dfSrcXSize=-1, double dfSrcYSize=-1, + double dfDstXOff=-1, double dfDstYOff=-1, + double dfDstXSize=-1, double dfDstYSize=-1, + double dfScaleOff=0.0, + double dfScaleRatio=1.0, + double dfNoDataValue = VRT_NODATA_UNSET, + int nColorTableComponent = 0); + + CPLErr AddMaskBandSource( GDALRasterBand *poSrcBand, + double dfSrcXOff=-1, double dfSrcYOff=-1, + double dfSrcXSize=-1, + double dfSrcYSize=-1, + double dfDstXOff=-1, double dfDstYOff=-1, + double dfDstXSize=-1, + double dfDstYSize=-1 ); + + CPLErr AddFuncSource( VRTImageReadFunc pfnReadFunc, void *hCBData, + double dfNoDataValue = VRT_NODATA_UNSET ); + + void ConfigureSource(VRTSimpleSource *poSimpleSource, + GDALRasterBand *poSrcBand, + int bAddAsMaskBand, + double dfSrcXOff, double dfSrcYOff, + double dfSrcXSize, double dfSrcYSize, + double dfDstXOff, double dfDstYOff, + double dfDstXSize, double dfDstYSize ); + + virtual CPLErr IReadBlock( int, int, void * ); + + virtual void GetFileList(char*** ppapszFileList, int *pnSize, + int *pnMaxSize, CPLHashSet* hSetFiles); + + virtual int CloseDependentDatasets(); + + virtual int IsSourcedRasterBand() { return TRUE; } +}; + +/************************************************************************/ +/* VRTWarpedRasterBand */ +/************************************************************************/ + +class CPL_DLL VRTWarpedRasterBand : public VRTRasterBand +{ + public: + VRTWarpedRasterBand( GDALDataset *poDS, int nBand, + GDALDataType eType = GDT_Unknown ); + virtual ~VRTWarpedRasterBand(); + + virtual CPLErr XMLInit( CPLXMLNode *, const char * ); + virtual CPLXMLNode * SerializeToXML( const char *pszVRTPath ); + + virtual CPLErr IReadBlock( int, int, void * ); + virtual CPLErr IWriteBlock( int, int, void * ); + + virtual int GetOverviewCount(); + virtual GDALRasterBand *GetOverview(int); +}; +/************************************************************************/ +/* VRTPansharpenedRasterBand */ +/************************************************************************/ + +class VRTPansharpenedRasterBand : public VRTRasterBand +{ + int m_nIndexAsPansharpenedBand; + + public: + VRTPansharpenedRasterBand( + GDALDataset *poDS, int nBand, + GDALDataType eDataType = GDT_Unknown ); + virtual ~VRTPansharpenedRasterBand(); + + virtual CPLErr XMLInit( CPLXMLNode *, const char * ); + virtual CPLXMLNode * SerializeToXML( const char *pszVRTPath ); + + virtual CPLErr IReadBlock( int, int, void * ); + + virtual CPLErr IRasterIO( GDALRWFlag eRWFlag, + int nXOff, int nYOff, int nXSize, int nYSize, + void * pData, int nBufXSize, int nBufYSize, + GDALDataType eBufType, + GSpacing nPixelSpace, GSpacing nLineSpace, + GDALRasterIOExtraArg* psExtraArg); + + virtual int GetOverviewCount(); + virtual GDALRasterBand *GetOverview(int); + + virtual int IsPansharpenRasterBand() { return TRUE; } + + void SetIndexAsPansharpenedBand( int nIdx ) + { m_nIndexAsPansharpenedBand = nIdx; } + int GetIndexAsPansharpenedBand() const + { return m_nIndexAsPansharpenedBand; } +}; + +/************************************************************************/ +/* VRTDerivedRasterBand */ +/************************************************************************/ + +class CPL_DLL VRTDerivedRasterBand : public VRTSourcedRasterBand +{ + public: + char *pszFuncName; + GDALDataType eSourceTransferType; + + VRTDerivedRasterBand( GDALDataset *poDS, int nBand ); + VRTDerivedRasterBand( GDALDataset *poDS, int nBand, + GDALDataType eType, int nXSize, int nYSize ); + virtual ~VRTDerivedRasterBand(); + + virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int, + void *, int, int, GDALDataType, + GSpacing nPixelSpace, GSpacing nLineSpace, + GDALRasterIOExtraArg* psExtraArg ); + + static CPLErr AddPixelFunction( const char *pszFuncName, + GDALDerivedPixelFunc pfnPixelFunc ); + static GDALDerivedPixelFunc GetPixelFunction( const char *pszFuncName ); + + void SetPixelFunctionName( const char *pszFuncName ); + void SetSourceTransferType( GDALDataType eDataType ); + + virtual CPLErr XMLInit( CPLXMLNode *, const char * ); + virtual CPLXMLNode * SerializeToXML( const char *pszVRTPath ); + +}; + +/************************************************************************/ +/* VRTRawRasterBand */ +/************************************************************************/ + +class RawRasterBand; + +class CPL_DLL VRTRawRasterBand : public VRTRasterBand +{ + RawRasterBand *m_poRawRaster; + + char *m_pszSourceFilename; + int m_bRelativeToVRT; + + public: + VRTRawRasterBand( GDALDataset *poDS, int nBand, + GDALDataType eType = GDT_Unknown ); + virtual ~VRTRawRasterBand(); + + virtual CPLErr XMLInit( CPLXMLNode *, const char * ); + virtual CPLXMLNode * SerializeToXML( const char *pszVRTPath ); + + virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int, + void *, int, int, GDALDataType, + GSpacing nPixelSpace, GSpacing nLineSpace, + GDALRasterIOExtraArg* psExtraArg ); + + virtual CPLErr IReadBlock( int, int, void * ); + virtual CPLErr IWriteBlock( int, int, void * ); + + CPLErr SetRawLink( const char *pszFilename, + const char *pszVRTPath, + int bRelativeToVRT, + vsi_l_offset nImageOffset, + int nPixelOffset, int nLineOffset, + const char *pszByteOrder ); + + void ClearRawLink(); + + virtual void GetFileList( char*** ppapszFileList, int *pnSize, + int *pnMaxSize, CPLHashSet* hSetFiles ); +}; + +/************************************************************************/ +/* VRTDriver */ +/************************************************************************/ + +class VRTDriver : public GDALDriver +{ + public: + VRTDriver(); + virtual ~VRTDriver(); + + char **papszSourceParsers; + + virtual char **GetMetadataDomainList(); + virtual char **GetMetadata( const char * pszDomain = "" ); + virtual CPLErr SetMetadata( char ** papszMetadata, + const char * pszDomain = "" ); + + VRTSource *ParseSource( CPLXMLNode *psSrc, const char *pszVRTPath ); + void AddSourceParser( const char *pszElementName, + VRTSourceParser pfnParser ); +}; + +/************************************************************************/ +/* VRTSimpleSource */ +/************************************************************************/ + +class CPL_DLL VRTSimpleSource : public VRTSource +{ +protected: + GDALRasterBand *m_poRasterBand; + + // When poRasterBand is a mask band, poMaskBandMainBand is the band + // from which the mask band is taken. + GDALRasterBand *m_poMaskBandMainBand; + + double m_dfSrcXOff; + double m_dfSrcYOff; + double m_dfSrcXSize; + double m_dfSrcYSize; + + double m_dfDstXOff; + double m_dfDstYOff; + double m_dfDstXSize; + double m_dfDstYSize; + + int m_bNoDataSet; + double m_dfNoDataValue; + CPLString m_osResampling; + + int m_nMaxValue; + + int m_bRelativeToVRTOri; + CPLString m_osSourceFileNameOri; + + int NeedMaxValAdjustment() const; + +public: + VRTSimpleSource(); + VRTSimpleSource( const VRTSimpleSource* poSrcSource, + double dfXDstRatio, double dfYDstRatio ); + virtual ~VRTSimpleSource(); + + virtual CPLErr XMLInit( CPLXMLNode *psTree, const char * ); + virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath ); + + void SetSrcBand( GDALRasterBand * ); + void SetSrcMaskBand( GDALRasterBand * ); + void SetSrcWindow( double, double, double, double ); + void SetDstWindow( double, double, double, double ); + void SetNoDataValue( double dfNoDataValue ); + const CPLString& GetResampling() const { return m_osResampling; } + void SetResampling( const char* pszResampling ); + + int GetSrcDstWindow( int, int, int, int, int, int, + double *pdfReqXOff, double *pdfReqYOff, + double *pdfReqXSize, double *pdfReqYSize, + int *, int *, int *, int *, + int *, int *, int *, int * ); + + virtual CPLErr RasterIO( int nXOff, int nYOff, int nXSize, int nYSize, + void *pData, int nBufXSize, int nBufYSize, + GDALDataType eBufType, + GSpacing nPixelSpace, GSpacing nLineSpace, + GDALRasterIOExtraArg* psExtraArg ); + + virtual double GetMinimum( int nXSize, int nYSize, int *pbSuccess ); + virtual double GetMaximum( int nXSize, int nYSize, int *pbSuccess ); + virtual CPLErr ComputeRasterMinMax( int nXSize, int nYSize, int bApproxOK, + double* adfMinMax ); + virtual CPLErr ComputeStatistics( int nXSize, int nYSize, + int bApproxOK, + double *pdfMin, double *pdfMax, + double *pdfMean, double *pdfStdDev, + GDALProgressFunc pfnProgress, + void *pProgressData ); + virtual CPLErr GetHistogram( int nXSize, int nYSize, + double dfMin, double dfMax, + int nBuckets, GUIntBig * panHistogram, + int bIncludeOutOfRange, int bApproxOK, + GDALProgressFunc pfnProgress, + void *pProgressData ); + + void DstToSrc( double dfX, double dfY, + double &dfXOut, double &dfYOut ); + void SrcToDst( double dfX, double dfY, + double &dfXOut, double &dfYOut ); + + virtual void GetFileList( char*** ppapszFileList, int *pnSize, + int *pnMaxSize, CPLHashSet* hSetFiles ); + + virtual int IsSimpleSource() { return TRUE; } + virtual const char* GetType() { return "SimpleSource"; } + + GDALRasterBand* GetBand(); + int IsSameExceptBandNumber( VRTSimpleSource* poOtherSource ); + CPLErr DatasetRasterIO( + int nXOff, int nYOff, int nXSize, int nYSize, + void * pData, int nBufXSize, int nBufYSize, + GDALDataType eBufType, + int nBandCount, int *panBandMap, + GSpacing nPixelSpace, GSpacing nLineSpace, + GSpacing nBandSpace, + GDALRasterIOExtraArg* psExtraArg ); + + void UnsetPreservedRelativeFilenames(); + + void SetMaxValue( int nVal ) { m_nMaxValue = nVal; } +}; + +/************************************************************************/ +/* VRTAveragedSource */ +/************************************************************************/ + +class VRTAveragedSource : public VRTSimpleSource +{ +public: + VRTAveragedSource(); + virtual CPLErr RasterIO( int nXOff, int nYOff, int nXSize, int nYSize, + void *pData, int nBufXSize, int nBufYSize, + GDALDataType eBufType, + GSpacing nPixelSpace, GSpacing nLineSpace, + GDALRasterIOExtraArg* psExtraArg ); + + virtual double GetMinimum( int nXSize, int nYSize, int *pbSuccess ); + virtual double GetMaximum( int nXSize, int nYSize, int *pbSuccess ); + virtual CPLErr ComputeRasterMinMax( int nXSize, int nYSize, int bApproxOK, + double* adfMinMax ); + virtual CPLErr ComputeStatistics( int nXSize, int nYSize, + int bApproxOK, + double *pdfMin, double *pdfMax, + double *pdfMean, double *pdfStdDev, + GDALProgressFunc pfnProgress, + void *pProgressData ); + virtual CPLErr GetHistogram( int nXSize, int nYSize, + double dfMin, double dfMax, + int nBuckets, GUIntBig * panHistogram, + int bIncludeOutOfRange, int bApproxOK, + GDALProgressFunc pfnProgress, + void *pProgressData ); + + virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath ); + virtual const char* GetType() { return "AveragedSource"; } +}; + +/************************************************************************/ +/* VRTComplexSource */ +/************************************************************************/ + +typedef enum +{ + VRT_SCALING_NONE, + VRT_SCALING_LINEAR, + VRT_SCALING_EXPONENTIAL, +} VRTComplexSourceScaling; + +class CPL_DLL VRTComplexSource : public VRTSimpleSource +{ +protected: + VRTComplexSourceScaling m_eScalingType; + double m_dfScaleOff; // For linear scaling. + double m_dfScaleRatio; // For linear scaling. + + // For non-linear scaling with a power function. + int m_bSrcMinMaxDefined; + double m_dfSrcMin; + double m_dfSrcMax; + double m_dfDstMin; + double m_dfDstMax; + double m_dfExponent; + + int m_nColorTableComponent; + + CPLErr RasterIOInternal( int nReqXOff, int nReqYOff, + int nReqXSize, int nReqYSize, + void *pData, int nOutXSize, int nOutYSize, + GDALDataType eBufType, + GSpacing nPixelSpace, GSpacing nLineSpace, + GDALRasterIOExtraArg* psExtraArg ); + +public: + VRTComplexSource(); + VRTComplexSource(const VRTComplexSource* poSrcSource, + double dfXDstRatio, double dfYDstRatio); + virtual ~VRTComplexSource(); + + virtual CPLErr RasterIO( int nXOff, int nYOff, int nXSize, int nYSize, + void *pData, int nBufXSize, int nBufYSize, + GDALDataType eBufType, + GSpacing nPixelSpace, GSpacing nLineSpace, + GDALRasterIOExtraArg* psExtraArg ); + + virtual double GetMinimum( int nXSize, int nYSize, int *pbSuccess ); + virtual double GetMaximum( int nXSize, int nYSize, int *pbSuccess ); + virtual CPLErr ComputeRasterMinMax( int nXSize, int nYSize, int bApproxOK, + double* adfMinMax ); + virtual CPLErr ComputeStatistics( int nXSize, int nYSize, + int bApproxOK, + double *pdfMin, double *pdfMax, + double *pdfMean, double *pdfStdDev, + GDALProgressFunc pfnProgress, + void *pProgressData ); + virtual CPLErr GetHistogram( int nXSize, int nYSize, + double dfMin, double dfMax, + int nBuckets, GUIntBig * panHistogram, + int bIncludeOutOfRange, int bApproxOK, + GDALProgressFunc pfnProgress, + void *pProgressData ); + + virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath ); + virtual CPLErr XMLInit( CPLXMLNode *, const char * ); + virtual const char* GetType() { return "ComplexSource"; } + + double LookupValue( double dfInput ); + + void SetLinearScaling( double dfOffset, double dfScale ); + void SetPowerScaling( double dfExponent, + double dfSrcMin, + double dfSrcMax, + double dfDstMin, + double dfDstMax ); + void SetColorTableComponent( int nComponent ); + + double *m_padfLUTInputs; + double *m_padfLUTOutputs; + int m_nLUTItemCount; +}; + +/************************************************************************/ +/* VRTFilteredSource */ +/************************************************************************/ + +class VRTFilteredSource : public VRTComplexSource +{ +private: + int IsTypeSupported( GDALDataType eType ); + +protected: + int m_nSupportedTypesCount; + GDALDataType m_aeSupportedTypes[20]; + + int m_nExtraEdgePixels; + +public: + VRTFilteredSource(); + virtual ~VRTFilteredSource(); + + void SetExtraEdgePixels( int ); + void SetFilteringDataTypesSupported( int, GDALDataType * ); + + virtual CPLErr FilterData( int nXSize, int nYSize, GDALDataType eType, + GByte *pabySrcData, GByte *pabyDstData ) = 0; + + virtual CPLErr RasterIO( int nXOff, int nYOff, int nXSize, int nYSize, + void *pData, int nBufXSize, int nBufYSize, + GDALDataType eBufType, + GSpacing nPixelSpace, GSpacing nLineSpace, + GDALRasterIOExtraArg* psExtraArg ); +}; + +/************************************************************************/ +/* VRTKernelFilteredSource */ +/************************************************************************/ + +class VRTKernelFilteredSource : public VRTFilteredSource +{ +protected: + int m_nKernelSize; + + double *m_padfKernelCoefs; + + int m_bNormalized; + +public: + VRTKernelFilteredSource(); + virtual ~VRTKernelFilteredSource(); + + virtual CPLErr XMLInit( CPLXMLNode *psTree, const char * ); + virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath ); + + virtual CPLErr FilterData( int nXSize, int nYSize, GDALDataType eType, + GByte *pabySrcData, GByte *pabyDstData ); + + CPLErr SetKernel( int nKernelSize, double *padfCoefs ); + void SetNormalized( int ); +}; + +/************************************************************************/ +/* VRTAverageFilteredSource */ +/************************************************************************/ + +class VRTAverageFilteredSource : public VRTKernelFilteredSource +{ +public: + explicit VRTAverageFilteredSource( int nKernelSize ); + virtual ~VRTAverageFilteredSource(); + + virtual CPLErr XMLInit( CPLXMLNode *psTree, const char * ); + virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath ); +}; + +/************************************************************************/ +/* VRTFuncSource */ +/************************************************************************/ +class VRTFuncSource : public VRTSource +{ +public: + VRTFuncSource(); + virtual ~VRTFuncSource(); + + virtual CPLErr XMLInit( CPLXMLNode *, const char *) { return CE_Failure; } + virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath ); + + virtual CPLErr RasterIO( int nXOff, int nYOff, int nXSize, int nYSize, + void *pData, int nBufXSize, int nBufYSize, + GDALDataType eBufType, + GSpacing nPixelSpace, GSpacing nLineSpace, + GDALRasterIOExtraArg* psExtraArg ); + + virtual double GetMinimum( int nXSize, int nYSize, int *pbSuccess ); + virtual double GetMaximum( int nXSize, int nYSize, int *pbSuccess ); + virtual CPLErr ComputeRasterMinMax( int nXSize, int nYSize, int bApproxOK, + double* adfMinMax ); + virtual CPLErr ComputeStatistics( int nXSize, int nYSize, + int bApproxOK, + double *pdfMin, double *pdfMax, + double *pdfMean, double *pdfStdDev, + GDALProgressFunc pfnProgress, + void *pProgressData ); + virtual CPLErr GetHistogram( int nXSize, int nYSize, + double dfMin, double dfMax, + int nBuckets, GUIntBig * panHistogram, + int bIncludeOutOfRange, int bApproxOK, + GDALProgressFunc pfnProgress, + void *pProgressData ); + + VRTImageReadFunc pfnReadFunc; + void *pCBData; + GDALDataType eType; + + float fNoDataValue; +}; + +#endif /* ndef VIRTUALDATASET_H_INCLUDED */ diff --git a/modules/globebrowsing/ext/gdal/lib/gdal201.dll b/modules/globebrowsing/ext/gdal/lib/gdal201.dll new file mode 100644 index 0000000000..bad96c9e37 Binary files /dev/null and b/modules/globebrowsing/ext/gdal/lib/gdal201.dll differ diff --git a/modules/globebrowsing/ext/gdal/lib/gdal_i.lib b/modules/globebrowsing/ext/gdal/lib/gdal_i.lib new file mode 100644 index 0000000000..0f5ee06fb0 Binary files /dev/null and b/modules/globebrowsing/ext/gdal/lib/gdal_i.lib differ diff --git a/modules/globebrowsing/rendering/clipmapglobe.cpp b/modules/globebrowsing/rendering/clipmapglobe.cpp index 7601137ed7..a5ef9101db 100644 --- a/modules/globebrowsing/rendering/clipmapglobe.cpp +++ b/modules/globebrowsing/rendering/clipmapglobe.cpp @@ -79,8 +79,16 @@ namespace openspace { // --------- // init Renderer - auto patchRenderer = new ClipMapPatchRenderer(); + auto patchRenderer = new ClipMapPatchRenderer(shared_ptr(new ClipMapGeometry(32))); _patchRenderer.reset(patchRenderer); + auto smallestPatchRenderer = new ClipMapPatchRenderer(shared_ptr( + new GridGeometry( + 32, + 32, + Geometry::Positions::No, + Geometry::TextureCoordinates::Yes, + Geometry::Normals::No))); + _smallestPatchRenderer.reset(smallestPatchRenderer); } ClipMapGlobe::~ClipMapGlobe() { @@ -107,10 +115,12 @@ namespace openspace { _patches[i].setCenter(LatLon::fromCartesian(data.camera.position().dvec3())); } // render patches - for (size_t i = 0; i < _patches.size(); i++) + for (size_t i = 0; i < _patches.size() - 1; i++) { _patchRenderer->renderPatch(_patches[i], data, 6.3e6); } + _smallestPatchRenderer->renderPatch(_patches[_patches.size() - 1], data, 6.3e6); + } void ClipMapGlobe::update(const UpdateData& data) { diff --git a/modules/globebrowsing/rendering/clipmapglobe.h b/modules/globebrowsing/rendering/clipmapglobe.h index e1ef78c87e..1d20f06c90 100644 --- a/modules/globebrowsing/rendering/clipmapglobe.h +++ b/modules/globebrowsing/rendering/clipmapglobe.h @@ -59,6 +59,7 @@ namespace openspace { private: std::unique_ptr _patchRenderer; + std::unique_ptr _smallestPatchRenderer; std::vector _patches; properties::IntProperty _rotation; diff --git a/modules/globebrowsing/rendering/patchrenderer.cpp b/modules/globebrowsing/rendering/patchrenderer.cpp index c92dca1b62..fdf910fbf0 100644 --- a/modules/globebrowsing/rendering/patchrenderer.cpp +++ b/modules/globebrowsing/rendering/patchrenderer.cpp @@ -154,8 +154,8 @@ namespace openspace { ////////////////////////////////////////////////////////////////////////////////////// // CLIPMAP PATCH RENDERER // ////////////////////////////////////////////////////////////////////////////////////// - ClipMapPatchRenderer::ClipMapPatchRenderer() - : PatchRenderer(shared_ptr(new ClipMapGeometry(32))) + ClipMapPatchRenderer::ClipMapPatchRenderer(shared_ptr geometry) + : PatchRenderer(geometry) { _programObject = OsEng.renderEngine().buildRenderProgram( "LatLonSphereMappingProgram", diff --git a/modules/globebrowsing/rendering/patchrenderer.h b/modules/globebrowsing/rendering/patchrenderer.h index 6c49ca4677..55b806ed3b 100644 --- a/modules/globebrowsing/rendering/patchrenderer.h +++ b/modules/globebrowsing/rendering/patchrenderer.h @@ -91,7 +91,7 @@ namespace openspace { class ClipMapPatchRenderer : public PatchRenderer { public: - ClipMapPatchRenderer(); + ClipMapPatchRenderer(shared_ptr geometry); void renderPatch( const LatLonPatch& patch, diff --git a/modules/globebrowsing/rendering/renderableglobe.cpp b/modules/globebrowsing/rendering/renderableglobe.cpp index f1594d9b96..3093493c48 100644 --- a/modules/globebrowsing/rendering/renderableglobe.cpp +++ b/modules/globebrowsing/rendering/renderableglobe.cpp @@ -66,8 +66,8 @@ namespace openspace { // Mainly for debugging purposes @AA addProperty(_rotation); - addSwitchValue(std::shared_ptr(new ClipMapGlobe(dictionary)), 1e9); - //addSwitchValue(std::shared_ptr(new ChunkLodGlobe(dictionary)), 1e9); + addSwitchValue(std::shared_ptr(new ClipMapGlobe(dictionary)), 1e7); + addSwitchValue(std::shared_ptr(new ChunkLodGlobe(dictionary)), 1e9); addSwitchValue(std::shared_ptr(new GlobeMesh(dictionary)), 1e10); diff --git a/modules/globebrowsing/rendering/texturetileset.h b/modules/globebrowsing/rendering/texturetileset.h index 189df7e8b0..7589f40502 100644 --- a/modules/globebrowsing/rendering/texturetileset.h +++ b/modules/globebrowsing/rendering/texturetileset.h @@ -69,7 +69,7 @@ namespace openspace { /// A transformation (translation and scaling) from the texture space of a patch /// to the texture space of a tile. - glm::mat3 getUvTransformationPatchToTile( + glm::mat3 getUvTransformationPatchToTile( LatLonPatch patch, const TileIndex& tileIndex);