From: PALAYRET Jacques <jacques.palayret@meteo.fr>
To: pgsql-general@lists.postgresql.org
Subject: Re: Circles with circle() vs ST_Buffer() Equality equalities
Date: Sat, 16 May 2020 15:09:33 +0200 (CEST)
Message-ID: <1529649361.3955401.1589634573649.JavaMail.zimbra@meteo.fr> (raw)
In-Reply-To: <1305841182.3445338.1589533315925.JavaMail.zimbra@meteo.fr>
References: <1305841182.3445338.1589533315925.JavaMail.zimbra@meteo.fr>
Hello,
Sorry, forget my questions.
I checked the differences between the 2 polygons too quickly.
Actually, I checked only some points and some attributes :
SELECT ST_Area(geometry), ST_Perimeter(geometry), ST_NPoints(ST_ExteriorRing(geometry))
FROM (
SELECT polygon(32, circle('POINT(1 2)'::geometry::point, 0.5::double precision))::geometry
UNION
SELECT ST_Buffer('POINT(1 2)'::geometry, 0.5::double precision)
) t(geometry)
;
st_area | st_perimeter | st_npoints
-------------------+------------------+------------
0.780361288064513 | 3.13654849054594 | 33
0.780361288064513 | 3.13654849054594 | 33
----------> exactly the same results with the 2 polygons
...
----------> But, NOT all the points are identical :
SELECT ST_AsText((g1).geom) FROM (
SELECT st_dumppoints(ST_ExteriorRing(geometry))
FROM (
SELECT polygon(32, circle('POINT(1 2)'::geometry::point, 0.5::double precision))::geometry
) t1(geometry)
)t11(g1)
EXCEPT
SELECT ST_AsText((g2).geom) FROM (
SELECT st_dumppoints(ST_ExteriorRing(geometry))
FROM (
SELECT ST_Buffer('POINT(1 2)'::geometry, 0.5::double precision)
) t2(geometry)
)t22(g2)
ORDER BY 1 ;
st_astext
-------------------------------------------
POINT(0.509607359798385 1.90245483899194)
POINT(0.509607359798385 2.09754516100806)
POINT(0.538060233744357 2.19134171618254)
POINT(0.584265193848727 1.7222148834902)
POINT(0.584265193848727 2.2777851165098)
POINT(0.646446609406726 1.64644660940673)
POINT(0.646446609406726 2.35355339059327)
POINT(0.722214883490199 1.58426519384873)
POINT(0.722214883490199 2.41573480615127)
POINT(0.808658283817455 1.53806023374436)
POINT(0.808658283817455 2.46193976625564)
POINT(0.902454838991936 1.50960735979838)
POINT(0.902454838991936 2.49039264020162)
POINT(1 2.5)
POINT(1.46193976625564 2.19134171618254)
POINT(1.49039264020162 2.09754516100806)
(16 lignes)
SELECT ST_AsText((g1).geom) FROM (
SELECT st_dumppoints(ST_ExteriorRing(geometry))
FROM (
SELECT ST_Buffer('POINT(1 2)'::geometry, 0.5::double precision)
) t1(geometry)
)t11(g1)
EXCEPT
SELECT ST_AsText((g2).geom) FROM (
SELECT st_dumppoints(ST_ExteriorRing(geometry))
FROM (
SELECT polygon(32, circle('POINT(1 2)'::geometry::point, 0.5::double precision))::geometry
) t2(geometry)
)t22(g2)
ORDER BY 1 ;
st_astext
-------------------------------------------
POINT(0.509607359798384 2.09754516100806)
POINT(0.509607359798385 1.90245483899193)
POINT(0.538060233744356 2.19134171618254)
POINT(0.584265193848726 2.2777851165098)
POINT(0.584265193848728 1.7222148834902)
POINT(0.646446609406725 2.35355339059327)
POINT(0.646446609406727 1.64644660940673)
POINT(0.722214883490197 2.41573480615127)
POINT(0.7222148834902 1.58426519384873)
POINT(0.808658283817453 2.46193976625564)
POINT(0.808658283817456 1.53806023374436)
POINT(0.902454838991934 2.49039264020161)
POINT(0.902454838991937 1.50960735979838)
POINT(0.999999999999998 2.5)
POINT(1.46193976625564 2.19134171618255)
POINT(1.49039264020161 2.09754516100807)
(16 lignes)
=> It is a bit weird, but it seems there are slight differences on some points.
For example :
POINT(1 2.5) for polygon(32, circle('POINT(1 2)'::geometry::point, 0.5::double precision))::geometry
and
POINT(0.999999999999998 2.5) for ST_Buffer('POINT(1 2)'::geometry, 0.5::double precision)
I guess it comes from rounding because the start point is not the same for the 2 polygons.
----- Météo-France -----
PALAYRET JACQUES
DCSC/MBD
jacques.palayret@meteo.fr
Fixe : +33 561078319
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: jacques.palayret@meteo.fr
Subject: Re: Circles with circle() vs ST_Buffer() Equality equalities
In-Reply-To: <1529649361.3955401.1589634573649.JavaMail.zimbra@meteo.fr>
References: <1305841182.3445338.1589533315925.JavaMail.zimbra@meteo.fr> <1529649361.3955401.1589634573649.JavaMail.zimbra@meteo.fr>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox