Skip to content

Commit f10f24d

Browse files
committed
Update mapaxisorder.h/.csv to EPSG 8.6 database (#5168)
A new script create_mapaxisorder_csv.py is added to do the refresh of mapaxisorder.csv from a EPSG database
1 parent c00e84a commit f10f24d

4 files changed

+4282
-4113
lines changed

create_mapaxisorder_csv.py

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/usr/bin/env python
2+
###############################################################################
3+
# Project: MapServer
4+
# Purpose: Generate the list of EPSG SRS codes that need axis inversion
5+
# Author: Even Rouault <even dot rouault at spatialys dot com
6+
#
7+
###############################################################################
8+
# Copyright (c) 2015, Even Rouault <even dot rouault at spatialys dot com
9+
#
10+
# Permission is hereby granted, free of charge, to any person obtaining a
11+
# copy of this software and associated documentation files (the "Software"),
12+
# to deal in the Software without restriction, including without limitation
13+
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
14+
# and/or sell copies of the Software, and to permit persons to whom the
15+
# Software is furnished to do so, subject to the following conditions:
16+
#
17+
# The above copyright notice and this permission notice shall be included
18+
# in all copies or substantial portions of the Software.
19+
#
20+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21+
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23+
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26+
# DEALINGS IN THE SOFTWARE.
27+
###############################################################################
28+
29+
# This requires the EPSG database to be loaded.
30+
# See https://trac.osgeo.org/geotiff/browser/trunk/libgeotiff/csv/README
31+
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""")
52+
53+
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()):
69+
print(code)

mapaxisorder.csv

+108-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
11
epsg_code
2-
4326
3-
4258
4-
31466
5-
31467
6-
31468
7-
31469
8-
2166
9-
2167
10-
2168
112
2036
123
2044
134
2045
@@ -51,6 +42,9 @@ epsg_code
5142
2130
5243
2131
5344
2132
45+
2166
46+
2167
47+
2168
5448
2169
5549
2170
5650
2171
@@ -858,6 +852,7 @@ epsg_code
858852
4255
859853
4256
860854
4257
855+
4258
861856
4259
862857
4260
863858
4261
@@ -919,6 +914,7 @@ epsg_code
919914
4319
920915
4322
921916
4324
917+
4326
922918
4327
923919
4329
924920
4339
@@ -1458,7 +1454,6 @@ epsg_code
14581454
5479
14591455
5480
14601456
5481
1461-
5482
14621457
5488
14631458
5489
14641459
5513
@@ -1523,6 +1518,105 @@ epsg_code
15231518
5815
15241519
5816
15251520
5830
1521+
5885
1522+
5886
1523+
6134
1524+
6135
1525+
6207
1526+
6244
1527+
6245
1528+
6246
1529+
6247
1530+
6248
1531+
6249
1532+
6250
1533+
6251
1534+
6252
1535+
6253
1536+
6254
1537+
6255
1538+
6256
1539+
6257
1540+
6258
1541+
6259
1542+
6260
1543+
6261
1544+
6262
1545+
6263
1546+
6264
1547+
6265
1548+
6266
1549+
6267
1550+
6268
1551+
6269
1552+
6270
1553+
6271
1554+
6272
1555+
6273
1556+
6274
1557+
6275
1558+
6318
1559+
6319
1560+
6321
1561+
6322
1562+
6324
1563+
6325
1564+
6362
1565+
6364
1566+
6365
1567+
6372
1568+
6381
1569+
6382
1570+
6383
1571+
6384
1572+
6385
1573+
6386
1574+
6387
1575+
6667
1576+
6668
1577+
6669
1578+
6670
1579+
6671
1580+
6672
1581+
6673
1582+
6674
1583+
6675
1584+
6676
1585+
6677
1586+
6678
1587+
6679
1588+
6680
1589+
6681
1590+
6682
1591+
6683
1592+
6684
1593+
6685
1594+
6686
1595+
6687
1596+
6705
1597+
6706
1598+
6707
1599+
6708
1600+
6709
1601+
6782
1602+
6783
1603+
6870
1604+
6875
1605+
6876
1606+
6881
1607+
6882
1608+
6883
1609+
6892
1610+
6894
1611+
6962
1612+
6979
1613+
6980
1614+
6982
1615+
6983
1616+
6986
1617+
6987
1618+
6989
1619+
6990
15261620
20004
15271621
20005
15281622
20006
@@ -1785,4 +1879,8 @@ epsg_code
17851879
31288
17861880
31289
17871881
31290
1882+
31466
1883+
31467
1884+
31468
1885+
31469
17881886
31700

0 commit comments

Comments
 (0)