pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #5745: geometry bug?
4+ messages / 3 participants
[nested] [flat]
* BUG #5745: geometry bug?
@ 2010-11-10 10:08 Jin <jindiax@gmail.com>
0 siblings, 1 reply; 4+ messages in thread
From: Jin @ 2010-11-10 10:08 UTC (permalink / raw)
To: pgsql-bugs
The following bug has been logged online:
Bug reference: 5745
Logged by: Jin
Email address: jindiax@gmail.com
PostgreSQL version: 8.4.5
Operating system: windows xp pro sp3
Description: geometry bug?
Details:
The distance of the horizontal lseg and the point on that is inaccurate.
select point(1.0,1.0) <-> lseg'(0.0,0.0),(2.0,0.0)';
↓
result 1.4142135623731
must be 1.0
P.S.
I'm sorry about if it was already reported.
Because I can't read English well.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: BUG #5745: geometry bug?
@ 2010-11-10 16:08 Mike Fowler <mike@mlfowler.com>
parent: Jin <jindiax@gmail.com>
0 siblings, 1 reply; 4+ messages in thread
From: Mike Fowler @ 2010-11-10 16:08 UTC (permalink / raw)
To: Jin <jindiax@gmail.com>; +Cc: pgsql-bugs
On 10/11/10 10:08, Jin wrote:
> The following bug has been logged online:
>
> Bug reference: 5745
> Logged by: Jin
> Email address: jindiax@gmail.com
> PostgreSQL version: 8.4.5
> Operating system: windows xp pro sp3
> Description: geometry bug?
> Details:
>
> The distance of the horizontal lseg and the point on that is inaccurate.
>
> select point(1.0,1.0)<-> lseg'(0.0,0.0),(2.0,0.0)';
> ↓
> result 1.4142135623731
>
> must be 1.0
>
> P.S.
> I'm sorry about if it was already reported.
> Because I can't read English well.
>
From my digging it appears that this is returning the distance between
the first point in the line and the individual point. To get 1.0 you
would be looking for the the distance between the midpoint of the line
and the individual point which can be achieved with:
SELECT POINT(1.0,1.0) <-> POINT(LSEG'(0.0,0.0),(2.0,0.0)');
Digging through the documentation I can't find anything that says which
point should be used in the line for distance comparisons. So I would
rephrase this bug as:
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?
Regards,
--
Mike Fowler
Registered Linux user: 379787
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: BUG #5745: geometry bug?
@ 2010-11-10 17:36 Tom Lane <tgl@sss.pgh.pa.us>
parent: Mike Fowler <mike@mlfowler.com>
0 siblings, 1 reply; 4+ messages in thread
From: Tom Lane @ 2010-11-10 17:36 UTC (permalink / raw)
To: Mike Fowler <mike@mlfowler.com>; +Cc: Jin <jindiax@gmail.com>; 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
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: BUG #5745: geometry bug?
@ 2010-11-10 18:57 Tom Lane <tgl@sss.pgh.pa.us>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 4+ messages in thread
From: Tom Lane @ 2010-11-10 18:57 UTC (permalink / raw)
To: Mike Fowler <mike@mlfowler.com>; Jin <jindiax@gmail.com>; pgsql-bugs
I wrote:
> 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.
Actually it's more basic than that: the line_construct_pm() function
is just completely bogus for the case of infinite slope. Will fix.
regards, tom lane
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2010-11-10 18:57 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2010-11-10 10:08 BUG #5745: geometry bug? Jin <jindiax@gmail.com>
2010-11-10 16:08 ` Mike Fowler <mike@mlfowler.com>
2010-11-10 17:36 ` Tom Lane <tgl@sss.pgh.pa.us>
2010-11-10 18:57 ` Tom Lane <tgl@sss.pgh.pa.us>
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