activerecord-spatialite-adapter 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/History.rdoc CHANGED
@@ -1,6 +1,12 @@
1
+ === 0.2.2 / 2010-12-27
2
+
3
+ * Support for basic spatial equality queries. e.g. constructs such as:
4
+ MyClass.where(:geom_column => factory.point(1, 2))
5
+ MyClass.where(:geom_column => 'POINT(1 2)')
6
+
1
7
  === 0.2.1 / 2010-12-15
2
8
 
3
- * Provides meta-information to RGeo 0.2.2 or later to support access to PostGIS's spatial reference system table.
9
+ * Provides meta-information to RGeo 0.2.2 or later to support access to SpatiaLite's spatial reference system table.
4
10
 
5
11
  === 0.2.0 / 2010-12-07
6
12
 
data/README.rdoc CHANGED
@@ -76,6 +76,19 @@ Now you can interact with the data using the RGeo types:
76
76
  # value will be cast from geographic to GEOS.
77
77
  RGeo::Geos.is_geos?(rec.shape) # => true
78
78
 
79
+ You can create simple queries based on spatial equality in the same way
80
+ you would on a scalar column:
81
+
82
+ rec = SpatialTable.where(:latlon => RGeo::Geos.factory.point(-122, 47)).first
83
+
84
+ You can also use WKT:
85
+
86
+ rec = SpatialTable.where(:latlon => 'POINT(-122 47)').first
87
+
88
+ Other types of queries currently must be written in SQL. However, we are
89
+ investigating writing a set of Arel extensions for constructing arbitrary
90
+ spatial queries.
91
+
79
92
  === Installation
80
93
 
81
94
  This adapter has the following requirements:
@@ -83,8 +96,8 @@ This adapter has the following requirements:
83
96
  * Ruby 1.8.7 or later. Ruby 1.9.2 or later preferred.
84
97
  * SpatiaLite 2.3 or later (2.4 recommended).
85
98
  * \ActiveRecord 3.0.3 or later. Earlier versions will not work.
86
- * rgeo gem 0.2.0 or later.
87
- * rgeo-activerecord gem 0.2.0 or later.
99
+ * rgeo gem 0.2.3 or later.
100
+ * rgeo-activerecord gem 0.2.1 or later.
88
101
  * sqlite3 gem 1.3 or later.
89
102
 
90
103
  Install this adapter as a gem:
data/Version CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2
@@ -42,7 +42,23 @@ require 'active_record/connection_adapters/sqlite3_adapter'
42
42
 
43
43
  module Arel
44
44
  module Visitors
45
- VISITORS['spatialite'] = ::Arel::Visitors::SQLite
45
+
46
+ class SpatiaLite < SQLite
47
+
48
+ FUNC_MAP = {
49
+ 'ST_WKTToSQL' => 'GeomFromText',
50
+ }
51
+
52
+ include ::RGeo::ActiveRecord::SpatialToSql
53
+
54
+ def st_func(standard_name_)
55
+ FUNC_MAP[standard_name_] || standard_name_
56
+ end
57
+
58
+ end
59
+
60
+ VISITORS['spatialite'] = ::Arel::Visitors::SpatiaLite
61
+
46
62
  end
47
63
  end
48
64
 
data/test/tc_basic.rb CHANGED
@@ -206,6 +206,32 @@ module RGeo
206
206
  end
207
207
 
208
208
 
209
+ def test_query_point
210
+ klass_ = populate_ar_class(:latlon_point)
211
+ obj_ = klass_.new
212
+ obj_.latlon = @factory.point(1, 2)
213
+ obj_.save!
214
+ id_ = obj_.id
215
+ obj2_ = klass_.where(:latlon => @factory.multi_point([@factory.point(1, 2)])).first
216
+ assert_equal(id_, obj2_.id)
217
+ obj3_ = klass_.where(:latlon => @factory.multi_point([@factory.point(2, 2)])).first
218
+ assert_nil(obj3_)
219
+ end
220
+
221
+
222
+ def test_query_point_wkt
223
+ klass_ = populate_ar_class(:latlon_point)
224
+ obj_ = klass_.new
225
+ obj_.latlon = @factory.point(1, 2)
226
+ obj_.save!
227
+ id_ = obj_.id
228
+ obj2_ = klass_.where(:latlon => 'POINT(1 2)').first
229
+ assert_equal(id_, obj2_.id)
230
+ obj3_ = klass_.where(:latlon => 'POINT(2 2)').first
231
+ assert_nil(obj3_)
232
+ end
233
+
234
+
209
235
  end
210
236
 
211
237
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 1
9
- version: 0.2.1
8
+ - 2
9
+ version: 0.2.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Daniel Azuma
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-12-15 00:00:00 -08:00
17
+ date: 2010-12-27 00:00:00 -08:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -28,8 +28,8 @@ dependencies:
28
28
  segments:
29
29
  - 0
30
30
  - 2
31
- - 0
32
- version: 0.2.0
31
+ - 1
32
+ version: 0.2.1
33
33
  type: :runtime
34
34
  version_requirements: *id001
35
35
  - !ruby/object:Gem::Dependency