Skip to content

Commit 2743e42

Browse files
authored
Merge pull request #4363 from rouault/fix_4362
Database: replicate EGM2008 grid transformation record to WGS 84 realizations
2 parents 5500ba7 + b769746 commit 2743e42

File tree

4 files changed

+98
-1
lines changed

4 files changed

+98
-1
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 "648183209a519b679cca32c4cec988e2")
34+
set(PROJ_DB_SQL_EXPECTED_MD5 "5e23b08c318cecbd9cace26233f8f5d4")
3535

3636
add_custom_command(
3737
OUTPUT ${PROJ_DB}

data/sql/customizations.sql

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,3 +581,51 @@ FROM grid_transformation gt
581581
JOIN usage u ON u.object_auth_name = gt.auth_name AND u.object_code = gt.code AND u.object_table_name = 'grid_transformation'
582582
WHERE method_auth_name = 'EPSG' AND method_name LIKE 'Geog3D to Geog2D+%'
583583
AND EXISTS (SELECT 1 FROM grid_transformation gt2 WHERE gt2.auth_name = 'PROJ' AND gt2.code = gt.auth_name || '_' || gt.code || '_RESTRICTED_TO_VERTCRS');
584+
585+
-- Add records corresponding to EGM2008 grid for WGS 84 realizations
586+
587+
INSERT INTO "grid_transformation"
588+
SELECT
589+
'PROJ' AS auth_name,
590+
replace(replace(replace(gcrs.name, ' ', '_'), '(', ''), ')', '') || '_TO_EGM2008',
591+
gcrs.name || ' to EGM2008 height (from ' || gt.name || ')' AS name,
592+
gt.description,
593+
gt.method_auth_name,
594+
gt.method_code,
595+
gt.method_name,
596+
gcrs.auth_name,
597+
gcrs.code,
598+
gt.target_crs_auth_name,
599+
gt.target_crs_code,
600+
gt.accuracy,
601+
gt.grid_param_auth_name,
602+
gt.grid_param_code,
603+
gt.grid_param_name,
604+
gt.grid_name,
605+
gt.grid2_param_auth_name,
606+
gt.grid2_param_code,
607+
gt.grid2_param_name,
608+
gt.grid2_name,
609+
gt.interpolation_crs_auth_name,
610+
gt.interpolation_crs_code,
611+
gt.operation_version,
612+
gt.deprecated
613+
FROM grid_transformation gt, geodetic_crs gcrs
614+
WHERE gt.name = 'WGS 84 to EGM2008 height (1)'
615+
AND gcrs.auth_name = 'EPSG' AND gcrs.name LIKE 'WGS 84 (G%' AND gcrs.type='geographic 3D' and gcrs.deprecated=0;
616+
617+
INSERT INTO "usage"
618+
SELECT
619+
'PROJ' AS auth_name,
620+
'USAGE_' || replace(replace(replace(gcrs.name, ' ', '_'), '(', ''), ')', '') || '_TO_EGM2008' AS code,
621+
'grid_transformation' AS object_table_name,
622+
'PROJ' AS object_auth_name,
623+
replace(replace(replace(gcrs.name, ' ', '_'), '(', ''), ')', '') || '_TO_EGM2008' AS object_code,
624+
u.extent_auth_name,
625+
u.extent_code,
626+
u.scope_auth_name,
627+
u.scope_code
628+
FROM grid_transformation gt, geodetic_crs gcrs
629+
JOIN usage u ON u.object_auth_name = gt.auth_name AND u.object_code = gt.code AND u.object_table_name = 'grid_transformation'
630+
WHERE gt.name = 'WGS 84 to EGM2008 height (1)'
631+
AND gcrs.auth_name = 'EPSG' AND gcrs.name LIKE 'WGS 84 (G%' AND gcrs.type='geographic 3D' and gcrs.deprecated=0;

src/iso19111/operation/singleoperation.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3482,8 +3482,28 @@ bool SingleOperation::exportToPROJStringGeneric(
34823482

34833483
auto sourceCRSGeod =
34843484
dynamic_cast<const crs::GeodeticCRS *>(sourceCRS().get());
3485+
if (!sourceCRSGeod) {
3486+
auto sourceCRSCompound =
3487+
dynamic_cast<const crs::CompoundCRS *>(sourceCRS().get());
3488+
if (sourceCRSCompound) {
3489+
sourceCRSGeod = dynamic_cast<const crs::GeodeticCRS *>(
3490+
sourceCRSCompound->componentReferenceSystems()
3491+
.front()
3492+
.get());
3493+
}
3494+
}
34853495
auto targetCRSGeod =
34863496
dynamic_cast<const crs::GeodeticCRS *>(targetCRS().get());
3497+
if (!targetCRSGeod) {
3498+
auto targetCRSCompound =
3499+
dynamic_cast<const crs::CompoundCRS *>(targetCRS().get());
3500+
if (targetCRSCompound) {
3501+
targetCRSGeod = dynamic_cast<const crs::GeodeticCRS *>(
3502+
targetCRSCompound->componentReferenceSystems()
3503+
.front()
3504+
.get());
3505+
}
3506+
}
34873507
if (sourceCRSGeod && targetCRSGeod) {
34883508
auto sourceCRSGeog =
34893509
dynamic_cast<const crs::GeographicCRS *>(sourceCRSGeod);

test/cli/test_projinfo.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1838,3 +1838,32 @@ tests:
18381838
Test that "CGVD28 height" to "CGVD28(HTv2.0) height" is a no-op
18391839
args: -s "CGVD28 height" -t "CGVD28(HTv2.0) height" -o PROJ -q
18401840
out: +proj=noop
1841+
- comment: >
1842+
Test custom records for WGS 84 realizations to EGM2008 (https://github.com/OSGeo/PROJ/issues/4362)
1843+
args: -s "WGS 84 (G1150) + EGM2008 height" -t "WGS 84 (G1674)" --3d -o PROJ -q
1844+
out: |
1845+
+proj=pipeline
1846+
+step +proj=axisswap +order=2,1
1847+
+step +proj=unitconvert +xy_in=deg +xy_out=rad
1848+
+step +proj=vgridshift +grids=us_nga_egm08_25.tif +multiplier=1
1849+
+step +proj=cart +ellps=WGS84
1850+
+step +proj=helmert +x=-0.0024 +y=0.0016 +z=0.0232 +rx=-0.00027 +ry=0.00027
1851+
+rz=-0.00038 +s=0.00208 +dx=-0.0001 +dy=-0.0001 +dz=0.0018 +drx=0 +dry=0
1852+
+drz=0 +ds=-8e-05 +t_epoch=2005 +convention=coordinate_frame
1853+
+step +inv +proj=cart +ellps=WGS84
1854+
+step +proj=unitconvert +xy_in=rad +xy_out=deg
1855+
+step +proj=axisswap +order=2,1
1856+
- comment: >
1857+
Test 'WGS 84 (Gxxx) + EGM2008 height' to 'WGS 84 (Gyyy) + EGM2008 height'
1858+
args: -s "WGS 84 (G1150) + EGM2008 height" -t "WGS 84 (G1674) + EGM2008 height" -o PROJ -q
1859+
out: |
1860+
+proj=pipeline
1861+
+step +proj=axisswap +order=2,1
1862+
+step +proj=unitconvert +xy_in=deg +xy_out=rad
1863+
+step +proj=cart +ellps=WGS84
1864+
+step +proj=helmert +x=-0.0024 +y=0.0016 +z=0.0232 +rx=-0.00027 +ry=0.00027
1865+
+rz=-0.00038 +s=0.00208 +dx=-0.0001 +dy=-0.0001 +dz=0.0018 +drx=0 +dry=0
1866+
+drz=0 +ds=-8e-05 +t_epoch=2005 +convention=coordinate_frame
1867+
+step +inv +proj=cart +ellps=WGS84
1868+
+step +proj=unitconvert +xy_in=rad +xy_out=deg
1869+
+step +proj=axisswap +order=2,1

0 commit comments

Comments
 (0)