Spatialite is a plugin for SQLite that allows for geo-spatial queries
- Include spatialite and sqlite header
#import <spatialite/spatialite.h>
#import <sqlite3/sqlite3.h>
- Initialize spatialite where ''mySQLite3Connection'' is your handle to a valid database instance
int sqliteInitStatus = sqlite3_initialize();
assert(sqliteInitStatus==SQLITE_OK);
int sqliteInitOSStatus = sqlite3_os_init();
assert(sqliteInitOSStatus==SQLITE_OK);
sqlite3_enable_load_extension(mySQLite3Connection, 1);
spatialite_initialize();
_spatialiteConn = spatialite_alloc_connection();
assert(_spatialiteConn);
spatialite_init_ex(mySQLite3Connection, _spatialiteConn, 1);```
After the above you can call SQLite with queries containing spatialite functions
If you use the sqlite3 built provided by iOS/Mac ensure this version supports loading extension (Alternatively build sqlite3 with extension support)
github 'Ryandev/proj4' == 4.9.2
github 'Ryandev/geos' == 3.5.0
SpatiaLite is licensed under the MPL tri-license terms; you are free to choose the best-fit license between: