Skip to content

Commit

Permalink
[Backport branch-8-2] Use EPSGTreatsAsLatLong and EPSGTreatsAsNorthin…
Browse files Browse the repository at this point in the history
…gEasting to determine inverted axis (MapServer#7099)
  • Loading branch information
github-actions[bot] authored Jul 8, 2024
1 parent 48c3f49 commit b054904
Show file tree
Hide file tree
Showing 4 changed files with 654 additions and 164 deletions.
36 changes: 26 additions & 10 deletions scripts/mapaxisorder/create_mapaxisorder_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,32 @@

from osgeo import gdal, osr

sr = osr.SpatialReference()
print("epsg_code")
for code in range(32767):

def inverted_axis(code):
gdal.PushErrorHandler()
ret = sr.ImportFromEPSGA(code)
gdal.PopErrorHandler()
if ret == 0 and sr.GetAxesCount() >= 2:
first_axis = sr.GetAxisOrientation(None, 0)
second_axis = sr.GetAxisOrientation(None, 1)
if first_axis == osr.OAO_North and second_axis == osr.OAO_East:
print(code)
elif first_axis == osr.OAO_South and second_axis == osr.OAO_West:
print(code)

if ret == 0 and sr.GetAxesCount() < 2:
return False

if sr.IsGeographic() and sr.EPSGTreatsAsLatLong():
return True
if sr.IsProjected() and sr.EPSGTreatsAsNorthingEasting():
return True

first_axis = sr.GetAxisOrientation(None, 0)
second_axis = sr.GetAxisOrientation(None, 1)
if first_axis == osr.OAO_North and second_axis == osr.OAO_East:
return True
if first_axis == osr.OAO_South and second_axis == osr.OAO_West:
return True

return False


sr = osr.SpatialReference()
print("epsg_code")
for code in range(32767):
if inverted_axis(code):
print(code)
Loading

0 comments on commit b054904

Please sign in to comment.