From: PALAYRET Jacques <jacques.palayret@meteo.fr>
To: pgsql-general@lists.postgresql.org
Subject: Circles with circle() vs ST_Buffer() Equality equalities
Date: Fri, 15 May 2020 11:01:55 +0200 (CEST)
Message-ID: <1305841182.3445338.1589533315925.JavaMail.zimbra@meteo.fr> (raw)
Hello,
With PostgreSQL 10.11, I was trying to compare a circle made with the function circle() to the « same » or similar one made thanks to the function ST_Buffer().
-> The circle of type circle : circle('POINT(1 2)'::geometry::point, 0.5::double precision) :
SELECT ST_AsText(polygon(32, circle('POINT(1 2)'::geometry::point, 0.5::double precision))::geometry) AS circle_cast_as_polygon ;
circle_cast_as_polygon
-------------------------------------------------------------------------------------------
POLYGON((0.5 2,0.509607359798385 2.09754516100806,0.538060233744357 2.19134171618254,0.584265193848727 2.2777851165098,0.646446609406726 2.35355339059327,0.722214883490199 2.41573480615127,0.808658283817455 2.46193976625564,0.902454838991936 2.49039264020162,1 2.5,1.09754516100806 2.49039264020162,1.19134171618254 2.46193976625564,1.27778511650982.41573480615127,1.35355339059327 2.35355339059327,1.41573480615127 2.2777851165098,1.46193976625564 2.19134171618254,1.49039264020162 2.09754516100806,1.5 2,1.490392640201621.90245483899194,1.46193976625564 1.80865828381746,1.41573480615127 1.7222148834902,1.35355339059327 1.64644660940673,1.2777851165098 1.58426519384873,1.19134171618255 1.53806023374436,1.09754516100806 1.50960735979838,1 1.5,0.902454838991936 1.50960735979838,0.808658283817455 1.53806023374436,0.722214883490199 1.58426519384873,0.646446609406726 1.64644660940673,0.584265193848727 1.7222148834902,0.538060233744357 1.80865828381745,0.509607359798385 1.90245483899194,0.5 2))
-> The circle of polygon sub-type : ST_Buffer('POINT(1 2)'::geometry, 0.5::double precision) :
SELECT ST_AsText(ST_Buffer('POINT(1 2)'::geometry, 0.5::double precision)) AS circle_as_polygon_via_ST_Buffer ;
circle_as_polygon_via_st_buffer
-------------------------------------------------------------------------------------------
POLYGON((1.5 2,1.49039264020162 1.90245483899194,1.46193976625564 1.80865828381746,1.41573480615127 1.7222148834902,1.35355339059327 1.64644660940673,1.2777851165098 1.58426519384873,1.19134171618255 1.53806023374436,1.09754516100806 1.50960735979838,1 1.5,0.902454838991937 1.50960735979838,0.808658283817456 1.53806023374436,0.7222148834902 1.58426519384873,0.646446609406727 1.64644660940673,0.584265193848728 1.7222148834902,0.538060233744357 1.80865828381745,0.509607359798385 1.90245483899193,0.5 2,0.509607359798384 2.09754516100806,0.538060233744356 2.19134171618254,0.584265193848726 2.2777851165098,0.646446609406725 2.35355339059327,0.722214883490197 2.41573480615127,0.808658283817453 2.46193976625564,0.902454838991934 2.49039264020161,0.999999999999998 2.5,1.09754516100806 2.49039264020162,1.19134171618254 2.46193976625564,1.2777851165098 2.41573480615127,1.35355339059327 2.35355339059327,1.41573480615127 2.2777851165098,1.46193976625564 2.19134171618255,1.49039264020161 2.09754516100807,1.5 2))
Comparison :
SELECT ST_OrderingEquals(ST_Buffer('POINT(1 2)'::geometry, 0.5::double precision) , polygon(32, circle('POINT(1 2)'::geometry::point, 0.5::double precision))::geometry) ;
st_orderingequals
-------------------
f
-> OK, with an ordering polygon equality
=> But, I was surprised by the result of the following 2 SQL queries, in particular by the second one :
SELECT ST_Equals(ST_Buffer('POINT(1 2)'::geometry, 0.5::double precision) , polygon(32, circle('POINT(1 2)'::geometry::point, 0.5::double precision))::geometry) ;
st_equals
-----------
f <= weird for me !
SELECT ST_Buffer('POINT(1 2)'::geometry, 0.5::double precision) = polygon(32, circle('POINT(1 2)'::geometry::point, 0.5::double precision))::geometry AS BounderingEquals ;
bounderingequals
------------------
f <= weird for me !
Details (OK) :
SELECT box(polygon(32, circle('POINT(1 2)'::geometry::point, 0.5::double precision))::geometry) AS box_from_circle_through_polygon ;
box_from_circle_through_polygon
---------------------------------
(1.5,2.5),(0.5,1.5)
SELECT box( ST_Buffer('POINT(1 2)'::geometry, 0.5::double precision)) AS box_from_ST_Buffer_polygon ;
box_from_st_buffer_polygon
----------------------------
(1.5,2.5),(0.5,1.5)
SELECT box(polygon(32, circle('POINT(1 2)'::geometry::point, 0.5::double precision))::geometry) = box( ST_Buffer('POINT(1 2)'::geometry, 0.5::double precision)) AS BounderingBoxEquals ;
bounderingboxequals
---------------------
t
=> Have you any explanations on the result (=false) of st_equals (NOT ordering) and bounderingequals ?
Thanks in advance.
Regards
----- 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: <1305841182.3445338.1589533315925.JavaMail.zimbra@meteo.fr>
References: <1305841182.3445338.1589533315925.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