aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/build_db.py19
-rwxr-xr-xscripts/build_db_create_ignf_from_xml.py4
-rwxr-xr-xscripts/build_db_from_esri.py6
3 files changed, 18 insertions, 11 deletions
diff --git a/scripts/build_db.py b/scripts/build_db.py
index 817b226b..47a275f1 100755
--- a/scripts/build_db.py
+++ b/scripts/build_db.py
@@ -167,7 +167,7 @@ def fill_geodetic_datum(proj_db_cursor):
for (datum_code, datum_name, ellipsoid_code, prime_meridian_code, publication_date, frame_reference_epoch, deprecated) in res:
publication_date = compute_publication_date(datum_code, datum_name, frame_reference_epoch, publication_date)
proj_db_cursor.execute(
- "INSERT INTO geodetic_datum VALUES (?, ?, ?, NULL, ?, ?, ?, ?, ?, ?, ?)", (EPSG_AUTHORITY, datum_code, datum_name, EPSG_AUTHORITY, ellipsoid_code, EPSG_AUTHORITY, prime_meridian_code, publication_date, frame_reference_epoch, deprecated))
+ "INSERT INTO geodetic_datum VALUES (?, ?, ?, NULL, ?, ?, ?, ?, ?, ?, NULL, ?)", (EPSG_AUTHORITY, datum_code, datum_name, EPSG_AUTHORITY, ellipsoid_code, EPSG_AUTHORITY, prime_meridian_code, publication_date, frame_reference_epoch, deprecated))
def fill_vertical_datum(proj_db_cursor):
@@ -177,29 +177,36 @@ def fill_vertical_datum(proj_db_cursor):
for (datum_code, datum_name, publication_date, frame_reference_epoch, deprecated) in res:
publication_date = compute_publication_date(datum_code, datum_name, frame_reference_epoch, publication_date)
proj_db_cursor.execute(
- "INSERT INTO vertical_datum VALUES (?, ?, ?, NULL, ?, ?)", (EPSG_AUTHORITY, datum_code, datum_name,publication_date, deprecated))
+ "INSERT INTO vertical_datum VALUES (?, ?, ?, NULL, ?, NULL, ?)", (EPSG_AUTHORITY, datum_code, datum_name,publication_date, deprecated))
def fill_datumensemble(proj_db_cursor):
- proj_db_cursor.execute("SELECT datum_code, datum_name, deprecated FROM epsg.epsg_datum WHERE datum_type = 'ensemble'")
+ proj_db_cursor.execute("SELECT datum_code, datum_name, ensemble_accuracy, deprecated FROM epsg.epsg_datum JOIN epsg.epsg_datumensemble ON datum_code = datum_ensemble_code WHERE datum_type = 'ensemble'")
rows = proj_db_cursor.fetchall()
- for (datum_code, datum_name, deprecated) in rows:
+ for (datum_code, datum_name, ensemble_accuracy, deprecated) in rows:
+ assert ensemble_accuracy is not None
proj_db_cursor.execute("SELECT DISTINCT datum_type, ellipsoid_code, prime_meridian_code FROM epsg.epsg_datum WHERE datum_code IN (SELECT datum_code FROM epsg.epsg_datumensemblemember WHERE datum_ensemble_code = ?)", (datum_code,))
subrows = proj_db_cursor.fetchall()
assert len(subrows) == 1, datum_code
datum_type = subrows[0][0]
if datum_type == 'vertical':
- proj_db_cursor.execute("INSERT INTO vertical_datum (auth_name, code, name, description, publication_date, deprecated) VALUES (?, ?, ?, ?, ?, ?)", (EPSG_AUTHORITY, datum_code, datum_name, None, None, deprecated))
+ datum_ensemble_member_table = 'vertical_datum_ensemble_member'
+ proj_db_cursor.execute("INSERT INTO vertical_datum (auth_name, code, name, description, publication_date, ensemble_accuracy, deprecated) VALUES (?, ?, ?, ?, ?, ?, ?)", (EPSG_AUTHORITY, datum_code, datum_name, None, None, ensemble_accuracy, deprecated))
else:
+ datum_ensemble_member_table = 'geodetic_datum_ensemble_member'
assert datum_type in ('dynamic geodetic', 'geodetic'), datum_code
ellipsoid_code = subrows[0][1]
prime_meridian_code = subrows[0][2]
assert ellipsoid_code, datum_code
assert prime_meridian_code, datum_code
proj_db_cursor.execute(
- "INSERT INTO geodetic_datum (auth_name, code, name, description, ellipsoid_auth_name, ellipsoid_code, prime_meridian_auth_name, prime_meridian_code, publication_date , deprecated) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", (EPSG_AUTHORITY, datum_code, datum_name, None, EPSG_AUTHORITY, ellipsoid_code, EPSG_AUTHORITY, prime_meridian_code, None, deprecated))
+ "INSERT INTO geodetic_datum (auth_name, code, name, description, ellipsoid_auth_name, ellipsoid_code, prime_meridian_auth_name, prime_meridian_code, publication_date , ensemble_accuracy, deprecated) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", (EPSG_AUTHORITY, datum_code, datum_name, None, EPSG_AUTHORITY, ellipsoid_code, EPSG_AUTHORITY, prime_meridian_code, None, ensemble_accuracy, deprecated))
+ proj_db_cursor.execute("SELECT datum_code, datum_sequence FROM epsg.epsg_datumensemblemember WHERE datum_ensemble_code = ? ORDER by datum_sequence", (datum_code,))
+ for member_code, sequence in proj_db_cursor.fetchall():
+ proj_db_cursor.execute(
+ "INSERT INTO " + datum_ensemble_member_table + " (ensemble_auth_name, ensemble_code, member_auth_name, member_code, sequence) VALUES (?, ?, ?, ?, ?)", (EPSG_AUTHORITY, datum_code, EPSG_AUTHORITY, member_code, sequence))
def fill_coordinate_system(proj_db_cursor):
proj_db_cursor.execute(
diff --git a/scripts/build_db_create_ignf_from_xml.py b/scripts/build_db_create_ignf_from_xml.py
index 73bb8a5e..dcc9cd4c 100755
--- a/scripts/build_db_create_ignf_from_xml.py
+++ b/scripts/build_db_create_ignf_from_xml.py
@@ -144,7 +144,7 @@ def ingest_datums(root, all_sql, mapEllpsId, mapPmId):
ellpsCode = extract_id_from_href(node.find('usesEllipsoid').attrib['href'])
assert ellpsCode in mapEllpsId
- sql = """INSERT INTO "geodetic_datum" VALUES('IGNF','%s','%s',NULL,'%s','%s','%s','%s',NULL,NULL,0);""" % (id, names[0], mapEllpsId[ellpsCode][0], mapEllpsId[ellpsCode][1], mapPmId[pmCode][0], mapPmId[pmCode][1])
+ sql = """INSERT INTO "geodetic_datum" VALUES('IGNF','%s','%s',NULL,'%s','%s','%s','%s',NULL,NULL,NULL,0);""" % (id, names[0], mapEllpsId[ellpsCode][0], mapEllpsId[ellpsCode][1], mapPmId[pmCode][0], mapPmId[pmCode][1])
all_sql.append(sql)
mapDatumId[id] = ('IGNF', id)
@@ -154,7 +154,7 @@ def ingest_datums(root, all_sql, mapEllpsId, mapPmId):
id = node.attrib['id']
names = [_name.text for _name in node.iter('name')]
- sql = """INSERT INTO "vertical_datum" VALUES('IGNF','%s','%s',NULL,NULL,0);"""% (id, names[0])
+ sql = """INSERT INTO "vertical_datum" VALUES('IGNF','%s','%s',NULL,NULL,NULL,0);"""% (id, names[0])
all_sql.append(sql)
mapVerticalDatumId[id] = ('IGNF', id)
diff --git a/scripts/build_db_from_esri.py b/scripts/build_db_from_esri.py
index 2cef6219..dbef495e 100755
--- a/scripts/build_db_from_esri.py
+++ b/scripts/build_db_from_esri.py
@@ -587,7 +587,7 @@ def import_geogcs():
p = map_datum_esri_to_parameters[datum_code]
- sql = """INSERT INTO "geodetic_datum" VALUES('ESRI','%s','%s','%s','%s','%s','%s','%s',NULL,NULL,%d);""" % (
+ sql = """INSERT INTO "geodetic_datum" VALUES('ESRI','%s','%s','%s','%s','%s','%s','%s',NULL,NULL,NULL,%d);""" % (
datum_code, p['esri_name'], p['description'], p['ellps_auth_name'], p['ellps_code'], pm_auth_name, pm_code, p['deprecated'])
all_sql.append(sql)
sql = """INSERT INTO "usage" VALUES('ESRI', '%s_USAGE','geodetic_datum','ESRI','%s','%s','%s','%s','%s');""" % (datum_code, datum_code, extent_auth_name, extent_code, 'EPSG', '1024')
@@ -618,7 +618,7 @@ def import_geogcs():
'deprecated': p['deprecated']
}
- sql = """INSERT INTO "geodetic_datum" VALUES('ESRI','%s','%s','%s','%s','%s','%s','%s',NULL,NULL,%d);""" % (
+ sql = """INSERT INTO "geodetic_datum" VALUES('ESRI','%s','%s','%s','%s','%s','%s','%s',NULL,NULL,NULL,%d);""" % (
datum_code, p['esri_name'], p['description'], p['ellps_auth_name'], p['ellps_code'], pm_auth_name, pm_code, p['deprecated'])
all_sql.append(sql)
sql = """INSERT INTO "usage" VALUES('ESRI', '%s_USAGE','geodetic_datum','ESRI','%s','%s','%s','%s','%s');""" % (datum_code, datum_code, extent_auth_name, extent_code, 'EPSG', '1024')
@@ -1259,7 +1259,7 @@ def import_vertcs():
datum_written.add(datum_code)
p = map_vdatum_esri_to_parameters[datum_code]
- sql = """INSERT INTO "vertical_datum" VALUES('ESRI','%s','%s',NULL,NULL,%d);""" % (
+ sql = """INSERT INTO "vertical_datum" VALUES('ESRI','%s','%s',NULL,NULL,NULL,%d);""" % (
datum_code, p['esri_name'], p['deprecated'])
all_sql.append(sql)
sql = """INSERT INTO "usage" VALUES('ESRI', '%s_USAGE','vertical_datum','ESRI','%s','%s','%s','%s','%s');""" % (datum_code, datum_code, extent_auth_name, extent_code, 'EPSG', '1024')