activerecord-postgis-adapter 3.0.0.beta2 → 3.0.0.beta3
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.
- checksums.yaml +4 -4
- data/lib/active_record/connection_adapters/postgis_adapter.rb +0 -3
- data/lib/active_record/connection_adapters/postgis_adapter/oid/spatial.rb +6 -2
- data/lib/active_record/connection_adapters/postgis_adapter/schema_statements.rb +1 -0
- data/lib/active_record/connection_adapters/postgis_adapter/spatial_column.rb +2 -2
- data/lib/active_record/connection_adapters/postgis_adapter/version.rb +1 -1
- data/test/ddl_test.rb +11 -1
- data/test/tasks_test.rb +2 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0d04c38823d342013ab3f6499e63555c327ae7d
|
4
|
+
data.tar.gz: 431f6916e008760398744c063d50732dc6474eea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f54ee77aca056fd2ab87c0af53782feb597e157a70862e23e509e4df17feca439b07de46d384e77a04e067089e78b230d186d9064a76cfe0268f2e3d640593fb
|
7
|
+
data.tar.gz: 065f3afcfbd9fc945125f4dcf7270cfa5a82e4cde7a9d9174ed05cb545a14f0a391c6b63ba614791ac50a082420f1efca0bc2d6c8c7060b91386f19f78663ad6
|
@@ -12,10 +12,7 @@ end
|
|
12
12
|
|
13
13
|
# :stopdoc:
|
14
14
|
|
15
|
-
require 'active_record'
|
16
15
|
require 'active_record/connection_adapters/postgresql_adapter'
|
17
|
-
require 'rgeo/active_record'
|
18
|
-
|
19
16
|
require 'active_record/connection_adapters/postgis_adapter/version'
|
20
17
|
require 'active_record/connection_adapters/postgis_adapter/schema_statements'
|
21
18
|
require 'active_record/connection_adapters/postgis_adapter/main_adapter'
|
@@ -11,7 +11,12 @@ module ActiveRecord
|
|
11
11
|
# "geometry(Geography,4326)"
|
12
12
|
def initialize(oid, sql_type)
|
13
13
|
@geo_type, @srid, @has_z, @has_m = self.class.parse_sql_type(sql_type)
|
14
|
-
|
14
|
+
if oid =~ /geography/
|
15
|
+
factory_opts = {srid: (@srid || 4326)}
|
16
|
+
factory_opts[:has_z_coordinate] = @has_z
|
17
|
+
factory_opts[:has_m_coordinate] = @has_m
|
18
|
+
@factory_generator = RGeo::Geographic.spherical_factory(factory_opts)
|
19
|
+
end
|
15
20
|
end
|
16
21
|
|
17
22
|
# sql_type: geometry, geometry(Point), geometry(Point,4326), ...
|
@@ -87,7 +92,6 @@ module ActiveRecord
|
|
87
92
|
return if value.nil?
|
88
93
|
RGeo::WKRep::WKBParser.new(@factory_generator, support_ewkb: true).parse(value)
|
89
94
|
rescue RGeo::Error::ParseError
|
90
|
-
puts "\ncast failed!!\n\n"
|
91
95
|
nil
|
92
96
|
end
|
93
97
|
|
@@ -9,7 +9,7 @@ module ActiveRecord # :nodoc:
|
|
9
9
|
# cast_type example classes:
|
10
10
|
# OID::Spatial
|
11
11
|
# OID::Integer
|
12
|
-
def initialize(factory_settings, table_name, name, default, cast_type, sql_type = nil, null = true, opts = nil)
|
12
|
+
def initialize(factory_settings, table_name, name, default, cast_type, sql_type = nil, null = true, default_function = nil, opts = nil)
|
13
13
|
@factory_settings = factory_settings
|
14
14
|
@table_name = table_name
|
15
15
|
@geographic = !!(sql_type =~ /geography\(/i)
|
@@ -29,7 +29,7 @@ module ActiveRecord # :nodoc:
|
|
29
29
|
# @geometric_type = geo_type_from_sql_type(sql_type)
|
30
30
|
build_from_sql_type(sql_type)
|
31
31
|
end
|
32
|
-
super(name, default, cast_type, sql_type, null)
|
32
|
+
super(name, default, cast_type, sql_type, null, default_function)
|
33
33
|
if spatial?
|
34
34
|
if @srid
|
35
35
|
@limit = { srid: @srid, type: geometric_type.type_name.underscore }
|
data/test/ddl_test.rb
CHANGED
@@ -197,7 +197,17 @@ class DDLTest < ActiveSupport::TestCase # :nodoc:
|
|
197
197
|
assert_equal RGeo::Feature::Point, klass.columns.last.geometric_type
|
198
198
|
end
|
199
199
|
|
200
|
-
def
|
200
|
+
def test_create_geometry_using_shortcut_with_srid
|
201
|
+
klass.connection.create_table(:spatial_models, force: true) do |t|
|
202
|
+
t.geometry 'latlon', srid: 4326
|
203
|
+
end
|
204
|
+
klass.reset_column_information
|
205
|
+
col = klass.columns.last
|
206
|
+
assert_equal RGeo::Feature::Geometry, col.geometric_type
|
207
|
+
assert_equal({ srid: 4326, type: 'geometry' }, col.limit)
|
208
|
+
end
|
209
|
+
|
210
|
+
def test_create_polygon_with_options
|
201
211
|
klass.connection.create_table(:spatial_models, force: true) do |t|
|
202
212
|
t.column 'region', :st_polygon, has_m: true, srid: 3785
|
203
213
|
end
|
data/test/tasks_test.rb
CHANGED
@@ -35,10 +35,12 @@ class TasksTest < ActiveSupport::TestCase # :nodoc:
|
|
35
35
|
setup_database_tasks
|
36
36
|
connection.create_table(:spatial_test, force: true) do |t|
|
37
37
|
t.st_point "latlon", geographic: true
|
38
|
+
t.geometry "geo_col", srid: 4326
|
38
39
|
end
|
39
40
|
ActiveRecord::Tasks::DatabaseTasks.structure_dump(NEW_CONNECTION, tmp_sql_filename)
|
40
41
|
data = File.read(tmp_sql_filename)
|
41
42
|
assert(data.index('latlon geography(Point,4326)'))
|
43
|
+
assert(data.index('geo_col geometry(Geometry,4326)'))
|
42
44
|
end
|
43
45
|
|
44
46
|
def test_index_sql_dump
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-postgis-adapter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.0.
|
4
|
+
version: 3.0.0.beta3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Azuma, Tee Parham
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -149,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
149
|
version: 1.3.1
|
150
150
|
requirements: []
|
151
151
|
rubyforge_project:
|
152
|
-
rubygems_version: 2.4.
|
152
|
+
rubygems_version: 2.4.6
|
153
153
|
signing_key:
|
154
154
|
specification_version: 4
|
155
155
|
summary: ActiveRecord adapter for PostGIS, based on RGeo.
|