I don't think this commit is necessary. You can load the spatialite
extensions without adding any extra code to the sqlite3 gem. Here is
an example program that uses the spacialite test database from here:
http://www.gaia-gis.it/spatialite-2.3.1/resources.html
require "sqlite3"
db = SQLite3::Database.new File.expand_path("~/Downloads/test-2.3.sqlite")
db.enable_load_extension 1
db.load_extension '/usr/local/lib/libspatialite.dylib'
p db.execute(<<-eosql)
SELECT name, peoples, AsText(Geometry)
from Towns
where peoples > 350000
order by peoples DESC
eosql
Two things to note about this program: 1) It's possible that your
sqlite3 installation doesn't support extension loading, and if that's
the case you'll get an error on the `enable_load_extension` method
call, and 2) your path to the spatialite extension may be different
than mine (since I'm on OS X and installed with homebrew).
Hope that helps!
--
Aaron Patterson
http://tenderlovemaking.com/
Win7 32bit with the existing sqlite3 gem also likes the example...
C:\Users\Jon\Documents>ripl
>> RUBY_DESCRIPTION
=> "ruby 1.9.3p143 (2012-02-24 revision 34791) [i386-mingw32]"
>> ENV['PATH'] += 'C:/devlibs/libiconv/bin;C:/devlibs/libgeos/bin;C:/devlibs/libproj/bin'
=> ...
>> require 'sqlite3'
=> true
>> SQLite3::VERSION
=> "1.3.5"
>> db = SQLite3::Database.new File.expand_path('test-2.3.sqlite')
=> #<SQLite3::Database:0x23d9318>
>> db.enable_load_extension 1
=> #<SQLite3::Database:0x23d9318>
>> db.load_extension 'C:/devlibs/libspatialite/bin/libspatialite-1.dll'
SpatiaLite version ..: 2.3.1 Supported Extensions:
- 'VirtualShape' [direct Shapefile access]
- 'VirtualText' [direct CSV/TXT access]
- 'VirtualNetwork [Dijkstra shortest path]
- 'RTree' [Spatial Index - R*Tree]
- 'MbrCache' [Spatial Index - MBR cache]
- 'VirtualFDO' [FDO-OGR interoperability]
- 'SpatiaLite' [Spatial SQL - OGC]
PROJ.4 Rel. 4.6.1, 21 August 2008
GEOS version 3.1.1-CAPI-1.6.0
=> #<SQLite3::Database:0x23d9318>
>> p db.execute(<<-eosql)
| SELECT name, peoples, AsText(Geometry)
| from Towns
| where peoples > 350000
| order by peoples DESC
| eosql
[["Roma", 2546804, "POINT(788703.57 4645636.3)"], ["Milano", 1256211, "POINT(514820.49 5034534.56)"],...
Jon
---
Fail fast. Fail often. Fail publicly. Learn. Adapt. Repeat.
http://thecodeshop.github.com | http://jonforums.github.com/
twitter: @jonforums
brew install sqlite libspatialite spatialite-tools
- Install sqlite3 gem with explicitely pointing to brew compiled sqlite: