Skip to content

Commit 2bfb80b

Browse files
author
jef
committedApr 5, 2009
add internal spatialite support
git-svn-id: http://svn.osgeo.org/qgis/trunk@10473 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 2ba8167 commit 2bfb80b

33 files changed

+144535
-14
lines changed
 

‎CMakeLists.txt

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,17 @@ IF (WITH_POSTGRESQL)
5050
SET (POSTGRESQL_PREFIX "" CACHE PATH "Path to POSTGRESQL base directory")
5151
ENDIF (WITH_POSTGRESQL)
5252

53-
# try to configure and build SPATIALITE support
5453
SET (WITH_SPATIALITE TRUE CACHE BOOL "Determines whether SPATIALITE support should be built")
54+
5555
IF (WITH_SPATIALITE)
56-
SET (SPATIALITE_PREFIX "" CACHE PATH "Path to SPATIALITE base directory")
56+
SET (WITH_INTERNAL_SPATIALITE TRUE CACHE BOOL "Determines whether SPATIALITE support should be built internally")
57+
IF(WITH_INTERNAL_SPATIALITE)
58+
SET(SPATIALITE_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/src/core/spatialite/headers)
59+
SET(HAVE_SPATIALITE TRUE)
60+
IF(WIN32)
61+
FIND_PACKAGE(Iconv REQUIRED)
62+
ENDIF(WIN32)
63+
ENDIF (WITH_INTERNAL_SPATIALITE)
5764
ENDIF (WITH_SPATIALITE)
5865

5966
# try to configure and build python bindings by default
@@ -112,6 +119,7 @@ IF (NOT WITH_INTERNAL_SQLITE3)
112119
MESSAGE (SEND_ERROR "sqlite3 dependency was not found (try compiling with sqlite3 internal)!")
113120
ENDIF (NOT SQLITE3_FOUND)
114121
ENDIF (NOT WITH_INTERNAL_SQLITE3)
122+
115123
FIND_PACKAGE(GEOS)
116124
FIND_PACKAGE(GDAL)
117125

@@ -124,9 +132,9 @@ FIND_PACKAGE(GSL) # Georeferencer
124132
IF (WITH_GRASS)
125133
FIND_PACKAGE(GRASS) # GRASS plugin
126134
ENDIF (WITH_GRASS)
127-
IF (WITH_SPATIALITE)
128-
FIND_PACKAGE(SPATIALITE) # SPATIALITE provider
129-
ENDIF (WITH_SPATIALITE)
135+
IF (WITH_SPATIALITE AND NOT WITH_INTERNAL_SPATIALITE)
136+
FIND_PACKAGE(SPATIALITE)
137+
ENDIF (WITH_SPATIALITE AND NOT WITH_INTERNAL_SPATIALITE)
130138

131139
IF (WITH_BINDINGS)
132140
# python support:
@@ -180,7 +188,7 @@ FIND_PROGRAM(QT_LRELEASE_EXECUTABLE
180188
# enable warnings
181189

182190
IF (PEDANTIC)
183-
MESSAGE ("Pedantic compiler settings enabled")
191+
MESSAGE ("-- Pedantic compiler settings enabled")
184192
IF(MSVC)
185193
ADD_DEFINITIONS( /W4 )
186194

‎src/app/CMakeLists.txt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,14 @@ IF (POSTGRES_FOUND)
178178
)
179179
ENDIF (POSTGRES_FOUND)
180180

181-
IF (SPATIALITE_FOUND)
181+
IF (HAVE_SPATIALITE)
182182
SET (QGIS_APP_SRCS ${QGIS_APP_SRCS}
183183
qgsspatialitesourceselect.cpp
184184
)
185185
SET (QGIS_APP_MOC_HDRS ${QGIS_APP_MOC_HDRS}
186186
qgsspatialitesourceselect.h
187187
)
188-
ENDIF (SPATIALITE_FOUND)
188+
ENDIF (HAVE_SPATIALITE)
189189

190190

191191
QT4_WRAP_CPP(QGIS_APP_MOC_SRCS ${QGIS_APP_MOC_HDRS})
@@ -239,9 +239,9 @@ IF (POSTGRES_FOUND)
239239
INCLUDE_DIRECTORIES(${POSTGRES_INCLUDE_DIR})
240240
ENDIF (POSTGRES_FOUND)
241241

242-
IF (SPATIALITE_FOUND)
242+
IF (HAVE_SPATIALITE)
243243
INCLUDE_DIRECTORIES(${SPATIALITE_INCLUDE_DIR})
244-
ENDIF (SPATIALITE_FOUND)
244+
ENDIF (HAVE_SPATIALITE)
245245

246246
#############
247247

@@ -268,6 +268,9 @@ TARGET_LINK_LIBRARIES(qgis
268268
qgis_core
269269
qgis_gui
270270
)
271+
IF(NOT WITH_INTERNAL_SQLITE AND NOT WITH_INTERNAL_SPATIALITE)
272+
TARGET_LINK_LIBRARIES(qgis ${SQLITE_LIBRARY})
273+
ENDIF(NOT WITH_INTERNAL_SQLITE AND NOT WITH_INTERNAL_SPATIALITE)
271274
IF (${QTVERSION} STRLESS "4.3.0")
272275
TARGET_LINK_LIBRARIES(qgis ${QT_QT3SUPPORT_LIBRARY} )
273276
ENDIF (${QTVERSION} STRLESS "4.3.0")

‎src/core/CMakeLists.txt

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,57 @@ IF (WITH_INTERNAL_SQLITE3)
9595
)
9696
ENDIF (WITH_INTERNAL_SQLITE3)
9797

98+
IF (WITH_INTERNAL_SPATIALITE)
99+
IF (WIN32)
100+
ADD_DEFINITIONS(-DDLL_EXPORT)
101+
IF (MSVC)
102+
ADD_DEFINITIONS("-DSQLITE_API=__declspec(dllexport)")
103+
ELSE (MSVC)
104+
ADD_DEFINITIONS("\"-DSQLITE_API=__declspec(dllexport)\"")
105+
ENDIF (MSVC)
106+
ENDIF (WIN32)
107+
108+
SET(QGIS_CORE_SRCS
109+
${QGIS_CORE_SRCS}
110+
spatialite/spatialite/mbrcache.c
111+
spatialite/spatialite/spatialite.c
112+
spatialite/spatialite/virtualfdo.c
113+
spatialite/spatialite/virtualnetwork.c
114+
spatialite/spatialite/virtualshape.c
115+
116+
spatialite/spatialite_c99/spatialite_c99.c
117+
118+
spatialite/gaiageo/gg_endian.c
119+
spatialite/gaiageo/gg_geometries.c
120+
spatialite/gaiageo/gg_advanced.c
121+
spatialite/gaiageo/gg_wkb.c
122+
spatialite/gaiageo/gg_wkt.c
123+
spatialite/gaiageo/gg_transform.c
124+
spatialite/gaiageo/gg_shape.c
125+
spatialite/gaiageo/gg_relations.c
126+
127+
spatialite/virtualtext/gaiaaux/gg_sqlaux.c
128+
spatialite/virtualtext/gaiaaux/gg_utf8.c
129+
130+
spatialite/virtualtext/sqlite3/sqlite3.c
131+
132+
spatialite/gaiaexif/gaia_exif.c
133+
134+
spatialite/virtualtext/virtualtext/virtualtext.c
135+
136+
spatialite/versioninfo/version.c
137+
138+
)
139+
140+
IF (NOT MSVC)
141+
SET_SOURCE_FILES_PROPERTIES(
142+
spatialite/spatialite_c99/spatialite_c99.c
143+
PROPERTIES COMPILE_FLAGS -std=c99)
144+
ENDIF (NOT MSVC)
145+
146+
INCLUDE_DIRECTORIES(spatialite/headers)
147+
ENDIF (WITH_INTERNAL_SPATIALITE)
148+
98149
ADD_FLEX_FILES(QGIS_CORE_SRCS qgssearchstringlexer.ll)
99150

100151
ADD_BISON_FILES(QGIS_CORE_SRCS qgssearchstringparser.yy)
@@ -220,6 +271,12 @@ TARGET_LINK_LIBRARIES(qgis_core
220271
${PLATFORM_LIBRARIES}
221272
)
222273

274+
IF (WITH_INTERNAL_SPATIALITE)
275+
IF (WIN32)
276+
TARGET_LINK_LIBRARIES(qgis_core ${ICONV_LIBRARY})
277+
ENDIF (WIN32)
278+
ENDIF (WITH_INTERNAL_SPATIALITE)
279+
223280
IF (NOT WITH_INTERNAL_SQLITE3)
224281
TARGET_LINK_LIBRARIES(qgis_core ${SQLITE3_LIBRARY})
225282
ENDIF (NOT WITH_INTERNAL_SQLITE3)

‎src/core/spatialite/gaiaexif/gaia_exif.c

Lines changed: 2663 additions & 0 deletions
Large diffs are not rendered by default.

‎src/core/spatialite/gaiageo/gg_advanced.c

Lines changed: 446 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 396 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,396 @@
1+
/*
2+
3+
gg_endian.c -- Gaia functions for litte/big endian values handling
4+
5+
version 2.3, 2008 October 13
6+
7+
Author: Sandro Furieri a.furieri@lqt.it
8+
9+
------------------------------------------------------------------------------
10+
11+
Version: MPL 1.1/GPL 2.0/LGPL 2.1
12+
13+
The contents of this file are subject to the Mozilla Public License Version
14+
1.1 (the "License"); you may not use this file except in compliance with
15+
the License. You may obtain a copy of the License at
16+
http://www.mozilla.org/MPL/
17+
18+
Software distributed under the License is distributed on an "AS IS" basis,
19+
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20+
for the specific language governing rights and limitations under the
21+
License.
22+
23+
The Original Code is the SpatiaLite library
24+
25+
The Initial Developer of the Original Code is Alessandro Furieri
26+
27+
Portions created by the Initial Developer are Copyright (C) 2008
28+
the Initial Developer. All Rights Reserved.
29+
30+
Contributor(s):
31+
32+
Alternatively, the contents of this file may be used under the terms of
33+
either the GNU General Public License Version 2 or later (the "GPL"), or
34+
the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
35+
in which case the provisions of the GPL or the LGPL are applicable instead
36+
of those above. If you wish to allow use of your version of this file only
37+
under the terms of either the GPL or the LGPL, and not to allow others to
38+
use your version of this file under the terms of the MPL, indicate your
39+
decision by deleting the provisions above and replace them with the notice
40+
and other provisions required by the GPL or the LGPL. If you do not delete
41+
the provisions above, a recipient may use your version of this file under
42+
the terms of any one of the MPL, the GPL or the LGPL.
43+
44+
*/
45+
46+
#include <stdlib.h>
47+
#include <stdio.h>
48+
49+
#include <spatialite/sqlite3ext.h>
50+
#include <spatialite/gaiageo.h>
51+
52+
GAIAGEO_DECLARE int
53+
gaiaEndianArch()
54+
{
55+
/* checking if target CPU is a little-endian one */
56+
union cvt
57+
{
58+
unsigned char byte[4];
59+
int int_value;
60+
} convert;
61+
convert.int_value = 1;
62+
if ( convert.byte[0] == 0 )
63+
return 0;
64+
return 1;
65+
}
66+
67+
GAIAGEO_DECLARE short
68+
gaiaImport16( const unsigned char *p, int little_endian, int little_endian_arch )
69+
{
70+
/* fetches a 16bit int from BLOB respecting declared endiannes */
71+
union cvt
72+
{
73+
unsigned char byte[2];
74+
short short_value;
75+
} convert;
76+
if ( little_endian_arch )
77+
{
78+
/* Litte-Endian architecture [e.g. x86] */
79+
if ( !little_endian )
80+
{
81+
/* Big Endian data */
82+
convert.byte[0] = *( p + 1 );
83+
convert.byte[1] = *( p + 0 );
84+
}
85+
else
86+
{
87+
/* Little Endian data */
88+
convert.byte[0] = *( p + 0 );
89+
convert.byte[1] = *( p + 1 );
90+
}
91+
}
92+
else
93+
{
94+
/* Big Endian architecture [e.g. PPC] */
95+
if ( !little_endian )
96+
{
97+
/* Big Endian data */
98+
convert.byte[0] = *( p + 0 );
99+
convert.byte[1] = *( p + 1 );
100+
}
101+
else
102+
{
103+
/* Little Endian data */
104+
convert.byte[0] = *( p + 1 );
105+
convert.byte[1] = *( p + 0 );
106+
}
107+
}
108+
return convert.short_value;
109+
}
110+
111+
GAIAGEO_DECLARE int
112+
gaiaImport32( const unsigned char *p, int little_endian, int little_endian_arch )
113+
{
114+
/* fetches a 32bit int from BLOB respecting declared endiannes */
115+
union cvt
116+
{
117+
unsigned char byte[4];
118+
int int_value;
119+
} convert;
120+
if ( little_endian_arch )
121+
{
122+
/* Litte-Endian architecture [e.g. x86] */
123+
if ( !little_endian )
124+
{
125+
/* Big Endian data */
126+
convert.byte[0] = *( p + 3 );
127+
convert.byte[1] = *( p + 2 );
128+
convert.byte[2] = *( p + 1 );
129+
convert.byte[3] = *( p + 0 );
130+
}
131+
else
132+
{
133+
/* Little Endian data */
134+
convert.byte[0] = *( p + 0 );
135+
convert.byte[1] = *( p + 1 );
136+
convert.byte[2] = *( p + 2 );
137+
convert.byte[3] = *( p + 3 );
138+
}
139+
}
140+
else
141+
{
142+
/* Big Endian architecture [e.g. PPC] */
143+
if ( !little_endian )
144+
{
145+
/* Big Endian data */
146+
convert.byte[0] = *( p + 0 );
147+
convert.byte[1] = *( p + 1 );
148+
convert.byte[2] = *( p + 2 );
149+
convert.byte[3] = *( p + 3 );
150+
}
151+
else
152+
{
153+
/* Little Endian data */
154+
convert.byte[0] = *( p + 3 );
155+
convert.byte[1] = *( p + 2 );
156+
convert.byte[2] = *( p + 1 );
157+
convert.byte[3] = *( p + 0 );
158+
}
159+
}
160+
return convert.int_value;
161+
}
162+
163+
GAIAGEO_DECLARE double
164+
gaiaImport64( const unsigned char *p, int little_endian, int little_endian_arch )
165+
{
166+
/* fetches a 64bit double from BLOB respecting declared endiannes */
167+
union cvt
168+
{
169+
unsigned char byte[8];
170+
double double_value;
171+
} convert;
172+
if ( little_endian_arch )
173+
{
174+
/* Litte-Endian architecture [e.g. x86] */
175+
if ( !little_endian )
176+
{
177+
/* Big Endian data */
178+
convert.byte[0] = *( p + 7 );
179+
convert.byte[1] = *( p + 6 );
180+
convert.byte[2] = *( p + 5 );
181+
convert.byte[3] = *( p + 4 );
182+
convert.byte[4] = *( p + 3 );
183+
convert.byte[5] = *( p + 2 );
184+
convert.byte[6] = *( p + 1 );
185+
convert.byte[7] = *( p + 0 );
186+
}
187+
else
188+
{
189+
/* Little Endian data */
190+
convert.byte[0] = *( p + 0 );
191+
convert.byte[1] = *( p + 1 );
192+
convert.byte[2] = *( p + 2 );
193+
convert.byte[3] = *( p + 3 );
194+
convert.byte[4] = *( p + 4 );
195+
convert.byte[5] = *( p + 5 );
196+
convert.byte[6] = *( p + 6 );
197+
convert.byte[7] = *( p + 7 );
198+
}
199+
}
200+
else
201+
{
202+
/* Big Endian architecture [e.g. PPC] */
203+
if ( !little_endian )
204+
{
205+
/* Big Endian data */
206+
convert.byte[0] = *( p + 0 );
207+
convert.byte[1] = *( p + 1 );
208+
convert.byte[2] = *( p + 2 );
209+
convert.byte[3] = *( p + 3 );
210+
convert.byte[4] = *( p + 4 );
211+
convert.byte[5] = *( p + 5 );
212+
convert.byte[6] = *( p + 6 );
213+
convert.byte[7] = *( p + 7 );
214+
}
215+
else
216+
{
217+
/* Little Endian data */
218+
convert.byte[0] = *( p + 7 );
219+
convert.byte[1] = *( p + 6 );
220+
convert.byte[2] = *( p + 5 );
221+
convert.byte[3] = *( p + 4 );
222+
convert.byte[4] = *( p + 3 );
223+
convert.byte[5] = *( p + 2 );
224+
convert.byte[6] = *( p + 1 );
225+
convert.byte[7] = *( p + 0 );
226+
}
227+
}
228+
return convert.double_value;
229+
}
230+
231+
GAIAGEO_DECLARE void
232+
gaiaExport16( unsigned char *p, short value, int little_endian,
233+
int little_endian_arch )
234+
{
235+
/* stores a 16bit int into a BLOB respecting declared endiannes */
236+
union cvt
237+
{
238+
unsigned char byte[2];
239+
short short_value;
240+
} convert;
241+
convert.short_value = value;
242+
if ( little_endian_arch )
243+
{
244+
/* Litte-Endian architecture [e.g. x86] */
245+
if ( !little_endian )
246+
{
247+
/* Big Endian data */
248+
*( p + 1 ) = convert.byte[1];
249+
*( p + 0 ) = convert.byte[0];
250+
}
251+
else
252+
{
253+
/* Little Endian data */
254+
*( p + 0 ) = convert.byte[0];
255+
*( p + 1 ) = convert.byte[1];
256+
}
257+
}
258+
else
259+
{
260+
/* Big Endian architecture [e.g. PPC] */
261+
if ( !little_endian )
262+
{
263+
/* Big Endian data */
264+
*( p + 0 ) = convert.byte[0];
265+
*( p + 1 ) = convert.byte[1];
266+
}
267+
else
268+
{
269+
/* Little Endian data */
270+
*( p + 1 ) = convert.byte[0];
271+
*( p + 0 ) = convert.byte[1];
272+
}
273+
}
274+
}
275+
276+
GAIAGEO_DECLARE void
277+
gaiaExport32( unsigned char *p, int value, int little_endian,
278+
int little_endian_arch )
279+
{
280+
/* stores a 32bit int into a BLOB respecting declared endiannes */
281+
union cvt
282+
{
283+
unsigned char byte[4];
284+
int int_value;
285+
} convert;
286+
convert.int_value = value;
287+
if ( little_endian_arch )
288+
{
289+
/* Litte-Endian architecture [e.g. x86] */
290+
if ( !little_endian )
291+
{
292+
/* Big Endian data */
293+
*( p + 3 ) = convert.byte[0];
294+
*( p + 2 ) = convert.byte[1];
295+
*( p + 1 ) = convert.byte[2];
296+
*( p + 0 ) = convert.byte[3];
297+
}
298+
else
299+
{
300+
/* Little Endian data */
301+
*( p + 0 ) = convert.byte[0];
302+
*( p + 1 ) = convert.byte[1];
303+
*( p + 2 ) = convert.byte[2];
304+
*( p + 3 ) = convert.byte[3];
305+
}
306+
}
307+
else
308+
{
309+
/* Big Endian architecture [e.g. PPC] */
310+
if ( !little_endian )
311+
{
312+
/* Big Endian data */
313+
*( p + 0 ) = convert.byte[0];
314+
*( p + 1 ) = convert.byte[1];
315+
*( p + 2 ) = convert.byte[2];
316+
*( p + 3 ) = convert.byte[3];
317+
}
318+
else
319+
{
320+
/* Little Endian data */
321+
*( p + 3 ) = convert.byte[0];
322+
*( p + 2 ) = convert.byte[1];
323+
*( p + 1 ) = convert.byte[2];
324+
*( p + 0 ) = convert.byte[3];
325+
}
326+
}
327+
}
328+
329+
GAIAGEO_DECLARE void
330+
gaiaExport64( unsigned char *p, double value, int little_endian,
331+
int little_endian_arch )
332+
{
333+
/* stores a 64bit double into a BLOB respecting declared endiannes */
334+
union cvt
335+
{
336+
unsigned char byte[8];
337+
double double_value;
338+
} convert;
339+
convert.double_value = value;
340+
if ( little_endian_arch )
341+
{
342+
/* Litte-Endian architecture [e.g. x86] */
343+
if ( !little_endian )
344+
{
345+
/* Big Endian data */
346+
*( p + 7 ) = convert.byte[0];
347+
*( p + 6 ) = convert.byte[1];
348+
*( p + 5 ) = convert.byte[2];
349+
*( p + 4 ) = convert.byte[3];
350+
*( p + 3 ) = convert.byte[4];
351+
*( p + 2 ) = convert.byte[5];
352+
*( p + 1 ) = convert.byte[6];
353+
*( p + 0 ) = convert.byte[7];
354+
}
355+
else
356+
{
357+
/* Little Endian data */
358+
*( p + 0 ) = convert.byte[0];
359+
*( p + 1 ) = convert.byte[1];
360+
*( p + 2 ) = convert.byte[2];
361+
*( p + 3 ) = convert.byte[3];
362+
*( p + 4 ) = convert.byte[4];
363+
*( p + 5 ) = convert.byte[5];
364+
*( p + 6 ) = convert.byte[6];
365+
*( p + 7 ) = convert.byte[7];
366+
}
367+
}
368+
else
369+
{
370+
/* Big Endian architecture [e.g. PPC] */
371+
if ( !little_endian )
372+
{
373+
/* Big Endian data */
374+
*( p + 0 ) = convert.byte[0];
375+
*( p + 1 ) = convert.byte[1];
376+
*( p + 2 ) = convert.byte[2];
377+
*( p + 3 ) = convert.byte[3];
378+
*( p + 4 ) = convert.byte[4];
379+
*( p + 5 ) = convert.byte[5];
380+
*( p + 6 ) = convert.byte[6];
381+
*( p + 7 ) = convert.byte[7];
382+
}
383+
else
384+
{
385+
/* Little Endian data */
386+
*( p + 7 ) = convert.byte[0];
387+
*( p + 6 ) = convert.byte[1];
388+
*( p + 5 ) = convert.byte[2];
389+
*( p + 4 ) = convert.byte[3];
390+
*( p + 3 ) = convert.byte[4];
391+
*( p + 2 ) = convert.byte[5];
392+
*( p + 1 ) = convert.byte[6];
393+
*( p + 0 ) = convert.byte[7];
394+
}
395+
}
396+
}

‎src/core/spatialite/gaiageo/gg_geometries.c

Lines changed: 1643 additions & 0 deletions
Large diffs are not rendered by default.

‎src/core/spatialite/gaiageo/gg_relations.c

Lines changed: 918 additions & 0 deletions
Large diffs are not rendered by default.

‎src/core/spatialite/gaiageo/gg_shape.c

Lines changed: 1823 additions & 0 deletions
Large diffs are not rendered by default.

‎src/core/spatialite/gaiageo/gg_transform.c

Lines changed: 730 additions & 0 deletions
Large diffs are not rendered by default.

‎src/core/spatialite/gaiageo/gg_wkb.c

Lines changed: 1613 additions & 0 deletions
Large diffs are not rendered by default.

‎src/core/spatialite/gaiageo/gg_wkt.c

Lines changed: 2029 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
spatialite.h -- Gaia spatial support for SQLite
3+
4+
version 2.3, 2008 October 13
5+
6+
Author: Sandro Furieri a.furieri@lqt.it
7+
8+
------------------------------------------------------------------------------
9+
10+
Version: MPL 1.1/GPL 2.0/LGPL 2.1
11+
12+
The contents of this file are subject to the Mozilla Public License Version
13+
1.1 (the "License"); you may not use this file except in compliance with
14+
the License. You may obtain a copy of the License at
15+
http://www.mozilla.org/MPL/
16+
17+
Software distributed under the License is distributed on an "AS IS" basis,
18+
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
19+
for the specific language governing rights and limitations under the
20+
License.
21+
22+
The Original Code is the SpatiaLite library
23+
24+
The Initial Developer of the Original Code is Alessandro Furieri
25+
26+
Portions created by the Initial Developer are Copyright (C) 2008
27+
the Initial Developer. All Rights Reserved.
28+
29+
Contributor(s):
30+
31+
Alternatively, the contents of this file may be used under the terms of
32+
either the GNU General Public License Version 2 or later (the "GPL"), or
33+
the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
34+
in which case the provisions of the GPL or the LGPL are applicable instead
35+
of those above. If you wish to allow use of your version of this file only
36+
under the terms of either the GPL or the LGPL, and not to allow others to
37+
use your version of this file under the terms of the MPL, indicate your
38+
decision by deleting the provisions above and replace them with the notice
39+
and other provisions required by the GPL or the LGPL. If you do not delete
40+
the provisions above, a recipient may use your version of this file under
41+
the terms of any one of the MPL, the GPL or the LGPL.
42+
43+
*/
44+
45+
#ifdef DLL_EXPORT
46+
#define SPATIALITE_DECLARE __declspec(dllexport)
47+
#else
48+
#define SPATIALITE_DECLARE extern
49+
#endif
50+
51+
#ifndef _SPATIALITE_H
52+
#define _SPATIALITE_H
53+
54+
#ifdef __cplusplus
55+
extern "C"
56+
{
57+
#endif
58+
59+
SPATIALITE_DECLARE const char *spatialite_version( void );
60+
SPATIALITE_DECLARE const char *virtualtext_version( void );
61+
SPATIALITE_DECLARE void spatialite_init( int verbose );
62+
SPATIALITE_DECLARE void dump_shapefile( sqlite3 * sqlite, char *table,
63+
char *column, char *charset,
64+
char *shp_path, char *geom_type );
65+
SPATIALITE_DECLARE void load_shapefile( sqlite3 * sqlite, char *shp_path,
66+
char *table, char *charset,
67+
int srid, char *column );
68+
SPATIALITE_DECLARE double math_round( double value );
69+
SPATIALITE_DECLARE sqlite3_int64 math_llabs( sqlite3_int64 value );
70+
SPATIALITE_DECLARE sqlite3_int64 min_rowid();
71+
72+
73+
#ifdef __cplusplus
74+
}
75+
#endif
76+
77+
#endif /* _SPATIALITE_H */
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/*
2+
gaiaaux.h -- Gaia common utility functions
3+
4+
version 2.3, 2008 October 13
5+
6+
Author: Sandro Furieri a.furieri@lqt.it
7+
8+
------------------------------------------------------------------------------
9+
10+
Version: MPL 1.1/GPL 2.0/LGPL 2.1
11+
12+
The contents of this file are subject to the Mozilla Public License Version
13+
1.1 (the "License"); you may not use this file except in compliance with
14+
the License. You may obtain a copy of the License at
15+
http://www.mozilla.org/MPL/
16+
17+
Software distributed under the License is distributed on an "AS IS" basis,
18+
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
19+
for the specific language governing rights and limitations under the
20+
License.
21+
22+
The Original Code is the SpatiaLite library
23+
24+
The Initial Developer of the Original Code is Alessandro Furieri
25+
26+
Portions created by the Initial Developer are Copyright (C) 2008
27+
the Initial Developer. All Rights Reserved.
28+
29+
Contributor(s):
30+
31+
Alternatively, the contents of this file may be used under the terms of
32+
either the GNU General Public License Version 2 or later (the "GPL"), or
33+
the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
34+
in which case the provisions of the GPL or the LGPL are applicable instead
35+
of those above. If you wish to allow use of your version of this file only
36+
under the terms of either the GPL or the LGPL, and not to allow others to
37+
use your version of this file under the terms of the MPL, indicate your
38+
decision by deleting the provisions above and replace them with the notice
39+
and other provisions required by the GPL or the LGPL. If you do not delete
40+
the provisions above, a recipient may use your version of this file under
41+
the terms of any one of the MPL, the GPL or the LGPL.
42+
43+
*/
44+
45+
#ifdef DLL_EXPORT
46+
#define GAIAAUX_DECLARE __declspec(dllexport)
47+
#else
48+
#define GAIAAUX_DECLARE extern
49+
#endif
50+
51+
#ifndef _GAIAAUX_H
52+
#define _GAIAAUX_H
53+
54+
#ifdef __cplusplus
55+
extern "C"
56+
{
57+
#endif
58+
59+
/* function prototipes */
60+
61+
GAIAAUX_DECLARE const char *gaiaGetLocaleCharset();
62+
GAIAAUX_DECLARE int gaiaConvertCharset( char **buf, const char *fromCs,
63+
const char *toCs );
64+
GAIAAUX_DECLARE int gaiaToUTF8( char **buf, const char *fromCs,
65+
const char *toCs );
66+
GAIAAUX_DECLARE void *gaiaCreateUTF8Converter( const char *fromCS );
67+
GAIAAUX_DECLARE void gaiaFreeUTF8Converter( void *cvtCS );
68+
GAIAAUX_DECLARE char *gaiaConvertToUTF8( void *cvtCS, const char *buf,
69+
int len, int *err );
70+
GAIAAUX_DECLARE int gaiaIsReservedSqliteName( const char *name );
71+
GAIAAUX_DECLARE int gaiaIsReservedSqlName( const char *name );
72+
GAIAAUX_DECLARE int gaiaIllegalSqlName( const char *name );
73+
GAIAAUX_DECLARE void gaiaCleanSqlString( char *value );
74+
75+
#ifdef __cplusplus
76+
}
77+
#endif
78+
79+
#endif /* _GAIAAUX_H */
Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
/*
2+
gaiaexif.h -- Gaia common EXIF Metadata reading functions
3+
4+
version 2.3, 2008 October 13
5+
6+
Author: Sandro Furieri a.furieri@lqt.it
7+
8+
------------------------------------------------------------------------------
9+
10+
Version: MPL 1.1/GPL 2.0/LGPL 2.1
11+
12+
The contents of this file are subject to the Mozilla Public License Version
13+
1.1 (the "License"); you may not use this file except in compliance with
14+
the License. You may obtain a copy of the License at
15+
http://www.mozilla.org/MPL/
16+
17+
Software distributed under the License is distributed on an "AS IS" basis,
18+
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
19+
for the specific language governing rights and limitations under the
20+
License.
21+
22+
The Original Code is the SpatiaLite library
23+
24+
The Initial Developer of the Original Code is Alessandro Furieri
25+
26+
Portions created by the Initial Developer are Copyright (C) 2008
27+
the Initial Developer. All Rights Reserved.
28+
29+
Contributor(s):
30+
31+
Alternatively, the contents of this file may be used under the terms of
32+
either the GNU General Public License Version 2 or later (the "GPL"), or
33+
the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
34+
in which case the provisions of the GPL or the LGPL are applicable instead
35+
of those above. If you wish to allow use of your version of this file only
36+
under the terms of either the GPL or the LGPL, and not to allow others to
37+
use your version of this file under the terms of the MPL, indicate your
38+
decision by deleting the provisions above and replace them with the notice
39+
and other provisions required by the GPL or the LGPL. If you do not delete
40+
the provisions above, a recipient may use your version of this file under
41+
the terms of any one of the MPL, the GPL or the LGPL.
42+
43+
*/
44+
45+
#ifdef DLL_EXPORT
46+
#define GAIAEXIF_DECLARE __declspec(dllexport)
47+
#else
48+
#define GAIAEXIF_DECLARE extern
49+
#endif
50+
51+
#ifndef _GAIAEXIF_H
52+
#define _GAIAEXIF_H
53+
54+
#ifdef __cplusplus
55+
extern "C"
56+
{
57+
#endif
58+
59+
/* constants used for BLOB value types */
60+
#define GAIA_HEX_BLOB 0
61+
#define GAIA_GIF_BLOB 1
62+
#define GAIA_PNG_BLOB 2
63+
#define GAIA_JPEG_BLOB 3
64+
#define GAIA_EXIF_BLOB 4
65+
#define GAIA_EXIF_GPS_BLOB 5
66+
#define GAIA_ZIP_BLOB 6
67+
#define GAIA_PDF_BLOB 7
68+
#define GAIA_GEOMETRY_BLOB 8
69+
70+
/* constants used for EXIF value types */
71+
#define GAIA_EXIF_NONE 0
72+
#define GAIA_EXIF_BYTE 1
73+
#define GAIA_EXIF_SHORT 2
74+
#define GAIA_EXIF_STRING 3
75+
#define GAIA_EXIF_LONG 4
76+
#define GAIA_EXIF_RATIONAL 5
77+
#define GAIA_EXIF_SLONG 9
78+
#define GAIA_EXIF_SRATIONAL 10
79+
80+
typedef struct gaiaExifTagStruct
81+
{
82+
/* an EXIF TAG */
83+
char Gps;
84+
unsigned short TagId;
85+
unsigned short Type;
86+
unsigned short Count;
87+
unsigned char TagOffset[4];
88+
unsigned char *ByteValue;
89+
char *StringValue;
90+
unsigned short *ShortValues;
91+
unsigned int *LongValues;
92+
unsigned int *LongRationals1;
93+
unsigned int *LongRationals2;
94+
short *SignedShortValues;
95+
int *SignedLongValues;
96+
int *SignedLongRationals1;
97+
int *SignedLongRationals2;
98+
float *FloatValues;
99+
double *DoubleValues;
100+
struct gaiaExifTagStruct *Next;
101+
} gaiaExifTag;
102+
typedef gaiaExifTag *gaiaExifTagPtr;
103+
104+
typedef struct gaiaExifTagListStruct
105+
{
106+
/* an EXIF TAG LIST */
107+
gaiaExifTagPtr First;
108+
gaiaExifTagPtr Last;
109+
int NumTags;
110+
gaiaExifTagPtr *TagsArray;
111+
} gaiaExifTagList;
112+
typedef gaiaExifTagList *gaiaExifTagListPtr;
113+
114+
/* function prototipes */
115+
116+
GAIAEXIF_DECLARE gaiaExifTagListPtr gaiaGetExifTags( const unsigned char
117+
*blob, int size );
118+
GAIAEXIF_DECLARE void gaiaExifTagsFree( gaiaExifTagListPtr tag_list );
119+
GAIAEXIF_DECLARE int gaiaGetExifTagsCount( gaiaExifTagListPtr tag_list );
120+
GAIAEXIF_DECLARE gaiaExifTagPtr gaiaGetExifTagByPos( gaiaExifTagListPtr
121+
tag_list,
122+
const int pos );
123+
GAIAEXIF_DECLARE gaiaExifTagPtr gaiaGetExifTagById( const gaiaExifTagListPtr
124+
tag_list,
125+
const unsigned short
126+
tag_id );
127+
GAIAEXIF_DECLARE gaiaExifTagPtr gaiaGetExifGpsTagById( const
128+
gaiaExifTagListPtr
129+
tag_list,
130+
const unsigned short
131+
tag_id );
132+
GAIAEXIF_DECLARE gaiaExifTagPtr gaiaGetExifTagByName( const
133+
gaiaExifTagListPtr
134+
tag_list,
135+
const char *tag_name );
136+
GAIAEXIF_DECLARE unsigned short gaiaExifTagGetId( const gaiaExifTagPtr tag );
137+
GAIAEXIF_DECLARE void gaiaExifTagGetName( const gaiaExifTagPtr tag,
138+
char *tag_name, int len );
139+
GAIAEXIF_DECLARE int gaiaIsExifGpsTag( const gaiaExifTagPtr tag );
140+
GAIAEXIF_DECLARE unsigned short gaiaExifTagGetValueType( const
141+
gaiaExifTagPtr
142+
tag );
143+
GAIAEXIF_DECLARE unsigned short gaiaExifTagGetNumValues( const
144+
gaiaExifTagPtr
145+
tag );
146+
GAIAEXIF_DECLARE unsigned char gaiaExifTagGetByteValue( const gaiaExifTagPtr
147+
tag, const int ind,
148+
int *ok );
149+
GAIAEXIF_DECLARE void gaiaExifTagGetStringValue( const gaiaExifTagPtr tag,
150+
char *str, int len,
151+
int *ok );
152+
GAIAEXIF_DECLARE unsigned short gaiaExifTagGetShortValue( const
153+
gaiaExifTagPtr
154+
tag,
155+
const int ind,
156+
int *ok );
157+
GAIAEXIF_DECLARE unsigned int gaiaExifTagGetLongValue( const gaiaExifTagPtr
158+
tag, const int ind,
159+
int *ok );
160+
GAIAEXIF_DECLARE unsigned int gaiaExifTagGetRational1Value( const
161+
gaiaExifTagPtr
162+
tag,
163+
const int ind,
164+
int *ok );
165+
GAIAEXIF_DECLARE unsigned int gaiaExifTagGetRational2Value( const
166+
gaiaExifTagPtr
167+
tag,
168+
const int ind,
169+
int *ok );
170+
GAIAEXIF_DECLARE double gaiaExifTagGetRationalValue( const gaiaExifTagPtr
171+
tag, const int ind,
172+
int *ok );
173+
GAIAEXIF_DECLARE short gaiaExifTagGetSignedShortValue( const gaiaExifTagPtr
174+
tag, const int ind,
175+
int *ok );
176+
GAIAEXIF_DECLARE int gaiaExifTagGetSignedLongValue( const gaiaExifTagPtr
177+
tag, const int ind,
178+
int *ok );
179+
GAIAEXIF_DECLARE int gaiaExifTagGetSignedRational1Value( const
180+
gaiaExifTagPtr tag,
181+
const int ind,
182+
int *ok );
183+
GAIAEXIF_DECLARE int gaiaExifTagGetSignedRational2Value( const
184+
gaiaExifTagPtr tag,
185+
const int ind,
186+
int *ok );
187+
GAIAEXIF_DECLARE double gaiaExifTagGetSignedRationalValue( const
188+
gaiaExifTagPtr
189+
tag,
190+
const int ind,
191+
int *ok );
192+
GAIAEXIF_DECLARE float gaiaExifTagGetFloatValue( const gaiaExifTagPtr tag,
193+
const int ind, int *ok );
194+
GAIAEXIF_DECLARE double gaiaExifTagGetDoubleValue( const gaiaExifTagPtr tag,
195+
const int ind, int *ok );
196+
GAIAEXIF_DECLARE void gaiaExifTagGetHumanReadable( const gaiaExifTagPtr tag,
197+
char *str, int len,
198+
int *ok );
199+
GAIAEXIF_DECLARE int gaiaGuessBlobType( const unsigned char *blob,
200+
int size );
201+
GAIAEXIF_DECLARE int gaiaGetGpsCoords( const unsigned char *blob, int size,
202+
double *longitude, double *latitude );
203+
GAIAEXIF_DECLARE int gaiaGetGpsLatLong( const unsigned char *blob, int size,
204+
char *latlong, int ll_size );
205+
206+
#ifdef __cplusplus
207+
}
208+
#endif
209+
210+
#endif /* _GAIAEXIF_H */

‎src/core/spatialite/headers/spatialite/gaiageo.h

Lines changed: 622 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
spatialite.h -- Gaia support for SQLite extensions
3+
4+
version 2.3, 2008 October 13
5+
6+
Author: Sandro Furieri a.furieri@lqt.it
7+
8+
------------------------------------------------------------------------------
9+
10+
Version: MPL 1.1/GPL 2.0/LGPL 2.1
11+
12+
The contents of this file are subject to the Mozilla Public License Version
13+
1.1 (the "License"); you may not use this file except in compliance with
14+
the License. You may obtain a copy of the License at
15+
http://www.mozilla.org/MPL/
16+
17+
Software distributed under the License is distributed on an "AS IS" basis,
18+
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
19+
for the specific language governing rights and limitations under the
20+
License.
21+
22+
The Original Code is the SpatiaLite library
23+
24+
The Initial Developer of the Original Code is Alessandro Furieri
25+
26+
Portions created by the Initial Developer are Copyright (C) 2008
27+
the Initial Developer. All Rights Reserved.
28+
29+
Contributor(s):
30+
31+
Alternatively, the contents of this file may be used under the terms of
32+
either the GNU General Public License Version 2 or later (the "GPL"), or
33+
the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
34+
in which case the provisions of the GPL or the LGPL are applicable instead
35+
of those above. If you wish to allow use of your version of this file only
36+
under the terms of either the GPL or the LGPL, and not to allow others to
37+
use your version of this file under the terms of the MPL, indicate your
38+
decision by deleting the provisions above and replace them with the notice
39+
and other provisions required by the GPL or the LGPL. If you do not delete
40+
the provisions above, a recipient may use your version of this file under
41+
the terms of any one of the MPL, the GPL or the LGPL.
42+
43+
*/
44+
45+
int rtree_extension_init( sqlite3 * db, const sqlite3_api_routines * pApi );
46+
int virtualshape_extension_init( sqlite3 * db,
47+
const sqlite3_api_routines * pApi );
48+
int virtualtext_extension_init( sqlite3 * db,
49+
const sqlite3_api_routines * pApi );
50+
int virtualnetwork_extension_init( sqlite3 * db,
51+
const sqlite3_api_routines * pApi );
52+
int mbrcache_extension_init( sqlite3 * db, const sqlite3_api_routines * pApi );
53+
54+
int virtualfdo_extension_init( sqlite3 * db, const sqlite3_api_routines * pApi );

‎src/core/spatialite/headers/spatialite/sqlite3.h

Lines changed: 6742 additions & 0 deletions
Large diffs are not rendered by default.

‎src/core/spatialite/headers/spatialite/sqlite3ext.h

Lines changed: 381 additions & 0 deletions
Large diffs are not rendered by default.

‎src/core/spatialite/spatialite/mbrcache.c

Lines changed: 1440 additions & 0 deletions
Large diffs are not rendered by default.

‎src/core/spatialite/spatialite/spatialite.c

Lines changed: 8012 additions & 0 deletions
Large diffs are not rendered by default.

‎src/core/spatialite/spatialite/virtualfdo.c

Lines changed: 1267 additions & 0 deletions
Large diffs are not rendered by default.

‎src/core/spatialite/spatialite/virtualnetwork.c

Lines changed: 1666 additions & 0 deletions
Large diffs are not rendered by default.

‎src/core/spatialite/spatialite/virtualshape.c

Lines changed: 521 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
3+
spatialite_c99.c -- FUNCTIONS NEEDING TO BE COMPILED WITH -std=c99
4+
5+
version 2.3, 2008 October 13
6+
7+
Author: Sandro Furieri a.furieri@lqt.it
8+
9+
------------------------------------------------------------------------------
10+
11+
Version: MPL 1.1/GPL 2.0/LGPL 2.1
12+
13+
The contents of this file are subject to the Mozilla Public License Version
14+
1.1 (the "License"); you may not use this file except in compliance with
15+
the License. You may obtain a copy of the License at
16+
http://www.mozilla.org/MPL/
17+
18+
Software distributed under the License is distributed on an "AS IS" basis,
19+
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20+
for the specific language governing rights and limitations under the
21+
License.
22+
23+
The Original Code is the SpatiaLite library
24+
25+
The Initial Developer of the Original Code is Alessandro Furieri
26+
27+
Portions created by the Initial Developer are Copyright (C) 2008
28+
the Initial Developer. All Rights Reserved.
29+
30+
Contributor(s):
31+
32+
Alternatively, the contents of this file may be used under the terms of
33+
either the GNU General Public License Version 2 or later (the "GPL"), or
34+
the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
35+
in which case the provisions of the GPL or the LGPL are applicable instead
36+
of those above. If you wish to allow use of your version of this file only
37+
under the terms of either the GPL or the LGPL, and not to allow others to
38+
use your version of this file under the terms of the MPL, indicate your
39+
decision by deleting the provisions above and replace them with the notice
40+
and other provisions required by the GPL or the LGPL. If you do not delete
41+
the provisions above, a recipient may use your version of this file under
42+
the terms of any one of the MPL, the GPL or the LGPL.
43+
44+
*/
45+
46+
#include <stdlib.h>
47+
#include <math.h>
48+
#include <limits.h>
49+
50+
#include <spatialite/sqlite3ext.h>
51+
#include <spatialite.h>
52+
53+
SPATIALITE_DECLARE sqlite3_int64
54+
math_llabs( sqlite3_int64 value )
55+
{
56+
/* wrapping the llabs() function */
57+
#ifndef _MSC_VER
58+
return llabs( value );
59+
#else
60+
return _abs64( value );
61+
#endif
62+
}
63+
64+
SPATIALITE_DECLARE double
65+
math_round( double value )
66+
{
67+
/* wrapping the round() function */
68+
#ifndef _MSC_VER
69+
return ( round( value ) );
70+
#else
71+
return value >= 0.0 ? floor( value + 0.5 ) : ceil( value - 0.5 );
72+
#endif
73+
}
74+
75+
SPATIALITE_DECLARE sqlite3_int64
76+
min_rowid()
77+
{
78+
/* returning the LLONG_MIN value */
79+
return LLONG_MIN;
80+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
version.c -- Gaia spatial support for SQLite
3+
4+
version 2.3, 2008 October 13
5+
6+
Author: Sandro Furieri a.furieri@lqt.it
7+
8+
------------------------------------------------------------------------------
9+
10+
Version: MPL 1.1/GPL 2.0/LGPL 2.1
11+
12+
The contents of this file are subject to the Mozilla Public License Version
13+
1.1 (the "License"); you may not use this file except in compliance with
14+
the License. You may obtain a copy of the License at
15+
http://www.mozilla.org/MPL/
16+
17+
Software distributed under the License is distributed on an "AS IS" basis,
18+
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
19+
for the specific language governing rights and limitations under the
20+
License.
21+
22+
The Original Code is the SpatiaLite library
23+
24+
The Initial Developer of the Original Code is Alessandro Furieri
25+
26+
Portions created by the Initial Developer are Copyright (C) 2008
27+
the Initial Developer. All Rights Reserved.
28+
29+
Contributor(s):
30+
31+
Alternatively, the contents of this file may be used under the terms of
32+
either the GNU General Public License Version 2 or later (the "GPL"), or
33+
the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
34+
in which case the provisions of the GPL or the LGPL are applicable instead
35+
of those above. If you wish to allow use of your version of this file only
36+
under the terms of either the GPL or the LGPL, and not to allow others to
37+
use your version of this file under the terms of the MPL, indicate your
38+
decision by deleting the provisions above and replace them with the notice
39+
and other provisions required by the GPL or the LGPL. If you do not delete
40+
the provisions above, a recipient may use your version of this file under
41+
the terms of any one of the MPL, the GPL or the LGPL.
42+
43+
*/
44+
45+
#include <spatialite/sqlite3.h>
46+
#include <spatialite.h>
47+
48+
const char spatialiteversion[] = "2.3";
49+
50+
SPATIALITE_DECLARE const char *
51+
spatialite_version( void )
52+
{
53+
return spatialiteversion;
54+
}

‎src/core/spatialite/virtualtext/gaiaaux/gg_sqlaux.c

Lines changed: 557 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
/*
2+
3+
gg_utf8.c -- locale charset handling
4+
5+
version 2.3, 2008 October 13
6+
7+
Author: Sandro Furieri a.furieri@lqt.it
8+
9+
------------------------------------------------------------------------------
10+
11+
Version: MPL 1.1/GPL 2.0/LGPL 2.1
12+
13+
The contents of this file are subject to the Mozilla Public License Version
14+
1.1 (the "License"); you may not use this file except in compliance with
15+
the License. You may obtain a copy of the License at
16+
http://www.mozilla.org/MPL/
17+
18+
Software distributed under the License is distributed on an "AS IS" basis,
19+
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20+
for the specific language governing rights and limitations under the
21+
License.
22+
23+
The Original Code is the SpatiaLite library
24+
25+
The Initial Developer of the Original Code is Alessandro Furieri
26+
27+
Portions created by the Initial Developer are Copyright (C) 2008
28+
the Initial Developer. All Rights Reserved.
29+
30+
Contributor(s):
31+
32+
Alternatively, the contents of this file may be used under the terms of
33+
either the GNU General Public License Version 2 or later (the "GPL"), or
34+
the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
35+
in which case the provisions of the GPL or the LGPL are applicable instead
36+
of those above. If you wish to allow use of your version of this file only
37+
under the terms of either the GPL or the LGPL, and not to allow others to
38+
use your version of this file under the terms of the MPL, indicate your
39+
decision by deleting the provisions above and replace them with the notice
40+
and other provisions required by the GPL or the LGPL. If you do not delete
41+
the provisions above, a recipient may use your version of this file under
42+
the terms of any one of the MPL, the GPL or the LGPL.
43+
44+
*/
45+
46+
#include <stdlib.h>
47+
#include <stdio.h>
48+
#include <string.h>
49+
#include <errno.h>
50+
51+
#ifdef __MINGW32__
52+
#define LIBICONV_STATIC
53+
#include <iconv.h>
54+
#define LIBCHARSET_STATIC
55+
#include <localcharset.h>
56+
#else /* not MINGW32 */
57+
#ifdef __APPLE__
58+
#include <iconv.h>
59+
#include <localcharset.h>
60+
#else /* not Mac OsX */
61+
#include <iconv.h>
62+
#ifndef _MSC_VER
63+
#include <langinfo.h>
64+
#else
65+
#include <locale.h>
66+
#endif
67+
#endif
68+
#endif
69+
#include <spatialite/gaiaaux.h>
70+
71+
#ifndef _MSC_VER
72+
GAIAAUX_DECLARE const char *
73+
gaiaGetLocaleCharset()
74+
{
75+
/* indentifies the locale charset */
76+
#if defined(__MINGW32__)
77+
return locale_charset();
78+
#else /* not MINGW32 */
79+
#ifdef __APPLE__
80+
return locale_charset();
81+
#else /* not Mac OsX */
82+
return nl_langinfo( CODESET );
83+
#endif
84+
#endif
85+
}
86+
#endif
87+
88+
GAIAAUX_DECLARE
89+
int
90+
gaiaConvertCharset( char **buf, const char *fromCs, const char *toCs )
91+
{
92+
/* converting a string from a charset to another "by-the-fly" */
93+
char utf8buf[65536];
94+
#if defined(__MINGW32__)
95+
const char *pBuf;
96+
int len;
97+
int utf8len;
98+
#else /* not MINGW32 */
99+
char *pBuf;
100+
size_t len;
101+
size_t utf8len;
102+
#endif
103+
char *pUtf8buf;
104+
iconv_t cvt = iconv_open( toCs, fromCs );
105+
if ( cvt == ( iconv_t ) - 1 )
106+
goto unsupported;
107+
len = strlen( *buf );
108+
utf8len = 65536;
109+
pBuf = *buf;
110+
pUtf8buf = utf8buf;
111+
if ( iconv( cvt, &pBuf, &len, &pUtf8buf, &utf8len ) < 0 )
112+
goto error;
113+
utf8buf[65536 - utf8len] = '\0';
114+
memcpy( *buf, utf8buf, ( 65536 - utf8len ) + 1 );
115+
iconv_close( cvt );
116+
return 1;
117+
error:
118+
iconv_close( cvt );
119+
unsupported:
120+
return 0;
121+
}
122+
123+
GAIAAUX_DECLARE void *
124+
gaiaCreateUTF8Converter( const char *fromCS )
125+
{
126+
/* creating an UTF8 converter and returning on opaque reference to it */
127+
iconv_t cvt = iconv_open( "UTF-8", fromCS );
128+
if ( cvt == ( iconv_t ) - 1 )
129+
return NULL;
130+
return cvt;
131+
}
132+
133+
GAIAAUX_DECLARE void
134+
gaiaFreeUTF8Converter( void *cvtCS )
135+
{
136+
/* destroyng an UTF8 converter */
137+
if ( cvtCS )
138+
iconv_close( cvtCS );
139+
}
140+
141+
GAIAAUX_DECLARE char *
142+
gaiaConvertToUTF8( void *cvtCS, const char *buf, int buflen, int *err )
143+
{
144+
/* converting a string to UTF8 */
145+
char *utf8buf = 0;
146+
#if defined(__MINGW32__) || defined(_MSC_VER)
147+
const char *pBuf;
148+
int len;
149+
int utf8len;
150+
#else
151+
char *pBuf;
152+
size_t len;
153+
size_t utf8len;
154+
#endif
155+
int maxlen = buflen * 4;
156+
char *pUtf8buf;
157+
*err = 0;
158+
if ( !cvtCS )
159+
{
160+
*err = 1;
161+
return NULL;
162+
}
163+
utf8buf = malloc( maxlen );
164+
len = buflen;
165+
utf8len = maxlen;
166+
pBuf = ( char * ) buf;
167+
pUtf8buf = utf8buf;
168+
if ( iconv( cvtCS, &pBuf, &len, &pUtf8buf, &utf8len ) < 0 )
169+
{
170+
free( utf8buf );
171+
*err = 1;
172+
return NULL;
173+
}
174+
utf8buf[maxlen - utf8len] = '\0';
175+
return utf8buf;
176+
}

‎src/core/spatialite/virtualtext/sqlite3/sqlite3.c

Lines changed: 109174 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
version.c -- VirtualText standalone
3+
4+
version 2.3, 2008 October 13
5+
6+
Author: Sandro Furieri a.furieri@lqt.it
7+
8+
------------------------------------------------------------------------------
9+
10+
Version: MPL 1.1/GPL 2.0/LGPL 2.1
11+
12+
The contents of this file are subject to the Mozilla Public License Version
13+
1.1 (the "License"); you may not use this file except in compliance with
14+
the License. You may obtain a copy of the License at
15+
http://www.mozilla.org/MPL/
16+
17+
Software distributed under the License is distributed on an "AS IS" basis,
18+
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
19+
for the specific language governing rights and limitations under the
20+
License.
21+
22+
The Original Code is the SpatiaLite library
23+
24+
The Initial Developer of the Original Code is Alessandro Furieri
25+
26+
Portions created by the Initial Developer are Copyright (C) 2008
27+
the Initial Developer. All Rights Reserved.
28+
29+
Contributor(s):
30+
31+
Alternatively, the contents of this file may be used under the terms of
32+
either the GNU General Public License Version 2 or later (the "GPL"), or
33+
the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
34+
in which case the provisions of the GPL or the LGPL are applicable instead
35+
of those above. If you wish to allow use of your version of this file only
36+
under the terms of either the GPL or the LGPL, and not to allow others to
37+
use your version of this file under the terms of the MPL, indicate your
38+
decision by deleting the provisions above and replace them with the notice
39+
and other provisions required by the GPL or the LGPL. If you do not delete
40+
the provisions above, a recipient may use your version of this file under
41+
the terms of any one of the MPL, the GPL or the LGPL.
42+
43+
*/
44+
45+
#include <spatialite/sqlite3ext.h>
46+
#include <spatialite.h>
47+
48+
const char virtualtextversion[] = "2.3-alpha";
49+
50+
SPATIALITE_DECLARE const char *
51+
virtualtext_version( void )
52+
{
53+
return virtualtextversion;
54+
}
55+
56+
57+
SPATIALITE_DECLARE int
58+
sqlite3_extension_init( sqlite3 * db, char **pzErrMsg,
59+
const sqlite3_api_routines * pApi )
60+
{
61+
/* initializing the VirtualText extension */
62+
virtualtext_extension_init( db, pApi );
63+
}

‎src/core/spatialite/virtualtext/virtualtext/virtualtext.c

Lines changed: 1015 additions & 0 deletions
Large diffs are not rendered by default.

‎src/providers/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ IF (POSTGRES_FOUND)
55
SUBDIRS (postgres)
66
ENDIF (POSTGRES_FOUND)
77

8-
IF (SPATIALITE_FOUND)
8+
IF (SPATIALITE_FOUND OR WITH_INTERNAL_SPATIALITE)
99
SUBDIRS (spatialite)
10-
ENDIF (SPATIALITE_FOUND)
10+
ENDIF (SPATIALITE_FOUND OR WITH_INTERNAL_SPATIALITE)
1111

1212
IF (EXPAT_FOUND)
1313
SUBDIRS (gpx wfs)

‎src/providers/spatialite/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ QT4_WRAP_CPP(SPATIALITE_MOC_SRCS ${SPATIALITE_MOC_HDRS})
1515
INCLUDE_DIRECTORIES(
1616
../../core
1717
${SPATIALITE_INCLUDE_DIR}
18-
${SPATIALITE_INCLUDE_DIR}
1918
${GEOS_INCLUDE_DIR}
2019
)
2120

@@ -24,10 +23,13 @@ ADD_LIBRARY (spatialiteprovider MODULE ${SPATIALITE_SRCS} ${SPATIALITE_MOC_SRCS}
2423
TARGET_LINK_LIBRARIES(spatialiteprovider
2524
${QT_QTCORE_LIBRARY}
2625
${QT_QTXML_LIBRARY}
27-
${SPATIALITE_LIBRARY}
2826
qgis_core
2927
)
3028

29+
IF(NOT WITH_INTERNAL_SPATIALITE)
30+
TARGET_LINK_LIBRARIES(spatialiteprovider ${SPATIALITE_LIBRARY})
31+
ENDIF(NOT WITH_INTERNAL_SPATIALITE)
32+
3133

3234
########################################################
3335
# Install

0 commit comments

Comments
 (0)
Please sign in to comment.