mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-06 00:07:29 -04:00
upgrading to SpatiaLite 2.4.0-RC4
git-svn-id: http://svn.osgeo.org/qgis/trunk@14763 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
d3b07d4140
commit
cdae0f6707
1
AUTHORS
1
AUTHORS
@ -40,3 +40,4 @@ Carson J. Q. Farmer <carson dot farmer at gmail dot com>
|
||||
Lorenzo Masini <lorenxo86 at gmail.com>
|
||||
Werner Macho <werner.macho at gmail.com>
|
||||
Giuseppe Sucameli <brush.tyler at gmail.com>
|
||||
Alessandro Furieri <a.furieri at lqt.it>
|
||||
|
1
debian/copyright
vendored
1
debian/copyright
vendored
@ -38,6 +38,7 @@ reported:
|
||||
Lorenzo Masini <lorenxo86 at gmail.com>
|
||||
Werner Macho <werner.macho at gmail.com>
|
||||
Giuseppe Sucameli <brush.tyler at gmail.com>
|
||||
Alessandro Furieri <a.furieri at lqt.it>
|
||||
|
||||
Copyright:
|
||||
|
||||
|
@ -139,10 +139,6 @@ static void qtgui_UpdatePyArgv(PyObject *argvlist, int argc, char **argv)
|
||||
//! Returns the path to the master qgis.db file.
|
||||
static const QString qgisMasterDbFilePath();
|
||||
|
||||
//! Returns the path to the spatialite template db file.
|
||||
//! @note added in 1.5
|
||||
static const QString qgisSpatialiteDbTemplatePath();
|
||||
|
||||
//! Returns the path to the settings directory in user's home dir
|
||||
static const QString qgisSettingsDirPath();
|
||||
|
||||
|
@ -187,9 +187,57 @@ void QgsNewSpatialiteLayerDialog::on_pbnFindSRID_clicked()
|
||||
}
|
||||
}
|
||||
|
||||
void QgsNewSpatialiteLayerDialog::initializeSpatialMetadata(sqlite3 *sqlite_handle)
|
||||
{
|
||||
// attempting to perform self-initialization for a newly created DB
|
||||
int ret;
|
||||
char sql[1024];
|
||||
char *errMsg = NULL;
|
||||
int count;
|
||||
int i;
|
||||
char **results;
|
||||
int rows;
|
||||
int columns;
|
||||
|
||||
if (sqlite_handle == NULL)
|
||||
return;
|
||||
// checking if this DB is really empty
|
||||
strcpy(sql, "SELECT Count(*) from sqlite_master");
|
||||
ret = sqlite3_get_table(sqlite_handle, sql, &results, &rows, &columns, NULL);
|
||||
if (ret != SQLITE_OK)
|
||||
return;
|
||||
if (rows < 1)
|
||||
;
|
||||
else
|
||||
{
|
||||
for (i = 1; i <= rows; i++)
|
||||
count = atoi(results[(i * columns) + 0]);
|
||||
}
|
||||
sqlite3_free_table(results);
|
||||
|
||||
if (count > 0)
|
||||
return;
|
||||
|
||||
// all right, it's empty: proceding to initialize
|
||||
strcpy(sql, "SELECT InitSpatialMetadata()");
|
||||
ret = sqlite3_exec(sqlite_handle, sql, NULL, NULL, &errMsg);
|
||||
if (ret != SQLITE_OK)
|
||||
{
|
||||
QString errCause = tr( "Unable to initialize SpatialMetedata:\n" );
|
||||
errCause += QString::fromUtf8(errMsg);
|
||||
QMessageBox::warning( 0, tr( "SpatiaLite Database" ), errCause );
|
||||
sqlite3_free(errMsg);
|
||||
return;
|
||||
}
|
||||
spatial_ref_sys_init(sqlite_handle, 0);
|
||||
}
|
||||
|
||||
bool QgsNewSpatialiteLayerDialog::createDb()
|
||||
{
|
||||
QSettings settings;
|
||||
int ret;
|
||||
sqlite3 *sqlite_handle;
|
||||
char *errMsg = NULL;
|
||||
|
||||
if ( mDatabaseComboBox->currentText().isEmpty() )
|
||||
return false;
|
||||
@ -199,10 +247,6 @@ bool QgsNewSpatialiteLayerDialog::createDb()
|
||||
{
|
||||
QgsDebugMsg( "creating a new db" );
|
||||
|
||||
// copy the spatilite template to the user specified path
|
||||
QString spatialiteTemplate = QgsApplication::qgisSpatialiteDbTemplatePath();
|
||||
QFile spatialiteTemplateDb( spatialiteTemplate );
|
||||
|
||||
QFileInfo fullPath = QFileInfo( mDatabaseComboBox->currentText() );
|
||||
QDir path = fullPath.dir();
|
||||
QgsDebugMsg( QString( "making this dir: %1" ).arg( path.absolutePath() ) );
|
||||
@ -210,15 +254,34 @@ bool QgsNewSpatialiteLayerDialog::createDb()
|
||||
// Must be sure there is destination directory ~/.qgis
|
||||
QDir().mkpath( path.absolutePath( ) );
|
||||
|
||||
QgsDebugMsg( QString( "Copying %1 to %2" ).arg( spatialiteTemplate ).arg( newDb.fileName() ) );
|
||||
|
||||
//now copy the template db file into the chosen location
|
||||
if ( !spatialiteTemplateDb.copy( newDb.fileName() ) )
|
||||
// creating/opening the new database
|
||||
QString dbPath = newDb.fileName();
|
||||
spatialite_init(0);
|
||||
ret = sqlite3_open_v2(dbPath.toUtf8().constData(), &sqlite_handle, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL);
|
||||
if (ret)
|
||||
{
|
||||
QMessageBox::warning( 0, tr( "SpatiaLite Database" ), tr( "Could not copy the template database to new location" ) );
|
||||
// an error occurred
|
||||
QString errCause = tr( "Could not create a new database\n" );
|
||||
errCause += QString::fromUtf8(sqlite3_errmsg(sqlite_handle));
|
||||
sqlite3_close(sqlite_handle);
|
||||
QMessageBox::warning( 0, tr( "SpatiaLite Database" ), errCause );
|
||||
pbnFindSRID->setEnabled( false );
|
||||
return false;
|
||||
}
|
||||
// activating Foreign Key constraints
|
||||
ret = sqlite3_exec(sqlite_handle, "PRAGMA foreign_keys = 1", NULL, 0, &errMsg);
|
||||
if (ret != SQLITE_OK)
|
||||
{
|
||||
QMessageBox::warning( 0, tr( "SpatiaLite Database" ), tr( "Unable to activate FOREIGN_KEY constraints" ) );
|
||||
sqlite3_free(errMsg);
|
||||
sqlite3_close(sqlite_handle);
|
||||
pbnFindSRID->setEnabled( false );
|
||||
return false;
|
||||
}
|
||||
initializeSpatialMetadata(sqlite_handle);
|
||||
|
||||
// all done: closing the DB connection
|
||||
sqlite3_close(sqlite_handle);
|
||||
}
|
||||
|
||||
QFileInfo fi( newDb );
|
||||
|
@ -59,6 +59,9 @@ class QgsNewSpatialiteLayerDialog: public QDialog, private Ui::QgsNewSpatialiteL
|
||||
/** Create a new database */
|
||||
bool createDb();
|
||||
|
||||
/** Initializes SpatialMetadata db-tables */
|
||||
void initializeSpatialMetadata( sqlite3 *sqlite_handle );
|
||||
|
||||
static QString quotedIdentifier( QString id );
|
||||
static QString quotedValue( QString value );
|
||||
};
|
||||
|
@ -277,14 +277,6 @@ const QString QgsApplication::qgisMasterDbFilePath()
|
||||
return mPkgDataPath + QString( "/resources/qgis.db" );
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the path to the spatialite template db file.
|
||||
*/
|
||||
const QString QgsApplication::qgisSpatialiteDbTemplatePath()
|
||||
{
|
||||
return mPkgDataPath + QString( "/resources/spatialite.db" );
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the path to the settings directory in user's home dir
|
||||
*/
|
||||
|
@ -90,10 +90,6 @@ class CORE_EXPORT QgsApplication: public QApplication
|
||||
//! Returns the path to the master qgis.db file.
|
||||
static const QString qgisMasterDbFilePath();
|
||||
|
||||
//! Returns the path to the spatialite template db file.
|
||||
//! @note added in 1.5
|
||||
static const QString qgisSpatialiteDbTemplatePath();
|
||||
|
||||
//! Returns the path to the settings directory in user's home dir
|
||||
static const QString qgisSettingsDirPath();
|
||||
|
||||
|
@ -57,7 +57,6 @@ extern "C"
|
||||
#endif
|
||||
|
||||
SPATIALITE_DECLARE const char *spatialite_version (void);
|
||||
SPATIALITE_DECLARE const char *virtualtext_version (void);
|
||||
SPATIALITE_DECLARE void spatialite_init (int verbose);
|
||||
SPATIALITE_DECLARE int dump_shapefile (sqlite3 * sqlite, char *table,
|
||||
char *column, char *charset,
|
||||
@ -65,10 +64,16 @@ extern "C"
|
||||
int verbose, int *rows);
|
||||
SPATIALITE_DECLARE int load_shapefile (sqlite3 * sqlite, char *shp_path,
|
||||
char *table, char *charset, int srid,
|
||||
char *column, int verbose,
|
||||
char *column, int coerce2d,
|
||||
int compressed, int verbose,
|
||||
int *rows);
|
||||
SPATIALITE_DECLARE int load_dbf (sqlite3 * sqlite, char *shp_path,
|
||||
char *table, char *charset, int verbose,
|
||||
int *rows);
|
||||
SPATIALITE_DECLARE double math_round (double value);
|
||||
SPATIALITE_DECLARE sqlite3_int64 math_llabs (sqlite3_int64 value);
|
||||
SPATIALITE_DECLARE void spatial_ref_sys_init (sqlite3 * sqlite,
|
||||
int verbose);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -58,11 +58,9 @@ extern "C"
|
||||
|
||||
/* function prototipes */
|
||||
|
||||
GAIAAUX_DECLARE const char *gaiaGetLocaleCharset ();
|
||||
GAIAAUX_DECLARE const char *gaiaGetLocaleCharset (void);
|
||||
GAIAAUX_DECLARE int gaiaConvertCharset (char **buf, const char *fromCs,
|
||||
const char *toCs);
|
||||
GAIAAUX_DECLARE int gaiaToUTF8 (char **buf, const char *fromCs,
|
||||
const char *toCs);
|
||||
GAIAAUX_DECLARE void *gaiaCreateUTF8Converter (const char *fromCS);
|
||||
GAIAAUX_DECLARE void gaiaFreeUTF8Converter (void *cvtCS);
|
||||
GAIAAUX_DECLARE char *gaiaConvertToUTF8 (void *cvtCS, const char *buf,
|
||||
|
@ -67,7 +67,6 @@ extern "C"
|
||||
#define GAIA_PDF_BLOB 7
|
||||
#define GAIA_GEOMETRY_BLOB 8
|
||||
#define GAIA_TIFF_BLOB 9
|
||||
#define GAIA_WAVELET_BLOB 10
|
||||
|
||||
/* constants used for EXIF value types */
|
||||
#define GAIA_EXIF_NONE 0
|
||||
|
@ -158,6 +158,7 @@ extern "C"
|
||||
/* constants used for VirtualNetwork */
|
||||
#define GAIA_NET_START 0x67
|
||||
#define GAIA_NET64_START 0x68
|
||||
#define GAIA_NET64_A_STAR_START 0x69
|
||||
#define GAIA_NET_END 0x87
|
||||
#define GAIA_NET_HEADER 0xc0
|
||||
#define GAIA_NET_CODE 0xa6
|
||||
@ -169,6 +170,7 @@ extern "C"
|
||||
#define GAIA_NET_TO 0xa2
|
||||
#define GAIA_NET_GEOM 0xa3
|
||||
#define GAIA_NET_NAME 0xa4
|
||||
#define GAIA_NET_A_STAR_COEFF 0xa5
|
||||
#define GAIA_NET_BLOCK 0xed
|
||||
|
||||
/* constants used for Coordinate Dimensions */
|
||||
@ -346,6 +348,7 @@ extern "C"
|
||||
double MaxY; /* MBR - BBOX */
|
||||
int DimensionModel; /* (x,y), (x,y,z), (x,y,m) or (x,y,z,m) */
|
||||
int DeclaredType; /* the declared TYPE for this Geometry */
|
||||
struct gaiaGeomCollStruct *Next; /* Vanuatu - used for linked list */
|
||||
} gaiaGeomColl;
|
||||
typedef gaiaGeomColl *gaiaGeomCollPtr;
|
||||
|
||||
@ -374,7 +377,7 @@ extern "C"
|
||||
char *Name; /* field name */
|
||||
unsigned char Type; /* field type */
|
||||
int Offset; /* buffer offset [this field begins at *buffer+offset* and extends for *length* bytes */
|
||||
unsigned char Length; /* field total length [in bytes] */
|
||||
unsigned char Length; /* field total lenght [in bytes] */
|
||||
unsigned char Decimals; /* decimal positions */
|
||||
gaiaValuePtr Value; /* the current multitype value for this attribute */
|
||||
struct gaiaDbfFieldStruct *Next; /* pointer to next element in linked list */
|
||||
@ -391,12 +394,30 @@ extern "C"
|
||||
} gaiaDbfList;
|
||||
typedef gaiaDbfList *gaiaDbfListPtr;
|
||||
|
||||
typedef struct gaiaDbfStruct
|
||||
{
|
||||
/* DBF TYPE */
|
||||
int endian_arch;
|
||||
int Valid; /* 1 = ready to process */
|
||||
char *Path; /* the DBF path */
|
||||
FILE *flDbf; /* the DBF file handle */
|
||||
gaiaDbfListPtr Dbf; /* the DBF attributes list */
|
||||
unsigned char *BufDbf; /* the DBF I/O buffer */
|
||||
int DbfHdsz; /* the DBF header length */
|
||||
int DbfReclen; /* the DBF record length */
|
||||
int DbfSize; /* current DBF size */
|
||||
int DbfRecno; /* current DBF record number */
|
||||
void *IconvObj; /* opaque reference to ICONV converter */
|
||||
char *LastError; /* last error message */
|
||||
} gaiaDbf;
|
||||
typedef gaiaDbf *gaiaDbfPtr;
|
||||
|
||||
typedef struct gaiaShapefileStruct
|
||||
{
|
||||
/* SHAPEFILE TYPE */
|
||||
int endian_arch;
|
||||
int Valid; /* 1 = ready to process */
|
||||
int ReadOnly; /* read or wite mode */
|
||||
int ReadOnly; /* read or write mode */
|
||||
char *Path; /* the shapefile abstract path [no suffixes] */
|
||||
FILE *flShx; /* the SHX file handle */
|
||||
FILE *flShp; /* the SHP file handle */
|
||||
@ -423,6 +444,95 @@ extern "C"
|
||||
} gaiaShapefile;
|
||||
typedef gaiaShapefile *gaiaShapefilePtr;
|
||||
|
||||
typedef struct gaiaOutBufferStruct
|
||||
{
|
||||
/* a struct handling a dynamically growing output buffer */
|
||||
char *Buffer;
|
||||
int WriteOffset;
|
||||
int BufferSize;
|
||||
int Error;
|
||||
} gaiaOutBuffer;
|
||||
typedef gaiaOutBuffer *gaiaOutBufferPtr;
|
||||
|
||||
#ifndef OMIT_ICONV /* ICONV enabled: supporting text reader */
|
||||
|
||||
#define VRTTXT_FIELDS_MAX 65535
|
||||
#define VRTTXT_BLOCK_MAX 65535
|
||||
|
||||
#define VRTTXT_TEXT 1
|
||||
#define VRTTXT_INTEGER 2
|
||||
#define VRTTXT_DOUBLE 3
|
||||
#define VRTTXT_NULL 4
|
||||
|
||||
struct vrttxt_line
|
||||
{
|
||||
/* a struct representing a full LINE (aka Record) */
|
||||
off_t offset;
|
||||
int len;
|
||||
int field_offsets[VRTTXT_FIELDS_MAX];
|
||||
int num_fields;
|
||||
int error;
|
||||
};
|
||||
|
||||
struct vrttxt_row
|
||||
{
|
||||
/* a struct storing Row offsets */
|
||||
int line_no;
|
||||
off_t offset;
|
||||
int len;
|
||||
int num_fields;
|
||||
};
|
||||
|
||||
struct vrttxt_row_block
|
||||
{
|
||||
/*
|
||||
/ for efficiency sake, individuale Row offsets
|
||||
/ are grouped in reasonably sized blocks
|
||||
*/
|
||||
struct vrttxt_row rows[VRTTXT_BLOCK_MAX];
|
||||
int num_rows;
|
||||
int min_line_no;
|
||||
int max_line_no;
|
||||
struct vrttxt_row_block *next;
|
||||
};
|
||||
|
||||
struct vrttxt_column_header
|
||||
{
|
||||
/* a struct representing a Column (aka Field) header */
|
||||
char *name;
|
||||
int type;
|
||||
};
|
||||
|
||||
typedef struct vrttxt_reader
|
||||
{
|
||||
/* the main TXT-Reader struct */
|
||||
struct vrttxt_column_header columns[VRTTXT_FIELDS_MAX];
|
||||
FILE *text_file;
|
||||
void *toUtf8; /* the UTF-8 ICONV converter */
|
||||
char field_separator;
|
||||
char text_separator;
|
||||
char decimal_separator;
|
||||
int first_line_titles;
|
||||
int error;
|
||||
struct vrttxt_row_block *first;
|
||||
struct vrttxt_row_block *last;
|
||||
struct vrttxt_row **rows;
|
||||
int num_rows;
|
||||
int line_no;
|
||||
int max_fields;
|
||||
int current_buf_sz;
|
||||
int current_buf_off;
|
||||
char *line_buffer;
|
||||
char *field_buffer;
|
||||
int field_offsets[VRTTXT_FIELDS_MAX];
|
||||
int field_lens[VRTTXT_FIELDS_MAX];
|
||||
int max_current_field;
|
||||
int current_line_ready;
|
||||
} gaiaTextReader;
|
||||
typedef gaiaTextReader *gaiaTextReaderPtr;
|
||||
|
||||
#endif /* end ICONV (text reader) */
|
||||
|
||||
/* function prototipes */
|
||||
|
||||
GAIAGEO_DECLARE int gaiaEndianArch (void);
|
||||
@ -608,13 +718,6 @@ extern "C"
|
||||
unsigned int size);
|
||||
GAIAGEO_DECLARE void gaiaToWkb (gaiaGeomCollPtr geom,
|
||||
unsigned char **result, int *size);
|
||||
GAIAGEO_DECLARE int gaiaFromWkbNoCheck (const unsigned char *in,
|
||||
unsigned int szin,
|
||||
unsigned char **out, int *szout,
|
||||
int srid);
|
||||
GAIAGEO_DECLARE int gaiaToWkbNoCheck (const unsigned char *in,
|
||||
unsigned int szin,
|
||||
unsigned char **out, int *szout);
|
||||
GAIAGEO_DECLARE char *gaiaToHexWkb (gaiaGeomCollPtr geom);
|
||||
GAIAGEO_DECLARE void gaiaFreeValue (gaiaValuePtr p);
|
||||
GAIAGEO_DECLARE void gaiaSetNullValue (gaiaDbfFieldPtr field);
|
||||
@ -659,11 +762,28 @@ extern "C"
|
||||
GAIAGEO_DECLARE int gaiaWriteShpEntity (gaiaShapefilePtr shp,
|
||||
gaiaDbfListPtr entity);
|
||||
GAIAGEO_DECLARE void gaiaFlushShpHeaders (gaiaShapefilePtr shp);
|
||||
GAIAGEO_DECLARE gaiaDbfPtr gaiaAllocDbf (void);
|
||||
GAIAGEO_DECLARE void gaiaFreeDbf (gaiaDbfPtr dbf);
|
||||
GAIAGEO_DECLARE void gaiaOpenDbfRead (gaiaDbfPtr dbf,
|
||||
const char *path,
|
||||
const char *charFrom,
|
||||
const char *charTo);
|
||||
GAIAGEO_DECLARE int gaiaReadDbfEntity (gaiaDbfPtr shp, int current_row,
|
||||
int *deleted);
|
||||
GAIAGEO_DECLARE gaiaGeomCollPtr gaiaParseWkt (const unsigned char
|
||||
*dirty_buffer, short type);
|
||||
GAIAGEO_DECLARE void gaiaOutWkt (gaiaGeomCollPtr geom, char **result);
|
||||
GAIAGEO_DECLARE void gaiaOutSvg (gaiaGeomCollPtr geom, char **result,
|
||||
int relative, int precision);
|
||||
GAIAGEO_DECLARE void gaiaOutWkt (gaiaOutBufferPtr out_buf,
|
||||
gaiaGeomCollPtr geom);
|
||||
GAIAGEO_DECLARE void gaiaOutSvg (gaiaOutBufferPtr out_buf,
|
||||
gaiaGeomCollPtr geom, int relative,
|
||||
int precision);
|
||||
GAIAGEO_DECLARE void gaiaOutBareKml (gaiaOutBufferPtr out_buf,
|
||||
gaiaGeomCollPtr geom, int precision);
|
||||
GAIAGEO_DECLARE void gaiaOutFullKml (gaiaOutBufferPtr out_buf,
|
||||
const char *name, const char *desc,
|
||||
gaiaGeomCollPtr geom, int precision);
|
||||
GAIAGEO_DECLARE void gaiaOutGml (gaiaOutBufferPtr out_buf, int version,
|
||||
int precision, gaiaGeomCollPtr geom);
|
||||
GAIAGEO_DECLARE gaiaGeomCollPtr gaiaFromFgf (const unsigned char *blob,
|
||||
unsigned int size);
|
||||
GAIAGEO_DECLARE void gaiaToFgf (gaiaGeomCollPtr geom,
|
||||
@ -752,6 +872,21 @@ extern "C"
|
||||
double *coords, int vert);
|
||||
GAIAGEO_DECLARE int gaiaConvertLength (double value, int unit_from,
|
||||
int unit_to, double *cvt);
|
||||
GAIAGEO_DECLARE int gaiaLineGetPoint (gaiaLinestringPtr ln, int v,
|
||||
double *x, double *y, double *z,
|
||||
double *m);
|
||||
GAIAGEO_DECLARE int gaiaLineSetPoint (gaiaLinestringPtr ln, int v, double x,
|
||||
double y, double z, double m);
|
||||
GAIAGEO_DECLARE int gaiaRingGetPoint (gaiaRingPtr rng, int v, double *x,
|
||||
double *y, double *z, double *m);
|
||||
GAIAGEO_DECLARE int gaiaRingSetPoint (gaiaRingPtr rng, int v, double x,
|
||||
double y, double z, double m);
|
||||
GAIAGEO_DECLARE gaiaGeomCollPtr gaiaSanitize (gaiaGeomCollPtr org);
|
||||
GAIAGEO_DECLARE int gaiaIsToxic (gaiaGeomCollPtr org);
|
||||
GAIAGEO_DECLARE void gaiaOutBufferInitialize (gaiaOutBufferPtr buf);
|
||||
GAIAGEO_DECLARE void gaiaOutBufferReset (gaiaOutBufferPtr buf);
|
||||
GAIAGEO_DECLARE void gaiaAppendToOutBuffer (gaiaOutBufferPtr buf,
|
||||
const char *text);
|
||||
|
||||
#ifndef OMIT_PROJ /* including PROJ.4 */
|
||||
|
||||
@ -765,6 +900,12 @@ extern "C"
|
||||
|
||||
#ifndef OMIT_GEOS /* including GEOS */
|
||||
|
||||
GAIAGEO_DECLARE void gaiaResetGeosMsg (void);
|
||||
GAIAGEO_DECLARE const char *gaiaGetGeosErrorMsg (void);
|
||||
GAIAGEO_DECLARE const char *gaiaGetGeosWarningMsg (void);
|
||||
GAIAGEO_DECLARE void gaiaSetGeosErrorMsg (const char *msg);
|
||||
GAIAGEO_DECLARE void gaiaSetGeosWarningMsg (const char *msg);
|
||||
|
||||
GAIAGEO_DECLARE int gaiaGeomCollEquals (gaiaGeomCollPtr geom1,
|
||||
gaiaGeomCollPtr geom2);
|
||||
GAIAGEO_DECLARE int gaiaGeomCollDisjoint (gaiaGeomCollPtr geom1,
|
||||
@ -832,6 +973,25 @@ extern "C"
|
||||
|
||||
#endif /* end including GEOS */
|
||||
|
||||
#ifndef OMIT_ICONV /* ICONV enabled: supporting text reader */
|
||||
GAIAGEO_DECLARE gaiaTextReaderPtr gaiaTextReaderAlloc (const char *path,
|
||||
char field_separator,
|
||||
char text_separator,
|
||||
char
|
||||
decimal_separator,
|
||||
int
|
||||
first_line_titles,
|
||||
const char
|
||||
*encoding);
|
||||
GAIAGEO_DECLARE void gaiaTextReaderDestroy (gaiaTextReaderPtr reader);
|
||||
GAIAGEO_DECLARE int gaiaTextReaderParse (gaiaTextReaderPtr reader);
|
||||
GAIAGEO_DECLARE int gaiaTextReaderGetRow (gaiaTextReaderPtr reader,
|
||||
int row_num);
|
||||
GAIAGEO_DECLARE int gaiaTextReaderFetchField (gaiaTextReaderPtr reader,
|
||||
int field_num, int *type,
|
||||
const char **value);
|
||||
#endif /* end ICONV (text reader) */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -43,6 +43,7 @@ the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*/
|
||||
|
||||
int virtualshape_extension_init (sqlite3 * db);
|
||||
int virtualdbf_extension_init (sqlite3 * db);
|
||||
int virtualtext_extension_init (sqlite3 * db);
|
||||
int virtualnetwork_extension_init (sqlite3 * db);
|
||||
int virtualfdo_extension_init (sqlite3 * db);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,3 +1,232 @@
|
||||
/*
|
||||
** alias MACROs to avoid any potential collision
|
||||
** for linker symbols declared into the sqlite3 code
|
||||
** internally embedded into SpatiaLite
|
||||
*/
|
||||
#define sqlite3_version SPLite3_version
|
||||
#define sqlite3_libversion SPLite3_libversion
|
||||
#define sqlite3_sourceid SPLite3_sourceid
|
||||
#define sqlite3_libversion_number SPLite3_libversion_number
|
||||
#define sqlite3_compileoption_used SPLite3_compileoption_used
|
||||
#define sqlite3_compileoption_get SPLite3_compileoption_get
|
||||
#define sqlite3_threadsafe SPLite3_threadsafe
|
||||
#define sqlite3_close SPLite3_close
|
||||
#define sqlite3_exec SPLite3_exec
|
||||
#define sqlite3_initialize SPLite3_initialize
|
||||
#define sqlite3_shutdown SPLite3_shutdown
|
||||
#define sqlite3_os_init SPLite3_os_init
|
||||
#define sqlite3_os_end SPLite3_os_end
|
||||
#define sqlite3_config SPLite3_config
|
||||
#define sqlite3_db_config SPLite3_db_config
|
||||
#define sqlite3_extended_result_codes SPLite3_extended_result_codes
|
||||
#define sqlite3_last_insert_rowid SPLite3_last_insert_rowid
|
||||
#define sqlite3_changes SPLite3_changes
|
||||
#define sqlite3_total_changes SPLite3_total_changes
|
||||
#define sqlite3_interrupt SPLite3_interrupt
|
||||
#define sqlite3_complete SPLite3_complete
|
||||
#define sqlite3_complete16 SPLite3_complete16
|
||||
#define sqlite3_busy_handler SPLite3_busy_handler
|
||||
#define sqlite3_busy_timeout SPLite3_busy_timeout
|
||||
#define sqlite3_get_table SPLite3_get_table
|
||||
#define sqlite3_free_table SPLite3_free_table
|
||||
#define sqlite3_mprintf SPLite3_mprintf
|
||||
#define sqlite3_vmprintf SPLite3_vmprintf
|
||||
#define sqlite3_snprintf SPLite3_snprintf
|
||||
#define sqlite3_malloc SPLite3_malloc
|
||||
#define sqlite3_realloc SPLite3_realloc
|
||||
#define sqlite3_free SPLite3_free
|
||||
#define sqlite3_memory_used SPLite3_memory_used
|
||||
#define sqlite3_memory_highwater SPLite3_memory_highwater
|
||||
#define sqlite3_randomness SPLite3_randomness
|
||||
#define sqlite3_set_authorizer SPLite3_set_authorizer
|
||||
#define sqlite3_trace SPLite3_trace
|
||||
#define sqlite3_progress_handler SPLite3_progress_handler
|
||||
#define sqlite3_open SPLite3_open
|
||||
#define sqlite3_open16 SPLite3_open16
|
||||
#define sqlite3_open_v2 SPLite3_open_v2
|
||||
#define sqlite3_errcode SPLite3_errcode
|
||||
#define sqlite3_extended_errcode SPLite3_extended_errcode
|
||||
#define sqlite3_errmsg SPLite3_errmsg
|
||||
#define sqlite3_errmsg16 SPLite3_errmsg16
|
||||
#define sqlite3_limit SPLite3_limit
|
||||
#define sqlite3_prepare SPLite3_prepare
|
||||
#define sqlite3_prepare_v2 SPLite3_prepare_v2
|
||||
#define sqlite3_prepare16 SPLite3_prepare16
|
||||
#define sqlite3_prepare16_v2 SPLite3_prepare16_v2
|
||||
#define sqlite3_sql SPLite3_sql
|
||||
#define sqlite3_bind_blob SPLite3_bind_blob
|
||||
#define sqlite3_bind_double SPLite3_bind_double
|
||||
#define sqlite3_bind_int SPLite3_bind_int
|
||||
#define sqlite3_bind_int64 SPLite3_bind_int64
|
||||
#define sqlite3_bind_null SPLite3_bind_null
|
||||
#define sqlite3_bind_text SPLite3_bind_text
|
||||
#define sqlite3_bind_text16 SPLite3_bind_text16
|
||||
#define sqlite3_bind_value SPLite3_bind_value
|
||||
#define sqlite3_bind_zeroblob SPLite3_bind_zeroblob
|
||||
#define sqlite3_bind_parameter_count SPLite3_bind_parameter_count
|
||||
#define sqlite3_bind_parameter_name SPLite3_bind_parameter_name
|
||||
#define sqlite3_bind_parameter_index SPLite3_bind_parameter_index
|
||||
#define sqlite3_clear_bindings SPLite3_clear_bindings
|
||||
#define sqlite3_column_count SPLite3_column_count
|
||||
#define sqlite3_column_name SPLite3_column_name
|
||||
#define sqlite3_column_name16 SPLite3_column_name16
|
||||
#define sqlite3_column_database_name SPLite3_column_database_name
|
||||
#define sqlite3_column_database_name16 SPLite3_column_database_name16
|
||||
#define sqlite3_column_table_name SPLite3_column_table_name
|
||||
#define sqlite3_column_table_name16 SPLite3_column_table_name16
|
||||
#define sqlite3_column_origin_name SPLite3_column_origin_name
|
||||
#define sqlite3_column_origin_name16 SPLite3_column_origin_name16
|
||||
#define sqlite3_column_decltype SPLite3_column_decltype
|
||||
#define sqlite3_column_decltype16 SPLite3_column_decltype16
|
||||
#define sqlite3_step SPLite3_step
|
||||
#define sqlite3_data_count SPLite3_data_count
|
||||
#define sqlite3_column_blob SPLite3_column_blob
|
||||
#define sqlite3_column_bytes SPLite3_column_bytes
|
||||
#define sqlite3_column_bytes16 SPLite3_column_bytes16
|
||||
#define sqlite3_column_double SPLite3_column_double
|
||||
#define sqlite3_column_int SPLite3_column_int
|
||||
#define sqlite3_column_int64 SPLite3_column_int64
|
||||
#define sqlite3_column_text SPLite3_column_text
|
||||
#define sqlite3_column_text16 SPLite3_column_text16
|
||||
#define sqlite3_column_type SPLite3_column_type
|
||||
#define sqlite3_column_value SPLite3_column_value
|
||||
#define sqlite3_finalize SPLite3_finalize
|
||||
#define sqlite3_reset SPLite3_reset
|
||||
#define sqlite3_create_function SPLite3_create_function
|
||||
#define sqlite3_create_function16 SPLite3_create_function16
|
||||
#define sqlite3_create_function_v2 SPLite3_create_function_v2
|
||||
#define sqlite3_value_blob SPLite3_value_blob
|
||||
#define sqlite3_value_bytes SPLite3_value_bytes
|
||||
#define sqlite3_value_bytes16 SPLite3_value_bytes16
|
||||
#define sqlite3_value_double SPLite3_value_double
|
||||
#define sqlite3_value_int SPLite3_value_int
|
||||
#define sqlite3_value_int64 SPLite3_value_int64
|
||||
#define sqlite3_value_text SPLite3_value_text
|
||||
#define sqlite3_value_text16 SPLite3_value_text16
|
||||
#define sqlite3_value_text16le SPLite3_value_text16le
|
||||
#define sqlite3_value_text16be SPLite3_value_text16be
|
||||
#define sqlite3_value_type SPLite3_value_type
|
||||
#define sqlite3_value_numeric_type SPLite3_value_numeric_type
|
||||
#define sqlite3_aggregate_context SPLite3_aggregate_context
|
||||
#define sqlite3_user_data SPLite3_user_data
|
||||
#define sqlite3_context_db_handle SPLite3_context_db_handle
|
||||
#define sqlite3_get_auxdata SPLite3_get_auxdata
|
||||
#define sqlite3_set_auxdata SPLite3_set_auxdata
|
||||
#define sqlite3_result_blob SPLite3_result_blob
|
||||
#define sqlite3_result_double SPLite3_result_double
|
||||
#define sqlite3_result_error SPLite3_result_error
|
||||
#define sqlite3_result_error16 SPLite3_result_error16
|
||||
#define sqlite3_result_error_toobig SPLite3_result_error_toobig
|
||||
#define sqlite3_result_error_nomem SPLite3_result_error_nomem
|
||||
#define sqlite3_result_error_code SPLite3_result_error_code
|
||||
#define sqlite3_result_int SPLite3_result_int
|
||||
#define sqlite3_result_int64 SPLite3_result_int64
|
||||
#define sqlite3_result_null SPLite3_result_null
|
||||
#define sqlite3_result_text SPLite3_result_text
|
||||
#define sqlite3_result_text16 SPLite3_result_text16
|
||||
#define sqlite3_result_text16le SPLite3_result_text16le
|
||||
#define sqlite3_result_text16be SPLite3_result_text16be
|
||||
#define sqlite3_result_value SPLite3_result_value
|
||||
#define sqlite3_result_zeroblob SPLite3_result_zeroblob
|
||||
#define sqlite3_create_collation SPLite3_create_collation
|
||||
#define sqlite3_create_collation_v2 SPLite3_create_collation_v2
|
||||
#define sqlite3_create_collation16 SPLite3_create_collation16
|
||||
#define sqlite3_collation_needed SPLite3_collation_needed
|
||||
#define sqlite3_collation_needed16 SPLite3_collation_needed16
|
||||
#define sqlite3_key SPLite3_key
|
||||
#define sqlite3_rekey SPLite3_rekey
|
||||
#define sqlite3_activate_see SPLite3_activate_see
|
||||
#define sqlite3_activate_cerod SPLite3_activate_cerod
|
||||
#define sqlite3_sleep SPLite3_sleep
|
||||
#define sqlite3_temp_directory SPLite3_temp_directory
|
||||
#define sqlite3_get_autocommit SPLite3_get_autocommit
|
||||
#define sqlite3_db_handle SPLite3_db_handle
|
||||
#define sqlite3_next_stmt SPLite3_next_stmt
|
||||
#define sqlite3_commit_hook SPLite3_commit_hook
|
||||
#define sqlite3_rollback_hook SPLite3_rollback_hook
|
||||
#define sqlite3_update_hook SPLite3_update_hook
|
||||
#define sqlite3_enable_shared_cache SPLite3_enable_shared_cache
|
||||
#define sqlite3_release_memory SPLite3_release_memory
|
||||
#define sqlite3_soft_heap_limit64 SPLite3_soft_heap_limit64
|
||||
#define sqlite3_table_column_metadata SPLite3_table_column_metadata
|
||||
#define sqlite3_load_extension SPLite3_load_extension
|
||||
#define sqlite3_enable_load_extension SPLite3_enable_load_extension
|
||||
#define sqlite3_auto_extension SPLite3_auto_extension
|
||||
#define sqlite3_reset_auto_extension SPLite3_reset_auto_extension
|
||||
#define sqlite3_create_module SPLite3_create_module
|
||||
#define sqlite3_create_module_v2 SPLite3_create_module_v2
|
||||
#define sqlite3_declare_vtab SPLite3_declare_vtab
|
||||
#define sqlite3_overload_function SPLite3_overload_function
|
||||
#define sqlite3_blob_open SPLite3_blob_open
|
||||
#define sqlite3_blob_close SPLite3_blob_close
|
||||
#define sqlite3_blob_bytes SPLite3_blob_bytes
|
||||
#define sqlite3_blob_read SPLite3_blob_read
|
||||
#define sqlite3_blob_write SPLite3_blob_write
|
||||
#define sqlite3_vfs_find SPLite3_vfs_find
|
||||
#define sqlite3_vfs_register SPLite3_vfs_register
|
||||
#define sqlite3_vfs_unregister SPLite3_vfs_unregister
|
||||
#define sqlite3_mutex_alloc SPLite3_mutex_alloc
|
||||
#define sqlite3_mutex_free SPLite3_mutex_free
|
||||
#define sqlite3_mutex_enter SPLite3_mutex_enter
|
||||
#define sqlite3_mutex_try SPLite3_mutex_try
|
||||
#define sqlite3_mutex_leave SPLite3_mutex_leave
|
||||
#define sqlite3_mutex_held SPLite3_mutex_held
|
||||
#define sqlite3_mutex_notheld SPLite3_mutex_notheld
|
||||
#define sqlite3_db_mutex SPLite3_db_mutex
|
||||
#define sqlite3_file_control SPLite3_file_control
|
||||
#define sqlite3_test_control SPLite3_test_control
|
||||
#define sqlite3_status SPLite3_status
|
||||
#define sqlite3_db_status SPLite3_db_status
|
||||
#define sqlite3_stmt_status SPLite3_stmt_status
|
||||
#define sqlite3_backup_init SPLite3_backup_init
|
||||
#define sqlite3_backup_step SPLite3_backup_step
|
||||
#define sqlite3_backup_finish SPLite3_backup_finish
|
||||
#define sqlite3_backup_remaining SPLite3_backup_remaining
|
||||
#define sqlite3_backup_pagecount SPLite3_backup_pagecount
|
||||
#define sqlite3_unlock_notify SPLite3_unlock_notify
|
||||
#define sqlite3_strnicmp SPLite3_strnicmp
|
||||
#define sqlite3_log SPLite3_log
|
||||
#define sqlite3_wal_hook SPLite3_wal_hook
|
||||
#define sqlite3_wal_autocheckpoint SPLite3_wal_autocheckpoint
|
||||
#define sqlite3_wal_checkpoint SPLite3_wal_checkpoint
|
||||
#define sqlite3_rtree_geometry_callback SPLite3_rtree_geometry_callback
|
||||
#define sqlite3_memdebug_vfs_oom_test SPLite3_memdebug_vfs_oom_test
|
||||
#define sqlite3_memory_alarm SPLite3_memory_alarm
|
||||
#define sqlite3_soft_heap_limit SPLite3_soft_heap_limit
|
||||
#define sqlite3_io_error_hit SPLite3_io_error_hit
|
||||
#define sqlite3_io_error_hardhit SPLite3_io_error_hardhit
|
||||
#define sqlite3_io_error_pending SPLite3_io_error_pending
|
||||
#define sqlite3_io_error_persist SPLite3_io_error_persist
|
||||
#define sqlite3_io_error_benign SPLite3_io_error_benign
|
||||
#define sqlite3_diskfull_pending SPLite3_diskfull_pending
|
||||
#define sqlite3_diskfull SPLite3_diskfull
|
||||
#define sqlite3_open_file_count SPLite3_open_file_count
|
||||
#define sqlite3_sync_count SPLite3_sync_count
|
||||
#define sqlite3_fullsync_count SPLite3_fullsync_count
|
||||
#define sqlite3_current_time SPLite3_current_time
|
||||
#define sqlite3_hostid_num SPLite3_hostid_num
|
||||
#define sqlite3_os_type SPLite3_os_type
|
||||
#define sqlite3_win32_mbcs_to_utf8 SPLite3_win32_mbcs_to_utf8
|
||||
#define sqlite3_pager_readdb_count SPLite3_pager_readdb_count
|
||||
#define sqlite3_pager_writedb_count SPLite3_pager_writedb_count
|
||||
#define sqlite3_pager_writej_count SPLite3_pager_writej_count
|
||||
#define sqlite3_opentemp_count SPLite3_opentemp_count
|
||||
#define sqlite3_expired SPLite3_expired
|
||||
#define sqlite3_aggregate_count SPLite3_aggregate_count
|
||||
#define sqlite3_transfer_bindings SPLite3_transfer_bindings
|
||||
#define sqlite3_search_count SPLite3_search_count
|
||||
#define sqlite3_interrupt_count SPLite3_interrupt_count
|
||||
#define sqlite3_sort_count SPLite3_sort_count
|
||||
#define sqlite3_max_blobsize SPLite3_max_blobsize
|
||||
#define sqlite3_found_count SPLite3_found_count
|
||||
#define sqlite3_like_count SPLite3_like_count
|
||||
#define sqlite3_xferopt_count SPLite3_xferopt_count
|
||||
#define sqlite3_profile SPLite3_profile
|
||||
#define sqlite3_global_recover SPLite3_global_recover
|
||||
#define sqlite3_thread_cleanup SPLite3_thread_cleanup
|
||||
#define sqlite3_fts3_enable_parentheses SPLite3_fts3_enable_parentheses
|
||||
/* end SpatiaLite/sqlite3 alias macros */
|
||||
|
||||
/*
|
||||
** 2006 June 7
|
||||
**
|
||||
@ -14,8 +243,6 @@
|
||||
** an SQLite instance. Shared libraries that intend to be loaded
|
||||
** as extensions by SQLite should #include this file instead of
|
||||
** sqlite3.h.
|
||||
**
|
||||
** @(#) $Id: sqlite3ext.h,v 1.25 2008/10/12 00:27:54 shane Exp $
|
||||
*/
|
||||
#ifndef _SQLITE3EXT_H_
|
||||
#define _SQLITE3EXT_H_
|
||||
@ -197,7 +424,7 @@ struct sqlite3_api_routines {
|
||||
|
||||
/*
|
||||
** The following macros redefine the API routines so that they are
|
||||
** redirected through the global sqlite3_api structure.
|
||||
** redirected throught the global sqlite3_api structure.
|
||||
**
|
||||
** This header file is also used by the loadext.c source file
|
||||
** (part of the main SQLite library - not an extension) so that
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -253,8 +253,56 @@ void QgsOfflineEditing::synchronize( QgsLegendInterface* legendInterface )
|
||||
sqlite3_close( db );
|
||||
}
|
||||
|
||||
void QgsOfflineEditing::initializeSpatialMetadata(sqlite3 *sqlite_handle)
|
||||
{
|
||||
// attempting to perform self-initialization for a newly created DB
|
||||
int ret;
|
||||
char sql[1024];
|
||||
char *errMsg = NULL;
|
||||
int count;
|
||||
int i;
|
||||
char **results;
|
||||
int rows;
|
||||
int columns;
|
||||
|
||||
if (sqlite_handle == NULL)
|
||||
return;
|
||||
// checking if this DB is really empty
|
||||
strcpy(sql, "SELECT Count(*) from sqlite_master");
|
||||
ret = sqlite3_get_table(sqlite_handle, sql, &results, &rows, &columns, NULL);
|
||||
if (ret != SQLITE_OK)
|
||||
return;
|
||||
if (rows < 1)
|
||||
;
|
||||
else
|
||||
{
|
||||
for (i = 1; i <= rows; i++)
|
||||
count = atoi(results[(i * columns) + 0]);
|
||||
}
|
||||
sqlite3_free_table(results);
|
||||
|
||||
if (count > 0)
|
||||
return;
|
||||
|
||||
// all right, it's empty: proceding to initialize
|
||||
strcpy(sql, "SELECT InitSpatialMetadata()");
|
||||
ret = sqlite3_exec(sqlite_handle, sql, NULL, NULL, &errMsg);
|
||||
if (ret != SQLITE_OK)
|
||||
{
|
||||
QString errCause = tr( "Unable to initialize SpatialMetedata:\n" );
|
||||
errCause += QString::fromUtf8(errMsg);
|
||||
showWarning( errCause );
|
||||
sqlite3_free(errMsg);
|
||||
return;
|
||||
}
|
||||
spatial_ref_sys_init(sqlite_handle, 0);
|
||||
}
|
||||
|
||||
bool QgsOfflineEditing::createSpatialiteDB( const QString& offlineDbPath )
|
||||
{
|
||||
int ret;
|
||||
sqlite3 *sqlite_handle;
|
||||
char *errMsg = NULL;
|
||||
QFile newDb( offlineDbPath );
|
||||
if ( newDb.exists() )
|
||||
{
|
||||
@ -263,22 +311,38 @@ bool QgsOfflineEditing::createSpatialiteDB( const QString& offlineDbPath )
|
||||
|
||||
// see also QgsNewSpatialiteLayerDialog::createDb()
|
||||
|
||||
// copy the spatialite template to the user specified path
|
||||
QString spatialiteTemplate = QgsApplication::qgisSpatialiteDbTemplatePath();
|
||||
QFile spatialiteTemplateDb( spatialiteTemplate );
|
||||
|
||||
QFileInfo fullPath = QFileInfo( offlineDbPath );
|
||||
QDir path = fullPath.dir();
|
||||
|
||||
// Must be sure there is destination directory ~/.qgis
|
||||
QDir().mkpath( path.absolutePath( ) );
|
||||
|
||||
// now copy the template db file into the chosen location
|
||||
if ( !spatialiteTemplateDb.copy( newDb.fileName() ) )
|
||||
// creating/opening the new database
|
||||
QString dbPath = newDb.fileName();
|
||||
spatialite_init(0);
|
||||
ret = sqlite3_open_v2(dbPath.toUtf8().constData(), &sqlite_handle, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL);
|
||||
if (ret)
|
||||
{
|
||||
showWarning( tr( "Could not copy the template database to new location" ) );
|
||||
// an error occurred
|
||||
QString errCause = tr( "Could not create a new database\n" );
|
||||
errCause += QString::fromUtf8(sqlite3_errmsg(sqlite_handle));
|
||||
sqlite3_close(sqlite_handle);
|
||||
showWarning( errCause );
|
||||
return false;
|
||||
}
|
||||
// activating Foreign Key constraints
|
||||
ret = sqlite3_exec(sqlite_handle, "PRAGMA foreign_keys = 1", NULL, 0, &errMsg);
|
||||
if (ret != SQLITE_OK)
|
||||
{
|
||||
showWarning( tr( "Unable to activate FOREIGN_KEY constraints" ) );
|
||||
sqlite3_free(errMsg);
|
||||
sqlite3_close(sqlite_handle);
|
||||
return false;
|
||||
}
|
||||
initializeSpatialMetadata(sqlite_handle);
|
||||
|
||||
// all done: closing the DB connection
|
||||
sqlite3_close(sqlite_handle);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ class QgsOfflineEditing : public QObject
|
||||
void synchronize( QgsLegendInterface* legendInterface );
|
||||
|
||||
private:
|
||||
void initializeSpatialMetadata( sqlite3 *sqlite_handle );
|
||||
bool createSpatialiteDB( const QString& offlineDbPath );
|
||||
void createLoggingTables( sqlite3* db );
|
||||
void copyVectorLayer( QgsVectorLayer* layer, sqlite3* db, const QString& offlineDbPath );
|
||||
|
@ -16,6 +16,7 @@ email : a.furieri@lqt.it
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include <sys/types.h>
|
||||
#include <sqlite3.h>
|
||||
#include <spatialite/gaiageo.h>
|
||||
#include <spatialite.h>
|
||||
|
Loading…
x
Reference in New Issue
Block a user