Re: postgres 9.2.2 point conversion from polygon doesn't always give accurate center - Mailing list pgsql-bugs

From Tom Lane
Subject Re: postgres 9.2.2 point conversion from polygon doesn't always give accurate center
Date
Msg-id 24313.1359757005@sss.pgh.pa.us
Whole thread Raw
In response to postgres 9.2.2 point conversion from polygon doesn't always give accurate center  (Colin Dunklau <colin.dunklau@gmail.com>)
Responses Re: postgres 9.2.2 point conversion from polygon doesn't always give accurate center
List pgsql-bugs
Colin Dunklau <colin.dunklau@gmail.com> writes:
> 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.

It looks like what the code is actually computing is the average X
position and average Y position of the points listed in the polygon.
I'm not sure how defensible that algorithm is (the comment attached
to it mumbles something about how it should be the weighted means
of the line segments instead).  But for non-convex polygons like
these I'm not sure there's any intuitively correct answer.  If you
want us to change the code to produce the answers you exhibit, you'd
better explain (1) how you got them and (2) why that's the right
answer and the current way is wrong.

            regards, tom lane

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: Violation of primary key constraint
Next
From: Toby Murray
Date:
Subject: Re: Violation of primary key constraint