3

This doesn't really effect me but I was just wondering if you find this a little bit strange or not. I think this issue is probably cause of this question also but I think the accepted answer does not apply to my question.

I am using ST_MakeEnvelope and it tax xmin,ymin,xmax,ymax values as arguments.

I realized that for example, if longitude distance is over 180 degrees, it seems to wrap around other way around (That is what I think is happening, I may be wrong?).

I thought it would always go from xmin to xmax. As in xmin=-81 to xmax=100 should go in direction -81,-80,-79...0,1...100 , yet it seems to make a boundary box going other way -81,-82,-83...(+/–)180,179...100

Am I imagining things and is this suppose to work like this? Any reason why this way is better than always assuming we should travel from xmin to xmin+ direction?

SELECT tbl1.column1, tbl2.column1, tbl1.column2 && tbl2.column2 AS overlaps FROM 
( VALUES
(1, 'POINT(0 0)'::geography), 
(2, 'POINT(-85 0)'::geography) ) AS tbl1,
( VALUES
(3, ST_MakeEnvelope(-80, -10, 100, 20, 4326)::geography), 
(4, ST_MakeEnvelope(-81, -10, 100, 20, 4326)::geography)) AS tbl2;

Results in:

 column1 | column1 | overlaps 
---------+---------+----------
       1 |       3 | t
       1 |       4 | f
       2 |       3 | f
       2 |       4 | t
3
  • Antipodal distances are usually either an error or wrapped the great circle direction.
    – Vince
    Nov 27, 2017 at 2:55
  • @JGH yes, I think that issue you linked seems to share the same background. @Vince The question is why function has xmin,xmax arguments yet it is designed to chose smallest area and if this is desired behavior or a bug, and if it is desired why?
    – yurtesen
    Nov 27, 2017 at 5:46

1 Answer 1

2

By the geography advanced FAQ http://postgis.net/docs/using_postgis_dbmanagement.html#idm1391 what you experience is intentional

What is the longest arc you can process?

We use great circle arcs as the "interpolation line" between two points. That means any two points are actually joined up two ways, depending on which direction you travel along the great circle. All our code assumes that the points are joined by the shorter of the two paths along the great circle. As a consequence, shapes that have arcs of more than 180 degrees will not be correctly modelled.

2
  • This is a nice answer. I think somebody should tell postgis people to put information about maximum possible ranges on their documentation.
    – yurtesen
    Nov 28, 2017 at 13:16
  • Great. Now I know why my map works weird. But is there a simple fix for that?
    – Mika
    Nov 19, 2021 at 17:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.