Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database: add a 'anchor' field to geodetic_datum and vertical_datum tables #2859

Merged
merged 2 commits into from
Sep 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,037 changes: 519 additions & 518 deletions data/sql/esri.sql

Large diffs are not rendered by default.

1,196 changes: 598 additions & 598 deletions data/sql/geodetic_datum.sql

Large diffs are not rendered by default.

226 changes: 113 additions & 113 deletions data/sql/ignf.sql

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion data/sql/metadata.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
-- DATABASE_LAYOUT_VERSION_MINOR constants in src/iso19111/factory.cpp must be
-- updated as well.
INSERT INTO "metadata" VALUES('DATABASE.LAYOUT.VERSION.MAJOR', 1);
INSERT INTO "metadata" VALUES('DATABASE.LAYOUT.VERSION.MINOR', 1);
INSERT INTO "metadata" VALUES('DATABASE.LAYOUT.VERSION.MINOR', 2);

INSERT INTO "metadata" VALUES('EPSG.VERSION', 'v10.035');
INSERT INTO "metadata" VALUES('EPSG.DATE', '2021-09-10');
Expand Down
2 changes: 2 additions & 0 deletions data/sql/nkg.sql
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ INSERT INTO "geodetic_datum" VALUES (
'2016-03-16', -- publication date
2000.0, -- frame reference epoch
NULL, -- ensemble accuracy
NULL, -- anchor
0 -- deprecated
);

Expand Down Expand Up @@ -91,6 +92,7 @@ INSERT INTO "geodetic_datum" VALUES (
'2021-03-01', -- publication date
2000.0, -- frame reference epoch
NULL, -- ensemble accuracy
NULL, -- anchor
0 -- deprecated
);

Expand Down
4 changes: 3 additions & 1 deletion data/sql/proj_db_table_defs.sql
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ CREATE TABLE geodetic_datum (
publication_date TEXT, --- YYYY-MM-DD format
frame_reference_epoch FLOAT, --- only set for dynamic datum, and should be set when it is a dynamic datum
ensemble_accuracy FLOAT CHECK (ensemble_accuracy IS NULL OR ensemble_accuracy > 0), --- only for a datum ensemble. and should be set when it is a datum ensemble
anchor TEXT,
deprecated BOOLEAN NOT NULL CHECK (deprecated IN (0, 1)),
CONSTRAINT pk_geodetic_datum PRIMARY KEY (auth_name, code),
CONSTRAINT fk_geodetic_datum_ellipsoid FOREIGN KEY (ellipsoid_auth_name, ellipsoid_code) REFERENCES ellipsoid(auth_name, code),
Expand Down Expand Up @@ -191,6 +192,7 @@ CREATE TABLE vertical_datum (
publication_date TEXT CHECK (NULL OR length(publication_date) = 10), --- YYYY-MM-DD format
frame_reference_epoch FLOAT, --- only set for dynamic datum, and should be set when it is a dynamic datum
ensemble_accuracy FLOAT CHECK (ensemble_accuracy IS NULL OR ensemble_accuracy > 0), --- only for a datum ensemble. and should be set when it is a datum ensemble
anchor TEXT,
deprecated BOOLEAN NOT NULL CHECK (deprecated IN (0, 1)),
CONSTRAINT pk_vertical_datum PRIMARY KEY (auth_name, code)
) WITHOUT ROWID;
Expand Down Expand Up @@ -247,7 +249,7 @@ CREATE TABLE geodetic_crs(
code INTEGER_OR_TEXT NOT NULL CHECK (length(code) >= 1),
name TEXT NOT NULL CHECK (length(name) >= 2),
description TEXT,
type TEXT NOT NULL CHECK (type IN ('geographic 2D', 'geographic 3D', 'geocentric')),
type TEXT NOT NULL CHECK (type IN ('geographic 2D', 'geographic 3D', 'geocentric', 'other')),
coordinate_system_auth_name TEXT,
coordinate_system_code INTEGER_OR_TEXT,
datum_auth_name TEXT,
Expand Down
460 changes: 230 additions & 230 deletions data/sql/vertical_datum.sql

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions scripts/build_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,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, ?, ?, ?, ?, ?, ?, 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, 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):
Expand All @@ -211,7 +211,7 @@ 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, ?, ?, NULL, ?)", (EPSG_AUTHORITY, datum_code, datum_name, publication_date, frame_reference_epoch, deprecated))
"INSERT INTO vertical_datum VALUES (?, ?, ?, NULL, ?, ?, NULL, NULL, ?)", (EPSG_AUTHORITY, datum_code, datum_name, publication_date, frame_reference_epoch, deprecated))


def fill_datumensemble(proj_db_cursor):
Expand All @@ -235,7 +235,7 @@ def fill_datumensemble(proj_db_cursor):
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, frame_reference_epoch, ensemble_accuracy, deprecated) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", (EPSG_AUTHORITY, datum_code, datum_name, None, EPSG_AUTHORITY, ellipsoid_code, EPSG_AUTHORITY, prime_meridian_code, None, None, ensemble_accuracy, deprecated))
"INSERT INTO geodetic_datum (auth_name, code, name, description, ellipsoid_auth_name, ellipsoid_code, prime_meridian_auth_name, prime_meridian_code, publication_date, frame_reference_epoch, ensemble_accuracy, anchor, deprecated) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", (EPSG_AUTHORITY, datum_code, datum_name, None, EPSG_AUTHORITY, ellipsoid_code, EPSG_AUTHORITY, prime_meridian_code, None, None, ensemble_accuracy, None, 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():
Expand Down
4 changes: 2 additions & 2 deletions scripts/build_db_create_ignf_from_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,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,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)
Expand All @@ -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,NULL,NULL,0);"""% (id, names[0])
sql = """INSERT INTO "vertical_datum" VALUES('IGNF','%s','%s',NULL,NULL,NULL,NULL,NULL,0);"""% (id, names[0])
all_sql.append(sql)

mapVerticalDatumId[id] = ('IGNF', id)
Expand Down
10 changes: 5 additions & 5 deletions scripts/build_db_from_esri.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,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,NULL,%d);""" % (
sql = """INSERT INTO "geodetic_datum" VALUES('ESRI','%s','%s','%s','%s','%s','%s','%s',NULL,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')
Expand Down Expand Up @@ -633,7 +633,7 @@ def import_geogcs():
'deprecated': p['deprecated']
}

sql = """INSERT INTO "geodetic_datum" VALUES('ESRI','%s','%s','%s','%s','%s','%s','%s',NULL,NULL,NULL,%d);""" % (
sql = """INSERT INTO "geodetic_datum" VALUES('ESRI','%s','%s','%s','%s','%s','%s','%s',NULL,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')
Expand Down Expand Up @@ -1329,7 +1329,7 @@ def import_vertcs():

datum_code = new_datum_code

sql = """INSERT INTO "vertical_datum" VALUES('ESRI','%s','%s',NULL,NULL,NULL,NULL,%d);""" % (
sql = """INSERT INTO "vertical_datum" VALUES('ESRI','%s','%s',NULL,NULL,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')
Expand All @@ -1345,13 +1345,13 @@ def import_vertcs():
vdatum_written.add(datum_code)

p = map_vdatum_esri_to_parameters[datum_code]
sql = """INSERT INTO "vertical_datum" VALUES('ESRI','%s','%s',NULL,NULL,NULL,NULL,%d);""" % (
sql = """INSERT INTO "vertical_datum" VALUES('ESRI','%s','%s',NULL,NULL,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')
all_sql.append(sql)

map_vertcs_esri_name_to_auth_code[esri_name] = ['ESRI', code]
#map_vertcs_esri_name_to_auth_code[esri_name] = ['ESRI', code]

cs_auth = 'EPSG'
if 'PARAMETER["Direction",1.0]' in wkt and 'UNIT["Meter"' in wkt:
Expand Down
Loading