Smallest patch of clipmap is rendered separately.

This commit is contained in:
Kalle Bladin
2016-04-19 18:42:25 -04:00
parent 152126f5a4
commit 6ff6ff1ace
89 changed files with 24515 additions and 8 deletions

View File

@@ -0,0 +1,106 @@
/**********************************************************************
* $Id$
*
* Name: cpl_atomic_ops.h
* Project: CPL - Common Portability Library
* Purpose: Atomic operation functions.
* Author: Even Rouault, <even dot rouault at mines dash paris dot org>
*
**********************************************************************
* Copyright (c) 2009-2010, Even Rouault <even dot rouault at mines-paris dot org>
*
* 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 */

View File

@@ -0,0 +1,136 @@
/**********************************************************************
* $Id$
*
* Name: cpl_aws.h
* Project: CPL - Common Portability Library
* Purpose: Amazon Web Services routines
* Author: Even Rouault <even.rouault at spatialys.com>
*
**********************************************************************
* Copyright (c) 2015, Even Rouault <even.rouault at spatialys.com>
*
* 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 <curl/curl.h>
#include <map>
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<CPLString, CPLString> 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 */

View File

@@ -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 <assert.h> header file. */
#define HAVE_ASSERT_H 1
/* Define to 1 if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
/* Define if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
#undef HAVE_LIBDL
/* Define to 1 if you have the <locale.h> 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 <direct.h> 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 */

View File

@@ -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

View File

@@ -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 <even dot rouault at mines-paris dot org>
*
* 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 */

View File

@@ -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 */

View File

@@ -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 */

View File

@@ -0,0 +1,94 @@
/**********************************************************************
* $Id$
*
* Name: cpl_hash_set.h
* Project: CPL - Common Portability Library
* Purpose: Hash set functions.
* Author: Even Rouault, <even dot rouault at mines dash paris dot org>
*
**********************************************************************
* Copyright (c) 2008-2009, Even Rouault <even dot rouault at mines-paris dot org>
*
* 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 */

View File

@@ -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 <even dot rouault at mines-paris dot org>
*
* 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 */

View File

@@ -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 <dron@remotesensing.org>
*
* 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 */

View File

@@ -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 */

View File

@@ -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 <even dot rouault at mines-paris dot org>
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 */

View File

@@ -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 <even dot rouault at mines-paris dot org>
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 <zlib.h>
#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 */

View File

@@ -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 */

View File

@@ -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 <even dot rouault at mines-paris dot org>
*
* 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_ */

View File

@@ -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 <windows.h>
#endif
#include <sql.h>
#include <sqlext.h>
#include <odbcinst.h>
#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

View File

@@ -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 <warmerdam@pobox.com>
* Copyright (c) 2008-2013, Even Rouault <even dot rouault at mines-paris dot org>
*
* 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 <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdarg.h>
#include <string.h>
#include <ctype.h>
#include <limits.h>
#include <time.h>
#if defined(HAVE_ERRNO_H)
# include <errno.h>
#endif
#ifdef HAVE_LOCALE_H
# include <locale.h>
#endif
#ifdef HAVE_DIRECT_H
# include <direct.h>
#endif
#if !defined(WIN32)
# include <strings.h>
#endif
#if defined(HAVE_LIBDBMALLOC) && defined(HAVE_DBMALLOC_H) && defined(DEBUG)
# define DBMALLOC
# include <dbmalloc.h>
#endif
#if !defined(DBMALLOC) && defined(HAVE_DMALLOC_H)
# define USE_DMALLOC
# include <dmalloc.h>
#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 <stddef.h> with __need_NULL, this overrides our #define NULL nullptr
// with #define NULL __null
#include <locale.h>
#include <unistd.h>
#include <sys/types.h>
#ifdef HAVE_ICONV
#include <iconv.h>
#endif
#ifdef HAVE_MMAP
#include <sys/mman.h>
#endif
#include <signal.h>
#ifndef _WIN32
#include <dlfcn.h>
#include <netdb.h>
#include <fcntl.h>
#endif
extern "C++" {
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cstddef>
#include <ostream>
#include <iostream>
#include <sstream>
}
#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) ((a<b) ? a : b)
# define MAX(a,b) ((a>b) ? 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 <float.h>
# 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 <ieeefp.h>
# 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 <bool b> struct CPLStaticAssert {};
template<> struct CPLStaticAssert<true>
{
static void my_function() {}
};
} /* extern "C++" */
#define CPL_STATIC_ASSERT(x) CPLStaticAssert<x>::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<size_t>(!(sizeof(array) % sizeof(*(array)))))
extern "C++" {
template<class T> 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 <vector>
#include <map>
#include <set>
#include <string>
#include <cstddef>
#include <limits>
#include <sstream>
#include <fstream>
#include <algorithm>
} /* 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 */

View File

@@ -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 */

View File

@@ -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, <even dot rouault at mines dash paris dot org>
*
******************************************************************************
* Copyright (c) 1999-2008, Frank Warmerdam
* Copyright (c) 2008-2014, Even Rouault <even dot rouault at mines-paris dot org>
*
* 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

View File

@@ -0,0 +1,68 @@
/* $Id$ */
/* The MIT License
Copyright (C) 2011 Zilong Tan (tzlloch@gmail.com)
Copyright (C) 2015 Even Rouault <even.rouault at spatialys.com>
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 */

View File

@@ -0,0 +1,78 @@
/**********************************************************************
* $Id$
*
* Project: CPL - Common Portability Library
* Purpose: Implement CPLSystem().
* Author: Even Rouault, <even dot rouault at mines dash paris dot org>
*
**********************************************************************
* Copyright (c) 2013, Even Rouault <even dot rouault at mines-paris dot org>
*
* 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 <windows.h>
typedef HANDLE CPL_FILE_HANDLE;
#define CPL_FILE_INVALID_HANDLE NULL
typedef DWORD CPL_PID;
#else
#include <sys/types.h>
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

View File

@@ -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 <even dot rouault at mines-paris dot org>
*
* 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 "<name>:<value>" (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 <string>
/*
* 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<std::string::size_type>(i));
}
const char& operator[](int i) const
{
return gdal_std_string::operator[](
static_cast<std::string::size_type>(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<int>(i)]; }
const char * operator[](int i) const;
const char * operator[](size_t i) const {
return (*this)[static_cast<int>(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 */

View File

@@ -0,0 +1,41 @@
/**********************************************************************
* $Id$
*
* Name: cpl_time.h
* Project: CPL - Common Portability Library
* Purpose: Time functions.
* Author: Even Rouault, <even dot rouault at mines dash paris dot org>
*
**********************************************************************
* Copyright (c) 2009, Even Rouault <even dot rouault at mines-paris dot org>
*
* 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 <time.h>
#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

View File

@@ -0,0 +1,390 @@
/**********************************************************************
* $Id$
*
* Name: cpl_virtualmem.h
* Project: CPL - Common Portability Library
* Purpose: Virtual memory
* Author: Even Rouault, <even dot rouault at mines dash paris dot org>
*
**********************************************************************
* Copyright (c) 2014, Even Rouault <even dot rouault at mines-paris dot org>
*
* 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 */

View File

@@ -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 <even dot rouault at mines-paris dot org>
*
* 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 <unistd.h>
#endif
/* Windows */
#include <sys/stat.h>
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 */

View File

@@ -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 <rdemanuele at gmail.com>
*
* 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 */

View File

@@ -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 <warmerdam@pobox.com>
* Copyright (c) 2010-2014, Even Rouault <even dot rouault at mines-paris dot org>
*
* 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 <map>
#include <vector>
#include <string>
/************************************************************************/
/* 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<std::string, VSIFilesystemHandler *> 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<CPLString,VSIArchiveContent*> oFileList;
virtual const char* GetPrefix() = 0;
virtual std::vector<CPLString> 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 */

View File

@@ -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 <even dot rouault at mines-paris dot org>
*
* 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

View File

@@ -0,0 +1,103 @@
/**********************************************************************
* $Id$
*
* Project: CPL - Common Portability Library
* Purpose: CPL worker thread pool
* Author: Even Rouault, <even dot rouault at spatialys dot com>
*
**********************************************************************
* Copyright (c) 2015, Even Rouault, <even dot rouault at spatialys dot com>
*
* 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 <vector>
/**
* \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<CPLWorkerThread> 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<void*>& apData);
void WaitCompletion(int nMaxRemainingJobs = 0);
int GetThreadCount() const { return (int)aWT.size(); }
};
#endif // CPL_WORKER_THREAD_POOL_H_INCLUDED_

View File

@@ -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 <warmerdam@pobox.com
*
******************************************************************************
* Copyright (c) 2008, Frank Warmerdam <warmerdam@pobox.com>
*
* 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 */

File diff suppressed because it is too large Load Diff

View File

@@ -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 <even dot rouault at mines-paris dot org>
*
* 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 */

View File

@@ -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 <dron@ak4719.spb.edu>
* Copyright (c) 2010-2013, Even Rouault <even dot rouault at mines-paris dot org>
*
* 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 DataType, class EqualityTest> 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<GInt32, IntEqualityTest> 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<class T> 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 numbers 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 */

View File

@@ -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 <even dot rouault at mines-paris dot org>
*
* 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

View File

@@ -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 <even dot rouault at mines-paris dot org>
*
* 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 */

View File

@@ -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

View File

@@ -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 <warmerdam@pobox.com>
*
* 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 */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,396 @@
/******************************************************************************
* $Id$
*
* Project: GDAL Core
* Purpose: GDAL Core C++/Private declarations
* Author: Even Rouault <even dot rouault at mines dash paris dot org>
*
******************************************************************************
* Copyright (c) 2008-2014, Even Rouault <even dot rouault at mines-paris dot org>
*
* 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 */

View File

@@ -0,0 +1,362 @@
/******************************************************************************
* $Id$
*
* Project: GDAL Core
* Purpose: GDALRasterAttributeTable class declarations.
* Author: Frank Warmerdam, warmerdam@pobox.com
*
******************************************************************************
* Copyright (c) 2005, Frank Warmerdam <warmerdam@pobox.com>
*
* 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<GInt32> anValues;
std::vector<double> adfValues;
std::vector<CPLString> aosValues;
};
/************************************************************************/
/* GDALDefaultRasterAttributeTable */
/************************************************************************/
//! Raster Attribute Table container.
class CPL_DLL GDALDefaultRasterAttributeTable : public GDALRasterAttributeTable
{
private:
std::vector<GDALRasterAttributeField> 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 */

View File

@@ -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 <list>
/**
* @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<GDALFeaturePoint>*
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<GDALFeaturePoint*> *poMatchPairs,
std::vector<GDALFeaturePoint> *poFirstCollect,
std::vector<GDALFeaturePoint> *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<MatchedPointPairInfo> *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_ */

View File

@@ -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 <even.rouault at spatialys.com>
* 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 */

View File

@@ -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

View File

@@ -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 <dron@ak4719.spb.edu>
*
* 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 */

View File

@@ -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

View File

@@ -0,0 +1,57 @@
/******************************************************************************
* $Id$
*
* Project: GDAL
* Purpose: GDALPamDataset with internal storage for georeferencing, with
* priority for PAM over internal georeferencing
* Author: Even Rouault <even dot rouault at mines-paris dot org>
*
******************************************************************************
* Copyright (c) 2013, Even Rouault <even dot rouault at mines-paris dot org>
*
* 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 */

View File

@@ -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 <dron@ak4719.spb.edu>
* Copyright (c) 2012, Even Rouault <even dot rouault at mines-paris dot org>
*
* 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 */

View File

@@ -0,0 +1,106 @@
/******************************************************************************
* $Id$
*
* Project: GDAL Gridding API.
* Purpose: Prototypes, and definitions for of GDAL scattered data gridder.
* Author: Even Rouault, <even dot rouault at mines dash paris dot org>
*
******************************************************************************
* Copyright (c) 2013, Even Rouault <even dot rouault at mines-paris dot org>
*
* 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

View File

@@ -0,0 +1,60 @@
/******************************************************************************
* $Id$
*
* Project: GDAL
* Purpose: GDALGeorefPamDataset with helper to read georeferencing and other
* metadata from JP2Boxes
* Author: Even Rouault <even dot rouault at mines-paris dot org>
*
******************************************************************************
* Copyright (c) 2013, Even Rouault <even dot rouault at mines-paris dot org>
*
* 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 */

View File

@@ -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 <warmerdam@pobox.com>
* Copyright (c) 2010-2013, Even Rouault <even dot rouault at mines-paris dot org>
*
* 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 */

View File

@@ -0,0 +1,40 @@
/******************************************************************************
* $Id$
*
* Project: GDAL
* Purpose: GDALJP2Metadata: metadata generator
* Author: Even Rouault <even dot rouault at spatialys dot com>
*
******************************************************************************
* 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 */

View File

@@ -0,0 +1,270 @@
/******************************************************************************
* $Id$
*
* Project: GDAL Pansharpening module
* Purpose: Prototypes, and definitions for pansharpening related work.
* Author: Even Rouault <even.rouault at spatialys.com>
*
******************************************************************************
* Copyright (c) 2015, Even Rouault <even.rouault at spatialys.com>
*
* 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 <vector>
#include "gdal_priv.h"
#include "cpl_worker_thread_pool.h"
#ifdef DEBUG_TIMING
#include <sys/time.h>
#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<int> anInputBands;
std::vector<GDALDataset*> aVDS; // to destroy
std::vector<GDALRasterBand*> 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<class WorkDataType, class OutDataType> void WeightedBroveyWithNoData(
const WorkDataType* pPanBuffer,
const WorkDataType* pUpsampledSpectralBuffer,
OutDataType* pDataBuf,
int nValues,
int nBandValues,
WorkDataType nMaxValue) const;
template<class WorkDataType, class OutDataType, int bHasBitDepth> void WeightedBrovey3(
const WorkDataType* pPanBuffer,
const WorkDataType* pUpsampledSpectralBuffer,
OutDataType* pDataBuf,
int nValues,
int nBandValues,
WorkDataType nMaxValue) const;
template<class WorkDataType, class OutDataType> void WeightedBrovey(
const WorkDataType* pPanBuffer,
const WorkDataType* pUpsampledSpectralBuffer,
OutDataType* pDataBuf,
int nValues,
int nBandValues,
WorkDataType nMaxValue) const;
template<class WorkDataType> CPLErr WeightedBrovey(
const WorkDataType* pPanBuffer,
const WorkDataType* pUpsampledSpectralBuffer,
void *pDataBuf,
GDALDataType eBufDataType,
int nValues,
int nBandValues,
WorkDataType nMaxValue) const;
template<class WorkDataType> 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 NINPUT, int NOUTPUT> 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 */

View File

@@ -0,0 +1,855 @@
/******************************************************************************
* $Id$
*
* Project: GDAL
* Purpose: SSE2 helper
* Author: Even Rouault <even dot rouault at spatialys dot com>
*
******************************************************************************
* Copyright (c) 2014, Even Rouault <even dot rouault at spatialys dot com>
*
* 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 <emmintrin.h>
#include <string.h>
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(&reg.low, low1, sizeof(double));
memcpy(&reg.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 */

View File

@@ -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 <even dot rouault at mines-paris dot org>
*
* 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 */

View File

@@ -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 <seth@pricepages.org>
*
* 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 <OpenCL/OpenCL.h>
#else
#include <CL/opencl.h>
#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) */

View File

@@ -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 */

File diff suppressed because it is too large Load Diff

View File

@@ -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 */

View File

@@ -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 <even dot rouault at mines-paris dot org>
*
* 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 */

View File

@@ -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 <warmerdam@pobox.com>
*
* 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 */

View File

@@ -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 <even dot rouault at mines-paris dot org>
*
* 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 &gt;= 2.0 */
wkbCompoundCurve = 9, /**< sequence of contiguous curves, ISO SQL/MM Part 3. GDAL &gt;= 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 &gt;= 2.0 */
wkbMultiCurve = 11, /**< GeometryCollection of Curves, ISO SQL/MM Part 3. GDAL &gt;= 2.0 */
wkbMultiSurface = 12, /**< GeometryCollection of Surfaces, ISO SQL/MM Part 3. GDAL &gt;= 2.0 */
wkbCurve = 13, /**< Curve (abstract type). ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
wkbSurface = 14, /**< Surface (abstract type). ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
wkbPolyhedralSurface = 15,/**< a contiguous collection of polygons, which share common boundary segments,
* ISO SQL/MM Part 3. Reserved in GDAL &gt;= 2.1 but not yet implemented */
wkbTIN = 16, /**< a PolyhedralSurface consisting only of Triangle patches
* ISO SQL/MM Part 3. Reserved in GDAL &gt;= 2.1 but not yet implemented */
wkbTriangle = 17, /** < a Triangle. ISO SQL/MM Part 3. Reserved in GDAL &gt;= 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 &gt;= 2.0 */
wkbCompoundCurveZ = 1009, /**< wkbCompoundCurve with Z component. ISO SQL/MM Part 3. GDAL &gt;= 2.0 */
wkbCurvePolygonZ = 1010, /**< wkbCurvePolygon with Z component. ISO SQL/MM Part 3. GDAL &gt;= 2.0 */
wkbMultiCurveZ = 1011, /**< wkbMultiCurve with Z component. ISO SQL/MM Part 3. GDAL &gt;= 2.0 */
wkbMultiSurfaceZ = 1012, /**< wkbMultiSurface with Z component. ISO SQL/MM Part 3. GDAL &gt;= 2.0 */
wkbCurveZ = 1013, /**< wkbCurve with Z component. ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
wkbSurfaceZ = 1014, /**< wkbSurface with Z component. ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
wkbPolyhedralSurfaceZ = 1015, /**< ISO SQL/MM Part 3. Reserved in GDAL &gt;= 2.1 but not yet implemented */
wkbTINZ = 1016, /**< ISO SQL/MM Part 3. Reserved in GDAL &gt;= 2.1 but not yet implemented */
wkbTriangleZ = 1017, /**< ISO SQL/MM Part 3. Reserved in GDAL &gt;= 2.1 but not yet implemented */
wkbPointM = 2001, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
wkbLineStringM = 2002, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
wkbPolygonM = 2003, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
wkbMultiPointM = 2004, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
wkbMultiLineStringM = 2005, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
wkbMultiPolygonM = 2006, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
wkbGeometryCollectionM = 2007, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
wkbCircularStringM = 2008, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
wkbCompoundCurveM = 2009, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
wkbCurvePolygonM = 2010, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
wkbMultiCurveM = 2011, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
wkbMultiSurfaceM = 2012, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
wkbCurveM = 2013, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
wkbSurfaceM = 2014, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
wkbPolyhedralSurfaceM = 2015, /**< ISO SQL/MM Part 3. Reserved in GDAL &gt;= 2.1 but not yet implemented */
wkbTINM = 2016, /**< ISO SQL/MM Part 3. Reserved in GDAL &gt;= 2.1 but not yet implemented */
wkbTriangleM = 2017, /**< ISO SQL/MM Part 3. Reserved in GDAL &gt;= 2.1 but not yet implemented */
wkbPointZM = 3001, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
wkbLineStringZM = 3002, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
wkbPolygonZM = 3003, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
wkbMultiPointZM = 3004, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
wkbMultiLineStringZM = 3005, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
wkbMultiPolygonZM = 3006, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
wkbGeometryCollectionZM = 3007, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
wkbCircularStringZM = 3008, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
wkbCompoundCurveZM = 3009, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
wkbCurvePolygonZM = 3010, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
wkbMultiCurveZM = 3011, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
wkbMultiSurfaceZM = 3012, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
wkbCurveZM = 3013, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
wkbSurfaceZM = 3014, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
wkbPolyhedralSurfaceZM = 3015, /**< ISO SQL/MM Part 3. Reserved in GDAL &gt;= 2.1 but not yet implemented */
wkbTINZM = 3016, /**< ISO SQL/MM Part 3. Reserved in GDAL &gt;= 2.1 but not yet implemented */
wkbTriangleZM = 3017, /**< ISO SQL/MM Part 3. Reserved in GDAL &gt;= 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: <a href="https://portal.opengeospatial.org/files/?artifact_id=320243">
* 09-009_Committee_Draft_ISOIEC_CD_13249-3_SQLMM_Spatial.pdf</a>,
* 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 <a href="http://portal.opengeospatial.org/files/?artifact_id=25355">
* OGC 06-103r4 "OpenGIS® Implementation Standard for Geographic information - Simple feature access - Part 1: Common architecture", v1.2.1</a>
*/
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 */

View File

@@ -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 <even dot rouault at mines-paris dot org>
*
* 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 <expat.h>
/* 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 */

View File

@@ -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 <even dot rouault at mines-paris dot org>
*
* 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 :
* <ul>
* <li>a name. See SetName() / GetNameRef()</li>
* <li>a type: OFTString, OFTInteger, OFTReal, ... See SetType() / GetType()</li>
* <li>a subtype (optional): OFSTBoolean, ... See SetSubType() / GetSubType()</li>
* <li>a width (optional): maximal number of characters. See SetWidth() / GetWidth()</li>
* <li>a precision (optional): number of digits after decimal point. See SetPrecision() / GetPrecision()</li>
* <li>a NOT NULL constraint (optional). See SetNullable() / IsNullable()</li>
* <li>a default value (optional). See SetDefault() / GetDefault()</li>
* <li>a boolean to indicate whether it should be ignored when retrieving features. See SetIgnored() / IsIgnored()</li>
* </ul>
*/
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 :
* <ul>
* <li>a name. See SetName() / GetNameRef()</li>
* <li>a type: wkbPoint, wkbLineString, ... See SetType() / GetType()</li>
* <li>a spatial reference system (optional). See SetSpatialRef() / GetSpatialRef()</li>
* <li>a NOT NULL constraint (optional). See SetNullable() / IsNullable()</li>
* <li>a boolean to indicate whether it should be ignored when retrieving features. See SetIgnored() / IsIgnored()</li>
* </ul>
*
* @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 */

View File

@@ -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 */

View File

@@ -0,0 +1,63 @@
/******************************************************************************
* $Id$
*
* Project: OpenGIS Simple Features Reference Implementation
* Purpose: Client of geocoding service.
* Author: Even Rouault, <even dot rouault at mines dash paris dot org>
*
******************************************************************************
* Copyright (c) 2012, Even Rouault <even dot rouault at mines-paris dot org>
*
* 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

File diff suppressed because it is too large Load Diff

View File

@@ -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 <warmerdam@pobox.com>
*
******************************************************************************
* Copyright (c) 2004, Frank Warmerdam <warmerdam@pobox.com>
*
* 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 <geos_c.h>
#else
namespace geos {
class Geometry;
};
#endif
#endif /* ndef OGR_GEOS_H_INCLUDED */

View File

@@ -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 <even dot rouault at mines-paris dot org>
*
* 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 */

View File

@@ -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 <even dot rouault at mines-paris dot org>
*
* 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 <a href="osr_tutorial.html">the tutorial</a> 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 */

View File

@@ -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 <even dot rouault at mines-paris dot org>
*
* 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 &gt;= 1.10 and PROJ &gt;= 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 */

View File

@@ -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
};

View File

@@ -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 <even.rouault at spatialys.com>
*
* 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 */

View File

@@ -0,0 +1,43 @@
/******************************************************************************
* $Id$
*
* Project: OpenGIS Simple Features Reference Implementation
* Purpose: Implements decoder of geomedia geometry blobs
* Author: Even Rouault, <even dot rouault at mines dash paris dot org>
*
******************************************************************************
* Copyright (c) 2011, Even Rouault <even dot rouault at mines-paris dot org>
*
* 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

View File

@@ -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 <warmerdam@pobox.com>
* Copyright (c) 2011-2014, Even Rouault <even dot rouault at mines-paris dot org>
*
* 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

View File

@@ -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 <even dot rouault at mines-paris dot org>
*
* 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 */

View File

@@ -0,0 +1,55 @@
/******************************************************************************
* $Id$
*
* Project: OpenGIS Simple Features Reference Implementation
* Purpose: CS WKT parser
* Author: Even Rouault, <even dot rouault at mines dash paris dot org>
*
******************************************************************************
* Copyright (c) 2013, Even Rouault <even dot rouault at mines-paris dot org>
*
* 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_ */

View File

@@ -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 <http://www.gnu.org/licenses/>. */
/* 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 */

View File

@@ -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 <even dot rouault at mines-paris dot org>
*
* 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<FILE *>( 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

View File

@@ -0,0 +1,389 @@
/******************************************************************************
*
* Component: OGDI Driver Support Library
* Purpose: Generic SQL WHERE Expression Evaluator Declarations.
* Author: Frank Warmerdam <warmerdam@pobox.com>
*
******************************************************************************
* Copyright (C) 2001 Information Interoperability Institute (3i)
* Copyright (c) 2010-2013, Even Rouault <even dot rouault at mines-paris dot org>
* 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_ */

View File

@@ -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);
};

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

View File

@@ -79,8 +79,16 @@ namespace openspace {
// ---------
// init Renderer
auto patchRenderer = new ClipMapPatchRenderer();
auto patchRenderer = new ClipMapPatchRenderer(shared_ptr<ClipMapGeometry>(new ClipMapGeometry(32)));
_patchRenderer.reset(patchRenderer);
auto smallestPatchRenderer = new ClipMapPatchRenderer(shared_ptr<GridGeometry>(
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) {

View File

@@ -59,6 +59,7 @@ namespace openspace {
private:
std::unique_ptr<ClipMapPatchRenderer> _patchRenderer;
std::unique_ptr<ClipMapPatchRenderer> _smallestPatchRenderer;
std::vector<LatLonPatch> _patches;
properties::IntProperty _rotation;

View File

@@ -154,8 +154,8 @@ namespace openspace {
//////////////////////////////////////////////////////////////////////////////////////
// CLIPMAP PATCH RENDERER //
//////////////////////////////////////////////////////////////////////////////////////
ClipMapPatchRenderer::ClipMapPatchRenderer()
: PatchRenderer(shared_ptr<ClipMapGeometry>(new ClipMapGeometry(32)))
ClipMapPatchRenderer::ClipMapPatchRenderer(shared_ptr<Geometry> geometry)
: PatchRenderer(geometry)
{
_programObject = OsEng.renderEngine().buildRenderProgram(
"LatLonSphereMappingProgram",

View File

@@ -91,7 +91,7 @@ namespace openspace {
class ClipMapPatchRenderer : public PatchRenderer {
public:
ClipMapPatchRenderer();
ClipMapPatchRenderer(shared_ptr<Geometry> geometry);
void renderPatch(
const LatLonPatch& patch,

View File

@@ -66,8 +66,8 @@ namespace openspace {
// Mainly for debugging purposes @AA
addProperty(_rotation);
addSwitchValue(std::shared_ptr<ClipMapGlobe>(new ClipMapGlobe(dictionary)), 1e9);
//addSwitchValue(std::shared_ptr<ChunkLodGlobe>(new ChunkLodGlobe(dictionary)), 1e9);
addSwitchValue(std::shared_ptr<ClipMapGlobe>(new ClipMapGlobe(dictionary)), 1e7);
addSwitchValue(std::shared_ptr<ChunkLodGlobe>(new ChunkLodGlobe(dictionary)), 1e9);
addSwitchValue(std::shared_ptr<GlobeMesh>(new GlobeMesh(dictionary)), 1e10);

View File

@@ -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);