Skip to content
Permalink
Browse files

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
  • Loading branch information
rouault committed Sep 23, 2015
1 parent c00e84a commit f10f24df536a84cf20fb7210d29832692ca45c1e
Showing with 4,282 additions and 4,113 deletions.
  1. +69 −0 create_mapaxisorder_csv.py
  2. +108 −10 mapaxisorder.csv
  3. +4,103 −4,103 mapaxisorder.h
  4. +2 −0 mapaxisorder.sh
@@ -0,0 +1,69 @@
#!/usr/bin/env python
###############################################################################
# Project: MapServer
# Purpose: Generate the list of EPSG SRS codes that need axis inversion
# Author: Even Rouault <even dot rouault at spatialys dot com
#
###############################################################################
# Copyright (c) 2015, Even Rouault <even dot rouault at spatialys dot com
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
###############################################################################

# This requires the EPSG database to be loaded.
# See https://trac.osgeo.org/geotiff/browser/trunk/libgeotiff/csv/README

from osgeo import ogr
ds = ogr.Open('PG:dbname=epsg')

sql_lyr = ds.ExecuteSQL("""SELECT *
FROM epsg_coordinatereferencesystem
WHERE coord_sys_code IN
(
SELECT CAA.coord_sys_code
FROM epsg_coordinateaxis AS CAA
INNER JOIN epsg_coordinateaxis AS CAB ON CAA.coord_sys_code = CAB.coord_sys_code
WHERE
CAA.coord_axis_order=1 AND CAB.coord_axis_order=2
AND
(
( CAA.coord_axis_orientation ILIKE 'north%' AND CAB.coord_axis_orientation ILIKE 'east%' )
OR
( CAA.coord_axis_orientation ILIKE 'south%' AND CAB.coord_axis_orientation ILIKE 'west%' )
)
) AND coord_ref_sys_code <= 32767
ORDER BY coord_ref_sys_code""")

print('epsg_code')
for f in sql_lyr:
print(f['coord_ref_sys_code'])


# Could work but GDAL doesn't support 3D geographical SRS at the moment
if False:
from osgeo import gdal, osr

sr = osr.SpatialReference()
print('epsg_code')
for code in range(32767):
gdal.PushErrorHandler()
ret = sr.ImportFromEPSGA(code)
gdal.PopErrorHandler()
if ret == 0 and (sr.EPSGTreatsAsLatLong() or sr.EPSGTreatsAsNorthingEasting()):
print(code)
@@ -1,13 +1,4 @@
epsg_code
4326
4258
31466
31467
31468
31469
2166
2167
2168
2036
2044
2045
@@ -51,6 +42,9 @@ epsg_code
2130
2131
2132
2166
2167
2168
2169
2170
2171
@@ -858,6 +852,7 @@ epsg_code
4255
4256
4257
4258
4259
4260
4261
@@ -919,6 +914,7 @@ epsg_code
4319
4322
4324
4326
4327
4329
4339
@@ -1458,7 +1454,6 @@ epsg_code
5479
5480
5481
5482
5488
5489
5513
@@ -1523,6 +1518,105 @@ epsg_code
5815
5816
5830
5885
5886
6134
6135
6207
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6318
6319
6321
6322
6324
6325
6362
6364
6365
6372
6381
6382
6383
6384
6385
6386
6387
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6705
6706
6707
6708
6709
6782
6783
6870
6875
6876
6881
6882
6883
6892
6894
6962
6979
6980
6982
6983
6986
6987
6989
6990
20004
20005
20006
@@ -1785,4 +1879,8 @@ epsg_code
31288
31289
31290
31466
31467
31468
31469
31700

0 comments on commit f10f24d

Please sign in to comment.
You can’t perform that action at this time.