我按照设置link想要将PostGIS ActiveRecord Adapter
集成到我的项目中,我的Rails项目已经postgis-and-rails-a-simple-approach安装了postgis
我按照这些步骤前往Working With Spatial Data
启动Rails控制台
c = Spatial.new()
c.lonlat = 'POINT(-122,48)'
2.1.0 :004 > c
+----+--------+------------+------------+-------+------+------+-----+-----+
| id | lonlat | created_at | updated_at | shap1 | shp2 | path | lon | lat |
+----+--------+------------+------------+-------+------+------+-----+-----+
| | | | | | | | | |
+----+--------+------------+------------+-------+------+------+-----+-----+
的database.yml
16 #
17 development:
18 adapter: postgis
19 encoding: unicode
20 database: goodshot_development
21 schema_search_path: public,postgis
迁移文件
class CreateSpatials < ActiveRecord::Migration
def change
create_table :spatials do |t|
t.column :shap1, :geometry
t.geometry :shp2
t.line_string :path, :srid => 3785
t.point :lonlat, :geographic => true
t.point :lon
t.point :lat
t.index :lonlat, :spatial => true
t.timestamps
end
end
end