문제

I'm using the rgeo gem in conjunction with the activerecord-postgis-adapter gem for some columns, and I'm wanting the change an option for an existing column

Allow me to show it this way, in the schema.rb file, currently this is the line recording the column

t.spatial  "shape", :limit => {:srid=>0, :type=>"multi_polygon"}

So this column has some special metatag options recognized by postgis.

I want to set the default srid of these :shape columns from 0 to 4326. I'd either like to do this with a migration, or even better, to be able to set the values for these points individually. Currently, I haven't located a setter method in the RGeo documentation for the :srid tag, only a reader. So I'm thinking my best bet is a migration.

I've tried this:

change_column :parcels, :shape, :srid, 4326

But got this error:

==  AddSridOptToShapes: migrating =============================================
-- change_column(:zones, :shape, :srid, 4326)
rake aborted!
An error has occurred, this and all later migrations canceled:

can't convert Symbol into Integer

I know that its possible to solve this problem by executing a string of SQL, but am hoping active record provides a way as well

도움이 되었습니까?

해결책

I solved this problem by simply creating a new column, and in my case, on for every projection I needed to use with a particular shapefile record

:proj_shape_0
:proj_shape_3361
:proj_shape_2264

etc where the number is the srid code

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top