0

In SQL, I have geographies stored. I want to check if geography is covering more than half globe, if geography crosses the international dateline or if geography crosses the equator.

I have come up with the below logic, now sure if it is correct.

  1. Geography covering more than half the globe - Is the logic seems the same as point #3
  2. Geography crossing international date line - If the coordinates of the international date line fall within the given coordinates then it seems to cross the international date line
  3. Geography crossing equator - If any of latitude from the given coordinates is <= 0 then it seems crossing the equator

Please correct there is any better logic.

Reyan Chougle
  • 4,917
  • 2
  • 30
  • 57

1 Answers1

0

Not sure what SQL database you use, but most have spatial functions. The syntax and lat/lon order might vary between databases thought.

Larger than hemisphere:

ST_Area(geo) > Earth-surface-area / 2

Crosses antimeridian (date line is slightly different though)

ST_Intersects(geo, ST_GeographyFromText('Linestring(180 -90, 180 0, 180 0)’))

Crosses equator:

ST_Intersects(geo, ST_GeographyFromText('Linestring(-180 0, -60 0, 60 0, 180 0’))

Michael Entin
  • 7,189
  • 3
  • 21
  • 26