[postgis-users] The_geom from default

Mark Cave-Ayland mark.cave-ayland at ilande.co.uk
Thu May 10 08:22:15 PDT 2007


On Thu, 2007-05-10 at 11:07 -0400, Stephen Crawford wrote:
> All,
> 
> Can 'the_geom' in a spatial table be set to a default to create the geometry
> from the 'lat' and 'lon' columns?  I have table of farms as points that will
> be updated occasionally; what I hope to achieve is that when a farm record
> is added with lat and lon, the 'the_geom' field will automatically be
> populated on insert.  Any good ideas on how to do this?
> 
> Thanks,
> Steve


Hi Steve,

The latitude and longitude are already stored as a POINT in your
'the_geom' column, so you don't actually need extra copies of the data
in 'lat' and 'lon' columns. Once you have created your 'the_geom'
column, the easiest option would be to modify your application SQL to
use something like this:

SELECT X(the_geom) AS lon, Y(the_geom) AS lat FROM mytable

...and then drop the 'lat' and 'lon' columns.


Kind regards,

Mark.

-- 
ILande - Open Source Consultancy
http://www.ilande.co.uk





More information about the postgis-users mailing list