Re: Multiply and Divide operators for geometry types

From: Alvaro Herrera <alvherre(at)atentus(dot)com>
To: Alvaro Herrera <alvherre(at)atentus(dot)com>
Cc: lockhart(at)fourpalms(dot)org, pgsql-general(at)postgresql(dot)org
Subject: Re: Multiply and Divide operators for geometry types
Date: 2002-04-11 07:04:51
Message-ID: 20020411030451.7a5b3629.alvherre@atentus.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

En Thu, 11 Apr 2002 02:36:30 -0400
Alvaro Herrera <alvherre(at)atentus(dot)com> escribió:

> There's something I don't quite understand here. If I do
>
> SELECT box '((2,3),(4,5))' * point '(3,4)';
> ?column?
> -----------------
> (-6,31),(-8,17)
>
> But my complex aritmethic gives me
>
> (-6,17),(-8,31)
>
> As I read in your mail, each point in the box gets multiplied by the
> other point, but this is not the case in the current code (CVS as of
> earlier today... well, yesterday). Is this a bug, or am I understanding
> something wrong?

Well, I don't know whether it's a bug or not, but the code has been like
this since at least 6.3, so if somebody uses this operator he surely
must be used to it being this way by this time.

Anyway, the code is (src/backend/utils/adt/geo_ops.c)

high = DatumGetPointP(DirectFunctionCall2(point_mul,
PointPGetDatum(&box->high),
PointPGetDatum(p)));
low = DatumGetPointP(DirectFunctionCall2(point_mul,
PointPGetDatum(&box->low),
PointPGetDatum(p)));

result = box_construct(high->x, low->x, high->y, low->y);

which gives a nice swap in the variables, since box_construct is
prototyped as
static BOX *box_construct(double x1, double x2, double y1, double y2);

Maybe it's _supposed_ to be like this...

--
Alvaro Herrera (<alvherre[a]atentus.com>)
Officer Krupke, what are we to do?
Gee, officer Krupke, Krup you! (West Side Story, "Gee, Officer Krupke")

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Pierre-Andre Michel 2002-04-11 08:17:09 Why does postgres not take into account my index on a bigint column ?
Previous Message Alvaro Herrera 2002-04-11 06:36:30 Re: Multiply and Divide operators for geometry types