rgeo 0.1.20 → 0.1.21

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.
Files changed (55) hide show
  1. data/History.rdoc +10 -0
  2. data/README.rdoc +38 -35
  3. data/Version +1 -1
  4. data/lib/active_record/connection_adapters/mysql2spatial_adapter.rb +1 -3
  5. data/lib/active_record/connection_adapters/mysqlspatial_adapter.rb +4 -4
  6. data/lib/active_record/connection_adapters/postgis_adapter.rb +426 -0
  7. data/lib/active_record/connection_adapters/spatialite_adapter.rb +488 -0
  8. data/lib/rgeo.rb +10 -29
  9. data/lib/rgeo/active_record/arel_modifications.rb +1 -0
  10. data/lib/rgeo/active_record/base_modifications.rb +27 -10
  11. data/lib/rgeo/active_record/common.rb +128 -0
  12. data/lib/rgeo/active_record/mysql_common.rb +14 -51
  13. data/lib/rgeo/cartesian/factory.rb +2 -2
  14. data/lib/rgeo/coord_sys.rb +1 -1
  15. data/lib/rgeo/coord_sys/proj4.rb +3 -2
  16. data/lib/rgeo/error.rb +0 -3
  17. data/lib/rgeo/feature.rb +1 -3
  18. data/lib/rgeo/feature/factory_generator.rb +8 -0
  19. data/lib/rgeo/geography/factory.rb +2 -2
  20. data/lib/rgeo/geography/interface.rb +3 -3
  21. data/lib/rgeo/geos/zm_factory.rb +2 -2
  22. data/lib/rgeo/wkrep/wkb_parser.rb +35 -36
  23. data/lib/rgeo/wkrep/wkt_parser.rb +36 -38
  24. data/test/active_record/common_setup_methods.rb +129 -0
  25. data/test/active_record/readme.txt +10 -0
  26. data/test/active_record/tc_mysqlspatial.rb +22 -71
  27. data/test/active_record/tc_postgis.rb +282 -0
  28. data/test/active_record/tc_spatialite.rb +198 -0
  29. data/test/coord_sys/tc_proj4.rb +12 -5
  30. data/test/projected_geography/tc_geometry_collection.rb +1 -1
  31. data/test/projected_geography/tc_line_string.rb +1 -1
  32. data/test/projected_geography/tc_multi_line_string.rb +1 -1
  33. data/test/projected_geography/tc_multi_point.rb +1 -1
  34. data/test/projected_geography/tc_multi_polygon.rb +2 -2
  35. data/test/projected_geography/tc_point.rb +4 -4
  36. data/test/projected_geography/tc_polygon.rb +1 -1
  37. data/test/simple_mercator/tc_geometry_collection.rb +1 -1
  38. data/test/simple_mercator/tc_line_string.rb +1 -1
  39. data/test/simple_mercator/tc_multi_line_string.rb +1 -1
  40. data/test/simple_mercator/tc_multi_point.rb +1 -1
  41. data/test/simple_mercator/tc_multi_polygon.rb +2 -2
  42. data/test/simple_mercator/tc_point.rb +4 -4
  43. data/test/simple_mercator/tc_polygon.rb +1 -1
  44. data/test/simple_mercator/tc_window.rb +1 -1
  45. data/test/spherical_geography/tc_geometry_collection.rb +1 -1
  46. data/test/spherical_geography/tc_line_string.rb +1 -1
  47. data/test/spherical_geography/tc_multi_line_string.rb +1 -1
  48. data/test/spherical_geography/tc_multi_point.rb +1 -1
  49. data/test/spherical_geography/tc_multi_polygon.rb +2 -2
  50. data/test/spherical_geography/tc_point.rb +4 -4
  51. data/test/spherical_geography/tc_polygon.rb +1 -1
  52. data/test/tc_oneoff.rb +3 -3
  53. data/test/wkrep/tc_wkb_parser.rb +14 -14
  54. data/test/wkrep/tc_wkt_parser.rb +37 -45
  55. metadata +10 -3
@@ -101,6 +101,14 @@ module RGeo
101
101
  end
102
102
 
103
103
 
104
+ # Return a new FactoryGenerator that always returns the given
105
+ # factory.
106
+
107
+ def self.single(factory_)
108
+ ::Proc.new{ |c_| factory_ }
109
+ end
110
+
111
+
104
112
  # Return a new FactoryGenerator that calls the given delegate, but
105
113
  # modifies the configuration passed to it. You can provide defaults
106
114
  # for configuration values not explicitly specified, and you can
@@ -185,14 +185,14 @@ module RGeo
185
185
  # See ::RGeo::Feature::Factory#parse_wkt
186
186
 
187
187
  def parse_wkt(str_)
188
- WKRep::WKTParser.new(:default_factory => self).parse(str_)
188
+ WKRep::WKTParser.new(self).parse(str_)
189
189
  end
190
190
 
191
191
 
192
192
  # See ::RGeo::Feature::Factory#parse_wkb
193
193
 
194
194
  def parse_wkb(str_)
195
- WKRep::WKBParser.new(:default_factory => self).parse(str_)
195
+ WKRep::WKBParser.new(self).parse(str_)
196
196
  end
197
197
 
198
198
 
@@ -101,7 +101,7 @@ module RGeo
101
101
  # to 4326, indicating the WGS84 crs, but note that that value
102
102
  # implies an ellipsoidal datum, not a spherical datum.
103
103
 
104
- def spherical(opts_={})
104
+ def spherical_factory(opts_={})
105
105
  Geography::Factory.new('Spherical', :support_z_coordinate => opts_[:support_z_coordinate], :support_m_coordinate => opts_[:support_m_coordinate], :proj4 => opts_[:proj4] || '+proj=longlat +a=6378137 +b=6378137 +towgs84=0,0,0,0,0,0,0 +no_defs', :srid => opts_[:srid] || 4055)
106
106
  end
107
107
 
@@ -172,7 +172,7 @@ module RGeo
172
172
  # <tt>z_coordinate</tt> and <tt>m_coordinate</tt>. They may at
173
173
  # most support one or the other.
174
174
 
175
- def simple_mercator(opts_={})
175
+ def simple_mercator_factory(opts_={})
176
176
  factory_ = Geography::Factory.new('Projected', :proj4 => '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs', :srid => 4326, :support_z_coordinate => opts_[:support_z_coordinate], :support_m_coordinate => opts_[:support_m_coordinate])
177
177
  projector_ = Geography::SimpleMercatorProjector.new(factory_, :buffer_resolution => opts_[:buffer_resolution], :lenient_multi_polygon_assertions => opts_[:lenient_multi_polygon_assertions], :support_z_coordinate => opts_[:support_z_coordinate], :support_m_coordinate => opts_[:support_m_coordinate])
178
178
  factory_._set_projector(projector_)
@@ -237,7 +237,7 @@ module RGeo
237
237
  # <tt>:support_m_coordinate</tt>::
238
238
  # Support <tt>m_coordinate</tt>. Default is false.
239
239
 
240
- def projected(opts_={})
240
+ def projected_factory(opts_={})
241
241
  unless CoordSys::Proj4.supported?
242
242
  raise Error::UnsupportedCapability, "Proj4 is not supported because the proj4 library was not found at install time."
243
243
  end
@@ -126,14 +126,14 @@ module RGeo
126
126
  # See ::RGeo::Feature::Factory#parse_wkt
127
127
 
128
128
  def parse_wkt(str_)
129
- WKRep::WKTParser.new(:default_factory => self).parse(str_)
129
+ WKRep::WKTParser.new(self).parse(str_)
130
130
  end
131
131
 
132
132
 
133
133
  # See ::RGeo::Feature::Factory#parse_wkb
134
134
 
135
135
  def parse_wkb(str_)
136
- WKRep::WKBParser.new(:default_factory => self).parse(str_)
136
+ WKRep::WKBParser.new(self).parse(str_)
137
137
  end
138
138
 
139
139
 
@@ -49,21 +49,15 @@ module RGeo
49
49
  #
50
50
  # === Configuration options
51
51
  #
52
- # The following options are recognized. These can be passed to the
53
- # constructor, or set on the object afterwards.
52
+ # You must provide each parser with an RGeo::Feature::FactoryGenerator.
53
+ # It should understand the configuration options <tt>:srid</tt>,
54
+ # <tt>:support_z_coordinate</tt>, and <tt>:support_m_coordinate</tt>.
55
+ # You may also pass a specific RGeo::Feature::Factory, or nil to
56
+ # specify the default Cartesian FactoryGenerator.
57
+ #
58
+ # The following additional options are recognized. These can be passed
59
+ # to the constructor, or set on the object afterwards.
54
60
  #
55
- # <tt>:default_factory</tt>::
56
- # The default factory for parsed geometries, used when no factory
57
- # generator is provided. If no default is provided either, the
58
- # default cartesian factory will be used as the default.
59
- # <tt>:factory_generator</tt>::
60
- # A factory generator that should return a factory based on the
61
- # srid and dimension settings in the input. The factory generator
62
- # should understand the configuration options <tt>:srid</tt>,
63
- # <tt>:support_z_coordinate</tt>, and <tt>:support_m_coordinate</tt>.
64
- # See RGeo::Feature::FactoryGenerator for more information.
65
- # If no generator is provided, the <tt>:default_factory</tt> is
66
- # used.
67
61
  # <tt>:support_ewkb</tt>::
68
62
  # Activate support for PostGIS EWKB type codes, which use high
69
63
  # order bits in the type code to signal the presence of Z, M, and
@@ -76,6 +70,9 @@ module RGeo
76
70
  # <tt>:ignore_extra_bytes</tt>::
77
71
  # If true, extra bytes at the end of the data are ignored. If
78
72
  # false (the default), extra bytes will trigger a parse error.
73
+ # <tt>:default_srid</tt>::
74
+ # A SRID to pass to the factory generator if no SRID is present in
75
+ # the input. Defaults to nil (i.e. don't specify a SRID).
79
76
 
80
77
  class WKBParser
81
78
 
@@ -83,34 +80,38 @@ module RGeo
83
80
  # Create and configure a WKB parser. See the WKBParser
84
81
  # documentation for the options that can be passed.
85
82
 
86
- def initialize(opts_={})
87
- @default_factory = opts_[:default_factory] || Cartesian.preferred_factory
88
- @factory_generator = opts_[:factory_generator]
83
+ def initialize(factory_generator_=nil, opts_={})
84
+ self.factory_generator = factory_generator_
89
85
  @support_ewkb = opts_[:support_ewkb] ? true : false
90
86
  @support_wkb12 = opts_[:support_wkb12] ? true : false
91
87
  @ignore_extra_bytes = opts_[:ignore_extra_bytes] ? true : false
88
+ @default_srid = opts_[:default_srid]
92
89
  end
93
90
 
94
91
 
95
- # Returns the default factory. See WKBParser for details.
96
- def default_factory
97
- @default_factory
98
- end
99
-
100
- # Sets the default factory. See WKBParser for details.
101
- def default_factory=(value_)
102
- @default_factory = value_ || Cartesian.preferred_factory
103
- end
104
-
105
- # Returns the factory generator, or nil if there is none.
106
- # See WKBParser for details.
92
+ # Returns the factory generator. See WKBParser for details.
107
93
  def factory_generator
108
94
  @factory_generator
109
95
  end
110
96
 
97
+ # If this parser was given an exact factory, returns it; otherwise
98
+ # returns nil.
99
+ def exact_factory
100
+ @exact_factory
101
+ end
102
+
111
103
  # Sets the factory_generator. See WKBParser for details.
112
104
  def factory_generator=(value_)
113
- @factory_generator = value_
105
+ if value_.kind_of?(Feature::Factory::Instance)
106
+ @factory_generator = Feature::FactoryGenerator.single(value_)
107
+ @exact_factory = value_
108
+ elsif value_.respond_to?(:call)
109
+ @factory_generator = value_
110
+ @exact_factory = nil
111
+ else
112
+ @factory_generator = Cartesian.method(:preferred_factory)
113
+ @exact_factory = nil
114
+ end
114
115
  end
115
116
 
116
117
  # Sets the factory_generator to the given block.
@@ -167,7 +168,7 @@ module RGeo
167
168
  @cur_has_m = nil
168
169
  @cur_srid = nil
169
170
  @cur_dims = 2
170
- @cur_factory = @default_factory
171
+ @cur_factory = nil
171
172
  begin
172
173
  _start_scanner(data_)
173
174
  obj_ = _parse_object(false)
@@ -189,7 +190,7 @@ module RGeo
189
190
  type_code_ = _get_integer(little_endian_)
190
191
  has_z_ = false
191
192
  has_m_ = false
192
- srid_ = nil
193
+ srid_ = contained_ ? nil : @default_srid
193
194
  if @support_ewkb
194
195
  has_z_ ||= type_code_ & 0x80000000 != 0
195
196
  has_m_ ||= type_code_ & 0x40000000 != 0
@@ -218,10 +219,8 @@ module RGeo
218
219
  @cur_has_z = has_z_
219
220
  @cur_has_m = has_m_
220
221
  @cur_dims = 2 + (@cur_has_z ? 1 : 0) + (@cur_has_m ? 1 : 0)
221
- @cur_srid = srid_.to_i
222
- if @factory_generator
223
- @cur_factory = @factory_generator.call(:srid => @cur_srid, :support_z_coordinate => has_z_, :support_m_coordinate => has_m_)
224
- end
222
+ @cur_srid = srid_
223
+ @cur_factory = @factory_generator.call(:srid => @cur_srid, :support_z_coordinate => has_z_, :support_m_coordinate => has_m_)
225
224
  if @cur_has_z && !@cur_factory.has_capability?(:z_coordinate)
226
225
  raise Error::ParseError, "Data has Z coordinates but the factory doesn't have z_coordinate capability"
227
226
  end
@@ -52,21 +52,15 @@ module RGeo
52
52
  #
53
53
  # === Configuration options
54
54
  #
55
- # The following options are recognized. These can be passed to the
56
- # constructor, or set on the object afterwards.
55
+ # You must provide each parser with an RGeo::Feature::FactoryGenerator.
56
+ # It should understand the configuration options <tt>:srid</tt>,
57
+ # <tt>:support_z_coordinate</tt>, and <tt>:support_m_coordinate</tt>.
58
+ # You may also pass a specific RGeo::Feature::Factory, or nil to
59
+ # specify the default Cartesian FactoryGenerator.
60
+ #
61
+ # The following additional options are recognized. These can be passed
62
+ # to the constructor, or set on the object afterwards.
57
63
  #
58
- # <tt>:default_factory</tt>::
59
- # The default factory for parsed geometries, used when no factory
60
- # generator is provided. If no default is provided either, the
61
- # default cartesian factory will be used as the default.
62
- # <tt>:factory_generator</tt>::
63
- # A factory generator that should return a factory based on the
64
- # srid and dimension settings in the input. The factory generator
65
- # should understand the configuration options <tt>:srid</tt>,
66
- # <tt>:support_z_coordinate</tt>, and <tt>:support_m_coordinate</tt>.
67
- # See RGeo::Feature::FactoryGenerator for more information.
68
- # If no generator is provided, the <tt>:default_factory</tt> is
69
- # used.
70
64
  # <tt>:support_ewkt</tt>::
71
65
  # Activate support for PostGIS EWKT type tags, which appends an "M"
72
66
  # to tags to indicate the presence of M but not Z, and also
@@ -83,6 +77,9 @@ module RGeo
83
77
  # <tt>:ignore_extra_tokens</tt>::
84
78
  # If true, extra tokens at the end of the data are ignored. If
85
79
  # false (the default), extra tokens will trigger a parse error.
80
+ # <tt>:default_srid</tt>::
81
+ # A SRID to pass to the factory generator if no SRID is present in
82
+ # the input. Defaults to nil (i.e. don't specify a SRID).
86
83
 
87
84
  class WKTParser
88
85
 
@@ -90,41 +87,45 @@ module RGeo
90
87
  # Create and configure a WKT parser. See the WKTParser
91
88
  # documentation for the options that can be passed.
92
89
 
93
- def initialize(opts_={})
94
- @default_factory = opts_[:default_factory] || Cartesian.preferred_factory
95
- @factory_generator = opts_[:factory_generator]
90
+ def initialize(factory_generator_=nil, opts_={})
91
+ self.factory_generator = factory_generator_
96
92
  @support_ewkt = opts_[:support_ewkt] ? true : false
97
93
  @support_wkt12 = opts_[:support_wkt12] ? true : false
98
94
  @strict_wkt11 = @support_ewkt || @support_wkt12 ? false : opts_[:strict_wkt11] ? true : false
99
95
  @ignore_extra_tokens = opts_[:ignore_extra_tokens] ? true : false
96
+ @default_srid = opts_[:default_srid]
100
97
  end
101
98
 
102
99
 
103
- # Returns the default factory. See WKTParser for details.
104
- def default_factory
105
- @default_factory
106
- end
107
-
108
- # Sets the default factory. See WKTParser for details.
109
- def default_factory=(value_)
110
- @default_factory = value_ || Cartesian.preferred_factory
111
- end
112
-
113
- # Returns the factory generator, or nil if there is none.
114
- # See WKTParser for details.
100
+ # Returns the factory generator. See WKTParser for details.
115
101
  def factory_generator
116
102
  @factory_generator
117
103
  end
118
104
 
105
+ # If this parser was given an exact factory, returns it; otherwise
106
+ # returns nil.
107
+ def exact_factory
108
+ @exact_factory
109
+ end
110
+
119
111
  # Sets the factory_generator. See WKTParser for details.
120
112
  def factory_generator=(value_)
121
- @factory_generator = value_
113
+ if value_.kind_of?(Feature::Factory::Instance)
114
+ @factory_generator = Feature::FactoryGenerator.single(value_)
115
+ @exact_factory = value_
116
+ elsif value_.respond_to?(:call)
117
+ @factory_generator = value_
118
+ @exact_factory = nil
119
+ else
120
+ @factory_generator = Cartesian.method(:preferred_factory)
121
+ @exact_factory = nil
122
+ end
122
123
  end
123
124
 
124
125
  # Sets the factory_generator to the given block.
125
126
  # See WKTParser for details.
126
127
  def to_generate_factory(&block_)
127
- @factory_generator = block_
128
+ self.factory_generator = block_
128
129
  end
129
130
 
130
131
  # Returns true if this parser supports EWKT.
@@ -176,14 +177,14 @@ module RGeo
176
177
 
177
178
  def parse(str_)
178
179
  str_ = str_.downcase
179
- @cur_factory = @factory_generator ? nil : @default_factory
180
+ @cur_factory = @exact_factory
180
181
  if @cur_factory
181
182
  @cur_factory_support_z = @cur_factory.has_capability?(:z_coordinate) ? true : false
182
183
  @cur_factory_support_m = @cur_factory.has_capability?(:m_coordinate) ? true : false
183
184
  end
184
185
  @cur_expect_z = nil
185
186
  @cur_expect_m = nil
186
- @cur_srid = nil
187
+ @cur_srid = @default_srid
187
188
  if @support_ewkt && str_ =~ /^srid=(\d+);/i
188
189
  str_ = $'
189
190
  @cur_srid = $1.to_i
@@ -213,10 +214,7 @@ module RGeo
213
214
 
214
215
  def _ensure_factory # :nodoc:
215
216
  unless @cur_factory
216
- if @factory_generator
217
- @cur_factory = @factory_generator.call(:srid => @cur_srid, :support_z_coordinate => @cur_expect_z, :support_m_coordinate => @cur_expect_m)
218
- end
219
- @cur_factory ||= @default_factory
217
+ @cur_factory = @factory_generator.call(:srid => @cur_srid, :support_z_coordinate => @cur_expect_z, :support_m_coordinate => @cur_expect_m)
220
218
  @cur_factory_support_z = @cur_factory.has_capability?(:z_coordinate) ? true : false
221
219
  @cur_factory_support_m = @cur_factory.has_capability?(:m_coordinate) ? true : false
222
220
  _check_factory_support unless @cur_expect_z.nil?
@@ -362,7 +360,7 @@ module RGeo
362
360
  def _parse_polygon # :nodoc:
363
361
  inner_rings_ = []
364
362
  if @cur_token == 'empty'
365
- outer_ring_ = @cur_factory.linear_ring([])
363
+ outer_ring_ = _ensure_factory.linear_ring([])
366
364
  else
367
365
  _expect_token_type(:begin)
368
366
  _next_token
@@ -0,0 +1,129 @@
1
+ # -----------------------------------------------------------------------------
2
+ #
3
+ # Common setup methods for ActiveRecord adapter tests
4
+ #
5
+ # -----------------------------------------------------------------------------
6
+ # Copyright 2010 Daniel Azuma
7
+ #
8
+ # All rights reserved.
9
+ #
10
+ # Redistribution and use in source and binary forms, with or without
11
+ # modification, are permitted provided that the following conditions are met:
12
+ #
13
+ # * Redistributions of source code must retain the above copyright notice,
14
+ # this list of conditions and the following disclaimer.
15
+ # * Redistributions in binary form must reproduce the above copyright notice,
16
+ # this list of conditions and the following disclaimer in the documentation
17
+ # and/or other materials provided with the distribution.
18
+ # * Neither the name of the copyright holder, nor the names of any other
19
+ # contributors to this software, may be used to endorse or promote products
20
+ # derived from this software without specific prior written permission.
21
+ #
22
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
+ # POSSIBILITY OF SUCH DAMAGE.
33
+ # -----------------------------------------------------------------------------
34
+ ;
35
+
36
+
37
+ require 'rgeo'
38
+ require 'yaml'
39
+ require 'active_record'
40
+ require 'logger'
41
+
42
+
43
+ module RGeo
44
+ module Tests # :nodoc:
45
+ module ActiveRecord # :nodoc:
46
+
47
+
48
+ if ::File.exists?(::File.dirname(__FILE__)+'/database.yml')
49
+
50
+ TESTS_AVAILABLE = true
51
+
52
+ ALL_DATABASES_CONFIG = ::YAML.load_file(::File.dirname(__FILE__)+'/database.yml')
53
+
54
+
55
+ module CommonSetupMethods # :nodoc:
56
+
57
+ @class_num = 0
58
+
59
+
60
+ def self.included(klass_)
61
+ database_config_ = ALL_DATABASES_CONFIG[klass_.const_get(:ADAPTER_NAME)]
62
+ database_config_.symbolize_keys!
63
+ if klass_.respond_to?(:before_open_database)
64
+ klass_.before_open_database(:config => database_config_)
65
+ end
66
+ klass_.const_set(:DATABASE_CONFIG, database_config_)
67
+ ar_class_ = CommonSetupMethods.new_class(database_config_)
68
+ klass_.const_set(:DEFAULT_AR_CLASS, ar_class_)
69
+ if klass_.respond_to?(:initialize_database)
70
+ klass_.initialize_database(:ar_class => ar_class_, :connection => ar_class_.connection)
71
+ end
72
+ end
73
+
74
+
75
+ def self.new_class(param_)
76
+ base_ = param_.kind_of?(::Class) ? param_ : ::ActiveRecord::Base
77
+ config_ = param_.kind_of?(::Hash) ? param_ : nil
78
+ klass_ = ::Class.new(base_)
79
+ @class_num += 1
80
+ self.const_set("Klass#{@class_num}".to_sym, klass_)
81
+ klass_.class_eval do
82
+ establish_connection(config_) if config_
83
+ set_table_name(:spatial_test)
84
+ end
85
+ klass_
86
+ end
87
+
88
+
89
+ def setup
90
+ @factory = ::RGeo::Cartesian.preferred_factory(:srid => 4326)
91
+ @geographic_factory = ::RGeo::Geography.spherical_factory(:srid => 4326)
92
+ cleanup_tables
93
+ end
94
+
95
+
96
+ def teardown
97
+ cleanup_tables
98
+ end
99
+
100
+
101
+ def cleanup_tables
102
+ klass_ = self.class.const_get(:DEFAULT_AR_CLASS)
103
+ if klass_.connection.tables.include?('spatial_test')
104
+ klass_.connection.drop_table(:spatial_test)
105
+ end
106
+ end
107
+
108
+
109
+ def create_ar_class(opts_={})
110
+ @ar_class = CommonSetupMethods.new_class(self.class.const_get(:DEFAULT_AR_CLASS))
111
+ end
112
+
113
+
114
+ end
115
+
116
+
117
+ else
118
+
119
+ TESTS_AVAILABLE = false
120
+
121
+ puts "WARNING: database.yml not found. Skipping ActiveRecord tests."
122
+ puts " See tests/active_record/readme.txt for more info."
123
+
124
+ end
125
+
126
+
127
+ end
128
+ end
129
+ end