nofxx-postgis_adapter 0.3.8 → 0.3.9

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/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 3
4
- :patch: 8
4
+ :patch: 9
@@ -39,7 +39,7 @@ ActiveRecord::Base.class_eval do
39
39
  if columns_hash[attr].is_a?(SpatialColumn)
40
40
  if value.is_a?(Array)
41
41
  attrs[attr.to_sym]= "BOX3D(" + value[0].join(" ") + "," + value[1].join(" ") + ")"
42
- "#{table_name}.#{column_name} && SetSRID(?::box3d, #{value[2] || DEFAULT_SRID} ) "
42
+ "#{table_name}.#{column_name} && SetSRID(?::box3d, #{value[2] || @@default_srid || DEFAULT_SRID} ) "
43
43
  elsif value.is_a?(Envelope)
44
44
  attrs[attr.to_sym]= "BOX3D(" + value.lower_corner.text_representation + "," + value.upper_corner.text_representation + ")"
45
45
  "#{table_name}.#{column_name} && SetSRID(?::box3d, #{value.srid} ) "
@@ -1,6 +1,5 @@
1
- # #
2
- # PostGIS Adapter
3
1
  #
2
+ # PostGIS Adapter
4
3
  #
5
4
  # http://github.com/nofxx/postgis_adapter
6
5
  #
@@ -14,23 +13,18 @@ module PostgisFunctions
14
13
  # acts_as_geom :geom
15
14
  def acts_as_geom(*columns)
16
15
  cattr_accessor :postgis_geoms
17
- geoms = columns.map do |g|
18
- geom_type = get_geom_type(g)
19
- case geom_type
20
- when :point
21
- send :include, PointFunctions
22
- when :polygon
23
- send :include, PolygonFunctions
24
- when :line_string
25
- send :include, LineStringFunctions
16
+ self.postgis_geoms = {:columns => columns}
17
+ columns.map do |g|
18
+ case get_geom_type(g)
19
+ when :point then send :include, PointFunctions
20
+ when :polygon then send :include, PolygonFunctions
21
+ when :line_string then send :include, LineStringFunctions
26
22
  end
27
- g
28
23
  end
29
- self.postgis_geoms = {:columns => geoms}#, :opts => options}
30
24
  end
31
25
 
32
26
  def get_geom_type(column)
33
- self.columns.select { |c| c.name == column.to_s}.first.geometry_type
27
+ self.columns.select { |c| c.name == column.to_s }[0].geometry_type
34
28
  rescue ActiveRecord::StatementInvalid => e
35
29
  nil
36
30
  end
@@ -1,4 +1,3 @@
1
- require File.dirname(__FILE__) + '/../spec_helper.rb'
2
1
 
3
2
  #add some postgis specific tables
4
3
  ActiveRecord::Schema.define() do
@@ -62,25 +61,25 @@ ActiveRecord::Schema.define() do
62
61
  t.polygon "geom", :with_m => true, :with_z => true, :srid => 4326
63
62
  end
64
63
 
65
- create_table :cities do |t|
64
+ create_table :cities, :force => true do |t|
66
65
  t.string :data, :limit => 100
67
66
  t.integer :value
68
67
  t.polygon :geom,:null=>false,:srid=>4326
69
68
  end
70
69
 
71
- create_table :positions do |t|
70
+ create_table :positions, :force => true do |t|
72
71
  t.string :data, :limit => 100
73
72
  t.integer :value
74
73
  t.point :geom,:null=>false,:srid=>4326
75
74
  end
76
75
 
77
- create_table :streets do |t|
76
+ create_table :streets, :force => true do |t|
78
77
  t.string :data, :limit => 100
79
78
  t.integer :value
80
79
  t.line_string :geom,:null=>false,:srid=>4326
81
80
  end
82
81
 
83
- create_table :common_geos do |t|
82
+ create_table :common_geos, :force => true do |t|
84
83
  t.string :data, :limit => 100
85
84
  t.integer :value
86
85
  t.point :geom,:null=>false,:srid=>4326
@@ -6,7 +6,7 @@ describe "ActsAsGeom" do
6
6
  class DiffColumn < ActiveRecord::Base
7
7
  acts_as_geom :ponto
8
8
  end
9
-
9
+
10
10
  class NotInDb < ActiveRecord::Base
11
11
  acts_as_geom :geom
12
12
  end
@@ -20,6 +20,10 @@ describe "ActsAsGeom" do
20
20
  NotInDb.get_geom_type(:geom).should be_nil
21
21
  end
22
22
 
23
+ it "should set the geom constant" do
24
+ # City::GEOMS[City].should eql([:geom])
25
+ end
26
+
23
27
  it "should query a diff column name" do
24
28
  # DiffColumn
25
29
  end
@@ -13,7 +13,7 @@ describe "CommonSpatialAdapter" do
13
13
  create_table "parks", :force => true do |t|
14
14
  t.string "data", :limit => 100
15
15
  t.integer "value"
16
- t.polygon "geom", :null=>false, :srid => 555 , :with_z => true,:with_m => true
16
+ t.polygon "geom", :null=>false, :srid => 4326 , :with_z => true,:with_m => true
17
17
  end
18
18
  end
19
19
  end
@@ -29,7 +29,7 @@ describe "CommonSpatialAdapter" do
29
29
  col.geometry_type.should eql(:polygon)
30
30
  col.type.should eql(:geometry)
31
31
  col.null.should be_false
32
- col.srid.should eql(555)
32
+ col.srid.should eql(4326)
33
33
  col.with_z.should be_true
34
34
  col.with_m.should be_true
35
35
  end
@@ -125,7 +125,7 @@ describe "CommonSpatialAdapter" do
125
125
  t.string "data", :limit => 100
126
126
  t.integer "value"
127
127
  #location is a postgreSQL keyword and is surrounded by double-quotes ("") when appearing in constraint descriptions ; tests a bug corrected in version 39
128
- t.point "location", :null=>false,:srid => 0, :with_m => true, :with_z => true
128
+ t.point "location", :null=>false,:srid => -1, :with_m => true, :with_z => true
129
129
  end
130
130
  end
131
131
 
@@ -190,7 +190,7 @@ describe "CommonSpatialAdapter" do
190
190
  create_table "parks", :force => true do |t|
191
191
  t.string "data" , :limit => 100
192
192
  t.integer "value"
193
- t.multi_polygon "geom", :null=>false,:srid => 0, :with_m => true, :with_z => true
193
+ t.multi_polygon "geom", :null=>false,:srid => -1, :with_m => true, :with_z => true
194
194
  end
195
195
  add_index "parks","geom",:spatial=>true,:name => "example_spatial_index"
196
196
  end
@@ -217,7 +217,7 @@ describe "CommonSpatialAdapter" do
217
217
  col.geometry_type.should eql(:multi_polygon)
218
218
  col.type.should eql(:geometry)
219
219
  col.null.should be_false
220
- col.srid.should eql(0)
220
+ col.srid.should eql(-1)
221
221
  col.with_z.should be_true
222
222
  col.with_m.should be_true
223
223
  end
data/spec/spec_helper.rb CHANGED
@@ -8,8 +8,9 @@ gem 'activerecord', "=2.3.2"
8
8
 
9
9
  $:.unshift((File.join(File.dirname(__FILE__), '..', 'lib')))
10
10
  require 'postgis_adapter'
11
-
11
+ GeoRuby::Base.srid = -1
12
12
  config = YAML.load_file(File.dirname(__FILE__) + '/db/database_postgis.yml')
13
13
  # ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log")
14
14
  ActiveRecord::Base.establish_connection(config)
15
+ #require File.dirname(__FILE__) + '/db/schema_postgis.rb'
15
16
  require File.dirname(__FILE__) + '/db/models_postgis.rb'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nofxx-postgis_adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.8
4
+ version: 0.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcos Augusto
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-23 00:00:00 -07:00
12
+ date: 2009-05-02 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -76,11 +76,11 @@ summary: PostGIS Adapter for Active Record
76
76
  test_files:
77
77
  - spec/db/models_postgis.rb
78
78
  - spec/db/schema_postgis.rb
79
+ - spec/postgis_functions/class_spec.rb
80
+ - spec/postgis_functions/bbox_spec.rb
81
+ - spec/postgis_functions/common_spec.rb
82
+ - spec/postgis_functions_spec.rb
83
+ - spec/postgis_adapter_spec.rb
79
84
  - spec/postgis_adapter/acts_as_geom_spec.rb
80
85
  - spec/postgis_adapter/common_spatial_adapter_spec.rb
81
- - spec/postgis_functions_spec.rb
82
86
  - spec/spec_helper.rb
83
- - spec/postgis_adapter_spec.rb
84
- - spec/postgis_functions/class_spec.rb
85
- - spec/postgis_functions/common_spec.rb
86
- - spec/postgis_functions/bbox_spec.rb