'Spliting a table column in 2

I have a this column :

t.geography "longlat", limit: {:srid=>4326, :type=>"st_point", :geographic=>true}

So basically im trying to work with postgis methods,and i need to get this column splited in 2, one with X coordinate data and the other one with y coordinate data.

Edit: My final task is to use this query :

Proba.where("ST_DistanceSphere(ST_MakePoint(x,y),ST_MakePoint(48.33300000000003, 33.0)) <= 500")

To comparare all longlat points to one im manualy putting to se if they are near 500 meters. But i only can make it work with 2 columns x,y not with only one, so im trying to make my longlat column into 2 and separate x and y coordinates.

Edit: photo of select postgis version: enter image description here



Solution 1:[1]

You should be able to do that as follows:

sql = "*, ST_X(my_table.longlat) as x, ST_Y(my_table.longlat) as y"
MyTable.select(sql)

not tested.

====

After your edit, instead of trying to break your field up I think you can use it directly:

Proba.where("ST_DistanceSphere(longlat::geometry,ST_MakePoint(48.33300000000003, 33.0)) <= 500")

again not tested.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1