Skip to content

Commit

Permalink
Add a anchor_epoch column to geodetic_datum and vertical_datum tables…
Browse files Browse the repository at this point in the history
…; bump DATABASE.LAYOUT.VERSION.MINOR to 4
  • Loading branch information
rouault committed Jan 7, 2024
1 parent 438e30b commit e6c2716
Show file tree
Hide file tree
Showing 17 changed files with 1,874 additions and 1,769 deletions.
1,192 changes: 596 additions & 596 deletions data/sql/esri.sql

Large diffs are not rendered by default.

1,280 changes: 640 additions & 640 deletions data/sql/geodetic_datum.sql

Large diffs are not rendered by default.

230 changes: 115 additions & 115 deletions data/sql/iau.sql

Large diffs are not rendered by default.

260 changes: 130 additions & 130 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', 3);
INSERT INTO "metadata" VALUES('DATABASE.LAYOUT.VERSION.MINOR', 4);

INSERT INTO "metadata" VALUES('EPSG.VERSION', 'v11.002');
INSERT INTO "metadata" VALUES('EPSG.DATE', '2024-01-07');
Expand Down
2 changes: 2 additions & 0 deletions data/sql/nkg.sql
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ INSERT INTO "geodetic_datum" VALUES (
2000.0, -- frame reference epoch
NULL, -- ensemble accuracy
NULL, -- anchor
NULL, -- anchor_epoch
0 -- deprecated
);

Expand Down Expand Up @@ -93,6 +94,7 @@ INSERT INTO "geodetic_datum" VALUES (
2000.0, -- frame reference epoch
NULL, -- ensemble accuracy
NULL, -- anchor
NULL, -- anchor_epoch
0 -- deprecated
);

Expand Down
2 changes: 2 additions & 0 deletions data/sql/proj_db_table_defs.sql
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ CREATE TABLE geodetic_datum (
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,
anchor_epoch FLOAT,
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) ON DELETE CASCADE,
Expand Down Expand Up @@ -191,6 +192,7 @@ CREATE TABLE vertical_datum (
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,
anchor_epoch FLOAT,
deprecated BOOLEAN NOT NULL CHECK (deprecated IN (0, 1)),
CONSTRAINT pk_vertical_datum PRIMARY KEY (auth_name, code)
) WITHOUT ROWID;
Expand Down
494 changes: 247 additions & 247 deletions data/sql/vertical_datum.sql

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions scripts/build_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,22 +196,22 @@ def fill_geodetic_datum(proj_db_cursor):
if res:
raise Exception('Found unexpected datum_type in epsg_datum: %s' % str(res))

proj_db_cursor.execute("SELECT datum_code, datum_name, ellipsoid_code, prime_meridian_code, publication_date, frame_reference_epoch, deprecated FROM epsg.epsg_datum WHERE datum_type IN ('geodetic', 'dynamic geodetic')")
proj_db_cursor.execute("SELECT datum_code, datum_name, ellipsoid_code, prime_meridian_code, publication_date, frame_reference_epoch, anchor_epoch, deprecated FROM epsg.epsg_datum WHERE datum_type IN ('geodetic', 'dynamic geodetic')")
res = proj_db_cursor.fetchall()
for (datum_code, datum_name, ellipsoid_code, prime_meridian_code, publication_date, frame_reference_epoch, deprecated) in res:
for (datum_code, datum_name, ellipsoid_code, prime_meridian_code, publication_date, frame_reference_epoch, anchor_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, 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, anchor_epoch, deprecated))


def fill_vertical_datum(proj_db_cursor):

proj_db_cursor.execute("SELECT datum_code, datum_name, publication_date, frame_reference_epoch, deprecated FROM epsg.epsg_datum WHERE datum_type IN ('vertical')")
proj_db_cursor.execute("SELECT datum_code, datum_name, publication_date, frame_reference_epoch, anchor_epoch, deprecated FROM epsg.epsg_datum WHERE datum_type IN ('vertical')")
res = proj_db_cursor.fetchall()
for (datum_code, datum_name, publication_date, frame_reference_epoch, deprecated) in res:
for (datum_code, datum_name, publication_date, frame_reference_epoch, anchor_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, 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, anchor_epoch, deprecated))


def fill_datumensemble(proj_db_cursor):
Expand Down
6 changes: 3 additions & 3 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,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,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,NULL,0);"""% (id, names[0])
sql = """INSERT INTO "vertical_datum" VALUES('IGNF','%s','%s',NULL,NULL,NULL,NULL,NULL,NULL,0);"""% (id, names[0])
all_sql.append(sql)

mapVerticalDatumId[id] = ('IGNF', id)
Expand Down Expand Up @@ -401,7 +401,7 @@ def get_scope_auth_name_code(scope):

# Corse
'http://geodesie.ign.fr/contenu/fichiers/documentation/grilles/RAC09.mnt':
'http://geodesie.ign.fr/contenu/fichiers/documentation/grilles/metropole/RAC09.mnt',
'https://geodesie.ign.fr/contenu/fichiers/documentation/grilles/anciennes/RAC09.mnt',



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

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

datum_code = new_datum_code

sql = """INSERT INTO "vertical_datum" VALUES('ESRI','%s','%s',NULL,NULL,NULL,NULL,NULL,%d);""" % (
sql = """INSERT INTO "vertical_datum" VALUES('ESRI','%s','%s',NULL,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 @@ -1781,7 +1781,7 @@ 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,NULL,%d);""" % (
sql = """INSERT INTO "vertical_datum" VALUES('ESRI','%s','%s',NULL,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 Down
4 changes: 2 additions & 2 deletions scripts/build_db_from_iau.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def generate_projected_crs(geod_crs_code, geod_crs_name, is_west):

spherical_datum_code = spherical_ellipsoid_code
spherical_datum_name = spherical_ellipsoid_name
all_sql.append("INSERT INTO geodetic_datum VALUES('%s',%d,'%s','','%s',%d,'%s',%d,NULL,NULL,NULL,%s,0);" % (AUTH_IAU2015, spherical_datum_code, spherical_datum_name, AUTH_IAU2015, spherical_ellipsoid_code, AUTH_IAU2015, prime_meridian_code, anchor))
all_sql.append("INSERT INTO geodetic_datum VALUES('%s',%d,'%s','','%s',%d,'%s',%d,NULL,NULL,NULL,%s,NULL,0);" % (AUTH_IAU2015, spherical_datum_code, spherical_datum_name, AUTH_IAU2015, spherical_ellipsoid_code, AUTH_IAU2015, prime_meridian_code, anchor))
add_usage('geodetic_datum', spherical_datum_code)

spherical_crs_code = Naif_id * 100
Expand Down Expand Up @@ -292,7 +292,7 @@ def generate_projected_crs(geod_crs_code, geod_crs_name, is_west):

ellipsoidal_datum_code = ellipsoidal_ellipsoid_code
ellipsoidal_datum_name = ellipsoidal_ellipsoid_name
all_sql.append("INSERT INTO geodetic_datum VALUES('%s',%d,'%s','','%s',%d,'%s',%d,NULL,NULL,NULL,%s,0);" % (AUTH_IAU2015, ellipsoidal_datum_code, ellipsoidal_datum_name, AUTH_IAU2015, ellipsoidal_ellipsoid_code, AUTH_IAU2015, prime_meridian_code, anchor))
all_sql.append("INSERT INTO geodetic_datum VALUES('%s',%d,'%s','','%s',%d,'%s',%d,NULL,NULL,NULL,%s,NULL,0);" % (AUTH_IAU2015, ellipsoidal_datum_code, ellipsoidal_datum_name, AUTH_IAU2015, ellipsoidal_ellipsoid_code, AUTH_IAU2015, prime_meridian_code, anchor))
add_usage('geodetic_datum', ellipsoidal_datum_code)

if has_ographic:
Expand Down
10 changes: 10 additions & 0 deletions src/iso19111/datum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,16 @@ void Datum::setProperties(
if (!publicationDateResult.empty()) {
d->publicationDate = common::DateTime::create(publicationDateResult);
}
std::string anchorEpoch;
properties.getStringValue("ANCHOR_EPOCH", anchorEpoch);
if (!anchorEpoch.empty()) {
bool success = false;
const double anchorEpochYear = c_locale_stod(anchorEpoch, success);
if (success) {
setAnchorEpoch(util::optional<common::Measure>(
common::Measure(anchorEpochYear, common::UnitOfMeasure::YEAR)));
}
}
ObjectUsage::setProperties(properties);
}

Expand Down
Loading

0 comments on commit e6c2716

Please sign in to comment.