Skip to content

Commit 067fe73

Browse files
authored
Merge pull request #4353 from rouault/epsg_tin_shift
Take into account new EPSG methods 'Cartesian Grid Offsets by TIN Interpolation (JSON)' and 'Vertical Offset by TIN Interpolation (JSON)'
2 parents cc0a63c + e7ef01b commit 067fe73

File tree

11 files changed

+243
-108
lines changed

11 files changed

+243
-108
lines changed

data/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ set(ALL_SQL_IN "${CMAKE_CURRENT_BINARY_DIR}/all.sql.in")
3131
set(PROJ_DB "${CMAKE_CURRENT_BINARY_DIR}/proj.db")
3232
include(sql_filelist.cmake)
3333

34-
set(PROJ_DB_SQL_EXPECTED_MD5 "179a5d10e801cb758db7aaa925b97a8f")
34+
set(PROJ_DB_SQL_EXPECTED_MD5 "c2184d9fca631e88f21e4c0d8899d391")
3535

3636
add_custom_command(
3737
OUTPUT ${PROJ_DB}

data/sql/consistency_checks_triggers.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,12 @@ FOR EACH ROW BEGIN
346346
SELECT RAISE(ABORT, 'insert on grid_transformation violates constraint: target_crs(auth_name, code) not found')
347347
WHERE NOT EXISTS (SELECT 1 FROM crs_view WHERE crs_view.auth_name = NEW.target_crs_auth_name AND crs_view.code = NEW.target_crs_code);
348348

349+
SELECT RAISE(ABORT, 'insert on grid_transformation violates constraint: interpolation_crs(auth_name, code) not found')
350+
WHERE NEW.interpolation_crs_code IS NOT NULL AND NOT EXISTS (SELECT 1 FROM crs_view WHERE crs_view.auth_name = NEW.interpolation_crs_auth_name AND crs_view.code = NEW.interpolation_crs_code);
351+
352+
SELECT RAISE(ABORT, 'insert on grid_transformation violates constraint: interpolation_crs must be a GeodeticCRS on non-TIN shift based files')
353+
WHERE NEW.method_name NOT LIKE '%JSON%' AND NEW.interpolation_crs_code IS NOT NULL AND NOT EXISTS (SELECT 1 FROM geodetic_crs WHERE geodetic_crs.auth_name = NEW.interpolation_crs_auth_name AND geodetic_crs.code = NEW.interpolation_crs_code);
354+
349355
SELECT RAISE(ABORT, 'insert on grid_transformation violates constraint: source_crs must not be deprecated when grid_transformation is not deprecated')
350356
WHERE EXISTS(SELECT 1 FROM crs_view crs WHERE crs.auth_name = NEW.source_crs_auth_name AND crs.code = NEW.source_crs_code AND crs.deprecated != 0) AND NEW.deprecated = 0 AND NOT (NEW.auth_name = 'ESRI');
351357
SELECT RAISE(ABORT, 'insert on grid_transformation violates constraint: target_crs must not be deprecated when grid_transformation is not deprecated')

data/sql/grid_transformation.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1762,6 +1762,12 @@ INSERT INTO "grid_transformation" VALUES('EPSG','10697','EUREF-FIN to N2000 heig
17621762
INSERT INTO "usage" VALUES('EPSG','22014','grid_transformation','EPSG','10697','EPSG','3333','EPSG','1133');
17631763
INSERT INTO "grid_transformation" VALUES('EPSG','10698','EUREF-FIN to EUREF-FIN + N2000 height (2)','Replaces EUREF-FIN to EUREF-FIN + N2000 height (1) (code 10696). Reversible alternative to EUREF-FIN to N2000 height (2) (code 10697). File also available in 3 ASCII formats.','EPSG','1124','Geog3D to Geog2D+GravityRelatedHeight (gtg)','EPSG','10689','EPSG','10692',0.014,'EPSG','8666','Geoid (height correction) model file','fi_nls_fin2023n2000.tif',NULL,NULL,NULL,NULL,'EPSG','10690','NLS-Fin 2023',0);
17641764
INSERT INTO "usage" VALUES('EPSG','22015','grid_transformation','EPSG','10698','EPSG','3333','EPSG','1270');
1765+
INSERT INTO "grid_transformation" VALUES('EPSG','10703','KKJ / Finland Uniform Coordinate System to EUREF-FIN / TM35FIN(E,N) (1)','This YKJ to ETRS-TM35FIN TINshift transformation is the recommended method for KKJ to EUREF-FIN transformations, to be used in preference to transformation KKJ to ETRS89 (2) (code 10098).','EPSG','1138','Cartesian Grid Offsets by TIN Interpolation (JSON)','EPSG','2393','EPSG','3067',0.03,'EPSG','1064','TIN offset file','fi_nls_ykj_etrs35fin.json',NULL,NULL,NULL,NULL,NULL,NULL,'NLS-FIN TINshift',0);
1766+
INSERT INTO "usage" VALUES('EPSG','22055','grid_transformation','EPSG','10703','EPSG','3333','EPSG','1273');
1767+
INSERT INTO "grid_transformation" VALUES('EPSG','10704','N43 height to N60 height (1)','Accuracy has not been determined.','EPSG','1137','Vertical Offset by TIN Interpolation (JSON)','EPSG','8675','EPSG','5717',999.0,'EPSG','1064','TIN offset file','fi_nls_n43_n60.json',NULL,NULL,NULL,NULL,'EPSG','2393','NLS-Fin TINshift',0);
1768+
INSERT INTO "usage" VALUES('EPSG','22018','grid_transformation','EPSG','10704','EPSG','4522','EPSG','1059');
1769+
INSERT INTO "grid_transformation" VALUES('EPSG','10705','N60 height to N2000 height (1)','Recommended method for N60<>N2000 trasformations, as more accurate than concatenating geoid models.','EPSG','1137','Vertical Offset by TIN Interpolation (JSON)','EPSG','5717','EPSG','3900',0.005,'EPSG','1064','TIN offset file','fi_nls_n60_n2000.json',NULL,NULL,NULL,NULL,'EPSG','2393','NLS-Fin TINshift',0);
1770+
INSERT INTO "usage" VALUES('EPSG','22201','grid_transformation','EPSG','10705','EPSG','3333','EPSG','1059');
17651771
INSERT INTO "grid_transformation" VALUES('EPSG','15486','CH1903 to CH1903+ (1)','For improved accuracy (0.01m) use CHENyx06 interpolation programme FINELTRA. File CHENyx06 replaced by CHENyx06a; there is a small area at the border of the data where some more real data has been introduced. swisstopo consider the change insignificant.','EPSG','9615','NTv2','EPSG','4149','EPSG','4150',0.2,'EPSG','8656','Latitude and longitude difference file','CHENyx06a.gsb',NULL,NULL,NULL,NULL,NULL,NULL,'BfL-Che',0);
17661772
INSERT INTO "usage" VALUES('EPSG','11497','grid_transformation','EPSG','15486','EPSG','1286','EPSG','1085');
17671773
INSERT INTO "grid_transformation" VALUES('EPSG','15488','RRAF 1991 to IGN 1988 MG height (1)','May be used for transformations from WGS 84 to IGN 1988 MG. Accuracy at each 0.025 deg x 0.025 degree grid node is given within the geoid model file.','EPSG','9664','Geographic3D to GravityRelatedHeight (IGN1997)','EPSG','4973','EPSG','5617',0.2,'EPSG','8666','Geoid (height correction) model file','ggg00_mg.txt',NULL,NULL,NULL,NULL,NULL,NULL,'IGN Glp MG',1);

data/sql/other_transformation_custom.sql

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,9 @@ INSERT INTO "usage" VALUES('PROJ','NGO48_TO_ETRS89NO_USAGE','other_transformatio
1818

1919
-- Finland triangulated files
2020

21-
INSERT INTO other_transformation VALUES(
22-
'PROJ','YKJ_TO_ETRS35FIN','KKJ / Finland Uniform Coordinate System to ETRS35FIN',
23-
'Transformation based on a triangulated irregular network',
24-
'PROJ','PROJString','+proj=pipeline +step +proj=axisswap +order=2,1 +step +proj=tinshift +file=fi_nls_ykj_etrs35fin.json',
25-
'EPSG','2393','EPSG','3067',0.1,
26-
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0);
27-
INSERT INTO "usage" VALUES('PROJ','YKJ_TO_ETRS35FIN_USAGE','other_transformation','PROJ','YKJ_TO_ETRS35FIN','EPSG','3333','EPSG','1024');
28-
29-
INSERT INTO "concatenated_operation" VALUES('PROJ','KKJ_TO_ETRS89','KKJ to ETRS89 (using PROJ:YKJ_TO_ETRS35FIN)','Transformation based on a triangulated irregular network','EPSG','4123','EPSG','4258',NULL,NULL,0);
21+
INSERT INTO "concatenated_operation" VALUES('PROJ','KKJ_TO_ETRS89','KKJ to ETRS89 (using EPSG:10703)','Transformation based on a triangulated irregular network','EPSG','4123','EPSG','4258',NULL,NULL,0);
3022
INSERT INTO "concatenated_operation_step" VALUES('PROJ','KKJ_TO_ETRS89',1,'EPSG','18193');
31-
INSERT INTO "concatenated_operation_step" VALUES('PROJ','KKJ_TO_ETRS89',2,'PROJ','YKJ_TO_ETRS35FIN');
23+
INSERT INTO "concatenated_operation_step" VALUES('PROJ','KKJ_TO_ETRS89',2,'EPSG','10703');
3224
INSERT INTO "concatenated_operation_step" VALUES('PROJ','KKJ_TO_ETRS89',3,'EPSG','16065');
3325
INSERT INTO "usage" VALUES(
3426
'PROJ',
@@ -40,9 +32,9 @@ INSERT INTO "usage" VALUES(
4032
'EPSG','1024' -- unknown
4133
);
4234

43-
INSERT INTO "concatenated_operation" VALUES('PROJ','KKJ_TO_EUREF_FIN','KKJ to EUREF-FIN (using PROJ:YKJ_TO_ETRS35FIN)','Transformation based on a triangulated irregular network','EPSG','4123','EPSG','10690',NULL,NULL,0);
35+
INSERT INTO "concatenated_operation" VALUES('PROJ','KKJ_TO_EUREF_FIN','KKJ to EUREF-FIN (using EPSG:10703)','Transformation based on a triangulated irregular network','EPSG','4123','EPSG','10690',NULL,NULL,0);
4436
INSERT INTO "concatenated_operation_step" VALUES('PROJ','KKJ_TO_EUREF_FIN',1,'EPSG','18193');
45-
INSERT INTO "concatenated_operation_step" VALUES('PROJ','KKJ_TO_EUREF_FIN',2,'PROJ','YKJ_TO_ETRS35FIN');
37+
INSERT INTO "concatenated_operation_step" VALUES('PROJ','KKJ_TO_EUREF_FIN',2,'EPSG','10703');
4638
INSERT INTO "concatenated_operation_step" VALUES('PROJ','KKJ_TO_EUREF_FIN',3,'EPSG','16065');
4739
INSERT INTO "usage" VALUES(
4840
'PROJ',
@@ -53,20 +45,3 @@ INSERT INTO "usage" VALUES(
5345
'EPSG','3333', -- extent
5446
'EPSG','1024' -- unknown
5547
);
56-
57-
INSERT INTO other_transformation VALUES(
58-
'PROJ','N43_TO_N60','N43 height to N60 height',
59-
'Transformation based on a triangulated irregular network',
60-
'PROJ','PROJString','+proj=pipeline +step +proj=tmerc +lat_0=0 +lon_0=27 +k=1 +x_0=3500000 +y_0=0 +ellps=intl +step +proj=tinshift +file=fi_nls_n43_n60.json +step +inv +proj=tmerc +lat_0=0 +lon_0=27 +k=1 +x_0=3500000 +y_0=0 +ellps=intl',
61-
'EPSG','8675','EPSG','5717',0.01,
62-
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'EPSG','4123',NULL,0);
63-
INSERT INTO "usage" VALUES('PROJ','N43_TO_N60_USAGE','other_transformation','PROJ','N43_TO_N60','EPSG','4522','EPSG','1024');
64-
65-
66-
INSERT INTO other_transformation VALUES(
67-
'PROJ','N60_TO_N2000','N60 height to N2000 height',
68-
'Transformation based on a triangulated irregular network',
69-
'PROJ','PROJString','+proj=pipeline +step +proj=tmerc +lat_0=0 +lon_0=27 +k=1 +x_0=3500000 +y_0=0 +ellps=intl +step +proj=tinshift +file=fi_nls_n60_n2000.json +step +inv +proj=tmerc +lat_0=0 +lon_0=27 +k=1 +x_0=3500000 +y_0=0 +ellps=intl',
70-
'EPSG','5717','EPSG','3900',0.01,
71-
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'EPSG','4123',NULL,0);
72-
INSERT INTO "usage" VALUES('PROJ','N60_TO_N2000_USAGE','other_transformation','PROJ','N60_TO_N2000','EPSG','3333','EPSG','1024');

data/sql/proj_db_table_defs.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -833,11 +833,11 @@ CREATE TABLE grid_transformation(
833833

834834
deprecated BOOLEAN NOT NULL CHECK (deprecated IN (0, 1)),
835835

836-
CONSTRAINT pk_grid_transformation PRIMARY KEY (auth_name, code),
836+
CONSTRAINT pk_grid_transformation PRIMARY KEY (auth_name, code)
837837
--CONSTRAINT fk_grid_transformation_coordinate_operation FOREIGN KEY (auth_name, code) REFERENCES coordinate_operation(auth_name, code) ON DELETE CASCADE,
838838
--CONSTRAINT fk_grid_transformation_source_crs FOREIGN KEY (source_crs_auth_name, source_crs_code) REFERENCES crs(auth_name, code) ON DELETE CASCADE,
839839
--CONSTRAINT fk_grid_transformation_target_crs FOREIGN KEY (target_crs_auth_name, target_crs_code) REFERENCES crs(auth_name, code) ON DELETE CASCADE,
840-
CONSTRAINT fk_grid_transformation_interpolation_crs FOREIGN KEY (interpolation_crs_auth_name, interpolation_crs_code) REFERENCES geodetic_crs(auth_name, code) ON DELETE CASCADE
840+
-- CONSTRAINT fk_grid_transformation_interpolation_crs FOREIGN KEY (interpolation_crs_auth_name, interpolation_crs_code) REFERENCES crs_view(auth_name, code) ON DELETE CASCADE
841841
) WITHOUT ROWID;
842842

843843
-- Table that describe packages/archives that contain several grids

scripts/build_db.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ def fill_helmert_transformation(proj_db_cursor):
692692
'?,?,?, ?, ?,?,?, ?,?, ?,?, ?, ?,?,?,?,?, ?,?,?,?,?, ?,?,?, ?,?,?,?,?, ?,?,?,?,?, ?,?,?, ?,?,?, ?,?,?,?,?, ?,?)', arg)
693693

694694
def fill_grid_transformation(proj_db_cursor):
695-
proj_db_cursor.execute("SELECT coord_op_code, coord_op_name, coord_op_method_code, coord_op_method_name, source_crs_code, target_crs_code, coord_op_accuracy, coord_tfm_version, epsg_coordoperation.deprecated, epsg_coordoperation.remarks FROM epsg.epsg_coordoperation LEFT JOIN epsg.epsg_coordoperationmethod USING (coord_op_method_code) WHERE coord_op_type IN ('transformation', 'point motion operation') AND coord_op_method_code NOT IN (1131, 1136) AND (coord_op_method_name LIKE 'Geographic3D to%' OR coord_op_method_name LIKE 'Geog3D to%' OR coord_op_method_name LIKE 'Point motion by grid%' OR coord_op_method_name LIKE 'Vertical % by %grid%' OR coord_op_method_name IN ('NADCON', 'NADCON5 (2D)', 'NADCON5 (3D)', 'NTv1', 'NTv2', 'VERTCON', 'Geocentric translation by Grid Interpolation (IGN)', 'Geographic3D Offset by velocity grid (NTv2_Vel)', 'New Zealand Deformation Model'))")
695+
proj_db_cursor.execute("SELECT coord_op_code, coord_op_name, coord_op_method_code, coord_op_method_name, source_crs_code, target_crs_code, coord_op_accuracy, coord_tfm_version, epsg_coordoperation.deprecated, epsg_coordoperation.remarks FROM epsg.epsg_coordoperation LEFT JOIN epsg.epsg_coordoperationmethod USING (coord_op_method_code) WHERE coord_op_type IN ('transformation', 'point motion operation') AND coord_op_method_code NOT IN (1131, 1136) AND (coord_op_method_name LIKE 'Geographic3D to%' OR coord_op_method_name LIKE 'Geog3D to%' OR coord_op_method_name LIKE 'Point motion by grid%' OR coord_op_method_name LIKE 'Vertical % by %grid%' OR coord_op_method_name IN ('NADCON', 'NADCON5 (2D)', 'NADCON5 (3D)', 'NTv1', 'NTv2', 'VERTCON', 'Geocentric translation by Grid Interpolation (IGN)', 'Geographic3D Offset by velocity grid (NTv2_Vel)', 'New Zealand Deformation Model', 'Cartesian Grid Offsets by TIN Interpolation (JSON)', 'Vertical Offset by TIN Interpolation (JSON)'))")
696696
for (code, name, method_code, method_name, source_crs_code, target_crs_code, coord_op_accuracy, coord_tfm_version, deprecated, remarks) in proj_db_cursor.fetchall():
697697
expected_order = 1
698698
max_n_params = 3 if method_name == 'Geocentric translation by Grid Interpolation (IGN)' else 2
@@ -731,7 +731,7 @@ def fill_grid_transformation(proj_db_cursor):
731731
expected_order += 1
732732
n_params = expected_order - 1
733733

734-
assert param_code[0] in (1048, 1050, 1063, 8656, 8657, 8666, 8732, 8727), (code, param_code[0])
734+
assert param_code[0] in (1048, 1050, 1063, 1064, 8656, 8657, 8666, 8732, 8727), (code, param_code[0])
735735

736736
grid2_param_auth_name = None
737737
grid2_param_code = None
@@ -783,9 +783,11 @@ def fill_grid_transformation(proj_db_cursor):
783783
# 1124: Geog3D to Geog2D+GravityRelatedHeight (gtg)
784784
# 1126: Vertical change by geoid grid difference (NRCan)
785785
# 1135: Geog3D to Geog2D+GravityRelatedHeight (NGS bin)
786+
# 1137: Vertical Offset by TIN Interpolation (JSON)
787+
# 1138: Cartesian Grid Offsets by TIN Interpolation (JSON)
786788
# WARNING: update Transformation::isGeographic3DToGravityRelatedHeight()
787789
# in src/iso19111/operation/singleoperation.cpp if adding new methods
788-
elif method_code in (1071, 1080, 1081, 1083, 1084, 1085, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1100, 1101, 1103, 1105, 1110, 1112, 1113, 1114, 1115, 1118, 1122, 1124, 1126, 1128, 1129, 1135) and n_params == 2:
790+
elif method_code in (1071, 1080, 1081, 1083, 1084, 1085, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1100, 1101, 1103, 1105, 1110, 1112, 1113, 1114, 1115, 1118, 1122, 1124, 1126, 1128, 1129, 1135, 1137, 1138) and n_params == 2:
789791
assert param_code[1] == 1048, (code, method_code, param_code[1])
790792
interpolation_crs_auth_name = EPSG_AUTHORITY
791793
interpolation_crs_code = str(int(param_value[1])) # needed to avoid codes like XXXX.0

src/iso19111/factory.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6281,7 +6281,7 @@ operation::CoordinateOperationNNPtr AuthorityFactory::createCoordinateOperation(
62816281
.set(common::IdentifiedObject::NAME_KEY, method_name);
62826282

62836283
std::vector<metadata::PositionalAccuracyNNPtr> accuracies;
6284-
if (!accuracy.empty()) {
6284+
if (!accuracy.empty() && accuracy != "999.0") {
62856285
accuracies.emplace_back(
62866286
metadata::PositionalAccuracy::create(accuracy));
62876287
}
@@ -6393,7 +6393,7 @@ operation::CoordinateOperationNNPtr AuthorityFactory::createCoordinateOperation(
63936393
.set(common::IdentifiedObject::NAME_KEY, method_name);
63946394

63956395
std::vector<metadata::PositionalAccuracyNNPtr> accuracies;
6396-
if (!accuracy.empty()) {
6396+
if (!accuracy.empty() && accuracy != "999.0") {
63976397
accuracies.emplace_back(
63986398
metadata::PositionalAccuracy::create(accuracy));
63996399
}
@@ -6531,7 +6531,7 @@ operation::CoordinateOperationNNPtr AuthorityFactory::createCoordinateOperation(
65316531
}
65326532

65336533
std::vector<metadata::PositionalAccuracyNNPtr> accuracies;
6534-
if (!accuracy.empty()) {
6534+
if (!accuracy.empty() && accuracy != "999.0") {
65356535
accuracies.emplace_back(
65366536
metadata::PositionalAccuracy::create(accuracy));
65376537
}
@@ -6646,8 +6646,10 @@ operation::CoordinateOperationNNPtr AuthorityFactory::createCoordinateOperation(
66466646

66476647
std::vector<metadata::PositionalAccuracyNNPtr> accuracies;
66486648
if (!accuracy.empty()) {
6649-
accuracies.emplace_back(
6650-
metadata::PositionalAccuracy::create(accuracy));
6649+
if (accuracy != "999.0") {
6650+
accuracies.emplace_back(
6651+
metadata::PositionalAccuracy::create(accuracy));
6652+
}
66516653
} else {
66526654
// Try to compute a reasonable accuracy from the members
66536655
double totalAcc = -1;

0 commit comments

Comments
 (0)