[postgis-tickets] [PostGIS] #4863: Geometry doesn't contain itself when ST_Scale down

PostGIS trac at osgeo.org
Fri Feb 26 04:11:53 PST 2021


#4863: Geometry doesn't contain itself when ST_Scale down
-----------------------+---------------------------
 Reporter:  Matt Amos  |      Owner:  pramsey
     Type:  defect     |     Status:  new
 Priority:  medium     |  Milestone:  PostGIS 3.1.2
Component:  postgis    |    Version:  3.1.x
 Keywords:             |
-----------------------+---------------------------
 I'm trying to check if a geometry contains a scaled-down version of its
 oriented bounding box, and was expecting the following query to return
 true:

 {{{
 # select st_contains(geometry, st_scale(st_orientedenvelope(geometry),
  'SRID=3857; POINT(0.8 0.8)', st_centroid(geometry))) from (select
  'SRID=3857; POLYGON((-141972.789895508 6755731.24770785,-141935.49511986
  6755733.56891884,-141934.403428904 6755716.1146343,-141971.698204552
  6755713.77835553,-141972.789895508 6755731.24770785))'::geometry as
  geometry) x;
  st_contains
 -------------
  f
 (1 row)
 }}}

 That seemed strange, so I tried exporting the geometries to visualise them
 and it really seemed like it should be true. Then I tried this query (note
 that I'm serialising the scaled geom to EWKB and parsing the result):

 {{{
 # select st_contains(geometry,
  st_geomfromewkb(st_asewkb(st_scale(st_orientedenvelope(geometry),
  'SRID=3857; POINT(0.8 0.8)', st_centroid(geometry))))) from (select
  'SRID=3857; POLYGON((-141972.789895508 6755731.24770785,-141935.49511986
  6755733.56891884,-141934.403428904 6755716.1146343,-141971.698204552
  6755713.77835553,-141972.789895508 6755731.24770785))'::geometry as
  geometry) x;
  st_contains
 -------------
  t
 (1 row)
 }}}

 Just in case I was misunderstanding what ST_Contains is supposed to do, I
 tried with ST_Covers as well and got the same result.

 Post* versions:

 {{{
 # select postgis_full_version();
 postgis_full_version
 -------------------------------------------------------------------------------------------------------------------------------------------------------------------
  POSTGIS="3.1.1 aaf4c79" [EXTENSION] PGSQL="130" GEOS="3.9.0-CAPI-1.16.2"
  PROJ="7.2.1" LIBXML="2.9.10" LIBJSON="0.15" LIBPROTOBUF="1.3.3"
 WAGYU="0.5.0
  (Internal)"
 (1 row)

 # select version();
                                                      version
 ------------------------------------------------------------------------------------------------------------------
  PostgreSQL 13.1 on x86_64-apple-darwin19.6.0, compiled by Apple clang
 version
  12.0.0 (clang-1200.0.32.2), 64-bit
 (1 row)
 }}}

-- 
Ticket URL: <https://trac.osgeo.org/postgis/ticket/4863>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.


More information about the postgis-tickets mailing list