rs_spatial_adapter 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +197 -0
- data/VERSION +1 -0
- data/lib/spatial_adapter.rb +41 -0
- data/lib/spatial_adapter/common/raw_geom_info.rb +23 -0
- data/lib/spatial_adapter/common/schema_definitions.rb +11 -0
- data/lib/spatial_adapter/common/schema_dumper.rb +136 -0
- data/lib/spatial_adapter/common/spatial_column.rb +70 -0
- data/lib/spatial_adapter/common/table_definition.rb +14 -0
- data/lib/spatial_adapter/mysql.rb +98 -0
- data/lib/spatial_adapter/mysql2.rb +97 -0
- data/lib/spatial_adapter/postgresql.rb +388 -0
- data/lib/spatial_adapter/railtie.rb +13 -0
- data/rails/init.rb +11 -0
- data/spec/README.txt +22 -0
- data/spec/db/mysql2_raw.rb +70 -0
- data/spec/db/mysql_raw.rb +70 -0
- data/spec/db/postgis_raw.rb +190 -0
- data/spec/models/common.rb +65 -0
- data/spec/mysql/connection_adapter_spec.rb +106 -0
- data/spec/mysql/migration_spec.rb +64 -0
- data/spec/mysql/models_spec.rb +65 -0
- data/spec/mysql/schema_dumper_spec.rb +56 -0
- data/spec/mysql2/connection_adapter_spec.rb +106 -0
- data/spec/mysql2/migration_spec.rb +64 -0
- data/spec/mysql2/models_spec.rb +65 -0
- data/spec/mysql2/schema_dumper_spec.rb +56 -0
- data/spec/postgresql/connection_adapter_spec.rb +227 -0
- data/spec/postgresql/migration_spec.rb +365 -0
- data/spec/postgresql/models_spec.rb +221 -0
- data/spec/postgresql/schema_dumper_spec.rb +79 -0
- data/spec/shared_examples.rb +43 -0
- data/spec/spec_helper.rb +90 -0
- metadata +131 -0
@@ -0,0 +1,221 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'shared_examples'
|
3
|
+
require 'spatial_adapter/postgresql'
|
4
|
+
require 'db/postgis_raw'
|
5
|
+
require 'models/common'
|
6
|
+
|
7
|
+
describe "Spatially-enabled Models" do
|
8
|
+
before :each do
|
9
|
+
postgis_connection
|
10
|
+
@connection = ActiveRecord::Base.connection
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "inserting records" do
|
14
|
+
it 'should save Point objects' do
|
15
|
+
model = PointModel.new(:extra => 'test', :geom => GeometryFactory.point)
|
16
|
+
@connection.should_receive(:select_value).with(Regexp.new(GeometryFactory.point.as_hex_ewkb))
|
17
|
+
model.save.should == true
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should save LineString objects' do
|
21
|
+
model = LineStringModel.new(:extra => 'test', :geom => GeometryFactory.line_string)
|
22
|
+
@connection.should_receive(:select_value).with(Regexp.new(GeometryFactory.line_string.as_hex_ewkb))
|
23
|
+
model.save.should == true
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should save Polygon objects' do
|
27
|
+
model = PolygonModel.new(:extra => 'test', :geom => GeometryFactory.polygon)
|
28
|
+
@connection.should_receive(:select_value).with(Regexp.new(GeometryFactory.polygon.as_hex_ewkb))
|
29
|
+
model.save.should == true
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should save MultiPoint objects' do
|
33
|
+
model = MultiPointModel.new(:extra => 'test', :geom => GeometryFactory.multi_point)
|
34
|
+
@connection.should_receive(:select_value).with(Regexp.new(GeometryFactory.multi_point.as_hex_ewkb))
|
35
|
+
model.save.should == true
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should save MultiLineString objects' do
|
39
|
+
model = MultiLineStringModel.new(:extra => 'test', :geom => GeometryFactory.multi_line_string)
|
40
|
+
@connection.should_receive(:select_value).with(Regexp.new(GeometryFactory.multi_line_string.as_hex_ewkb))
|
41
|
+
model.save.should == true
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should save MultiPolygon objects' do
|
45
|
+
model = MultiPolygonModel.new(:extra => 'test', :geom => GeometryFactory.multi_polygon)
|
46
|
+
@connection.should_receive(:select_value).with(Regexp.new(GeometryFactory.multi_polygon.as_hex_ewkb))
|
47
|
+
model.save.should == true
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should save GeometryCollection objects' do
|
51
|
+
model = GeometryCollectionModel.new(:extra => 'test', :geom => GeometryFactory.geometry_collection)
|
52
|
+
@connection.should_receive(:select_value).with(Regexp.new(GeometryFactory.geometry_collection.as_hex_ewkb))
|
53
|
+
model.save.should == true
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should save Geometry objects' do
|
57
|
+
model = GeometryModel.new(:extra => 'test', :geom => GeometryFactory.point)
|
58
|
+
@connection.should_receive(:select_value).with(Regexp.new(GeometryFactory.point.as_hex_ewkb))
|
59
|
+
model.save.should == true
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should save 3D Point (with Z coord) objects' do
|
63
|
+
model = PointzModel.new(:extra => 'test', :geom => GeometryFactory.pointz)
|
64
|
+
@connection.should_receive(:select_value).with(Regexp.new(GeometryFactory.pointz.as_hex_ewkb))
|
65
|
+
model.save.should == true
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'should save 3D Point (with M coord) objects' do
|
69
|
+
model = PointmModel.new(:extra => 'test', :geom => GeometryFactory.pointm)
|
70
|
+
@connection.should_receive(:select_value).with(Regexp.new(GeometryFactory.pointm.as_hex_ewkb))
|
71
|
+
model.save.should == true
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'should save 4D Point objects' do
|
75
|
+
model = Point4Model.new(:extra => 'test', :geom => GeometryFactory.point4)
|
76
|
+
@connection.should_receive(:select_value).with(Regexp.new(GeometryFactory.point4.as_hex_ewkb))
|
77
|
+
model.save.should == true
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'should save Point geography objects' do
|
81
|
+
model = GeographyPointModel.new(:extra => 'test', :geom => GeometryFactory.point)
|
82
|
+
@connection.should_receive(:select_value).with(Regexp.new(GeometryFactory.point.as_hex_ewkb))
|
83
|
+
model.save.should == true
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'should save LineString geography objects' do
|
87
|
+
model = GeographyLineStringModel.new(:extra => 'test', :geom => GeometryFactory.line_string)
|
88
|
+
@connection.should_receive(:select_value).with(Regexp.new(GeometryFactory.line_string.as_hex_ewkb))
|
89
|
+
model.save.should == true
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'should save Polygon geography objects' do
|
93
|
+
model = GeographyPolygonModel.new(:extra => 'test', :geom => GeometryFactory.polygon)
|
94
|
+
@connection.should_receive(:select_value).with(Regexp.new(GeometryFactory.polygon.as_hex_ewkb))
|
95
|
+
model.save.should == true
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'should save MultiPoint geography objects' do
|
99
|
+
model = GeographyMultiPointModel.new(:extra => 'test', :geom => GeometryFactory.multi_point)
|
100
|
+
@connection.should_receive(:select_value).with(Regexp.new(GeometryFactory.multi_point.as_hex_ewkb))
|
101
|
+
model.save.should == true
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'should save MultiLineString geography objects' do
|
105
|
+
model = GeographyMultiLineStringModel.new(:extra => 'test', :geom => GeometryFactory.multi_line_string)
|
106
|
+
@connection.should_receive(:select_value).with(Regexp.new(GeometryFactory.multi_line_string.as_hex_ewkb))
|
107
|
+
model.save.should == true
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'should save MultiPolygon geography objects' do
|
111
|
+
model = GeographyMultiPolygonModel.new(:extra => 'test', :geom => GeometryFactory.multi_polygon)
|
112
|
+
@connection.should_receive(:select_value).with(Regexp.new(GeometryFactory.multi_polygon.as_hex_ewkb))
|
113
|
+
model.save.should == true
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'should save GeometryCollection geography objects' do
|
117
|
+
model = GeographyGeometryCollectionModel.new(:extra => 'test', :geom => GeometryFactory.geometry_collection)
|
118
|
+
@connection.should_receive(:select_value).with(Regexp.new(GeometryFactory.geometry_collection.as_hex_ewkb))
|
119
|
+
model.save.should == true
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'should save Geography objects' do
|
123
|
+
model = GeographyModel.new(:extra => 'test', :geom => GeometryFactory.point)
|
124
|
+
@connection.should_receive(:select_value).with(Regexp.new(GeometryFactory.point.as_hex_ewkb))
|
125
|
+
model.save.should == true
|
126
|
+
end
|
127
|
+
|
128
|
+
it 'should save 3D Point (with Z coord) geography objects' do
|
129
|
+
model = GeographyPointzModel.new(:extra => 'test', :geom => GeometryFactory.pointz)
|
130
|
+
@connection.should_receive(:select_value).with(Regexp.new(GeometryFactory.pointz.as_hex_ewkb))
|
131
|
+
model.save.should == true
|
132
|
+
end
|
133
|
+
|
134
|
+
it 'should save 3D Point (with M coord) geography objects' do
|
135
|
+
model = GeographyPointmModel.new(:extra => 'test', :geom => GeometryFactory.pointm)
|
136
|
+
@connection.should_receive(:select_value).with(Regexp.new(GeometryFactory.pointm.as_hex_ewkb))
|
137
|
+
model.save.should == true
|
138
|
+
end
|
139
|
+
|
140
|
+
it 'should save 4D Point geography objects' do
|
141
|
+
model = GeographyPoint4Model.new(:extra => 'test', :geom => GeometryFactory.point4)
|
142
|
+
@connection.should_receive(:select_value).with(Regexp.new(GeometryFactory.point4.as_hex_ewkb))
|
143
|
+
model.save.should == true
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
include CommonModelActions
|
148
|
+
|
149
|
+
describe "finding records" do
|
150
|
+
it 'should retrieve 3D Point (with Z coord) objects' do
|
151
|
+
model = PointzModel.create(:extra => 'test', :geom => GeometryFactory.pointz)
|
152
|
+
PointzModel.find(model.id).geom.should == GeometryFactory.pointz
|
153
|
+
end
|
154
|
+
|
155
|
+
it 'should retrieve 3D Point (with M coord) objects' do
|
156
|
+
model = GeographyPointmModel.create(:extra => 'test', :geom => GeometryFactory.pointm)
|
157
|
+
GeographyPointmModel.find(model.id).geom.should == GeometryFactory.pointm
|
158
|
+
end
|
159
|
+
|
160
|
+
it 'should retrieve 4D Point objects' do
|
161
|
+
model = GeographyPoint4Model.create(:extra => 'test', :geom => GeometryFactory.point4)
|
162
|
+
GeographyPoint4Model.find(model.id).geom.should == GeometryFactory.point4
|
163
|
+
end
|
164
|
+
|
165
|
+
it 'should retrieve Point geography objects' do
|
166
|
+
model = GeographyPointModel.create(:extra => 'test', :geom => GeometryFactory.point)
|
167
|
+
GeographyPointModel.find(model.id).geom.should == GeometryFactory.point
|
168
|
+
end
|
169
|
+
|
170
|
+
it 'should retrieve LineString geography objects' do
|
171
|
+
model = GeographyLineStringModel.create(:extra => 'test', :geom => GeometryFactory.line_string)
|
172
|
+
GeographyLineStringModel.find(model.id).geom.should == GeometryFactory.line_string
|
173
|
+
end
|
174
|
+
|
175
|
+
it 'should retrieve Polygon geography objects' do
|
176
|
+
model = GeographyPolygonModel.create(:extra => 'test', :geom => GeometryFactory.polygon)
|
177
|
+
GeographyPolygonModel.find(model.id).geom.should == GeometryFactory.polygon
|
178
|
+
end
|
179
|
+
|
180
|
+
it 'should retrieve MultiPoint geography objects' do
|
181
|
+
model = GeographyMultiPointModel.create(:extra => 'test', :geom => GeometryFactory.multi_point)
|
182
|
+
GeographyMultiPointModel.find(model.id).geom.should == GeometryFactory.multi_point
|
183
|
+
end
|
184
|
+
|
185
|
+
it 'should retrieve MultiLineString geography objects' do
|
186
|
+
model = GeographyMultiLineStringModel.create(:extra => 'test', :geom => GeometryFactory.multi_line_string)
|
187
|
+
GeographyMultiLineStringModel.find(model.id).geom.should == GeometryFactory.multi_line_string
|
188
|
+
end
|
189
|
+
|
190
|
+
it 'should retrieve MultiPolygon geography objects' do
|
191
|
+
model = GeographyMultiPolygonModel.create(:extra => 'test', :geom => GeometryFactory.multi_polygon)
|
192
|
+
GeographyMultiPolygonModel.find(model.id).geom.should == GeometryFactory.multi_polygon
|
193
|
+
end
|
194
|
+
|
195
|
+
it 'should retrieve GeometryCollection geography objects' do
|
196
|
+
model = GeographyGeometryCollectionModel.create(:extra => 'test', :geom => GeometryFactory.geometry_collection)
|
197
|
+
GeographyGeometryCollectionModel.find(model.id).geom.should == GeometryFactory.geometry_collection
|
198
|
+
end
|
199
|
+
|
200
|
+
it 'should retrieve Geometry geography objects' do
|
201
|
+
model = GeographyModel.create(:extra => 'test', :geom => GeometryFactory.point)
|
202
|
+
GeographyModel.find(model.id).geom.should == GeometryFactory.point
|
203
|
+
end
|
204
|
+
|
205
|
+
it 'should retrieve 3D Point (with Z coord) geography objects' do
|
206
|
+
model = GeographyPointzModel.create(:extra => 'test', :geom => GeometryFactory.pointz)
|
207
|
+
GeographyPointzModel.find(model.id).geom.should == GeometryFactory.pointz
|
208
|
+
end
|
209
|
+
|
210
|
+
it 'should retrieve 3D Point (with M coord) geography objects' do
|
211
|
+
model = GeographyPointmModel.create(:extra => 'test', :geom => GeometryFactory.pointm)
|
212
|
+
GeographyPointmModel.find(model.id).geom.should == GeometryFactory.pointm
|
213
|
+
end
|
214
|
+
|
215
|
+
it 'should retrieve 4D Point geography objects' do
|
216
|
+
model = GeographyPoint4Model.create(:extra => 'test', :geom => GeometryFactory.point4)
|
217
|
+
GeographyPoint4Model.find(model.id).geom.should == GeometryFactory.point4
|
218
|
+
end
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'spatial_adapter/postgresql'
|
3
|
+
|
4
|
+
describe "Spatially-enabled Schema Dumps" do
|
5
|
+
before :all do
|
6
|
+
postgis_connection
|
7
|
+
@connection = ActiveRecord::Base.connection
|
8
|
+
|
9
|
+
# Create a new table
|
10
|
+
ActiveRecord::Schema.define do
|
11
|
+
create_table :migrated_geometry_models, :force => true do |t|
|
12
|
+
t.integer :extra
|
13
|
+
t.point :geom, :with_m => true, :with_z => true, :srid => 4326
|
14
|
+
end
|
15
|
+
add_index :migrated_geometry_models, :geom, :spatial => true, :name => 'test_spatial_index'
|
16
|
+
|
17
|
+
create_table :migrated_geography_models, :force => true do |t|
|
18
|
+
t.integer :extra
|
19
|
+
t.point :geom, :with_m => true, :with_z => true, :geographic => true
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
File.open('schema.rb', "w") do |file|
|
24
|
+
ActiveRecord::SchemaDumper.dump(@connection, file)
|
25
|
+
end
|
26
|
+
|
27
|
+
# Drop the original tables
|
28
|
+
@connection.drop_table "migrated_geometry_models"
|
29
|
+
@connection.drop_table "migrated_geography_models"
|
30
|
+
|
31
|
+
# Load the dumped schema
|
32
|
+
load('schema.rb')
|
33
|
+
end
|
34
|
+
|
35
|
+
after :all do
|
36
|
+
# delete the schema file
|
37
|
+
File.delete('schema.rb')
|
38
|
+
|
39
|
+
# Drop the new tables
|
40
|
+
@connection.drop_table "migrated_geometry_models"
|
41
|
+
@connection.drop_table "migrated_geography_models"
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should preserve spatial attributes of geometry tables" do
|
45
|
+
columns = @connection.columns("migrated_geometry_models")
|
46
|
+
|
47
|
+
columns.should have(3).items
|
48
|
+
geom_column = columns.select{|c| c.name == 'geom'}.first
|
49
|
+
geom_column.should be_a(SpatialAdapter::SpatialColumn)
|
50
|
+
geom_column.geometry_type.should == :point
|
51
|
+
geom_column.type.should == :string
|
52
|
+
geom_column.with_z.should == true
|
53
|
+
geom_column.with_m.should == true
|
54
|
+
geom_column.srid.should == 4326
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should preserve spatial attributes of geography tables" do
|
58
|
+
columns = @connection.columns("migrated_geography_models")
|
59
|
+
|
60
|
+
columns.should have(3).items
|
61
|
+
geom_column = columns.select{|c| c.name == 'geom'}.first
|
62
|
+
geom_column.should be_a(SpatialAdapter::SpatialColumn)
|
63
|
+
geom_column.geometry_type.should == :point
|
64
|
+
geom_column.type.should == :string
|
65
|
+
geom_column.with_z.should == true
|
66
|
+
geom_column.with_m.should == true
|
67
|
+
geom_column.should be_geographic
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should preserve spatial indexes" do
|
71
|
+
indexes = @connection.indexes("migrated_geometry_models")
|
72
|
+
|
73
|
+
indexes.should have(1).item
|
74
|
+
|
75
|
+
indexes.first.name.should == 'test_spatial_index'
|
76
|
+
indexes.first.columns.should == ["geom"]
|
77
|
+
indexes.first.spatial.should == true
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
share_as :CommonModelActions do
|
2
|
+
describe 'finding records' do
|
3
|
+
it 'should retrieve Point objects' do
|
4
|
+
model = PointModel.create(:extra => 'test', :geom => GeometryFactory.point)
|
5
|
+
PointModel.find(model.id).geom.should == GeometryFactory.point
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'should retrieve LineString objects' do
|
9
|
+
model = LineStringModel.create(:extra => 'test', :geom => GeometryFactory.line_string)
|
10
|
+
LineStringModel.find(model.id).geom.should == GeometryFactory.line_string
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should retrieve Polygon objects' do
|
14
|
+
model = PolygonModel.create(:extra => 'test', :geom => GeometryFactory.polygon)
|
15
|
+
PolygonModel.find(model.id).geom.should == GeometryFactory.polygon
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should retrieve MultiPoint objects' do
|
19
|
+
model = MultiPointModel.create(:extra => 'test', :geom => GeometryFactory.multi_point)
|
20
|
+
MultiPointModel.find(model.id).geom.should == GeometryFactory.multi_point
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should retrieve MultiLineString objects' do
|
24
|
+
model = MultiLineStringModel.create(:extra => 'test', :geom => GeometryFactory.multi_line_string)
|
25
|
+
MultiLineStringModel.find(model.id).geom.should == GeometryFactory.multi_line_string
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should retrieve MultiPolygon objects' do
|
29
|
+
model = MultiPolygonModel.create(:extra => 'test', :geom => GeometryFactory.multi_polygon)
|
30
|
+
MultiPolygonModel.find(model.id).geom.should == GeometryFactory.multi_polygon
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should retrieve GeometryCollection objects' do
|
34
|
+
model = GeometryCollectionModel.create(:extra => 'test', :geom => GeometryFactory.geometry_collection)
|
35
|
+
GeometryCollectionModel.find(model.id).geom.should == GeometryFactory.geometry_collection
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should retrieve Geometry objects' do
|
39
|
+
model = GeometryModel.create(:extra => 'test', :geom => GeometryFactory.point)
|
40
|
+
GeometryModel.find(model.id).geom.should == GeometryFactory.point
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'spec'
|
3
|
+
require 'geo_ruby'
|
4
|
+
gem 'activerecord', '=3.0.3'
|
5
|
+
require 'active_record'
|
6
|
+
|
7
|
+
$:.unshift((File.join(File.dirname(__FILE__), '..', 'lib')))
|
8
|
+
|
9
|
+
include GeoRuby::SimpleFeatures
|
10
|
+
|
11
|
+
|
12
|
+
def postgis_connection
|
13
|
+
ActiveRecord::Base.establish_connection(
|
14
|
+
:adapter => 'postgresql',
|
15
|
+
:database => 'spatial_adapter'
|
16
|
+
)
|
17
|
+
# Turn off those annoying NOTICE messages
|
18
|
+
ActiveRecord::Base.connection.execute 'set client_min_messages = warning'
|
19
|
+
|
20
|
+
# Don't output migration logging
|
21
|
+
ActiveRecord::Migration.verbose = false
|
22
|
+
end
|
23
|
+
|
24
|
+
def mysql_connection
|
25
|
+
ActiveRecord::Base.establish_connection(
|
26
|
+
:adapter => 'mysql',
|
27
|
+
:database => 'spatial_adapter',
|
28
|
+
:username => 'root',
|
29
|
+
:host => 'localhost'
|
30
|
+
)
|
31
|
+
|
32
|
+
# Don't output migration logging
|
33
|
+
ActiveRecord::Migration.verbose = false
|
34
|
+
end
|
35
|
+
|
36
|
+
def mysql2_connection
|
37
|
+
ActiveRecord::Base.establish_connection(
|
38
|
+
:adapter => 'mysql2',
|
39
|
+
:database => 'spatial_adapter',
|
40
|
+
:username => 'root',
|
41
|
+
:host => 'localhost'
|
42
|
+
)
|
43
|
+
|
44
|
+
# Don't output migration logging
|
45
|
+
ActiveRecord::Migration.verbose = false
|
46
|
+
end
|
47
|
+
|
48
|
+
class GeometryFactory
|
49
|
+
class << self
|
50
|
+
def point
|
51
|
+
Point.from_x_y(1, 2, 4326)
|
52
|
+
end
|
53
|
+
|
54
|
+
def line_string
|
55
|
+
LineString.from_coordinates([[1.4,2.5],[1.5,6.7]], 4326)
|
56
|
+
end
|
57
|
+
|
58
|
+
def polygon
|
59
|
+
Polygon.from_coordinates([[[12.4,-45.3],[45.4,41.6],[4.456,1.0698],[12.4,-45.3]],[[2.4,5.3],[5.4,1.4263],[14.46,1.06],[2.4,5.3]]], 4326)
|
60
|
+
end
|
61
|
+
|
62
|
+
def multi_point
|
63
|
+
MultiPoint.from_coordinates([[12.4,-23.3],[-65.1,23.4],[23.55555555,23]], 4326)
|
64
|
+
end
|
65
|
+
|
66
|
+
def multi_line_string
|
67
|
+
MultiLineString.from_line_strings([LineString.from_coordinates([[1.5,45.2],[-54.12312,-0.012]]),LineString.from_coordinates([[1.5,45.2],[-54.12312,-0.012],[45.123,23.3]])], 4326)
|
68
|
+
end
|
69
|
+
|
70
|
+
def multi_polygon
|
71
|
+
MultiPolygon.from_polygons([Polygon.from_coordinates([[[12.4,-45.3],[45.4,41.6],[4.456,1.0698],[12.4,-45.3]],[[2.4,5.3],[5.4,1.4263],[14.46,1.06],[2.4,5.3]]]),Polygon.from_coordinates([[[0,0],[4,0],[4,4],[0,4],[0,0]],[[1,1],[3,1],[3,3],[1,3],[1,1]]])], 4326)
|
72
|
+
end
|
73
|
+
|
74
|
+
def geometry_collection
|
75
|
+
GeometryCollection.from_geometries([Point.from_x_y(4.67,45.4),LineString.from_coordinates([[5.7,12.45],[67.55,54]])], 4326)
|
76
|
+
end
|
77
|
+
|
78
|
+
def pointz
|
79
|
+
Point.from_x_y_z(1, 2, 3, 4326)
|
80
|
+
end
|
81
|
+
|
82
|
+
def pointm
|
83
|
+
Point.from_x_y_m(1, 2, 3, 4326)
|
84
|
+
end
|
85
|
+
|
86
|
+
def point4
|
87
|
+
Point.from_x_y_z_m(1, 2, 3, 4, 4326)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
metadata
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rs_spatial_adapter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.2.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Pete Deffendol
|
9
|
+
- Guilhem Vellut
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2011-01-08 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: activerecord
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 2.2.2
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ! '>='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: 2.2.2
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
name: GeoRuby
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: 1.3.0
|
39
|
+
type: :runtime
|
40
|
+
prerelease: false
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 1.3.0
|
47
|
+
description: Provides enhancements to ActiveRecord to handle spatial datatypes in
|
48
|
+
PostgreSQL and MySQL.
|
49
|
+
email: pete@fragility.us
|
50
|
+
executables: []
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files:
|
53
|
+
- README.rdoc
|
54
|
+
files:
|
55
|
+
- MIT-LICENSE
|
56
|
+
- README.rdoc
|
57
|
+
- VERSION
|
58
|
+
- lib/spatial_adapter.rb
|
59
|
+
- lib/spatial_adapter/common/raw_geom_info.rb
|
60
|
+
- lib/spatial_adapter/common/schema_definitions.rb
|
61
|
+
- lib/spatial_adapter/common/schema_dumper.rb
|
62
|
+
- lib/spatial_adapter/common/spatial_column.rb
|
63
|
+
- lib/spatial_adapter/common/table_definition.rb
|
64
|
+
- lib/spatial_adapter/mysql.rb
|
65
|
+
- lib/spatial_adapter/mysql2.rb
|
66
|
+
- lib/spatial_adapter/postgresql.rb
|
67
|
+
- lib/spatial_adapter/railtie.rb
|
68
|
+
- rails/init.rb
|
69
|
+
- spec/README.txt
|
70
|
+
- spec/db/mysql2_raw.rb
|
71
|
+
- spec/db/mysql_raw.rb
|
72
|
+
- spec/db/postgis_raw.rb
|
73
|
+
- spec/models/common.rb
|
74
|
+
- spec/mysql/connection_adapter_spec.rb
|
75
|
+
- spec/mysql/migration_spec.rb
|
76
|
+
- spec/mysql/models_spec.rb
|
77
|
+
- spec/mysql/schema_dumper_spec.rb
|
78
|
+
- spec/mysql2/connection_adapter_spec.rb
|
79
|
+
- spec/mysql2/migration_spec.rb
|
80
|
+
- spec/mysql2/models_spec.rb
|
81
|
+
- spec/mysql2/schema_dumper_spec.rb
|
82
|
+
- spec/postgresql/connection_adapter_spec.rb
|
83
|
+
- spec/postgresql/migration_spec.rb
|
84
|
+
- spec/postgresql/models_spec.rb
|
85
|
+
- spec/postgresql/schema_dumper_spec.rb
|
86
|
+
- spec/shared_examples.rb
|
87
|
+
- spec/spec_helper.rb
|
88
|
+
homepage: http://github.com/fragility/spatial_adapter
|
89
|
+
licenses: []
|
90
|
+
post_install_message:
|
91
|
+
rdoc_options: []
|
92
|
+
require_paths:
|
93
|
+
- lib
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
+
none: false
|
96
|
+
requirements:
|
97
|
+
- - ! '>='
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
none: false
|
102
|
+
requirements:
|
103
|
+
- - ! '>='
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
requirements: []
|
107
|
+
rubyforge_project:
|
108
|
+
rubygems_version: 1.8.25
|
109
|
+
signing_key:
|
110
|
+
specification_version: 3
|
111
|
+
summary: Spatial Adapter for ActiveRecord
|
112
|
+
test_files:
|
113
|
+
- spec/README.txt
|
114
|
+
- spec/db/mysql2_raw.rb
|
115
|
+
- spec/db/mysql_raw.rb
|
116
|
+
- spec/db/postgis_raw.rb
|
117
|
+
- spec/models/common.rb
|
118
|
+
- spec/mysql/connection_adapter_spec.rb
|
119
|
+
- spec/mysql/migration_spec.rb
|
120
|
+
- spec/mysql/models_spec.rb
|
121
|
+
- spec/mysql/schema_dumper_spec.rb
|
122
|
+
- spec/mysql2/connection_adapter_spec.rb
|
123
|
+
- spec/mysql2/migration_spec.rb
|
124
|
+
- spec/mysql2/models_spec.rb
|
125
|
+
- spec/mysql2/schema_dumper_spec.rb
|
126
|
+
- spec/postgresql/connection_adapter_spec.rb
|
127
|
+
- spec/postgresql/migration_spec.rb
|
128
|
+
- spec/postgresql/models_spec.rb
|
129
|
+
- spec/postgresql/schema_dumper_spec.rb
|
130
|
+
- spec/shared_examples.rb
|
131
|
+
- spec/spec_helper.rb
|