ar-postgis 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (26) hide show
  1. checksums.yaml +7 -0
  2. data/Documentation.rdoc +292 -0
  3. data/History.rdoc +147 -0
  4. data/LICENSE.txt +29 -0
  5. data/README.rdoc +78 -0
  6. data/lib/active_record/connection_adapters/postgis_adapter.rb +38 -0
  7. data/lib/active_record/connection_adapters/postgis_adapter/rails4/create_connection.rb +29 -0
  8. data/lib/active_record/connection_adapters/postgis_adapter/rails4/databases.rake +17 -0
  9. data/lib/active_record/connection_adapters/postgis_adapter/rails4/main_adapter.rb +202 -0
  10. data/lib/active_record/connection_adapters/postgis_adapter/rails4/postgis_database_tasks.rb +204 -0
  11. data/lib/active_record/connection_adapters/postgis_adapter/rails4/spatial_column.rb +184 -0
  12. data/lib/active_record/connection_adapters/postgis_adapter/rails4/spatial_table_definition.rb +121 -0
  13. data/lib/active_record/connection_adapters/postgis_adapter/railtie.rb +3 -0
  14. data/lib/active_record/connection_adapters/postgis_adapter/shared/arel_tosql.rb +23 -0
  15. data/lib/active_record/connection_adapters/postgis_adapter/shared/common_adapter_methods.rb +46 -0
  16. data/lib/active_record/connection_adapters/postgis_adapter/shared/railtie.rb +13 -0
  17. data/lib/active_record/connection_adapters/postgis_adapter/shared/setup.rb +21 -0
  18. data/lib/active_record/connection_adapters/postgis_adapter/version.rb +7 -0
  19. data/lib/activerecord-postgis-adapter.rb +1 -0
  20. data/test/database.yml +5 -0
  21. data/test/tc_basic.rb +212 -0
  22. data/test/tc_ddl.rb +303 -0
  23. data/test/tc_nested_class.rb +48 -0
  24. data/test/tc_spatial_queries.rb +126 -0
  25. data/test/tc_tasks.rb +112 -0
  26. metadata +149 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 66f98e01b84021d93b38379d634fe8cd1487f1aa
4
+ data.tar.gz: 4481b6e93272c9c9a94040b520de1c401bc98f5a
5
+ SHA512:
6
+ metadata.gz: e83a78c8ef67b34f642b4a18bd7afd5b77a5e1729e429334e2d1e5b3ce4d77ad83920239b786f94877d6486ba1c077d4980c2742b2330e60a56295c3a12c0942
7
+ data.tar.gz: 862aab26d4f807aa77e72f157f2a94c18659dbd047b72253149369ef2178ae892fdf4964ca397360fe90bebef517ab15a7177b12cb3dcbf83d57adea2b3b553b
@@ -0,0 +1,292 @@
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://dazuma.github.com/activerecord-postgis-adapter.
10
+
11
+ == Installation and Configuration
12
+
13
+ === General Installation Considerations
14
+
15
+ Generally, we recommend starting with the latest versions of Ruby, Rails, PostgreSQL, and PostGIS. As of this writing, those are Ruby 2.1.0, Rails 4.0, PostgreSQL 9.3, and PostGIS 2.1. If you cannot upgrade, the minimum supported configuration is the following:
16
+
17
+ * Ruby 2.0.0
18
+ * Rails 4.0.2
19
+ * PostgreSQL 9.1
20
+ * PostGIS 2.0
21
+
22
+ However, older software versions can make for a more involved setup process, so we recommend using the latest available if possible.
23
+
24
+ === Creating a Spatial Rails App
25
+
26
+ 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.
27
+
28
+ To create a new Rails application using activerecord-postgis-adapter, start by using the postgresql adapter.
29
+
30
+ rails new my_app --database=postgresql
31
+
32
+ Next, add the activerecord-postgis-adapter gem to the Gemfile as follows:
33
+
34
+ gem 'activerecord-postgis-adapter'
35
+
36
+ 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.
37
+
38
+ 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.
39
+
40
+ 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.
41
+
42
+ Once you have set up your database configs, you should be able to run:
43
+
44
+ rake db:create
45
+
46
+ to create your development database. The adapter will automatically add the PostGIS spatial definitions to your database.
47
+
48
+ 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:
49
+
50
+ CREATE EXTENSION postgis;
51
+
52
+ For more information, see the PostGIS documentation, or any relevant documentation provided by your hosting service.
53
+
54
+ === Upgrading an Existing Database With Spatial Features
55
+
56
+ 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.
57
+
58
+ First, add the activerecord-postgis-adapter gem to the Gemfile, and update your bundle by running <code>bundle install</code>.
59
+
60
+ 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".
61
+
62
+ Once you have set up your database configs, run:
63
+
64
+ rake db:gis:setup
65
+
66
+ This rake task adds the PostGIS extension to your existing development database.
67
+
68
+ 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:
69
+
70
+ CREATE EXTENSION postgis;
71
+
72
+ For more information, see the PostGIS documentation, or any relevant documentation provided by your hosting service.
73
+
74
+ === Recommended Configuration
75
+
76
+ 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.
77
+
78
+ Assuming you have at least PostgreSQL 9.2 and PostGIS 2.0, the following is the recommended configuration:
79
+
80
+ development:
81
+ adapter: postgis
82
+ encoding: unicode
83
+ postgis_extension: true
84
+ schema_search_path: public,postgis
85
+ pool: 5
86
+ database: my_app_development # substitute your dev database name
87
+ username: my_app_user # substitute the username your app will use to connect
88
+ password: my_app_password # substitute the user's password
89
+ su_username: my_global_user # substitute a superuser for the database
90
+ su_password: my_global_pasword # substitute the superuser's password
91
+
92
+ The adapter name _must_ be set to "postgis" to invoke the adapter.
93
+
94
+ 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.
95
+
96
+ 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.
97
+
98
+ 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.
99
+
100
+ === Alternate Configuration Schemes
101
+
102
+ Here are some configuration options for other cases.
103
+
104
+ *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>.
105
+
106
+ This directory is usually in the share/contrib directory of your PostgreSQL installation. To find it, run
107
+
108
+ pg_config --sharedir
109
+
110
+ 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>.
111
+
112
+ *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.
113
+
114
+ *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.
115
+
116
+ == Spatial Database Structure
117
+
118
+ 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.
119
+
120
+ PostGIS is a plugin for PostgreSQL that provides definitions for the objects you need to add to a database to enable geospatial capabilities.
121
+
122
+ 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:
123
+
124
+ SELECT POSTGIS_VERSION(); # succeeds if PostGIS objects are present.
125
+
126
+ 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.
127
+
128
+ === Creating Spatial Tables
129
+
130
+ 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.
131
+
132
+ The activerecord-postgis-adapter extends \ActiveRecord's migration syntax to support these spatial types. The following example creates four spatial columns in a table:
133
+
134
+ create_table :my_spatial_table do |t|
135
+ t.column :shape1, :geometry
136
+ t.geometry :shape2
137
+ t.line_string :path, :srid => 3785
138
+ t.point :lonlat, :geographic => true
139
+ t.point :lonlatheight, :geographic => true, :has_z => true
140
+ end
141
+
142
+ 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.
143
+
144
+ 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.
145
+
146
+ 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.
147
+
148
+ 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.
149
+
150
+ The following are the data types understood by PostGIS and exposed by activerecord-postgis-adapter:
151
+
152
+ * <tt>:geometry</tt> -- Any geometric type
153
+ * <tt>:point</tt> -- Point data
154
+ * <tt>:line_string</tt> -- LineString data
155
+ * <tt>:polygon</tt> -- Polygon data
156
+ * <tt>:geometry_collection</tt> -- Any collection type
157
+ * <tt>:multi_point</tt> -- A collection of Points
158
+ * <tt>:multi_line_string</tt> -- A collection of LineStrings
159
+ * <tt>:multi_polygon</tt> -- A collection of Polygons
160
+
161
+ Following are the options understood by the adapter:
162
+
163
+ * <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.
164
+ * <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.
165
+ * <tt>:has_z</tt> -- Specify that objects in this column include a Z coordinate. Default is false.
166
+ * <tt>:has_m</tt> -- Specify that objects in this column include an M coordinate. Default is false.
167
+
168
+ 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:
169
+
170
+ change_table :my_spatial_table do |t|
171
+ t.index :lonlat, :spatial => true
172
+ end
173
+
174
+ === Configuring the \ActiveRecord class
175
+
176
+ \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.
177
+
178
+ 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.
179
+
180
+ 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.
181
+
182
+ 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:
183
+
184
+ * <tt>:srid</tt> -- the SRID of the database column
185
+ * <tt>:has_z_coordinate</tt> -- true if the database column has a Z coordinate
186
+ * <tt>:has_m_coordinate</tt> -- true if the database column has a M coordinate
187
+ * <tt>:geographic</tt> -- true if the database column is geographic instead of geometric
188
+
189
+ Here are some examples, given the spatial table defined above:
190
+
191
+ class MySpatialTable < ActiveRecord::Base
192
+
193
+ # By default, use the GEOS implementation for spatial columns.
194
+ self.rgeo_factory_generator = RGeo::Geos.factory_generator
195
+
196
+ # But use a geographic implementation for the :lonlat column.
197
+ set_rgeo_factory_for_column(:lonlat, RGeo::Geographic.spherical_factory(:srid => 4326))
198
+
199
+ end
200
+
201
+ 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.
202
+
203
+ === Schema Dump and Reload
204
+
205
+ 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.
206
+
207
+ Because of this, we recommend the following.
208
+
209
+ * 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.
210
+
211
+ * 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.
212
+
213
+ 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.
214
+
215
+ == Working With Spatial Data
216
+
217
+ 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.
218
+
219
+ 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.
220
+
221
+ === Reading and Writing Spatial Columns
222
+
223
+ 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:
224
+
225
+ record = MySpatialTable.find(1)
226
+ p = record.lonlat # Returns an RGeo::Feature::Point
227
+ puts p.x # displays the x coordinate
228
+ puts p.geometry_type.type_name # displays "Point"
229
+
230
+ 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:
231
+
232
+ factory = p.factory # returns a spherical factory
233
+
234
+ 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.
235
+
236
+ record.lonlat = 'POINT(-122, 47)' # sets the value to the given point
237
+
238
+ If the WKT parsing fails, the value currently will be silently set to nil. In the future, however, this will raise an exception.
239
+
240
+ record.lonlat = 'POINT(x)' # sets the value to nil
241
+
242
+ 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.
243
+
244
+ p2 = factory.point(-122, 47) # p2 is a point in a spherical factory
245
+ record.lonlat = p2 # sets the value to the given point
246
+ record.shape1 = p2 # shape1 uses a flat geos factory, so it
247
+ # will cast p2 into that coordinate system
248
+ # before setting the value
249
+ record.save
250
+
251
+ 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.
252
+
253
+ record.path = p2 # This will appear to work, but...
254
+ record.save # This will raise an exception from the database
255
+
256
+ === Spatial Queries
257
+
258
+ You can create simple queries based on representational equality in the same way you would on a scalar column:
259
+
260
+ record2 = MySpatialTable.where(:lonlat => factory.point(-122, 47)).first
261
+
262
+ You can also use WKT:
263
+
264
+ record3 = MySpatialTable.where(:lonlat => 'POINT(-122 47)').first
265
+
266
+ 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.
267
+
268
+ 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.
269
+
270
+ 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:
271
+
272
+ SELECT * FROM my_spatial_table WHERE ST_Intersects(lonlat, <i>my-polygon</i>);
273
+
274
+ Using squeel, you can write this as follows:
275
+
276
+ my_polygon = get_my_polygon() # Obtain the polygon as an RGeo geometry
277
+ MySpatialTable.where{st_intersects(lonlat, my_polygon)}.first
278
+
279
+ 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.
280
+
281
+ 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:
282
+
283
+ sw = get_sw_corner_in_projected_coordinates()
284
+ ne = get_ne_corner_in_projected_coordinates()
285
+ window = RGeo::Cartesian::BoundingBox.create_from_points(sw, ne)
286
+ MySpatialTable.where{path.op('&&', window)}.all
287
+
288
+ 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.
289
+
290
+ == License
291
+
292
+ https://github.com/neighborland/activerecord-postgis-adapter/LICENSE.txt
data/History.rdoc ADDED
@@ -0,0 +1,147 @@
1
+ === 0.7.0
2
+
3
+ * Require ruby 2.0
4
+ * Require ActiveRecord 4.0
5
+ * Drop JRuby support
6
+
7
+ === 0.6.5 / 2013-06-24
8
+
9
+ * Fixed stoopid syntax errors in rake db:gis:setup tass. (Pull requests by rhodrid and jdurand)
10
+
11
+ === 0.6.4 / 2013-05-28
12
+
13
+ * Fixed a crash with array conversions in Rails 4. (Contributed by Christopher Bull)
14
+ * The gis setup task was broken in any Rails other than 3.2.x. Fixed (I think). (Reports by Rupert de Guzman and slbug)
15
+ * Raise a more useful exception for the (as yet) unsupported combination of Rails 4 and JRuby.
16
+
17
+ === 0.6.3 / 2013-05-04
18
+
19
+ * Several fixes for compatibility with changes to Rails 4.0.0 rc1. (Reports by slbug and Victor Costan)
20
+ * Rails 3 rake tasks properly set PGUSER when appropriate. (Pull request by Mitin Pavel)
21
+ * Fixed a nil exception on some Rails 4 migrations. (Pull request by ivanfoong and Victor Costan)
22
+
23
+ === 0.6.2 / 2013-03-08
24
+
25
+ * The PostGIS setup now properly connects as the superuser. (Reported by Adam Trilling)
26
+ * Fix database setup rake tasks under jruby/jdbc adapter. (Pull request by Nick Muerdter)
27
+ * Drop table no longer tries to modify the geometry_columns view under PostGIS 2.0.
28
+ * The Rakefile is now compatible with RubyGems 2.0.
29
+
30
+ === 0.6.1 / 2013-02-28
31
+
32
+ * Fixed some gem loading issues.
33
+
34
+ === 0.6.0 / 2013-02-28
35
+
36
+ * Experimental support for the recently released Rails 4.0 beta.
37
+ * Documentation improvements.
38
+
39
+ === 0.5.1 / 2013-02-04
40
+
41
+ * Database creation properly treats geometry_columns as a view when setting owner. (Pull request by hendrikstier)
42
+ * Provide rake db:gis:setup task. (Pull request by Cody Russell)
43
+ * Modifications for compatibility with postgres_ext. (Pull request by legendetm)
44
+ * SpatialTableDefinition properly subclasses the Postgres-specific table definition class, if available. (Pull request by Joe Noon)
45
+ * Database creation script no longer fails if the username includes weird characters. (Contributed by Toms Mikoss)
46
+ * Updates for compatibility with jdbc-postgres 9.2.1002.1
47
+
48
+ === 0.5.0 / 2012-12-12
49
+
50
+ 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.
51
+
52
+ * Add JRuby compatibility with the activerecord-jdbcpostgresql-adapter gem. (Pull request by Nick Muerdter)
53
+ * Allow WKT to be to be specified as a string-like object rather than having to be a String. (Pull request by Bryan Larsen)
54
+ * Ignore postgis_topology tables 'layer' and 'topology' in rake db:schema:dump. (Pull request by Greg Phillips)
55
+ * Create schemas specified in schema_search_path only if they don't exist. (Pull request by legendetm)
56
+ * Force the postgis_topology extension be created in the topology schema. (Pull request by Dimitri Roche)
57
+ * Specifically set the ownership of the postgis related tables to the regular user. (Pull request by corneverbruggen)
58
+ * The gemspec no longer includes the timestamp in the version, so that bundler can pull from github. (Reported by corneverbruggen)
59
+ * Update tests for PostGIS 2.0 compatibility.
60
+ * Travis-CI integration. (Pull request by Nick Muerdter)
61
+ * Add a missing srid in the Readme. (Pull request by gouthamvel)
62
+ * Readme clarifies that BoundingBox objects can be used in a query only for projected coordinate systems. (Reported by Tee Parham)
63
+ * Update URLs to point to new website.
64
+
65
+ === 0.4.3 / 2012-04-13
66
+
67
+ * 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.
68
+
69
+ === 0.4.2 / 2012-04-12
70
+
71
+ * Support the db:structure:load rake task in recent versions of Rails.
72
+ * Support installing PostGIS via the PostgreSQL extension mechanism (requires at least PostGIS 2.0 and PostgreSQL 9.1).
73
+ * Support bounding boxes in queries (useful for "window" queries such as finding objects to display in a map region).
74
+ * Fix some issues determine the correct default value for spatial columns.
75
+
76
+ === 0.4.1 / 2012-02-22
77
+
78
+ * Some compatibility fixes for Rails 3.2. (Reported by Ryan Williams with implementation help from Radek Paviensky.)
79
+ * Now requires rgeo-activerecord 0.4.3.
80
+
81
+ === 0.4.0 / 2011-08-15
82
+
83
+ * Various fixes for Rails 3.1 compatibility.
84
+ * Now requires rgeo-activerecord 0.4.0.
85
+ * 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.
86
+
87
+ === 0.3.6 / 2011-06-21
88
+
89
+ * Require latest rgeo-activerecord to get some fixes.
90
+ * Note PostgreSQL 9 requirement in the README. (Reported by Samuel Cochran)
91
+ * Now doesn't throw exceptions if an RGeo cast fails when setting an attribute.
92
+
93
+ === 0.3.5 / 2011-04-12
94
+
95
+ * The .gemspec was missing the databases.rake file. Fixed.
96
+
97
+ === 0.3.4 / 2011-04-11
98
+
99
+ * A .gemspec file is now available for gem building and bundler git integration.
100
+
101
+ === 0.3.3 / 2011-02-28
102
+
103
+ * INCOMPATIBLE CHANGE: the default SRID for non-geography columns is now -1, rather than 4326. (Geography columns still default to 4326.)
104
+ * 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)
105
+ * Now requires rgeo-activerecord 0.3.1 (which brings a critical fix involving declaring multiple spatial columns in a migration).
106
+
107
+ === 0.3.2 / 2011-02-11
108
+
109
+ * 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.
110
+ * Database creation tasks automatically create all schemas listed in the schema search path.
111
+
112
+ === 0.3.1 / 2011-02-01
113
+
114
+ * Fixed a syntax error that prevented the adapter from loading on Ruby 1.8. Whoops. (Reported by miguelperez)
115
+
116
+ === 0.3.0 / 2011-01-26
117
+
118
+ * Reworked type and constraint handling, which should result in a large number of bug fixes, especially related to schema dumps.
119
+ * Experimental support for complex spatial queries. (Requires Arel 2.1, which is expected to be released with Rails 3.1.)
120
+ * The path to the Railtie is now different (see the README), though a compatibility wrapper has been left in the old location.
121
+ * Getting index information from the ActiveRecord class now properly recognizes spatial-ness.
122
+ * Reorganized the code a bit for better clarity.
123
+
124
+ === 0.2.3 / 2011-01-06
125
+
126
+ * 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.)
127
+ * Dumping schema.rb now omits the PostGIS internal tables.
128
+ * Added a new configuration parameter pointing to the script directory, for rake db:create.
129
+ * 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.
130
+
131
+ === 0.2.2 / 2010-12-27
132
+
133
+ * Support for basic spatial equality queries. e.g. constructs such as:
134
+ MyClass.where(:geom_column => factory.point(1, 2))
135
+ MyClass.where(:geom_column => 'POINT(1 2)')
136
+ * Fixed an exception when adding spatial columns where the column name is specified as a symbol.
137
+
138
+ === 0.2.1 / 2010-12-15
139
+
140
+ * Provides meta-information to RGeo 0.2.2 or later to support access to PostGIS's spatial reference system table.
141
+
142
+ === 0.2.0 / 2010-12-07
143
+
144
+ * Initial public alpha release. Spun activerecord-postgis-adapter off from the core rgeo gem.
145
+ * You can now set the factory for a specific column by name.
146
+
147
+ For earlier history, see the History file for the rgeo gem.
data/LICENSE.txt ADDED
@@ -0,0 +1,29 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Copyright 2012 Daniel Azuma
3
+ #
4
+ # All rights reserved.
5
+ #
6
+ # Redistribution and use in source and binary forms, with or without
7
+ # modification, are permitted provided that the following conditions are met:
8
+ #
9
+ # * Redistributions of source code must retain the above copyright notice,
10
+ # this list of conditions and the following disclaimer.
11
+ # * Redistributions in binary form must reproduce the above copyright notice,
12
+ # this list of conditions and the following disclaimer in the documentation
13
+ # and/or other materials provided with the distribution.
14
+ # * Neither the name of the copyright holder, nor the names of any other
15
+ # contributors to this software, may be used to endorse or promote products
16
+ # derived from this software without specific prior written permission.
17
+ #
18
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
+ # POSSIBILITY OF SUCH DAMAGE.
29
+ # -----------------------------------------------------------------------------