Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jZWEM-0006Ta-Js for pgsql-general@arkaria.postgresql.org; Fri, 15 May 2020 09:02:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jZWEL-0005SE-B0 for pgsql-general@arkaria.postgresql.org; Fri, 15 May 2020 09:02:09 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jZWEK-0005S4-UG for pgsql-general@lists.postgresql.org; Fri, 15 May 2020 09:02:09 +0000 Received: from smtp-zimbra.meteo.fr ([137.129.16.22] helo=celebrian1.meteo.fr) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jZWEC-0002Sd-9H for pgsql-general@lists.postgresql.org; Fri, 15 May 2020 09:02:07 +0000 Received: from localhost (localhost [127.0.0.1]) by celebrian1.meteo.fr (Postfix) with ESMTP id 1CC9E232002 for ; Fri, 15 May 2020 11:01:57 +0200 (CEST) Received: from celebrian1.meteo.fr ([127.0.0.1]) by localhost (celebrian1.meteo.fr [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id keEHja9Cg1S7 for ; Fri, 15 May 2020 11:01:57 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by celebrian1.meteo.fr (Postfix) with ESMTP id 01CD5232003 for ; Fri, 15 May 2020 11:01:57 +0200 (CEST) X-Virus-Scanned: amavisd-new at celebrian1.meteo.fr Received: from celebrian1.meteo.fr ([127.0.0.1]) by localhost (celebrian1.meteo.fr [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id G63lRe-1FOPZ for ; Fri, 15 May 2020 11:01:56 +0200 (CEST) Received: from zumba5.meteo.fr (zumba5 [172.31.9.201]) by celebrian1.meteo.fr (Postfix) with ESMTP id DC861232002 for ; Fri, 15 May 2020 11:01:56 +0200 (CEST) Date: Fri, 15 May 2020 11:01:55 +0200 (CEST) From: PALAYRET Jacques To: pgsql-general@lists.postgresql.org Message-ID: <1305841182.3445338.1589533315925.JavaMail.zimbra@meteo.fr> Subject: Circles with circle() vs ST_Buffer() Equality equalities MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="=_62c62f3f-a2be-4a10-9101-1e3e6a4097e2" X-Originating-IP: [172.31.9.205] X-Mailer: Zimbra 8.7.11_GA_3822 (ZimbraWebClient - FF76 (Win)/8.7.11_GA_3822) Thread-Index: GcmNfuq5AWS/GJROwfXt+fgWNaTXiw== Thread-Topic: Circles with circle() vs ST_Buffer() Equality equalities List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --=_62c62f3f-a2be-4a10-9101-1e3e6a4097e2 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello,=20 With PostgreSQL 10.11, I was trying to compare a circle made with the funct= ion circle() to the =C2=AB same =C2=BB or similar one made thanks to the fu= nction ST_Buffer().=20 -> The circle of type circle : circle('POINT(1 2)'::geometry::point, 0.5::d= ouble precision) :=20 SELECT ST_AsText(polygon(32, circle('POINT(1 2)'::geometry::point, 0.5::dou= ble precision))::geometry) AS circle_cast_as_polygon ;=20 circle_cast_as_polygon=20 ---------------------------------------------------------------------------= ----------------=20 POLYGON((0.5 2,0.509607359798385 2.09754516100806,0.538060233744357 2.19134= 171618254,0.584265193848727 2.2777851165098,0.646446609406726 2.35355339059= 327,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.35355339= 059327 2.35355339059327,1.41573480615127 2.2777851165098,1.46193976625564 2= .19134171618254,1.49039264020162 2.09754516100806,1.5 2,1.490392640201621.9= 0245483899194,1.46193976625564 1.80865828381746,1.41573480615127 1.72221488= 34902,1.35355339059327 1.64644660940673,1.2777851165098 1.58426519384873,1.= 19134171618255 1.53806023374436,1.09754516100806 1.50960735979838,1 1.5,0.9= 02454838991936 1.50960735979838,0.808658283817455 1.53806023374436,0.722214= 883490199 1.58426519384873,0.646446609406726 1.64644660940673,0.58426519384= 8727 1.7222148834902,0.538060233744357 1.80865828381745,0.509607359798385 1= .90245483899194,0.5 2))=20 -> The circle of polygon sub-type : ST_Buffer('POINT(1 2)'::geometry, 0.5::= double precision) :=20 SELECT ST_AsText(ST_Buffer('POINT(1 2)'::geometry, 0.5::double precision)) = AS circle_as_polygon_via_ST_Buffer ;=20 circle_as_polygon_via_st_buffer=20 ---------------------------------------------------------------------------= ----------------=20 POLYGON((1.5 2,1.49039264020162 1.90245483899194,1.46193976625564 1.8086582= 8381746,1.41573480615127 1.7222148834902,1.35355339059327 1.64644660940673,= 1.2777851165098 1.58426519384873,1.19134171618255 1.53806023374436,1.097545= 16100806 1.50960735979838,1 1.5,0.902454838991937 1.50960735979838,0.808658= 283817456 1.53806023374436,0.7222148834902 1.58426519384873,0.6464466094067= 27 1.64644660940673,0.584265193848728 1.7222148834902,0.538060233744357 1.8= 0865828381745,0.509607359798385 1.90245483899193,0.5 2,0.509607359798384 2.= 09754516100806,0.538060233744356 2.19134171618254,0.584265193848726 2.27778= 51165098,0.646446609406725 2.35355339059327,0.722214883490197 2.41573480615= 127,0.808658283817453 2.46193976625564,0.902454838991934 2.49039264020161,0= .999999999999998 2.5,1.09754516100806 2.49039264020162,1.19134171618254 2.4= 6193976625564,1.2777851165098 2.41573480615127,1.35355339059327 2.353553390= 59327,1.41573480615127 2.2777851165098,1.46193976625564 2.19134171618255,1.= 49039264020161 2.09754516100807,1.5 2))=20 Comparison :=20 SELECT ST_OrderingEquals(ST_Buffer('POINT(1 2)'::geometry, 0.5::double prec= ision) , polygon(32, circle('POINT(1 2)'::geometry::point, 0.5::double prec= ision))::geometry) ;=20 st_orderingequals=20 -------------------=20 f=20 -> OK, with an ordering polygon equality=20 =3D> But, I was surprised by the result of the following 2 SQL queries, in = particular by the second one :=20 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) ;=20 st_equals=20 -----------=20 f <=3D weird for me !=20 SELECT ST_Buffer('POINT(1 2)'::geometry, 0.5::double precision) =3D polygon= (32, circle('POINT(1 2)'::geometry::point, 0.5::double precision))::geometr= y AS BounderingEquals ;=20 bounderingequals=20 ------------------=20 f <=3D weird for me !=20 Details (OK) :=20 SELECT box(polygon(32, circle('POINT(1 2)'::geometry::point, 0.5::double pr= ecision))::geometry) AS box_from_circle_through_polygon ;=20 box_from_circle_through_polygon=20 ---------------------------------=20 (1.5,2.5),(0.5,1.5)=20 SELECT box( ST_Buffer('POINT(1 2)'::geometry, 0.5::double precision)) AS bo= x_from_ST_Buffer_polygon ;=20 box_from_st_buffer_polygon=20 ----------------------------=20 (1.5,2.5),(0.5,1.5)=20 SELECT box(polygon(32, circle('POINT(1 2)'::geometry::point, 0.5::double pr= ecision))::geometry) =3D box( ST_Buffer('POINT(1 2)'::geometry, 0.5::double= precision)) AS BounderingBoxEquals ;=20 bounderingboxequals=20 ---------------------=20 t=20 =3D> Have you any explanations on the result (=3Dfalse) of st_equals (NOT o= rdering) and bounderingequals ?=20 Thanks in advance.=20 Regards=20 ----- M=C3=A9t=C3=A9o-France -----=20 PALAYRET JACQUES=20 DCSC/MBD=20 jacques.palayret@meteo.fr=20 Fixe : +33 561078319=20 --=_62c62f3f-a2be-4a10-9101-1e3e6a4097e2 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
Hello,

With PostgreSQL 10.11, I = was trying to compare a circle made with the function circle() to the =C2= =AB same =C2=BB or similar one made thanks to the function ST_Buf= fer().
-> The circle of type circle : circle('POINT(1 2)'::geometry::= point, 0.5::double precision) :
SELECT  ST_AsText(polygon(32, circl= e('POINT(1 2)'::geometry::point, 0.5::double precision))::geometry) AS circ= le_cast_as_polygon ;
        &nb= sp;            =             &nb= sp;            =             circle_c= ast_as_polygon
---------------------------------------------------------= ----------------------------------
 POLYGON((0.5 2,0.50960735979838= 5 2.09754516100806,0.538060233744357 2.19134171618254,0.584265193848727 2.2= 777851165098,0.646446609406726 2.35355339059327,0.722214883490199 2.4157348= 0615127,0.808658283817455 2.46193976625564,0.902454838991936 2.490392640201= 62,1 2.5,1.09754516100806 2.49039264020162,1.19134171618254 2.4619397662556= 4,1.27778511650982.41573480615127,1.35355339059327 2.35355339059327,1.41573= 480615127 2.2777851165098,1.46193976625564 2.19134171618254,1.4903926402016= 2 2.09754516100806,1.5 2,1.490392640201621.90245483899194,1.46193976625564 = 1.80865828381746,1.41573480615127 1.7222148834902,1.35355339059327 1.646446= 60940673,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.64= 6446609406726 1.64644660940673,0.584265193848727 1.7222148834902,0.53806023= 3744357 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&nbs= p; ST_AsText(ST_Buffer('POINT(1 2)'::geometry, 0.5::double precision)) AS c= ircle_as_polygon_via_ST_Buffer  ;
     &nb= sp;            =             &nb= sp;            =             &nb= sp;  circle_as_polygon_via_st_buffer
------------------------------= -------------------------------------------------------------
 POLY= GON((1.5 2,1.49039264020162 1.90245483899194,1.46193976625564 1.80865828381= 746,1.41573480615127 1.7222148834902,1.35355339059327 1.64644660940673,1.27= 77851165098 1.58426519384873,1.19134171618255 1.53806023374436,1.0975451610= 0806 1.50960735979838,1 1.5,0.902454838991937 1.50960735979838,0.8086582838= 17456 1.53806023374436,0.7222148834902 1.58426519384873,0.646446609406727 1= .64644660940673,0.584265193848728 1.7222148834902,0.538060233744357 1.80865= 828381745,0.509607359798385 1.90245483899193,0.5 2,0.509607359798384 2.0975= 4516100806,0.538060233744356 2.19134171618254,0.584265193848726 2.277785116= 5098,0.646446609406725 2.35355339059327,0.722214883490197 2.41573480615127,= 0.808658283817453 2.46193976625564,0.902454838991934 2.49039264020161,0.999= 999999999998 2.5,1.09754516100806 2.49039264020162,1.19134171618254 2.46193= 976625564,1.2777851165098 2.41573480615127,1.35355339059327 2.3535533905932= 7,1.41573480615127 2.2777851165098,1.46193976625564 2.19134171618255,1.4903= 9264020161 2.09754516100807,1.5 2))

Comparison :
SELECT ST_Orderi= ngEquals(ST_Buffer('POINT(1 2)'::geometry, 0.5::double precision) , polygon= (32, circle('POINT(1 2)'::geometry::point, 0.5::double precision))::geometr= y) ;
 st_orderingequals
-------------------
 f
-> = OK, with an ordering polygon equality

=3D> But, I was surprised b= y the result of the following 2 SQL queries, in particular by the second on= e :

SELECT ST_Equals(ST_Buffer('POINT(1 2)'::geometry, 0.5::double p= recision) , polygon(32, circle('POINT(1 2)'::geometry::point, 0.5::double p= recision))::geometry) ;
 st_equals
-----------
 f &= nbsp;           &nbs= p;      <=3D weird for me !
SELECT ST_Buffer= ('POINT(1 2)'::geometry, 0.5::double precision) =3D polygon(32, circle('POI= NT(1 2)'::geometry::point, 0.5::double precision))::geometry AS BounderingE= quals ;
 bounderingequals
------------------
 f &nb= sp;            =       <=3D weird for me !

Details (OK) :=
SELECT box(polygon(32, circle('POINT(1 2)'::geometry::point, 0.5::doubl= e 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::doub= le precision))::geometry) =3D  box( ST_Buffer('POINT(1 2)'::geometry, = 0.5::double precision)) AS BounderingBoxEquals ;
 bounderingboxequa= ls
---------------------
 t

=3D> Have you any explanat= ions on the result (=3Dfalse) of  st_equals (NOT ordering)  and&n= bsp; bounderingequals ?

Thanks in advance.
Regards
----- M=C3=A9t=C3=A9o-France -----
PALAYRET = JACQUES
DCSC/MBD
jacques.palayret@meteo.fr
Fixe : +33 561078319<= /div>
--=_62c62f3f-a2be-4a10-9101-1e3e6a4097e2--