Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 468FD1337B50 for ; Wed, 10 Nov 2010 13:01:17 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 03553-08 for ; Wed, 10 Nov 2010 17:01:10 +0000 (UTC) X-Greylist: delayed 00:52:16.898504 by SQLgrey-1.7.6 Received: from milan.hostgo.com (milan.hostgo.com [72.52.99.130]) by mail.postgresql.org (Postfix) with ESMTP id D34FE1337B2F for ; Wed, 10 Nov 2010 13:01:09 -0400 (AST) Received: from [217.10.134.34] (helo=[192.168.1.142]) by milan.hostgo.com with esmtpa (Exim 4.69) (envelope-from ) id 1PGDE9-0001zt-Vu; Wed, 10 Nov 2010 11:08:50 -0500 Message-ID: <4CDAC390.9030903@mlfowler.com> Date: Wed, 10 Nov 2010 16:08:48 +0000 From: Mike Fowler User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.10) Gecko/20100527 Thunderbird/3.0.5 MIME-Version: 1.0 To: Jin CC: pgsql-bugs@postgresql.org Subject: Re: BUG #5745: geometry bug? References: <201011101008.oAAA8Xm2028579@wwwmaster.postgresql.org> In-Reply-To: <201011101008.oAAA8Xm2028579@wwwmaster.postgresql.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - milan.hostgo.com X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - mlfowler.com X-Source: X-Source-Args: X-Source-Dir: X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201011/58 X-Sequence-Number: 28638 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