Обсуждение: BUG #2240: length() with geometric types

Поиск
Список
Период
Сортировка

BUG #2240: length() with geometric types

От
"Andreas Erber"
Дата:
The following bug has been logged online:

Bug reference:      2240
Logged by:          Andreas Erber
Email address:      post@andreas-erber.net
PostgreSQL version: 8.0.2
Operating system:   Windows XP
Description:        length() with geometric types
Details:

Hi,

I discovered some strange behaviour:
The length() function returns different results depending on the geometric
data type used as argument.

length(lseg) produces the correct result, i.e. length(lseg('(0,0),(2,0)')) =
2

length(path) always produces the double result (independently from the
length of the path), i.e.
length(path('(0,0),(2,0)')) = 4
length(path('(0,0),(2,0),(4,0),(6,0),(8,0)')) = 16

Is it supposed to be that way? If yes, why?

CU
ae

Re: BUG #2240: length() with geometric types

От
James William Pye
Дата:
On Mon, Feb 06, 2006 at 02:41:39PM +0000, Andreas Erber wrote:
> Hi,
>
> I discovered some strange behaviour:
> The length() function returns different results depending on the geometric
> data type used as argument.
>
> length(lseg) produces the correct result, i.e. length(lseg('(0,0),(2,0)')) =
> 2
>
> length(path) always produces the double result (independently from the
> length of the path), i.e.
> length(path('(0,0),(2,0)')) = 4
> length(path('(0,0),(2,0),(4,0),(6,0),(8,0)')) = 16
>
> Is it supposed to be that way? If yes, why?

Yes.

You specified your path as a closed path. With its "loopback", it's twice as
long.

To specify it as an open path, do path('[(0,0),(2,0)]').

SELECT length(path('[(1,0),(0,0)]')) = '1';
SELECT length(path('(1,0),(0,0)')) = '2';
--
Regards, James William Pye

Re: BUG #2240: length() with geometric types

От
Andreas Erber
Дата:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

sorry to bug you with that. I figured that out, too, in the meantime. I
wonder why the default behaviour of the path-constructor to end up in a
closed path. I would intentionally expect an open path - since I
understand a path as a connection of points that go from a start to a
destination and not necessarily back. If I would like to have a closed
path I would probably use the polygon datatype.

What was the intenion behind some of the geometric datatypes anyway. I
would have liked to work with them (esp. path) but they turned out not
to be very useful. (I cannot append or prepend a point to a path, I
cannot index-access it, I didn't even find a way to cast it to a string).

Is there any further development planned or will you keep this status? I
would prefer to see these datatypes handier in the future so they
probably get more useful.

Thx
CU
ae

James William Pye schrieb:
> On Mon, Feb 06, 2006 at 02:41:39PM +0000, Andreas Erber wrote:
>> Hi,
>>
>> I discovered some strange behaviour:
>> The length() function returns different results depending on the geometric
>> data type used as argument.
>>
>> length(lseg) produces the correct result, i.e. length(lseg('(0,0),(2,0)')) =
>> 2
>>
>> length(path) always produces the double result (independently from the
>> length of the path), i.e.
>> length(path('(0,0),(2,0)')) = 4
>> length(path('(0,0),(2,0),(4,0),(6,0),(8,0)')) = 16
>>
>> Is it supposed to be that way? If yes, why?
>
> Yes.
>
> You specified your path as a closed path. With its "loopback", it's twice as
> long.
>
> To specify it as an open path, do path('[(0,0),(2,0)]').
>
> SELECT length(path('[(1,0),(0,0)]')) = '1';
> SELECT length(path('(1,0),(0,0)')) = '2';

- --
- ------------------------------------------------------
  Information is a weapon of mass destruction
                                          [Faithless]
- ------------------------------------------------------
 Andreas Erber
 Berlin
 Germany
- ----------------------------------------------------
 e-mail  post@andreas-erber.net
 home    http://www.andreas-erber.net
- ----------------------------------------------------
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFD6KhuBzgniz6LxFMRArrzAJ49GKPSOqB+S3ifW/RRzCEPjvMFOQCeMJjn
AJX3rHfm+YEzEcfJv5epuf4=
=6+08
-----END PGP SIGNATURE-----

Вложения