Re:

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "PATTERSON,JEFF (A-Sonoma,ex1)" <jeff_patterson(at)agilent(dot)com>
Cc: "'pgsql-general(at)postgresql(dot)org'" <pgsql-general(at)postgresql(dot)org>
Subject: Re:
Date: 2002-02-04 22:24:42
Message-ID: 21384.1012861482@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"PATTERSON,JEFF (A-Sonoma,ex1)" <jeff_patterson(at)agilent(dot)com> writes:
> I have done an exhaustive (and exhausting) search of the documentation, the
> pg_tables and the Internet and have discovered to my great dismay that there
> appears to be no way of extracting the x and y coordinates from a geometric
> point. If true, this seems to be a singularity surprisingly close to the
> origin for a project as mature as postgreSQL.

Documentation deficiencies are par for the course around here,
particularly in obscure features originally invented at Berkeley :-(.
But a point is a 2-item float8 array, so:

regression=# \d point_tbl
Table "point_tbl"
Column | Type | Modifiers
--------+-------+-----------
f1 | point |

regression=# select f1, f1[0], f1[1] from point_tbl;
f1 | f1 | f1
------------+-----+------
(0,0) | 0 | 0
(-10,0) | -10 | 0
(-3,4) | -3 | 4
(5.1,34.5) | 5.1 | 34.5
(-5,-12) | -5 | -12
(10,10) | 10 | 10
(6 rows)

regression=# update point_tbl set f1[1] = f1[1] + 1;
UPDATE 6

regression=# select f1, f1[0], f1[1] from point_tbl;
f1 | f1 | f1
------------+-----+------
(0,1) | 0 | 1
(-10,1) | -10 | 1
(-3,5) | -3 | 5
(5.1,35.5) | 5.1 | 35.5
(-5,-11) | -5 | -11
(10,11) | 10 | 11
(6 rows)

regression=#

(Note array origin zero, not 1, for historical reasons ...)

regards, tom lane

In response to

  • at 2002-02-04 22:08:56 from PATTERSON,JEFF (A-Sonoma,ex1)

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2002-02-04 22:26:15 Re: Solaris Performance
Previous Message PATTERSON,JEFF (A-Sonoma,ex1) 2002-02-04 22:08:56