Skip to content

Commit f4846fa

Browse files
committed
Update mapaxisorder.h/.csv to EPSG 9.7.0 database
1 parent d2e0517 commit f4846fa

File tree

3 files changed

+402
-149
lines changed

3 files changed

+402
-149
lines changed

Diff for: create_mapaxisorder_csv.py

+13-37
Original file line numberDiff line numberDiff line change
@@ -26,44 +26,20 @@
2626
# DEALINGS IN THE SOFTWARE.
2727
###############################################################################
2828

29-
# This requires the EPSG database to be loaded.
30-
# See https://trac.osgeo.org/geotiff/browser/trunk/libgeotiff/csv/README
29+
# To be run with GDAL 3.1
3130

32-
from osgeo import ogr
33-
ds = ogr.Open('PG:dbname=epsg')
34-
35-
sql_lyr = ds.ExecuteSQL("""SELECT *
36-
FROM epsg_coordinatereferencesystem
37-
WHERE coord_sys_code IN
38-
(
39-
SELECT CAA.coord_sys_code
40-
FROM epsg_coordinateaxis AS CAA
41-
INNER JOIN epsg_coordinateaxis AS CAB ON CAA.coord_sys_code = CAB.coord_sys_code
42-
WHERE
43-
CAA.coord_axis_order=1 AND CAB.coord_axis_order=2
44-
AND
45-
(
46-
( CAA.coord_axis_orientation ILIKE 'north%' AND CAB.coord_axis_orientation ILIKE 'east%' )
47-
OR
48-
( CAA.coord_axis_orientation ILIKE 'south%' AND CAB.coord_axis_orientation ILIKE 'west%' )
49-
)
50-
) AND coord_ref_sys_code <= 32767
51-
ORDER BY coord_ref_sys_code""")
31+
from osgeo import gdal, osr
5232

33+
sr = osr.SpatialReference()
5334
print('epsg_code')
54-
for f in sql_lyr:
55-
print(f['coord_ref_sys_code'])
56-
57-
58-
# Could work but GDAL doesn't support 3D geographical SRS at the moment
59-
if False:
60-
from osgeo import gdal, osr
61-
62-
sr = osr.SpatialReference()
63-
print('epsg_code')
64-
for code in range(32767):
65-
gdal.PushErrorHandler()
66-
ret = sr.ImportFromEPSGA(code)
67-
gdal.PopErrorHandler()
68-
if ret == 0 and (sr.EPSGTreatsAsLatLong() or sr.EPSGTreatsAsNorthingEasting()):
35+
for code in range(32767):
36+
gdal.PushErrorHandler()
37+
ret = sr.ImportFromEPSGA(code)
38+
gdal.PopErrorHandler()
39+
if ret == 0 and sr.GetAxesCount() >= 2:
40+
first_axis = sr.GetAxisOrientation(None, 0)
41+
second_axis = sr.GetAxisOrientation(None, 1)
42+
if first_axis == osr.OAO_North and second_axis == osr.OAO_East:
43+
print(code)
44+
elif first_axis == osr.OAO_South and second_axis == osr.OAO_West:
6945
print(code)

0 commit comments

Comments
 (0)