当Address
模型具有 RGeo 属性时,有一个典型的模式:
t.st_point :coordinates, geographic: true, srid: 4326
通常它被包裹在RGeo::Geographic::SphericalPointImpl
类中
Realty.last.address.coordinates
#<RGeo::Geographic::SphericalPointImpl:0x2b1a364b429c "POINT (106.5 10.5)">
但在某些情况下,它是用完全不合适的笛卡尔包装器包装的RGeo::Cartesian::PointImpl
Realty.joins(:address).select('realties.id, addresses.coordinates::geometry').first.coordinates
#<RGeo::Cartesian::PointImpl:0x2b1a364a691c "POINT (106.0 10.0)">
我正在使用最新'activerecord-postgis-adapter 3.1.4'
的rails 4.2.4
也许有人知道如何解决这个问题,即coordinates
总是返回实例RGeo::Geographic::SphericalPointImpl
?