ST_MakeEnvelope in PostGIS to try and make geometries that cross the international dateline (antimeridian), but they are making a shape that wraps the other way around the globe.
The geometry I want is one which covers the eastern half of Australia and the dateline.
It looks something like:
ST_MakeEnvelope(133, -49, -170, 0, 4283)
ST_Intersects(ST_SetSRID(ST_MakePoint(150, -25), 4283), ST_MakeEnvelope(133, -49, -170, 0, 4283));
returns false. The shape goes the wrong way around the world!
If I just take:
ST_Intersects(ST_SetSRID(ST_MakePoint(150, -25), 4283), ST_MakeEnvelope(133, -49, 180,v0, 4283));
I get true, as expected.
How can I set a direction to my envelope? Or should I create a polygon some other way?
(If you're wondering: I'm trying to select geometries in a table for a map view, and when the view includes the dateline, nothing is shown on the map)
If it helps, the box actually arrives in Spherical Mercator, looking something like:
14855319.859171, -6294627.0589708, 21149946.918142, 0
st_transform(st_makeenvelope(14855319.859171, -6294627.0589708, 21149946.918142, 0, 900913), 4283)
Results in geometries with the negative-valued longitudes:
SRID=4283;POLYGON((133.447608799776 -49.1163523261112,133.447608799776 0,-170.006794251165 0,-170.006794251165 -49.1163523261112,133.447608799776 -49.1163523261112))