[BUGS] postgres 9.2.2 point conversion from polygon doesn't always give accurate center

2013-02-01 Thread Colin Dunklau
Hello! I believe I've found a bug in the type conversion process from
polygon to point.

In the documentation found here
http://www.postgresql.org/docs/9.2/interactive/functions-geometry.html,

Table 9-32 claims that running the point() function on a polygon
returns the "center of polygon". This is not the case for some
polygons, as shown below.

I'm running postgres 9.2.2, on Mac 10.8. This is a fresh install of
Postgres.app from http://postgresapp.com/ :

frink:~ cdunklau$ psql
psql (9.2.2)
Type "help" for help.

For the below two queries, I expect to get a result of (0.5, 0.5).

cdunklau=# select point( polygon '((0,0),(0,1),(1,1),(0,1))');
point
-
 (0.25,0.75)
(1 row)

cdunklau=# select point( polygon '((0,0),(1,0),(1,1),(1,0))');
point
-
 (0.75,0.25)
(1 row)


The conversion does indeed work as expected for other polygons:

cdunklau=# select point( polygon '((-1,-1),(-1,1),(1,1),(1,-1))');
 point
---
 (0,0)
(1 row)


Please let me know if you have problems reproducing this error, or if
I can assist in any way to isolate the problem. I had hoped to use the
type conversion to replace center-finding application logic, but it
appears I'll need to keep the application logic at least until this
bug is fixed.

Best regards,

Colin Dunklau


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs


Re: [BUGS] postgres 9.2.2 point conversion from polygon doesn't always give accurate center

2013-02-04 Thread Colin Dunklau
You nailed it, stupid typos.

Sorry for the inconvenience, and thank you all for your assistance.

On Sun, Feb 3, 2013 at 3:33 AM, Simon Riggs  wrote:
> On 1 February 2013 17:54, Colin Dunklau  wrote:
>
>> For the below two queries, I expect to get a result of (0.5, 0.5).
>>
>> cdunklau=# select point( polygon '((0,0),(0,1),(1,1),(0,1))');
>> point
>> -
>>  (0.25,0.75)
>> (1 row)
>>
>
> I think you just simply mistyped the coordinates...
>
> sriggs=# select point( polygon '((0,0),(0,1),(1,1),(1,0))');
>point
> ---
>  (0.5,0.5)
> (1 row)
>
> Your last point is a duplicate of the 2nd point, so you have a
> 4-pointed triangle and hence a strange centre.
>
> --
>  Simon Riggs   http://www.2ndQuadrant.com/
>  PostgreSQL Development, 24x7 Support, Training & Services


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs