# How do you represent parallel/meridian bounding boxes in a geography column?

This PostGIS one-off query returns true:

``````psql=> select ST_Covers(
ST_SetSRID(ST_MakeBox2D(ST_Point(-180, -30), ST_Point(20, 90)), 4326),
ST_SetSRID(ST_Point(-77.4874420166016, 39.043758392334), 4326));
st_covers
-----------
t
``````

But if you cast both geometries to geographies, it returns false:

``````psql=> select ST_Covers(
ST_SetSRID(ST_MakeBox2D(ST_Point(-180, -30), ST_Point(20, 90)), 4326)::geography,
ST_SetSRID(ST_Point(-77.4874420166016, 39.043758392334), 4326)::geography);
st_covers
-----------
f
``````

I understand from this old question and this other old question that this is because geography uses great circles to connect points in a polygon, not parallels and meridians.

The question is, how do you convert a parallels-and-meridians bounding rectangle to a geography object that covers exactly the same region of the earth? In the real thing, these rectangles go into a table which is then joined against another table with a long list of points, and that table has to use geography for other reasons, so I need these parallel-and-meridian rectangles as geographies so the indices work properly.

When a polygon is more than 180 degree wide, it has the same definition as the smaller polygon going through the other side of the world (that is, a polygon between -179 and +179 (358 degrees wide) is considered as a polygon being 2 degrees wide).

Your box goes from -180 to +20, so the "small" polygon going over Asia, not America, is used, and your point is not in this area.

You can read this related post.

A possible solution would be to break your box in smaller ones - each being less than 180 degrees wide

``````select ST_Covers(
ST_SetSRID(ST_MakeBox2D(ST_Point(-180, -30), ST_Point(-90, 90)), 4326)::geography,
ST_SetSRID(ST_Point(-77.4874420166016, 39.043758392334), 4326)::geography)
OR
ST_Covers(
ST_SetSRID(ST_MakeBox2D(ST_Point(-90, -30), ST_Point(20, 90)), 4326)::geography,
ST_SetSRID(ST_Point(-77.4874420166016, 39.043758392334), 4326)::geography);

?column?
-----------
t
``````