aboutsummaryrefslogtreecommitdiff
path: root/scripts/build_db.py
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2018-12-06 13:45:24 +0100
committerEven Rouault <even.rouault@spatialys.com>2018-12-06 13:45:24 +0100
commit25fa18055f43d0881a1a2bf9990c99fecfcbdbb7 (patch)
tree8643f1f767cfda8becd58f47edae60dd8af11246 /scripts/build_db.py
parentdccf4658ac4cf9194682350ec292a086a2bb24a1 (diff)
downloadPROJ-25fa18055f43d0881a1a2bf9990c99fecfcbdbb7.tar.gz
PROJ-25fa18055f43d0881a1a2bf9990c99fecfcbdbb7.zip
Take into account supersession information to filter out irrelevant transformations
Diffstat (limited to 'scripts/build_db.py')
-rwxr-xr-xscripts/build_db.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/scripts/build_db.py b/scripts/build_db.py
index 77f53fd9..46bef8c8 100755
--- a/scripts/build_db.py
+++ b/scripts/build_db.py
@@ -518,6 +518,33 @@ def fill_alias(proj_db_cursor):
else:
print('Cannot find datum %s in geodetic_datum or vertical_datum' % (code))
+
+def find_table(proj_db_cursor, code):
+ for table_name in ('helmert_transformation', 'grid_transformation', 'concatenated_operation'):
+ proj_db_cursor.execute('SELECT name FROM %s WHERE code = ?' % table_name, (code,))
+ row = proj_db_cursor.fetchone()
+ if row is not None:
+ return row[0], table_name
+ return None
+
+def fill_supersession(proj_db_cursor):
+ proj_db_cursor.execute("SELECT object_code, superseded_by FROM epsg.epsg_supersession WHERE object_table_name = 'epsg_coordoperation' AND object_code != superseded_by")
+ for row in proj_db_cursor.fetchall():
+ code, superseded_by = row
+ proj_db_cursor.execute('SELECT 1 FROM coordinate_operation_view WHERE code = ?', (code,))
+ if proj_db_cursor.fetchone() is None:
+ print('Skipping supersession of %d since it has not been imported' % code)
+ continue
+
+ src_name, superseded_table_name = find_table(proj_db_cursor, code)
+ dst_name, replacement_table_name = find_table(proj_db_cursor, superseded_by)
+ assert superseded_table_name, row
+ assert replacement_table_name, row
+ if superseded_table_name == 'grid_transformation' and replacement_table_name == 'grid_transformation' and src_name.startswith('NAD27 to NAD83'):
+ print('Skipping supersession of %d (%s) by %d (%s)' % (code, src_name, superseded_by, dst_name))
+ continue
+ proj_db_cursor.execute("INSERT INTO supersession VALUES (?,'EPSG',?,?,'EPSG',?,'EPSG')", (superseded_table_name, code, replacement_table_name, superseded_by))
+
def report_non_imported_operations(proj_db_cursor):
proj_db_cursor.execute("SELECT coord_op_code, coord_op_type, coord_op_name, coord_op_method_code, coord_op_method_name, source_crs_code, target_crs_code, area_of_use_code, coord_op_accuracy, epsg_coordoperation.deprecated FROM epsg.epsg_coordoperation LEFT JOIN epsg.epsg_coordoperationmethod USING (coord_op_method_code) WHERE coord_op_code NOT IN (SELECT code FROM coordinate_operation_with_conversion_view)")
rows = []
@@ -563,6 +590,7 @@ fill_grid_transformation(proj_db_cursor)
fill_other_transformation(proj_db_cursor)
fill_concatenated_operation(proj_db_cursor)
fill_alias(proj_db_cursor)
+fill_supersession(proj_db_cursor)
non_imported_operations = report_non_imported_operations(proj_db_cursor)
proj_db_cursor.close()