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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Colin Dunklau <colin(dot)dunklau(at)gmail(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: postgres 9.2.2 point conversion from polygon doesn't always give accurate center
Date: 2013-02-01 22:16:45
Message-ID: 24313.1359757005@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Colin Dunklau <colin(dot)dunklau(at)gmail(dot)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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Toby Murray 2013-02-01 23:18:16 Re: Violation of primary key constraint
Previous Message Tom Lane 2013-02-01 21:58:27 Re: Violation of primary key constraint