Re: polygon && polygon and precision

Поиск
Список
Период
Сортировка
От Kyotaro Horiguchi
Тема Re: polygon && polygon and precision
Дата
Msg-id 20200313.094926.1670626366541216586.horikyota.ntt@gmail.com
обсуждение исходный текст
Ответ на polygon && polygon and precision  (Patrick Dowler <pdowler.cadc@gmail.com>)
Список pgsql-general
Hello, Patrick.

At Thu, 12 Mar 2020 10:16:15 -0700, Patrick Dowler <pdowler.cadc@gmail.com> wrote in 
> I am using polygon datatype with some very small values and discovered that
> the overlaps operator appears to break down and give false positives for
> values smaller than ~1e-6. I have tested this on 9.5 (.3 and .16) and 10.10.

For usability, geometric arithmetics is performed having 1.0E-6 of
tolerance. For example equalness between two floating point values is
defined as:

#define EPSILON 1.0E-06
#define FPeq(A, B)  (fabs((A) - (B)) <= EPSILON)

Point-same-as is defined using the comparison, so the following
comparison gives true.

=# select '(1.5E-06, 0)'::point ~= '(1.0E-06, 0.5E-06)'::point;
 ?column? 
----------
 t

All comparisons are performed taking that degree of tolerance. By a
rough calculation, that tolerance in long-lat coordinate is
corresnponding to that of about 40 meters on the ground.

> To reproduce (these examples only differ in the x-axis exponents) and
> should be false but the first one is t(rue)
> 
> select '((3.0e-07,-2),(9.0e-07,-2),(9.0e-07,1),(3.0e-07,1))'::polygon
>     &&
> '((2.0e-07,-0.1),(2.0e-07,0.1),(2.01e-07,0.1),(2.01e-07,-0.1))'::polygon;
> 
> select '((3.0e-06,-2),(9.0e-06,-2),(9.0e-06,1),(3.0e-06,1))'::polygon
>     &&
> '((2.0e-06,-0.1),(2.0e-06,0.1),(2.01e-06,0.1),(2.01e-06,-0.1))'::polygon;
> 
> Maybe suggests some single-precision floating point use in the
> calculations...

regards.

-- 
Kyotaro Horiguchi
NTT Open Source Software Center



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

Предыдущее
От: Rob Sargent
Дата:
Сообщение: Re: plperl syntax question
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: plperl syntax question