Today I released the first version of postgres_ext-postgis), which extends ActiveRecord to support PostGIS data types and some querying. This is definitely a beta release, but ready to the point where people can play around with it.
With postgres_ext-postgis, you can easily add geometry columns:
create_table :districts do |t| t.geometry :district_boundries end
If you’d like to include your projection or geometry type, just include them as options to your column:
create_table :districts do |t| t.geometry :district_boundries, spatial_type: :multipolygon, srid: 4326 end
Your geometry columns will be typecasted into RGeo objects. You can set your attributes with RGeo objects or EWKT/EWKB strings. EWKT/EWKB strings will be converted to RGeo objects:
user.location = 'SRID=4623;POINT(1 1)'
For now, the only added querying method for ActiveRecord is
The above query will utilize PostGIS’s
ST_CONTAINS to see if the
district_boundries column contains the
user.location. I plan to add
a convience method to convert EWKT strings to RGeo object, something
PostgreExt.geom('SRID=4623;POINT(1 1)'), to make generating
queries from, say, a mobile user’s current location a bit easier.
As I get feedback and use postgres_ext-postgis, more features will get added. Stay tuned!