From: Tom Lane <tgl@sss.pgh.pa.us>
To: Mike Fowler <mike@mlfowler.com>
Cc: Jin <jindiax@gmail.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #5745: geometry bug?
Date: Wed, 10 Nov 2010 12:36:15 -0500
Message-ID: <5790.1289410575@sss.pgh.pa.us> (raw)
In-Reply-To: <4CDAC390.9030903@mlfowler.com>
References: <201011101008.oAAA8Xm2028579@wwwmaster.postgresql.org>
<4CDAC390.9030903@mlfowler.com>
Mike Fowler <mike@mlfowler.com> writes:
> On 10/11/10 10:08, Jin wrote:
>> The distance of the horizontal lseg and the point on that is inaccurate.
> From my digging it appears that this is returning the distance between
> the first point in the line and the individual point.
I didn't look into the code yet, but that would match the result.
> The distance of the horizontal lseg and the point is calculated against
> the first point in the line. Should this be calculated against the
> midpoint of the line instead?
The standard geometrical notion of distance between a point and a line
is that you drop the perpendicular from the point to the line, and the
length of that perpendicular is the distance. Now, in the case of a
line segment, the perpendicular might not intersect the segment:
x
|
|
|
+ o-----------------o
in which case I think the distance from the point to the segment's
nearer endpoint is a reasonable definition. In some quick testing
it seems to work that way for every case except a perfectly horizontal
line segment. So I'm thinking somebody fat-fingered the corner case
where the perpendicular would have infinite slope, and it is falling
through to the "take the nearer endpoint" case when it shouldn't.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, mike@mlfowler.com, jindiax@gmail.com
Subject: Re: BUG #5745: geometry bug?
In-Reply-To: <5790.1289410575@sss.pgh.pa.us>
References: <201011101008.oAAA8Xm2028579@wwwmaster.postgresql.org> <4CDAC390.9030903@mlfowler.com> <5790.1289410575@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox