PostGIS: geometric shapes crossing 180 meridian

How to deal with a problem of intersection of geometry shape (linestring, polygon) and 180 meridian?

I have polygons distributed all over the Earth globe, some of them intersecting 180 meridian.

The problem is, to define a polygon being over the 180 meridian, I have to split it into two. I couldn't find a way to define a polygon from let say +170 to -170 meridian.

What I already tried - shift the -180/+180 system to 0/+360 system, which does not solves the problem, it just moves it to a different position of the globe.

I can split the polygons which are placed over 180 meridian but I would like to avoid this.

My goal is to check intersection of linestrings and polygons without limitation of splitting the globe. Is there any way to define geometric shapes (polygons, linestrings) without the limit of splitting them if they intersect 180 meridian?

• How can you possibly avoid splitting the polygon outside the the date line? It's valid to have a `geometry` that starts at longitude +179 and extends to longitude +181, but if you have other data from -180 to -179, they won't overlap (unless you represent it (and everything else) twice, once on either side of the dateline). There are index consequences to having a geometry that spans the globe in two parts, but there are also consequences for storing the parts as separate features. In the end, this becomes a personal preference as to how to model it. Commented Jan 19, 2022 at 14:47
• Could you provide an example of your polygons and an example of the interect check you're trying to do. I think you could probably get away with some fancy SQL to only do the shift_longitude where applicable
– RedM
Commented Jan 21, 2022 at 8:46
• I have polygons distributed all over the globe, all together they cross every meridian. I will have linestrings (flight paths) also distributed in the same way. So with shift_longitude it could get messy to decide when to use and when not to. I will prepare some example and will add it here. Commented Jan 24, 2022 at 7:31