[GENERAL] Geometric, getting x and y co-ordinates from point datatype

From: Stuart Rison <stuart(at)ludwig(dot)ucl(dot)ac(dot)uk>
To: pgsql-general(at)postgresql(dot)org
Subject: [GENERAL] Geometric, getting x and y co-ordinates from point datatype
Date: 1999-06-04 09:58:24
Message-ID: v04020a00b37d50fecaed@[128.40.242.190]
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi there,

Suppose you have a table:

id pos
1 (0,5)
2 (-1,6)
3 (5.5,9.8)

Are there functions to get to the individual coords such that

SELECT id,get_x(pos),get_y(pos) FROM table;

gives

id get_x get_y
1 0 5
2 -1 6
3 5.5 9.8

>From doing a bit of snooping about in the Programmer's Guide, I can only
assume that this would involve a modified version point_out.

Are these functions already out there?
If not, can someone give me pointers to the answer?
Would the solution indeed be a modified version of point_out and if so, can
someone give me the point_out source to work with?
(I don't program in C -hell, I don't really program in anything, I dabble-
but I'm quite happy to experiment)

Regards,

Stuart.

+-------------------------+--------------------------------------+
| Stuart Rison | Ludwig Institute for Cancer Research |
+-------------------------+ 91 Riding House Street |
| Tel. (0171) 878 4041 | London, W1P 8BT, UNITED KINGDOM. |
| Fax. (0171) 878 4040 | stuart(at)ludwig(dot)ucl(dot)ac(dot)uk |
+-------------------------+--------------------------------------+

Responses

Browse pgsql-general by date

  From Date Subject
Next Message James Thompson 1999-06-04 13:49:37 Re: [GENERAL] Embedded SQL in 'C' (cursors)
Previous Message Jim Mercer 1999-06-04 05:49:54 Re: [GENERAL] Question about indexes.