rgeo / activerecord-spatialite-adapter

ActiveRecord connection adapter for SpatiaLite, based on sqlite3 and rgeo
11 stars 14 forks source link

violates Geometry constraint [geom-type or SRID not allowed] #5

Closed wallacyyy closed 11 years ago

wallacyyy commented 11 years ago

Dazuma,

When i tried to follow your example on readme i got this error:

"property_name" violates Geometry constraint [geom-type or SRID not allowed]

And sometimes i got some errors on active record libraries. This gem was tested on the latests versions of active record? My db was perfectly created with all the tables for spatialite, and i'm using the RGeo::Geographic.spherical_factory for the column ( t.point data type)

Thanks in advance.

wallacyyy commented 11 years ago

The query is filling this parameters:

GeomFromText(?,?)

With this values:

["latlng", #<RGeo::Geographic::SphericalPointImpl:0x3ff44974b968 "POINT (120.0 90.0)">], ["latlng", 4055]

wallacyyy commented 11 years ago

Just to clarify (because some ppl have asking me the same question), you need set the value of SRID on the migration file, like this:

t.point :latlon, :srid => 4326

And the geographic implementation... set_rgeo_factory_for_column ( :latlon, RGeo::Geographic.spherical_factory( :srid => 4326 ) )

That was my solution. Cya o/