Forum: Ruby on Rails PostGIS and MySql Spatial Extensions in Rails

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
A262d628c2f154b8eb31626904033227?d=identicon&s=25 Guilhem Vellut (Guest)
on 2006-05-03 18:57
(Received via mailing list)
Hello,

This post is to announce a new release of the Spatial Adapter for Rails,
which is a plugin that adds support for columns of geometric types
(point,
linestring, polygon,etc...) to ActiveRecord. Currently the only
supported
databases are MySql and PostGIS.
With this release, geometric columns should behave like columns of any
other
basic types in all areas: migration, data access, dumping in ruby schema
mode...
For example, here is how you would define a "restaurants" table in a
migration, along with a spatial index on the geometric column:

ActiveRecord::Schema.define do
  create_table "restaurants", :force => true do |t|
    t.column "data", :string
    t.column "geom", :point, :null=>false, :srid => 123
  end

  add_index "restaurants", "geom", :spatial=>true
end

Here is the model to use it:

class Restaurant < ActiveRecord::Base
end

And you would access the geom column in the following way:

rt = Restaurant.find_first
puts rt.geom.x #access the geom column like any other

Documentation and instructions for installation are available at
http://thepochisuperstarmegashow.com/projects/ .

It is distributed under the MIT license.

guilhem
This topic is locked and can not be replied to.