activerecord-postgis-adapter 1.1.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (20) hide show
  1. checksums.yaml +4 -4
  2. data/lib/active_record/connection_adapters/postgis_adapter.rb +10 -13
  3. data/lib/active_record/connection_adapters/postgis_adapter/{shared/arel_tosql.rb → arel_tosql.rb} +0 -0
  4. data/lib/active_record/connection_adapters/postgis_adapter/{shared/common_adapter_methods.rb → common_adapter_methods.rb} +6 -1
  5. data/lib/active_record/connection_adapters/postgis_adapter/{rails4/create_connection.rb → create_connection.rb} +0 -0
  6. data/lib/active_record/connection_adapters/postgis_adapter/{rails4/databases.rake → databases.rake} +0 -0
  7. data/lib/active_record/connection_adapters/postgis_adapter/{rails4/main_adapter.rb → main_adapter.rb} +0 -0
  8. data/lib/active_record/connection_adapters/postgis_adapter/{rails4/postgis_database_tasks.rb → postgis_database_tasks.rb} +1 -45
  9. data/lib/active_record/connection_adapters/postgis_adapter/railtie.rb +12 -1
  10. data/lib/active_record/connection_adapters/postgis_adapter/{shared/setup.rb → setup.rb} +0 -0
  11. data/lib/active_record/connection_adapters/postgis_adapter/{rails4/spatial_column.rb → spatial_column.rb} +0 -0
  12. data/lib/active_record/connection_adapters/postgis_adapter/{rails4/spatial_table_definition.rb → spatial_table_definition.rb} +0 -0
  13. data/lib/active_record/connection_adapters/postgis_adapter/version.rb +1 -1
  14. data/test/{test_tasks.rb → tasks_test.rb} +12 -14
  15. data/test/test_helper.rb +6 -0
  16. metadata +18 -39
  17. data/Documentation.rdoc +0 -320
  18. data/History.rdoc +0 -163
  19. data/README.rdoc +0 -101
  20. data/lib/active_record/connection_adapters/postgis_adapter/shared/railtie.rb +0 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ce9c5498b97818ea15208bc26dcba1ae43815443
4
- data.tar.gz: 278397fdce7c4d48c6c4b1dbf730249ef39c3fb2
3
+ metadata.gz: 5d2bd161f205308afbc558cdd1b78a3895fa6d57
4
+ data.tar.gz: 9d8012bd9863180566481fa062582d15a0b093a4
5
5
  SHA512:
6
- metadata.gz: 5a9b10d39cc0eb914432b66b8d65eab3888e0bdd3a5dc1b1860ceccd45083da9310201d53e2a67d6ff541ee9bc0ab263df6732676c593937bc239bd701a185a4
7
- data.tar.gz: d8c6c6404887acadc2040b4344cbe5a116d8572b87ce36ffd4e08024a2b707afc8d68df55cf8061f30a244787d596ddb237275a8dddb7ca374a43650f7454139
6
+ metadata.gz: 2f791f644fedb57ec26b2c2adc6cdcca315246f6ad51b2e2f6e056eb612d3b2f88305e0ba99836b70dc59d8b76db3febfe64941226dc37d7a9eedde5a9437ae2
7
+ data.tar.gz: 061590b4d9fbe64b2cb03c8dab47263ed91c4d980683fd366a055675a106c715d10691c846008afeab03aaffb2d64286357510e4f2af909e050bb09b981ad6fc
@@ -2,12 +2,9 @@
2
2
  # connection adapter into ActiveRecord.
3
3
 
4
4
  module ActiveRecord
5
- # All ActiveRecord adapters go in this namespace.
6
- # This adapter is installed into the PostGISAdapter submodule.
7
5
  module ConnectionAdapters
8
- # The PostGIS Adapter lives in this namespace.
9
6
  module PostGISAdapter
10
- # The name returned by the adapter_name method of this adapter.
7
+ # The name returned by #adapter_name
11
8
  ADAPTER_NAME = 'PostGIS'.freeze
12
9
  end
13
10
  end
@@ -20,19 +17,19 @@ require 'active_record/connection_adapters/postgresql_adapter'
20
17
  require 'rgeo/active_record'
21
18
 
22
19
  require 'active_record/connection_adapters/postgis_adapter/version.rb'
23
- require 'active_record/connection_adapters/postgis_adapter/shared/common_adapter_methods.rb'
24
- require 'active_record/connection_adapters/postgis_adapter/rails4/main_adapter.rb'
25
- require 'active_record/connection_adapters/postgis_adapter/rails4/spatial_table_definition.rb'
26
- require 'active_record/connection_adapters/postgis_adapter/rails4/spatial_column.rb'
27
- require 'active_record/connection_adapters/postgis_adapter/shared/arel_tosql.rb'
28
- require 'active_record/connection_adapters/postgis_adapter/shared/setup.rb'
29
- require 'active_record/connection_adapters/postgis_adapter/rails4/create_connection'
30
- require 'active_record/connection_adapters/postgis_adapter/rails4/postgis_database_tasks.rb'
20
+ require 'active_record/connection_adapters/postgis_adapter/common_adapter_methods.rb'
21
+ require 'active_record/connection_adapters/postgis_adapter/main_adapter.rb'
22
+ require 'active_record/connection_adapters/postgis_adapter/spatial_table_definition.rb'
23
+ require 'active_record/connection_adapters/postgis_adapter/spatial_column.rb'
24
+ require 'active_record/connection_adapters/postgis_adapter/arel_tosql.rb'
25
+ require 'active_record/connection_adapters/postgis_adapter/setup.rb'
26
+ require 'active_record/connection_adapters/postgis_adapter/create_connection'
27
+ require 'active_record/connection_adapters/postgis_adapter/postgis_database_tasks.rb'
31
28
 
32
29
  ::ActiveRecord::ConnectionAdapters::PostGISAdapter.initial_setup
33
30
 
34
31
  if defined?(::Rails::Railtie)
35
- load ::File.expand_path('postgis_adapter/shared/railtie.rb', ::File.dirname(__FILE__))
32
+ load ::File.expand_path('postgis_adapter/railtie.rb', ::File.dirname(__FILE__))
36
33
  end
37
34
 
38
35
  # :startdoc:
@@ -30,7 +30,12 @@ module ActiveRecord # :nodoc:
30
30
  end
31
31
 
32
32
  def srs_database_columns
33
- {:srtext_column => 'srtext', :proj4text_column => 'proj4text', :auth_name_column => 'auth_name', :auth_srid_column => 'auth_srid'}
33
+ {
34
+ :auth_name_column => 'auth_name',
35
+ :auth_srid_column => 'auth_srid',
36
+ :proj4text_column => 'proj4text',
37
+ :srtext_column => 'srtext',
38
+ }
34
39
  end
35
40
 
36
41
  def quote(value, column=nil)
@@ -10,15 +10,11 @@ module ActiveRecord # :nodoc:
10
10
 
11
11
  def setup_gis
12
12
  establish_su_connection
13
- setup_gis_schemas
14
13
  if script_dir
15
14
  setup_gis_from_script_dir
16
15
  elsif extension_names
17
16
  setup_gis_from_extension
18
17
  end
19
- if has_su? && (script_dir || extension_names)
20
- setup_gis_grant_privileges
21
- end
22
18
  establish_connection(configuration)
23
19
  end
24
20
 
@@ -37,18 +33,6 @@ module ActiveRecord # :nodoc:
37
33
  end
38
34
  end
39
35
 
40
- # Overridden to remove postgis schema
41
- def structure_dump(filename)
42
- set_psql_env
43
- _search_path = search_path.dup
44
- _search_path.delete('postgis')
45
- _search_path = ['public'] if _search_path.length == 0
46
- search_path_clause_ = _search_path.map{ |part_| "--schema=#{::Shellwords.escape(part_)}" }.join(' ')
47
- command = "pg_dump -i -s -x -O -f #{::Shellwords.escape(filename)} #{search_path_clause_} #{::Shellwords.escape(configuration['database'])}"
48
- raise 'Error dumping database' unless ::Kernel.system(command)
49
- ::File.open(filename, "a") { |f_| f_ << "SET search_path TO #{ActiveRecord::Base.connection.schema_search_path};\n\n" }
50
- end
51
-
52
36
  private
53
37
 
54
38
  # Overridden to use su_username and su_password
@@ -96,10 +80,6 @@ module ActiveRecord # :nodoc:
96
80
  @search_path ||= configuration['schema_search_path'].to_s.strip.split(',').map(&:strip)
97
81
  end
98
82
 
99
- def postgis_schema
100
- @postgis_schema ||= search_path.include?('postgis') ? 'postgis' : (search_path.last || 'public')
101
- end
102
-
103
83
  def script_dir
104
84
  @script_dir = configuration['script_dir'] unless defined?(@script_dir)
105
85
  @script_dir
@@ -132,45 +112,21 @@ module ActiveRecord # :nodoc:
132
112
  end
133
113
  end
134
114
 
135
- def setup_gis_schemas
136
- auth_ = has_su? ? " AUTHORIZATION #{quoted_username}" : ''
137
- search_path.each do |schema_|
138
- if schema_.downcase != 'public' && !connection.execute("SELECT 1 FROM pg_catalog.pg_namespace WHERE nspname='#{schema_}'").try(:first)
139
- connection.execute("CREATE SCHEMA #{schema_}#{auth_}")
140
- end
141
- end
142
- end
143
-
144
115
  def setup_gis_from_extension
145
116
  extension_names.each do |extname|
146
117
  if extname == 'postgis_topology'
147
118
  raise ::ArgumentError, "'topology' must be in schema_search_path for postgis_topology" unless search_path.include?('topology')
148
119
  connection.execute("CREATE EXTENSION IF NOT EXISTS #{extname} SCHEMA topology")
149
120
  else
150
- connection.execute("CREATE EXTENSION IF NOT EXISTS #{extname} SCHEMA #{postgis_schema}")
121
+ connection.execute("CREATE EXTENSION IF NOT EXISTS #{extname}")
151
122
  end
152
123
  end
153
124
  end
154
125
 
155
126
  def setup_gis_from_script_dir
156
- connection.execute("SET search_path TO #{postgis_schema}")
157
127
  connection.execute(::File.read(::File.expand_path('postgis.sql', script_dir)))
158
128
  connection.execute(::File.read(::File.expand_path('spatial_ref_sys.sql', script_dir)))
159
129
  end
160
-
161
- def setup_gis_grant_privileges
162
- connection.execute("GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA #{postgis_schema} TO #{quoted_username}")
163
- connection.execute("GRANT ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA #{postgis_schema} TO #{quoted_username}")
164
- postgis_version_ = connection.execute( "SELECT #{postgis_schema}.postgis_version();" ).first['postgis_version']
165
- if postgis_version_ =~ /^2/
166
- connection.execute("ALTER VIEW #{postgis_schema}.geometry_columns OWNER TO #{quoted_username}")
167
- connection.execute("ALTER VIEW #{postgis_schema}.geography_columns OWNER TO #{quoted_username}")
168
- else
169
- connection.execute("ALTER TABLE #{postgis_schema}.geometry_columns OWNER TO #{quoted_username}")
170
- end
171
- connection.execute("ALTER TABLE #{postgis_schema}.spatial_ref_sys OWNER TO #{quoted_username}")
172
- end
173
-
174
130
  end
175
131
 
176
132
  ::ActiveRecord::Tasks::DatabaseTasks.register_task(/postgis/, PostGISDatabaseTasks)
@@ -1,3 +1,14 @@
1
1
  require 'rails/railtie'
2
2
  require 'active_record/connection_adapters/postgis_adapter'
3
- load ::File.expand_path('shared/railtie.rb', ::File.dirname(__FILE__))
3
+
4
+ module ActiveRecord # :nodoc:
5
+ module ConnectionAdapters # :nodoc:
6
+ module PostGISAdapter # :nodoc:
7
+ class Railtie < ::Rails::Railtie # :nodoc:
8
+ rake_tasks do
9
+ load ::File.expand_path("databases.rake", ::File.dirname(__FILE__))
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,7 +1,7 @@
1
1
  module ActiveRecord
2
2
  module ConnectionAdapters
3
3
  module PostGISAdapter
4
- VERSION = '1.1.0'.freeze
4
+ VERSION = '2.0.0'.freeze
5
5
  end
6
6
  end
7
7
  end
@@ -1,10 +1,11 @@
1
1
  require 'test_helper'
2
+ require 'active_record/schema_dumper'
2
3
 
3
4
  module RGeo
4
5
  module ActiveRecord # :nodoc:
5
6
  module PostGISAdapter # :nodoc:
6
7
  module Tests # :nodoc:
7
- class TestTasks < BASE_TEST_CLASS # :nodoc:
8
+ class TasksTest < BASE_TEST_CLASS # :nodoc:
8
9
  DATABASE_CONFIG_PATH = ::File.dirname(__FILE__) + '/database.yml'
9
10
  OVERRIDE_DATABASE_CONFIG_PATH = ::File.dirname(__FILE__) + '/database_local.yml'
10
11
 
@@ -21,12 +22,12 @@ module RGeo
21
22
  def cleanup_tables
22
23
  ::ActiveRecord::Base.remove_connection
23
24
  ::ActiveRecord::Base.clear_active_connections!
24
- TestTasks::DEFAULT_AR_CLASS.connection.execute("DROP DATABASE IF EXISTS \"postgis_adapter_test2\"")
25
+ TasksTest::DEFAULT_AR_CLASS.connection.execute("DROP DATABASE IF EXISTS \"postgis_adapter_test2\"")
25
26
  end
26
27
 
27
28
  define_test_methods do
28
29
  def test_create_database_from_extension_in_public_schema
29
- ::ActiveRecord::Tasks::DatabaseTasks.create(TestTasks.new_database_config)
30
+ ::ActiveRecord::Tasks::DatabaseTasks.create(TasksTest.new_database_config)
30
31
  ::ActiveRecord::Base.connection.select_values("SELECT * from public.spatial_ref_sys")
31
32
  end
32
33
 
@@ -34,21 +35,21 @@ module RGeo
34
35
  filename = ::File.expand_path('../tmp/tmp.sql', ::File.dirname(__FILE__))
35
36
  ::FileUtils.rm_f(filename)
36
37
  ::FileUtils.mkdir_p(::File.dirname(filename))
37
- ::ActiveRecord::Tasks::DatabaseTasks.create(TestTasks.new_database_config.merge('schema_search_path' => 'public,postgis'))
38
- ::ActiveRecord::Tasks::DatabaseTasks.structure_dump(TestTasks.new_database_config, filename)
38
+ ::ActiveRecord::Tasks::DatabaseTasks.create(TasksTest.new_database_config.merge('schema_search_path' => 'public'))
39
+ ::ActiveRecord::Tasks::DatabaseTasks.structure_dump(TasksTest.new_database_config, filename)
39
40
  sql = ::File.read(filename)
40
- assert(sql !~ /CREATE/)
41
+ assert(sql !~ /CREATE TABLE/)
41
42
  end
42
43
 
43
44
  def test_basic_geography_sql_dump
44
45
  filename = ::File.expand_path('../tmp/tmp.sql', ::File.dirname(__FILE__))
45
46
  ::FileUtils.rm_f(filename)
46
47
  ::FileUtils.mkdir_p(::File.dirname(filename))
47
- ::ActiveRecord::Tasks::DatabaseTasks.create(TestTasks.new_database_config.merge('schema_search_path' => 'public,postgis'))
48
+ ::ActiveRecord::Tasks::DatabaseTasks.create(TasksTest.new_database_config.merge('schema_search_path' => 'public'))
48
49
  ::ActiveRecord::Base.connection.create_table(:spatial_test) do |t|
49
50
  t.point "latlon", :geographic => true
50
51
  end
51
- ::ActiveRecord::Tasks::DatabaseTasks.structure_dump(TestTasks.new_database_config, filename)
52
+ ::ActiveRecord::Tasks::DatabaseTasks.structure_dump(TasksTest.new_database_config, filename)
52
53
  data = ::File.read(filename)
53
54
  assert(data.index('latlon geography(Point,4326)'))
54
55
  end
@@ -57,8 +58,7 @@ module RGeo
57
58
  filename = ::File.expand_path('../tmp/tmp.rb', ::File.dirname(__FILE__))
58
59
  ::FileUtils.rm_f(filename)
59
60
  ::FileUtils.mkdir_p(::File.dirname(filename))
60
- ::ActiveRecord::Tasks::DatabaseTasks.create(TestTasks.new_database_config.merge('schema_search_path' => 'public,postgis'))
61
- require 'active_record/schema_dumper'
61
+ ::ActiveRecord::Tasks::DatabaseTasks.create(TasksTest.new_database_config.merge('schema_search_path' => 'public'))
62
62
  ::File.open(filename, "w:utf-8") do |file|
63
63
  ::ActiveRecord::SchemaDumper.dump(::ActiveRecord::Base.connection, file)
64
64
  end
@@ -70,13 +70,12 @@ module RGeo
70
70
  filename = ::File.expand_path('../tmp/tmp.rb', ::File.dirname(__FILE__))
71
71
  ::FileUtils.rm_f(filename)
72
72
  ::FileUtils.mkdir_p(::File.dirname(filename))
73
- ::ActiveRecord::Tasks::DatabaseTasks.create(TestTasks.new_database_config.merge('schema_search_path' => 'public,postgis'))
73
+ ::ActiveRecord::Tasks::DatabaseTasks.create(TasksTest.new_database_config.merge('schema_search_path' => 'public'))
74
74
  conn = ::ActiveRecord::Base.connection
75
75
  conn.create_table(:spatial_test) do |t|
76
76
  t.geometry 'object1'
77
77
  t.spatial "object2", :limit => {:srid=>conn.default_srid, :type=>"geometry"}
78
78
  end
79
- require 'active_record/schema_dumper'
80
79
  ::File.open(filename, "w:utf-8") do |file|
81
80
  ::ActiveRecord::SchemaDumper.dump(conn, file)
82
81
  end
@@ -89,13 +88,12 @@ module RGeo
89
88
  filename = ::File.expand_path('../tmp/tmp.rb', ::File.dirname(__FILE__))
90
89
  ::FileUtils.rm_f(filename)
91
90
  ::FileUtils.mkdir_p(::File.dirname(filename))
92
- ::ActiveRecord::Tasks::DatabaseTasks.create(TestTasks.new_database_config.merge('schema_search_path' => 'public,postgis'))
91
+ ::ActiveRecord::Tasks::DatabaseTasks.create(TasksTest.new_database_config.merge('schema_search_path' => 'public'))
93
92
  conn = ::ActiveRecord::Base.connection
94
93
  conn.create_table(:spatial_test) do |t|
95
94
  t.point "latlon1", :geographic => true
96
95
  t.spatial "latlon2", :limit => {:srid=>4326, :type=>"point", :geographic=>true}
97
96
  end
98
- require 'active_record/schema_dumper'
99
97
  ::File.open(filename, "w:utf-8") do |file|
100
98
  ::ActiveRecord::SchemaDumper.dump(conn, file)
101
99
  end
data/test/test_helper.rb CHANGED
@@ -1,6 +1,12 @@
1
1
  require 'minitest/autorun'
2
2
  require 'rgeo/active_record/adapter_test_helper'
3
3
 
4
+ begin
5
+ require 'byebug'
6
+ rescue LoadError
7
+ # ignore
8
+ end
9
+
4
10
  BASE_TEST_CLASS = if ActiveRecord::VERSION::STRING > '4.1'
5
11
  Minitest::Test
6
12
  else
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: 1.1.0
4
+ version: 2.0.0
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: 2014-05-08 00:00:00.000000000 Z
11
+ date: 2014-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -52,47 +52,26 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '10.2'
55
- - !ruby/object:Gem::Dependency
56
- name: rdoc
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '4.1'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '4.1'
69
- description: This is an ActiveRecord connection adapter for PostGIS. It is based on
70
- the stock PostgreSQL adapter, but provides built-in support for the spatial extensions
71
- provided by PostGIS. It uses the RGeo library to represent spatial data in Ruby.
55
+ description: ActiveRecord connection adapter for PostGIS. It is based on the stock
56
+ PostgreSQL adapter, but provides built-in support for the spatial extensions provided
57
+ by PostGIS. It uses the RGeo library to represent spatial data in Ruby.
72
58
  email: dazuma@gmail.com, parhameter@gmail.com
73
59
  executables: []
74
60
  extensions: []
75
- extra_rdoc_files:
76
- - Documentation.rdoc
77
- - History.rdoc
78
- - README.rdoc
61
+ extra_rdoc_files: []
79
62
  files:
80
- - Documentation.rdoc
81
- - History.rdoc
82
63
  - LICENSE.txt
83
- - README.rdoc
84
64
  - lib/active_record/connection_adapters/postgis_adapter.rb
85
- - lib/active_record/connection_adapters/postgis_adapter/rails4/create_connection.rb
86
- - lib/active_record/connection_adapters/postgis_adapter/rails4/databases.rake
87
- - lib/active_record/connection_adapters/postgis_adapter/rails4/main_adapter.rb
88
- - lib/active_record/connection_adapters/postgis_adapter/rails4/postgis_database_tasks.rb
89
- - lib/active_record/connection_adapters/postgis_adapter/rails4/spatial_column.rb
90
- - lib/active_record/connection_adapters/postgis_adapter/rails4/spatial_table_definition.rb
65
+ - lib/active_record/connection_adapters/postgis_adapter/arel_tosql.rb
66
+ - lib/active_record/connection_adapters/postgis_adapter/common_adapter_methods.rb
67
+ - lib/active_record/connection_adapters/postgis_adapter/create_connection.rb
68
+ - lib/active_record/connection_adapters/postgis_adapter/databases.rake
69
+ - lib/active_record/connection_adapters/postgis_adapter/main_adapter.rb
70
+ - lib/active_record/connection_adapters/postgis_adapter/postgis_database_tasks.rb
91
71
  - lib/active_record/connection_adapters/postgis_adapter/railtie.rb
92
- - lib/active_record/connection_adapters/postgis_adapter/shared/arel_tosql.rb
93
- - lib/active_record/connection_adapters/postgis_adapter/shared/common_adapter_methods.rb
94
- - lib/active_record/connection_adapters/postgis_adapter/shared/railtie.rb
95
- - lib/active_record/connection_adapters/postgis_adapter/shared/setup.rb
72
+ - lib/active_record/connection_adapters/postgis_adapter/setup.rb
73
+ - lib/active_record/connection_adapters/postgis_adapter/spatial_column.rb
74
+ - lib/active_record/connection_adapters/postgis_adapter/spatial_table_definition.rb
96
75
  - lib/active_record/connection_adapters/postgis_adapter/version.rb
97
76
  - lib/activerecord-postgis-adapter.rb
98
77
  - lib/activerecord/postgis/adapter.rb
@@ -102,8 +81,8 @@ files:
102
81
  - test/nested_class_test.rb
103
82
  - test/setup_test.rb
104
83
  - test/spatial_queries_test.rb
84
+ - test/tasks_test.rb
105
85
  - test/test_helper.rb
106
- - test/test_tasks.rb
107
86
  homepage: http://github.com/rgeo/activerecord-postgis-adapter
108
87
  licenses:
109
88
  - BSD
@@ -127,7 +106,7 @@ rubyforge_project:
127
106
  rubygems_version: 2.2.2
128
107
  signing_key:
129
108
  specification_version: 4
130
- summary: An ActiveRecord adapter for PostGIS, based on RGeo.
109
+ summary: ActiveRecord adapter for PostGIS, based on RGeo.
131
110
  test_files:
132
111
  - test/basic_test.rb
133
112
  - test/database.yml
@@ -135,6 +114,6 @@ test_files:
135
114
  - test/nested_class_test.rb
136
115
  - test/setup_test.rb
137
116
  - test/spatial_queries_test.rb
117
+ - test/tasks_test.rb
138
118
  - test/test_helper.rb
139
- - test/test_tasks.rb
140
119
  has_rdoc:
data/Documentation.rdoc DELETED
@@ -1,320 +0,0 @@
1
- == \Documentation for the PostGIS \ActiveRecord Adapter
2
-
3
- This document provides basic how-to information that should help get you started with integrating your Rails application with a PostGIS database. We cover three parts:
4
-
5
- * How to install the adapter, and how to configure your database.yml.
6
- * How to set up and configure spatial columns and tables.
7
- * How to read, write, and query spatial data.
8
-
9
- This document is part of the distribution for the activerecord-postgis-adapter gem. For more information, please visit http://rgeo.github.com/activerecord-postgis-adapter.
10
-
11
- == Installation and Configuration
12
-
13
- === Dependencies
14
-
15
- Generally, we recommend starting with the latest versions of Ruby, Rails, PostgreSQL, and PostGIS. The minimum supported configuration is the following:
16
-
17
- * Ruby 1.8.7
18
- * Rails 3.0.3
19
- * PostgreSQL 9.0
20
- * PostGIS 1.5
21
-
22
- We recommend using the latest available if possible.
23
-
24
- JRuby and the JDBC Postgres Adapter are supported for Rails 3.x. Support is coming soon for Rails 4.
25
-
26
- === Creating a Spatial Rails App
27
-
28
- This section covers starting a new Rails application from scratch. If you need to add geospatial capabilities to an existing Rails application (i.e. you need to convert a non-spatial database to a spatial database), see the section on "Upgrading a Database With Spatial Features" below.
29
-
30
- To create a new Rails application using activerecord-postgis-adapter, start by using the postgresql adapter.
31
-
32
- rails new my_app --database=postgresql
33
-
34
- Next, add the activerecord-postgis-adapter gem to the Gemfile as follows:
35
-
36
- gem 'activerecord-postgis-adapter'
37
-
38
- We also recommend including the "squeel" gem, which comes in very useful for writing spatial queries. Then run <code>bundle install</code> to complete your bundle.
39
-
40
- The adapter includes a railtie that provides specialized rake tasks for managing spatial databases. Earlier versions of this adapter required you to load that railtie explicitly by adding a certain require statement to your <code>config/application.rb</code>. As of version 0.6, that explicit require statement is no longer necessary. If your code already has that require statement, it will not harm anything in this version, but it is considered deprecated.
41
-
42
- Next, you need to modify your <code>config/database.yml</code> file to invoke the postgis adapter, and to provide additional information it may need to set up a new database with spatial features. For example, at minimum, you will need to change the <code>adapter</code> field from "postgresql" to "postgis". Please see the Configuration sections below to see how to set up your database configs properly before proceeding.
43
-
44
- Once you have set up your database configs, you should be able to run:
45
-
46
- rake db:create
47
-
48
- to create your development database. The adapter will automatically add the PostGIS spatial definitions to your database.
49
-
50
- When you create your production database, you'll also need to add PostGIS to that database. The adapter does not provide rake tasks for setting up your production database; you will have to do that yourself. Generally, that means logging into your newly created production database and running, as a superuser:
51
-
52
- CREATE EXTENSION postgis;
53
-
54
- For more information, see the PostGIS documentation, or any relevant documentation provided by your hosting service.
55
-
56
- === Upgrading an Existing Database With Spatial Features
57
-
58
- If you have an existing Rails app and an existing database that uses Postgres, and you want to add geospatial features, you should follow these steps.
59
-
60
- First, add the activerecord-postgis-adapter gem to the Gemfile, and update your bundle by running <code>bundle install</code>.
61
-
62
- Next, modify your <code>config/database.yml</code> file to invoke the postgis adapter, as described above. At minimum, you will need to change the <code>adapter</code> field from "postgresql" to "postgis".
63
-
64
- Once you have set up your database configs, run:
65
-
66
- rake db:gis:setup
67
-
68
- This rake task adds the PostGIS extension to your existing development database.
69
-
70
- Prior to deployment, you will also need to add the PostGIS extension to your production database. Generally, that means logging into your production database and running, as a superuser:
71
-
72
- CREATE EXTENSION postgis;
73
-
74
- For more information, see the PostGIS documentation, or any relevant documentation provided by your hosting service.
75
-
76
- === Recommended Configuration
77
-
78
- Setting up the database.yml is a bit of an art. In this section, we'll cover a recommended configuration to get you started. This should be sufficient for most cases. We'll cover some of the alternate configuration options in more detail in the next section.
79
-
80
- Assuming you have at least PostgreSQL 9.2 and PostGIS 2.0, the following is the recommended configuration:
81
-
82
- development:
83
- adapter: postgis
84
- encoding: unicode
85
- postgis_extension: true
86
- schema_search_path: public,postgis
87
- pool: 5
88
- database: my_app_development # substitute your dev database name
89
- username: my_app_user # substitute the username your app will use to connect
90
- password: my_app_password # substitute the user's password
91
- su_username: my_global_user # substitute a superuser for the database
92
- su_password: my_global_pasword # substitute the superuser's password
93
-
94
- The adapter name _must_ be set to "postgis" to invoke the adapter.
95
-
96
- The <code>postgis_extension</code> tells the adapter to add the PostGIS extension to the database when the database is created (i.e. <code>rake db:create</code>). If it is missing, you will need to add PostGIS to your database through some other mechanism.
97
-
98
- The <code>schema_search_path</code> is an important value. If you include a schema called "postgis" in the search path, the adapter will isolate all the PostGIS-specific definitions, including data types, functions, views, and so forth, into that schema instead of including them in the default "public" schema. Then, when Rails needs to dump the schema (for example, to replicate it for the test database), it can use that isolation to omit the PostGIS definitions from cluttering the schema dump.
99
-
100
- The credentials that your app will use to connect to the database should be given in the <code>username</code> and <code>password</code> fields. Generally, for security reasons, it is not a good idea for this user to have "superuser" privileges. However, the adapter _does_ need superuser privileges for one function: installing PostGIS into the database when the database is first created. Therefore, you should provide a _second_ set of credentials, <code>su_username</code> and <code>su_password</code>, which identify a superuser account. This account will be used once, when you create the database (i.e. rake db:create), and not afterward.
101
-
102
- === Alternate Configuration Schemes
103
-
104
- Here are some configuration options for other cases.
105
-
106
- *If you have an older PostgreSQL or an older PostGIS* you will not be able to use the Postgres extension mechanism to install PostGIS into your database. In this case, instead of including <code>postgis_extension</code>, you should include <code>script_dir</code> in the configuration. This should be set to a directory containing two files that contain all the PostGIS-provided spatial definitions: <code>postgis.sql</code> and <code>spatial_ref_sys.sql</code>.
107
-
108
- This directory is usually in the share/contrib directory of your PostgreSQL installation. To find it, run
109
-
110
- pg_config --sharedir
111
-
112
- Then, append <code>contrib</code>, and look for a subdirectory named "postgis-(version)". For example, if you installed PostgreSQL in /usr/local, and you are running PostGIS 1.5, you should probably set <code>script_dir</code> to <code>/usr/local/share/contrib/postgis-1.5</code>.
113
-
114
- *If you are using a template to install PostGIS into your database* then set the <code>template</code> configuration as appropriate, and _omit_ both the <code>postgis_extension</code> and <code>script_dir</code> configurations. In this case, you also do not need to include <code>su_username</code> or <code>su_password</code>, since those configurations apply only to adding the extension or using the script dir.
115
-
116
- *If you do not want the spatial declarations to live in a separate schema* then do _not_ include "postgis" on the <code>schema_search_path</code>. Note that we recommend separating PostGIS into a separate schema, because that is the best way to ensure <code>rake test</code> works properly and is able to create the test database.
117
-
118
- == Spatial Database Structure
119
-
120
- A spatial database is one that includes a set of data types, functions, tables, and other objects related to geospatial data. When these objects are present in your database, you can use them to store and query spatial objects such as points, lines, and polygons.
121
-
122
- PostGIS is a plugin for PostgreSQL that provides definitions for the objects you need to add to a database to enable geospatial capabilities.
123
-
124
- When you create your Rails database as described above in the section on installation and configuration, activerecord-postgis-adapter automatically invokes PostGIS to add the appropriate definitions to your database. You can determine whether your database includes the correct definitions by attempting to invoke the POSTGIS_VERSION function:
125
-
126
- SELECT POSTGIS_VERSION(); # succeeds if PostGIS objects are present.
127
-
128
- Standard spatial databases also include a table called <code>spatial_ref_sys</code>. This table includes a set of "spatial reference systems", or coordinate systems--- for example, WGS84 latitude and longitude, or Mercator Projection. Spatial databases also usually include a table called <code>geometry_columns</code>, which includes information on each database column that includes geometric data. In recent versions of PostGIS, <code>geometry_columns</code> is actually not a table but a view into the system catalogs.
129
-
130
- === Creating Spatial Tables
131
-
132
- To store spatial data, you must create a column with a spatial type. PostGIS provides a variety of spatial types, including point, linestring, polygon, and different kinds of collections. These types are defined in a standard produced by the Open Geospatial Consortium. Furthermore, you can specify options indicating the coordinate system and number of coordinates for the values you are storing.
133
-
134
- The activerecord-postgis-adapter extends \ActiveRecord's migration syntax to support these spatial types. The following example creates four spatial columns in a table:
135
-
136
- create_table :my_spatial_table do |t|
137
- t.column :shape1, :geometry
138
- t.geometry :shape2
139
- t.line_string :path, :srid => 3785
140
- t.point :lonlat, :geographic => true
141
- t.point :lonlatheight, :geographic => true, :has_z => true
142
- end
143
-
144
- The first column, "shape1", is created with type "geometry". This is a general "base class" for spatial types; the column declares that it can contain values of _any_ spatial type. The second column, "shape2", uses a shorthand syntax for the same type. Like "normal" types, you can create a column either by invoking <code>column</code> or invoking the name of the type directly.
145
-
146
- The third column, "path", has a specific geometric type, <code>line_string</code>. It also specifies an SRID (spatial reference ID) that indicates which coordinate system it expects the data to be in. The column now has a "constraint" on it; it will accept only LineString data, and only data whose SRID is 3785.
147
-
148
- The fourth column, "lonlat", has the <code>point</code> type, and accepts only Point data. Furthermore, it declares the column as "geographic", which means it accepts longitude/latitude data, and performs calculations such as distances using a spheroidal domain.
149
-
150
- The fifth column, "lonlatheight", is a geographic (longitude/latitude) point that also includes a third "z" coordinate that can be used to store height information.
151
-
152
- The following are the data types understood by PostGIS and exposed by activerecord-postgis-adapter:
153
-
154
- * <tt>:geometry</tt> -- Any geometric type
155
- * <tt>:point</tt> -- Point data
156
- * <tt>:line_string</tt> -- LineString data
157
- * <tt>:polygon</tt> -- Polygon data
158
- * <tt>:geometry_collection</tt> -- Any collection type
159
- * <tt>:multi_point</tt> -- A collection of Points
160
- * <tt>:multi_line_string</tt> -- A collection of LineStrings
161
- * <tt>:multi_polygon</tt> -- A collection of Polygons
162
-
163
- Following are the options understood by the adapter:
164
-
165
- * <tt>:geographic</tt> -- If set to true, create a PostGIS geography column for longitude/latitude data over a spheroidal domain; otherwise create a geometry column in a flat coordinate system. Default is false. Also implies :srid set to 4326.
166
- * <tt>:srid</tt> -- Set a SRID constraint for the column. Default is 4326 for a geography column, or -1 for a geometry column. Note that PostGIS currently (as of version 2.0) requires geography columns to have SRID 4326, so this constraint is of limited use for geography columns.
167
- * <tt>:has_z</tt> -- Specify that objects in this column include a Z coordinate. Default is false.
168
- * <tt>:has_m</tt> -- Specify that objects in this column include an M coordinate. Default is false.
169
-
170
- The adapter also extends the \ActiveRecord migration syntax for creating spatial indexes. To create a PostGIS spatial index, simply set the :spatial option to true, as follows:
171
-
172
- change_table :my_spatial_table do |t|
173
- t.index :lonlat, :spatial => true
174
- end
175
-
176
- === Configuring the \ActiveRecord class
177
-
178
- \ActiveRecord's usefulness stems from the way it automatically configures classes based on the database structure and schema. If a column in the database has an integer type, \ActiveRecord automatically casts the data to a Ruby Integer. In the same way, the activerecord-postgis-adapter automatically casts spatial data to a corresponding RGeo data type.
179
-
180
- However, RGeo offers more "flexibility" in its type system than can be interpreted solely from analyzing the database column. For example, you can configure RGeo objects to exhibit certain behaviors related to their serialization, validation, coordinate system, or computation. These settings are embodied in the RGeo "factory" associated with the object.
181
-
182
- Therefore, you can configure the adapter to use a particular factory (i.e. a particular combination of settings) for data associated with each column in the database. This is done by calling class methods on the \ActiveRecord class associated with that database table. Specifically, you can call <code>set_rgeo_factory_for_column</code> to set the factory that \ActiveRecord uses for a particular column.
183
-
184
- You can also provide a "factory generator" function which takes information from the database column and returns a suitable factory. Set the factory generator by setting the <code>rgeo_factory_generator</code> class attribute of your \ActiveRecord class. The generator should be a callable object that takes a hash that could include the following keys:
185
-
186
- * <tt>:srid</tt> -- the SRID of the database column
187
- * <tt>:has_z_coordinate</tt> -- true if the database column has a Z coordinate
188
- * <tt>:has_m_coordinate</tt> -- true if the database column has a M coordinate
189
- * <tt>:geographic</tt> -- true if the database column is geographic instead of geometric
190
-
191
- Here are some examples, given the spatial table defined above:
192
-
193
- class MySpatialTable < ActiveRecord::Base
194
-
195
- # By default, use the GEOS implementation for spatial columns.
196
- self.rgeo_factory_generator = RGeo::Geos.factory_generator
197
-
198
- # But use a geographic implementation for the :lonlat column.
199
- set_rgeo_factory_for_column(:lonlat, RGeo::Geographic.spherical_factory(:srid => 4326))
200
-
201
- end
202
-
203
- The <code>rgeo_factory_generator</code> attribute and <code>set_rgeo_factory_for_column</code> method are actually implemented (and documented) in the "rgeo-activerecord" gem, which is a dependency of the activerecord-postgis-adapter.
204
-
205
- === Schema Dump and Reload
206
-
207
- The presence of geospatial data in a database causes some issues with \ActiveRecord's schema dump and restore functions. This is because (1) installing PostGIS into your database injects a lot of objects in your database that can clutter up schema dumps, and (2) to define a spatial column correctly, you generally must call a SQL function such as AddGeometryColumn(), and Rails's schema dumper isn't smart enough to reproduce those function calls.
208
-
209
- Because of this, we recommend the following.
210
-
211
- * Install the PostGIS definitions in a separate schema called "postgis" (as described in the recommended installation procedure above). The activerecord-postgis-adapter will ignore a schema called "postgis" when dumping the schema, thus omitting the clutter.
212
-
213
- * Set the \ActiveRecord schema format to <code>:ruby</code>, _not_ <code>:sql</code>. The former emits higher level commands that can be interpreted correctly to reproduce the schema. The latter, however, emits low level SQL, which loses information such as the fact that AddGeometryColumn() was originally used to generate a column. Executing a <code>:sql</code> format schema dump will _not_ correctly reproduce the schema.
214
-
215
- Of course, the above discussion is really relevant only if you are using the \ActiveRecord rake tasks that create and restore databases, either directly such as <code>rake db:create</code> or indirectly such as <code>rake test</code>. It does not have any effect on running migrations or normal website execution.
216
-
217
- == Working With Spatial Data
218
-
219
- Of course, you're using this adapter because you want to work with geospatial data in your \ActiveRecord models. Once you've installed the adapter, set up your database, and run your migrations, you can interact directly with spatial data in your models as RGeo objects.
220
-
221
- RGeo is a Ruby implementation of the industry standard OGC Simple Features specification. It's a set of data types that can represent a variety of geospatial objects such as points, lines, polygons, and collections. It also provides the standard set of spatial analysis operations such as computing intersections or bounding boxes, calculating length or area, and so forth. We recommend browsing the RGeo documentation for a clearer understanding of its capabilities. For now, just note that the data values you will be working with are all RGeo geometry objects.
222
-
223
- === Reading and Writing Spatial Columns
224
-
225
- When you access a spatial attribute on your \ActiveRecord model, it is given to you as an RGeo geometry object (or nil, for attributes that allow null values). You can then call the RGeo api on the object. For example, consider the MySpatialTable class we worked with above:
226
-
227
- record = MySpatialTable.find(1)
228
- p = record.lonlat # Returns an RGeo::Feature::Point
229
- puts p.x # displays the x coordinate
230
- puts p.geometry_type.type_name # displays "Point"
231
-
232
- The RGeo factory for the value is determined by how you configured the \ActiveRecord class, as described above. In this case, we explicitly set a spherical factory for the <code>:lonlat</code> column:
233
-
234
- factory = p.factory # returns a spherical factory
235
-
236
- You can set a spatial attribute by providing an RGeo geometry object, or by providing the WKT string representation of the geometry. If a string is provided, the activerecord-postgis-adapter will attempt to parse it as WKT and set the value accordingly.
237
-
238
- record.lonlat = 'POINT(-122 47)' # sets the value to the given point
239
-
240
- If the WKT parsing fails, the value currently will be silently set to nil. In the future, however, this will raise an exception.
241
-
242
- record.lonlat = 'POINT(x)' # sets the value to nil
243
-
244
- If you set the value to an RGeo object, the factory needs to match the factory for the attribute. If the factories do not match, activerecord-postgis-adapter will attempt to cast the value to the correct factory.
245
-
246
- p2 = factory.point(-122, 47) # p2 is a point in a spherical factory
247
- record.lonlat = p2 # sets the value to the given point
248
- record.shape1 = p2 # shape1 uses a flat geos factory, so it
249
- # will cast p2 into that coordinate system
250
- # before setting the value
251
- record.save
252
-
253
- If, however, you attempt to set the value to the wrong type-- for example, setting a linestring attribute to a point value, you will get an exception from Postgres when you attempt to save the record.
254
-
255
- record.path = p2 # This will appear to work, but...
256
- record.save # This will raise an exception from the database
257
-
258
- === Spatial Queries
259
-
260
- You can create simple queries based on representational equality in the same way you would on a scalar column:
261
-
262
- record2 = MySpatialTable.where(:lonlat => factory.point(-122, 47)).first
263
-
264
- You can also use WKT:
265
-
266
- record3 = MySpatialTable.where(:lonlat => 'POINT(-122 47)').first
267
-
268
- Note that these queries use representational equality, meaning they return records where the lonlat value matches the given value exactly. A 0.00001 degree difference would not match, nor would a different representation of the same geometry (like a multipoint with a single element). Equality queries aren't generally all that useful in real world applications. Typically, if you want to perform a spatial query, you'll look for, say, all the points within a given area. For those queries, you'll need to use the standard spatial SQL functions provided by PostGIS.
269
-
270
- Unfortunately, Rails by itself doesn't provide good support for embedding arbitrary function calls in your where clause. You could get around this by writing raw SQL. But the solution we recommend is to use the "squeel" gem. This gem extends the \ActiveRecord syntax to support more complex queries.
271
-
272
- Let's say you wanted to find all records whose lonlat fell within a particular polygon. In the query, you can accomplish this by calling the ST_Intersects() SQL function on the lonlat and the polygon. That is, you'd want to generate SQL that looks something like this:
273
-
274
- SELECT * FROM my_spatial_table WHERE ST_Intersects(lonlat, <i>my-polygon</i>);
275
-
276
- Using squeel, you can write this as follows:
277
-
278
- my_polygon = get_my_polygon() # Obtain the polygon as an RGeo geometry
279
- MySpatialTable.where{st_intersects(lonlat, my_polygon)}.first
280
-
281
- Notice the curly brackets instead of parentheses in the where clause. This is how to write squeel queries: squeel is actually a DSL, and you're passing a block to the where method instead of an argument list. Also note that Squeel requires \ActiveRecord 3.1 or later to handle SQL function calls such as ST_Intersects.
282
-
283
- As another example, one common query is to find all objects displaying in a window. This can be done using the overlap (&&) operator with a bounding box. Here's an example that finds linestrings in the "path" column that intersect a bounding box:
284
-
285
- sw = get_sw_corner_in_projected_coordinates()
286
- ne = get_ne_corner_in_projected_coordinates()
287
- window = RGeo::Cartesian::BoundingBox.create_from_points(sw, ne)
288
- MySpatialTable.where{path.op('&&', window)}.all
289
-
290
- Note that bounding box queries make sense only in a projected coordinate system; you shouldn't try to run such a query against a lat/long (geographic) column.
291
-
292
- == License
293
-
294
- Copyright 2010-2013 Daniel Azuma
295
-
296
- All rights reserved.
297
-
298
- Redistribution and use in source and binary forms, with or without
299
- modification, are permitted provided that the following conditions are met:
300
-
301
- * Redistributions of source code must retain the above copyright notice,
302
- this list of conditions and the following disclaimer.
303
- * Redistributions in binary form must reproduce the above copyright notice,
304
- this list of conditions and the following disclaimer in the documentation
305
- and/or other materials provided with the distribution.
306
- * Neither the name of the copyright holder, nor the names of any other
307
- contributors to this software, may be used to endorse or promote products
308
- derived from this software without specific prior written permission.
309
-
310
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
311
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
312
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
313
- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
314
- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
315
- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
316
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
317
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
318
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
319
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
320
- POSSIBILITY OF SUCH DAMAGE.
data/History.rdoc DELETED
@@ -1,163 +0,0 @@
1
- === 1.1.0 / 2014-05-07
2
-
3
- * Relax the ActiveRecord version requirement to support both 4.0.x and 4.1.x in a single gem.
4
- * The 0.7.x versions and 0.7-stable branch are now obsolete.
5
-
6
- === 1.0.0 / 2014-05-06
7
-
8
- * Require rgeo-activerecord 1.0.0
9
- * Require ActiveRecord 4.1
10
-
11
- === 0.7.1 / 2014-05-06
12
-
13
- * Updates for the Rails 4.0.x-compatible adapater can be found on the 0.7-stable branch
14
- * Require rgeo-activerecord 0.6.0, which includes bug fixes for Rails 4.0.x
15
-
16
- === 0.7.0 / 2014-05-06
17
-
18
- * Version 0.7.0 is for Rails 4.0.x
19
- * Require ruby 1.9.3+
20
- * Require ActiveRecord 4.0
21
- * Drop JRuby support (temporary)
22
-
23
- === 0.6.5 / 2013-06-24
24
-
25
- * Fixed stoopid syntax errors in rake db:gis:setup tass. (Pull requests by rhodrid and jdurand)
26
-
27
- === 0.6.4 / 2013-05-28
28
-
29
- * Fixed a crash with array conversions in Rails 4. (Contributed by Christopher Bull)
30
- * The gis setup task was broken in any Rails other than 3.2.x. Fixed (I think). (Reports by Rupert de Guzman and slbug)
31
- * Raise a more useful exception for the (as yet) unsupported combination of Rails 4 and JRuby.
32
-
33
- === 0.6.3 / 2013-05-04
34
-
35
- * Several fixes for compatibility with changes to Rails 4.0.0 rc1. (Reports by slbug and Victor Costan)
36
- * Rails 3 rake tasks properly set PGUSER when appropriate. (Pull request by Mitin Pavel)
37
- * Fixed a nil exception on some Rails 4 migrations. (Pull request by ivanfoong and Victor Costan)
38
-
39
- === 0.6.2 / 2013-03-08
40
-
41
- * The PostGIS setup now properly connects as the superuser. (Reported by Adam Trilling)
42
- * Fix database setup rake tasks under jruby/jdbc adapter. (Pull request by Nick Muerdter)
43
- * Drop table no longer tries to modify the geometry_columns view under PostGIS 2.0.
44
- * The Rakefile is now compatible with RubyGems 2.0.
45
-
46
- === 0.6.1 / 2013-02-28
47
-
48
- * Fixed some gem loading issues.
49
-
50
- === 0.6.0 / 2013-02-28
51
-
52
- * Experimental support for the recently released Rails 4.0 beta.
53
- * Documentation improvements.
54
-
55
- === 0.5.1 / 2013-02-04
56
-
57
- * Database creation properly treats geometry_columns as a view when setting owner. (Pull request by hendrikstier)
58
- * Provide rake db:gis:setup task. (Pull request by Cody Russell)
59
- * Modifications for compatibility with postgres_ext. (Pull request by legendetm)
60
- * SpatialTableDefinition properly subclasses the Postgres-specific table definition class, if available. (Pull request by Joe Noon)
61
- * Database creation script no longer fails if the username includes weird characters. (Contributed by Toms Mikoss)
62
- * Updates for compatibility with jdbc-postgres 9.2.1002.1
63
-
64
- === 0.5.0 / 2012-12-12
65
-
66
- Thanks to the many who have submitted pull requests. A bunch of them are in this release. Special thanks to Nick Muerdter, who succeeded in porting the adapter to work with the JDBC Postgres adapter in JRuby, and also got Travis up and running for the project.
67
-
68
- * Add JRuby compatibility with the activerecord-jdbcpostgresql-adapter gem. (Pull request by Nick Muerdter)
69
- * Allow WKT to be to be specified as a string-like object rather than having to be a String. (Pull request by Bryan Larsen)
70
- * Ignore postgis_topology tables 'layer' and 'topology' in rake db:schema:dump. (Pull request by Greg Phillips)
71
- * Create schemas specified in schema_search_path only if they don't exist. (Pull request by legendetm)
72
- * Force the postgis_topology extension be created in the topology schema. (Pull request by Dimitri Roche)
73
- * Specifically set the ownership of the postgis related tables to the regular user. (Pull request by corneverbruggen)
74
- * The gemspec no longer includes the timestamp in the version, so that bundler can pull from github. (Reported by corneverbruggen)
75
- * Update tests for PostGIS 2.0 compatibility.
76
- * Travis-CI integration. (Pull request by Nick Muerdter)
77
- * Add a missing srid in the Readme. (Pull request by gouthamvel)
78
- * Readme clarifies that BoundingBox objects can be used in a query only for projected coordinate systems. (Reported by Tee Parham)
79
- * Update URLs to point to new website.
80
-
81
- === 0.4.3 / 2012-04-13
82
-
83
- * Rake tasks failed on Rails 3.0.x because of an issue with rgeo-activerecord pre-0.4.5. Now we require the fixed version.
84
-
85
- === 0.4.2 / 2012-04-12
86
-
87
- * Support the db:structure:load rake task in recent versions of Rails.
88
- * Support installing PostGIS via the PostgreSQL extension mechanism (requires at least PostGIS 2.0 and PostgreSQL 9.1).
89
- * Support bounding boxes in queries (useful for "window" queries such as finding objects to display in a map region).
90
- * Fix some issues determine the correct default value for spatial columns.
91
-
92
- === 0.4.1 / 2012-02-22
93
-
94
- * Some compatibility fixes for Rails 3.2. (Reported by Ryan Williams with implementation help from Radek Paviensky.)
95
- * Now requires rgeo-activerecord 0.4.3.
96
-
97
- === 0.4.0 / 2011-08-15
98
-
99
- * Various fixes for Rails 3.1 compatibility.
100
- * Now requires rgeo-activerecord 0.4.0.
101
- * INCOMPATIBLE CHANGE: simple queries (e.g. MyClass.where(:latlon => my_point)) use an objective rather than spatial equality test. Earlier versions transformed this form to use st_equals, but now if you need to test for spatial equality, you'll need to call st_equals explicitly. I'm still evaluating which direction we want to go with this in the future, but we may be stuck with the current behavior because the hack required to transform these queries to use spatial equality was egregious and broke in Rails 3.1 with no clear workaround.
102
-
103
- === 0.3.6 / 2011-06-21
104
-
105
- * Require latest rgeo-activerecord to get some fixes.
106
- * Note PostgreSQL 9 requirement in the README. (Reported by Samuel Cochran)
107
- * Now doesn't throw exceptions if an RGeo cast fails when setting an attribute.
108
-
109
- === 0.3.5 / 2011-04-12
110
-
111
- * The .gemspec was missing the databases.rake file. Fixed.
112
-
113
- === 0.3.4 / 2011-04-11
114
-
115
- * A .gemspec file is now available for gem building and bundler git integration.
116
-
117
- === 0.3.3 / 2011-02-28
118
-
119
- * INCOMPATIBLE CHANGE: the default SRID for non-geography columns is now -1, rather than 4326. (Geography columns still default to 4326.)
120
- * It is now possible to create a spatial column without a corresponding entry in the geometry_columns table, and the adapter now handles this case properly. (Reported by Pirmin Kalberer)
121
- * Now requires rgeo-activerecord 0.3.1 (which brings a critical fix involving declaring multiple spatial columns in a migration).
122
-
123
- === 0.3.2 / 2011-02-11
124
-
125
- * You can now specify a separate "database creation" superuser role so your normal PostgreSQL login role doesn't need superuser privileges when running database creation tasks.
126
- * Database creation tasks automatically create all schemas listed in the schema search path.
127
-
128
- === 0.3.1 / 2011-02-01
129
-
130
- * Fixed a syntax error that prevented the adapter from loading on Ruby 1.8. Whoops. (Reported by miguelperez)
131
-
132
- === 0.3.0 / 2011-01-26
133
-
134
- * Reworked type and constraint handling, which should result in a large number of bug fixes, especially related to schema dumps.
135
- * Experimental support for complex spatial queries. (Requires Arel 2.1, which is expected to be released with Rails 3.1.)
136
- * The path to the Railtie is now different (see the README), though a compatibility wrapper has been left in the old location.
137
- * Getting index information from the ActiveRecord class now properly recognizes spatial-ness.
138
- * Reorganized the code a bit for better clarity.
139
-
140
- === 0.2.3 / 2011-01-06
141
-
142
- * Many of ActiveRecord's rake tasks weren't working because they need to know about every adapter explicitly. I hesitate to call this "fixed" since I see it as a problem in ActiveRecord, but we now at least have a workaround so the rake tasks will run properly. (Reported by Tad Thorley.)
143
- * Dumping schema.rb now omits the PostGIS internal tables.
144
- * Added a new configuration parameter pointing to the script directory, for rake db:create.
145
- * If the "postgis" schema is included in the schema search path, it is used as a container for the PostGIS internal definitions when running rake db:create. Furthermore, that schema is omitted when dumping the structure.sql. This should eliminate all the PostGIS internal cruft from SQL structure dumps, and also eliminate the errors that would appear when rebuilding a test database because the PostGIS internals would get applied twice.
146
-
147
- === 0.2.2 / 2010-12-27
148
-
149
- * Support for basic spatial equality queries. e.g. constructs such as:
150
- MyClass.where(:geom_column => factory.point(1, 2))
151
- MyClass.where(:geom_column => 'POINT(1 2)')
152
- * Fixed an exception when adding spatial columns where the column name is specified as a symbol.
153
-
154
- === 0.2.1 / 2010-12-15
155
-
156
- * Provides meta-information to RGeo 0.2.2 or later to support access to PostGIS's spatial reference system table.
157
-
158
- === 0.2.0 / 2010-12-07
159
-
160
- * Initial public alpha release. Spun activerecord-postgis-adapter off from the core rgeo gem.
161
- * You can now set the factory for a specific column by name.
162
-
163
- For earlier history, see the History file for the rgeo gem.
data/README.rdoc DELETED
@@ -1,101 +0,0 @@
1
- == PostGIS \ActiveRecord Adapter
2
-
3
- The activerecord-postgis-adapter is a plugin that provides access to features of the PostGIS geospatial database from \ActiveRecord. Technically, it extends the standard postgresql adapter to provide support for the spatial data types and features added by the PostGIS extension. It uses the {RGeo}[http://github.com/rgeo/rgeo] library to represent spatial data in Ruby.
4
-
5
- == About the PostGIS Adapter
6
-
7
- This is a brief summary covering how to use activerecord-postgis-adapter. For full documentation, see Documentation.rdoc.
8
-
9
- === Features
10
-
11
- The adapter provides three basic capabilities.
12
-
13
- First, it provides *spatial migrations*. It extends the \ActiveRecord migration syntax to support creating spatially-typed columns and spatial indexes. You can control the various PostGIS-provided attributes such as srid, dimension, and geographic vs geometric math.
14
-
15
- Second, it recognizes spatial types and casts them properly to RGeo geometry objects. The adapter can configure these objects automatically based on the srid and dimension in the database table, or you can tell it to convert the data to a different form. You can also set attribute data using WKT format.
16
-
17
- Third, it lets you include simple spatial data in queries. WKT format data and RGeo objects can be embedded in where clauses. If you include the Squeel gem, the adapter also supports advanced queries utilizing the standard SQL spatial function set.
18
-
19
- === Install
20
-
21
- The adapter requires PostgreSQL 9.0+.
22
-
23
- ===== Version 1.1.x: ActiveRecord 4.0+
24
-
25
- Requirements:
26
- ActiveRecord 4.0+
27
- Ruby 1.9.3+
28
- PostGIS 2.0+
29
-
30
- Gemfile:
31
- gem 'activerecord-postgis-adapter'
32
-
33
- Support for JRuby will be added soon.
34
-
35
- ===== Version 0.6.x: ActiveRecord 3.x
36
-
37
- Requirements:
38
- ActiveRecord 3.x only
39
- Ruby 1.8.7+, JRuby, Rubinius
40
- PostGIS 1.5+
41
-
42
- Gemfile:
43
- gem 'activerecord-postgis-adapter', '~> 0.6.6'
44
-
45
- Please note that this adapter uses the rgeo gem, which may have additional dependencies. Please see the \README documentation for rgeo for more information.
46
-
47
- Once you have installed the adapter, you'll need to edit your config/database.yml to call for it. At minimum, this means changing the adapter name from "postgresql" to "postgis". It may also require other settings to ensure that other functions (such as rake test) continue to work as expected. We recommend reading the Configuration section in the Documentation.rdoc file carefully before starting to use this adapter.
48
-
49
- == Development and Support
50
-
51
- \Documentation is available at http://rgeo.github.com/activerecord-postgis-adapter/rdoc
52
-
53
- Source code is hosted on Github at http://github.com/rgeo/activerecord-postgis-adapter
54
-
55
- Contributions are welcome. Fork the project on Github.
56
-
57
- Report issues at http://github.com/rgeo/activerecord-postgis-adapter/issues
58
-
59
- Support is available on the rgeo-users google group at http://groups.google.com/group/rgeo-users
60
-
61
- == Acknowledgments
62
-
63
- The PostGIS Adapter and its supporting libraries (including RGeo) are
64
- written by Daniel Azuma (http://www.daniel-azuma.com).
65
-
66
- Development is supported by Pirq. (http://pirq.com).
67
-
68
- This adapter implementation owes some debt to the spatial_adapter plugin
69
- (http://github.com/fragility/spatial_adapter). Although we made some
70
- different design decisions for this adapter, studying the spatial_adapter
71
- source gave us a head start on the implementation.
72
-
73
- == License
74
-
75
- Copyright 2010-2013 Daniel Azuma
76
-
77
- All rights reserved.
78
-
79
- Redistribution and use in source and binary forms, with or without
80
- modification, are permitted provided that the following conditions are met:
81
-
82
- * Redistributions of source code must retain the above copyright notice,
83
- this list of conditions and the following disclaimer.
84
- * Redistributions in binary form must reproduce the above copyright notice,
85
- this list of conditions and the following disclaimer in the documentation
86
- and/or other materials provided with the distribution.
87
- * Neither the name of the copyright holder, nor the names of any other
88
- contributors to this software, may be used to endorse or promote products
89
- derived from this software without specific prior written permission.
90
-
91
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
92
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
93
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
94
- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
95
- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
96
- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
97
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
98
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
99
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
100
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
101
- POSSIBILITY OF SUCH DAMAGE.
@@ -1,13 +0,0 @@
1
- unless defined?(::ActiveRecord::ConnectionAdapters::PostGISAdapter::Railtie)
2
- module ActiveRecord # :nodoc:
3
- module ConnectionAdapters # :nodoc:
4
- module PostGISAdapter # :nodoc:
5
- class Railtie < ::Rails::Railtie # :nodoc:
6
- rake_tasks do
7
- load ::File.expand_path("../rails4/databases.rake", ::File.dirname(__FILE__))
8
- end
9
- end
10
- end
11
- end
12
- end
13
- end