Skip to content

Commit

Permalink
Use EPSGTreatsAsLatLong and EPSGTreatsAsNorthingEasting to determine …
Browse files Browse the repository at this point in the history
…inverted axis (MapServer#7096)
  • Loading branch information
PatrikSylve authored Jul 8, 2024
1 parent 759ef93 commit a56a91a
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 a56a91a

Please sign in to comment.