Skip to content

Instantly share code, notes, and snippets.

@sixman9
sixman9 / Load Spatialite library in .NET
Created January 26, 2011 14:40
How to load libspatialite under C#
using (DbConnection connection = new SQLiteConnection("Data Source=" + database)) {
connection.Open(); // load the extension
using (DbCommand command = connection.CreateCommand()) {
//Load the libspatialite library extension - *.dll on windows, *.a on iOS
command.CommandText = "SELECT load_extension('libspatialite-2.dll');";
command.ExecuteNonQuery(); // Run queries here
}
}
@sixman9
sixman9 / Load Spatialite library in .NET
Created January 26, 2011 14:40
How to load libspatialite under C#
//'using' System.Data.SQLite;
using (DbConnection connection = new SQLiteConnection("Data Source=" + database)) {
connection.Open(); // load the extension
using (DbCommand command = connection.CreateCommand()) {
//Load the libspatialite library extension - *.dll on windows, *.a on iOS
command.CommandText = "SELECT load_extension('libspatialite-2.dll');";
command.ExecuteNonQuery(); // Run queries here
}
}
@sixman9
sixman9 / Loading Spatialite in C#, early 2011
Created January 26, 2011 14:43
Another spacialite library example, slighty different execute method
//'using' System.Data.SQLite
public void SQLiteTest()
{
string cnString = @"Data Source=C:\Working\whodatashapefiles\whodata.db3";
using (SQLiteConnection conn = new SQLiteConnection(cnString))
{
conn.Open();
using (SQLiteCommand cmd = conn.CreateCommand())
{
@sixman9
sixman9 / Setting and unsetting hard links on Mac OSX
Created January 27, 2011 08:37
Apple have 'crippled' the 'ln' command on Mac OSX - need to follow external folder for Git inclusion etc. etc.
@sixman9
sixman9 / Hints on running Spatialite on iPhone
Created January 27, 2011 15:26
Spatialite on iPhone hints, includes using a newer version of SQLite
From: http://groups.google.com/group/spatialite-users/browse_thread/thread/f3b5941da7eded8d
[I have] SpatiaLite running on the iPhone (device + simulator) and GEOS
for the geometries model etc. as static libraries. I can not directly
give you the library (or libraries), but you can make it (or them)
yourself. There are just a few things you need to be aware of before
trying to add the database extension to the phone.
The native SQLite version is old, for instance, the function names
used by SpatiaLite do not work with that particular version. I myself
@sixman9
sixman9 / SQLite Run-Time Library Version Numbers
Created January 27, 2011 15:50
Useful to ensure code is user the required version of SQLite, say when using a newer version, on iphone etc.
SQLITE_EXTERN const char sqlite3_version[];
const char *sqlite3_libversion(void);
const char *sqlite3_sourceid(void);
int sqlite3_libversion_number(void);
These interfaces provide the same information as the SQLITE_VERSION, SQLITE_VERSION_NUMBER, and SQLITE_SOURCE_ID C preprocessor macros but are associated with the library instead of the header file. Cautious programmers might include assert() statements in their application to verify that values returned by these interfaces match the macros in the header, and thus insure that the application is compiled with matching library and header files.
assert( sqlite3_libversion_number()==SQLITE_VERSION_NUMBER );
assert( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)==0 );
assert( strcmp(sqlite3_libversion(),SQLITE_VERSION)==0 );
@sixman9
sixman9 / SQLite Cmake script for win32
Created January 27, 2011 16:02
SQLite Cmake script for win32 - starting point for iPhone version?
#cmakelists.txt
cmake_minimum_required ( VERSION 2.6 FATAL_ERROR )
project ( sqlite3 C )
SET( CMAKE_INSTALL_PREFIX "f:/doof" )
set ( SOURCES sqlite3.c )
set ( HEADERS sqlite3.h )
@sixman9
sixman9 / SQLite cmakelist.txt for Apple Mac OSX
Created January 27, 2011 17:06
SQLite cmakelist.txt for Apple OSX - Should be able to hack it to generate iPhone binary :-)
#Found at http://gitorious.org/~akeru/tagaini-jisho/akeru-tagaini-jisho
# The project name decides the naming pattern of many things - choose it according
# to the standard of the platform we run on.
if(APPLE)
project("Tagaini Jisho")
else(APPLE)
project("tagainijisho")
endif(APPLE)
# Set the program name to be the same as the project
@sixman9
sixman9 / Another iPhone cmakelists.txt example
Created January 28, 2011 03:31
For safe keeping - may come in handy
cmake_minimum_required(VERSION 2.8)
cmake_policy(SET CMP0015 NEW)
cmake_policy(SET CMP0016 NEW)
project(test)
set(NAME test)
file(GLOB headers *.h)
file(GLOB sources *.cpp)
@sixman9
sixman9 / cmakelists.txt
Created January 28, 2011 03:31
For safe keeping - may come in handy
cmake_minimum_required(VERSION 2.8)
cmake_policy(SET CMP0015 NEW)
cmake_policy(SET CMP0016 NEW)
project(test)
set(NAME test)
file(GLOB headers *.h)
file(GLOB sources *.cpp)