Re: Multiply and Divide operators for geometry types

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: Multiply and Divide operators for geometry types
Дата
Msg-id 20020411030451.7a5b3629.alvherre@atentus.com
обсуждение исходный текст
Ответ на Re: Multiply and Divide operators for geometry types  (Alvaro Herrera <alvherre@atentus.com>)
Ответы Re: Multiply and Divide operators for geometry types  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
En Thu, 11 Apr 2002 02:36:30 -0400
Alvaro Herrera <alvherre@atentus.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")

В списке pgsql-general по дате отправления:

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: Multiply and Divide operators for geometry types
Следующее
От: Curt Sampson
Дата:
Сообщение: Importing Large Amounts of Data