Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#4641 closed enhancement (fixed)

ST_TileEnvelope default geometry precision

Reported by: Algunenano Owned by: pramsey
Priority: medium Milestone: PostGIS 3.1.0
Component: postgis Version: master
Keywords: Cc:

Description

Today I was tinkering with ST_TileEnvelope and projections and notice that things weren't exact.

For example, when transforming 0/0/0 to 4326 I'd expect x to go from -180 to 180; but it is just a tiny bit less:

SELECT ST_AsText( ST_Transform(ST_TileEnvelope(0, 0, 0), 4326));                                                                                         st_astext                           
                                                               
-----------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------
 POLYGON((-179.999999999998 -85.0511287798064,-179.999999999998 85.0511287798064,179.999999999998 85.0511287798064,179.999999
999998 -85.0511287798064,-179.999999999998 -85.0511287798064))

I'm not sure if this is worth fixing, but changing to a more precise input does return the expected 180:

SELECT ST_AsText(ST_Transform(ST_TileEnvelope(0, 0, 0, ST_SetSRID(ST_MakeBox2D(
    ST_Point(- 6378137.0 * pi(), - 6378137.0 * pi()),
    ST_Point(6378137.0 * pi(), 6378137.0 * pi())),3857)), 4326)
);
                                                         st_astext                                                         
---------------------------------------------------------------------------------------------------------------------------
 POLYGON((-180 -85.0511287798066,-180 85.0511287798066,180 85.0511287798066,180 -85.0511287798066,-180 -85.0511287798066))

Any thoughts?

Change History (3)

comment:1 by Paul Ramsey <pramsey@…>, 5 years ago

Resolution: fixed
Status: newclosed

In 57ff7ac/git:

increase precision of the default plane bounds, closes #4641

comment:2 by Paul Ramsey <pramsey@…>, 5 years ago

In 7f44267/git:

repair typo in linestring literal, references #4641

comment:3 by Algunenano, 5 years ago

I'm not sure why updating the default value doesn't require dropping the old one, but it works:

# Select postgis_extensions_upgrade();
NOTICE:  Updating extension postgis 3.1.0dev
NOTICE:  Updating extension postgis_raster 3.1.0dev
NOTICE:  Updating extension postgis_topology 3.1.0dev
NOTICE:  Extension postgis_tiger_geocoder is not available or not packagable for some reason
                    postgis_extensions_upgrade                     
-------------------------------------------------------------------
 Upgrade completed, run SELECT postgis_full_version(); for details
(1 row)


# \df *st_tileenvelope*
                                                                                                                      List of
 functions
 Schema |      Name       | Result data type |                                                                               
            Argument data types                                                                                           | T
ype 
--------+-----------------+------------------+-------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------+--
----
 public | st_tileenvelope | geometry         | zoom integer, x integer, y integer, bounds geometry DEFAULT '0102000020110F000
00200000093107C45F81B73C193107C45F81B73C193107C45F81B734193107C45F81B7341'::geometry, margin double precision DEFAULT 0.0 | f
unc

# SELECT ST_AsText( ST_Transform(ST_TileEnvelope(0, 0, 0), 4326));                                                                                         st_astext                           
                                                         st_astext                                                         
---------------------------------------------------------------------------------------------------------------------------
 POLYGON((-180 -85.0511287798066,-180 85.0511287798066,180 85.0511287798066,180 -85.0511287798066,-180 -85.0511287798066))
(1 row)

So LGTM. Thanks for tackling this, Paul.

Note: See TracTickets for help on using tickets.