Re: BUG #5745: geometry bug? - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #5745: geometry bug?
Date
Msg-id 5790.1289410575@sss.pgh.pa.us
Whole thread Raw
In response to Re: BUG #5745: geometry bug?  (Mike Fowler <mike@mlfowler.com>)
Responses Re: BUG #5745: geometry bug?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
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

pgsql-bugs by date:

Previous
From: "Kurt Stam"
Date:
Subject: BUG #5747: TimeStamps too far into the future are invalid
Next
From: Tom Lane
Date:
Subject: Re: BUG #5747: TimeStamps too far into the future are invalid