Skip site navigation (1) Skip section navigation (2)

Re: BUG #5745: geometry bug?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Mike Fowler <mike(at)mlfowler(dot)com>
Cc: Jin <jindiax(at)gmail(dot)com>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5745: geometry bug?
Date: 2010-11-10 17:36:15
Message-ID: 5790.1289410575@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-bugs
Mike Fowler <mike(at)mlfowler(dot)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

In response to

Responses

pgsql-bugs by date

Next:From: Tom LaneDate: 2010-11-10 17:42:51
Subject: Re: BUG #5747: TimeStamps too far into the future are invalid
Previous:From: Mike FowlerDate: 2010-11-10 16:08:48
Subject: Re: BUG #5745: geometry bug?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group