From 10d8e9af8d3b4b5219d37552fc253ba716436f4a Mon Sep 17 00:00:00 2001
From: Even Rouault <even.rouault@spatialys.com>
Date: Fri, 29 May 2020 16:48:36 +0200
Subject: Database: register NZGD2000 -> ITRF96 transformation for NZGD2000
 database

Related to https://github.com/OSGeo/PROJ-data/pull/22

An entry is added in the ``other_transformation`` table, using a raw PROJ
string. Later, once the deformation model has been registered in EPSG, we'll
have to add code to map the EPSG transformation method and parameters to
+proj=defmodel

In the meantime, this works pretty well:

```
$ src/projinfo -s EPSG:4959 -t EPSG:7907
Candidate operations found: 1
-------------------------------------
Operation No. 1:

PROJ:NZGD2000-20180701, NZGD2000 to ITRF96 deformation model, unknown accuracy, New Zealand

PROJ string:
+proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=axisswap +order=2,1 +step +proj=defmodel +model=nz_linz_nzgd2000-20180701.json +step +proj=axisswap +order=2,1 +step +proj=unitconvert +xy_in=rad +xy_out=deg

WKT2:2019 string:
COORDINATEOPERATION["NZGD2000 to ITRF96 deformation model",
    VERSION["20180701"],
    SOURCECRS[
        GEOGCRS["NZGD2000",
            DATUM["New Zealand Geodetic Datum 2000",
                ELLIPSOID["GRS 1980",6378137,298.257222101,
                    LENGTHUNIT["metre",1]]],
            PRIMEM["Greenwich",0,
                ANGLEUNIT["degree",0.0174532925199433]],
            CS[ellipsoidal,3],
                AXIS["geodetic latitude (Lat)",north,
                    ORDER[1],
                    ANGLEUNIT["degree",0.0174532925199433]],
                AXIS["geodetic longitude (Lon)",east,
                    ORDER[2],
                    ANGLEUNIT["degree",0.0174532925199433]],
                AXIS["ellipsoidal height (h)",up,
                    ORDER[3],
                    LENGTHUNIT["metre",1]],
            ID["EPSG",4959]]],
    TARGETCRS[
        GEOGCRS["ITRF96",
            DATUM["International Terrestrial Reference Frame 1996",
                ELLIPSOID["GRS 1980",6378137,298.257222101,
                    LENGTHUNIT["metre",1]]],
            PRIMEM["Greenwich",0,
                ANGLEUNIT["degree",0.0174532925199433]],
            CS[ellipsoidal,3],
                AXIS["geodetic latitude (Lat)",north,
                    ORDER[1],
                    ANGLEUNIT["degree",0.0174532925199433]],
                AXIS["geodetic longitude (Lon)",east,
                    ORDER[2],
                    ANGLEUNIT["degree",0.0174532925199433]],
                AXIS["ellipsoidal height (h)",up,
                    ORDER[3],
                    LENGTHUNIT["metre",1]],
            ID["EPSG",7907]]],
    METHOD["PROJ-based operation method: +proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=axisswap +order=2,1 +step +proj=defmodel +model=nz_linz_nzgd2000-20180701.json +step +proj=axisswap +order=2,1 +step +proj=unitconvert +xy_in=rad +xy_out=deg"],
    USAGE[
        SCOPE["unknown"],
        AREA["New Zealand"],
        BBOX[-55.95,160.6,-25.88,-171.2]],
    ID["PROJ","NZGD2000-20180701"],
    REMARK["New Zealand Deformation Model. Defines the secular model (National Deformation Model) and patches for significant deformation events since 2000"]]
```

```
$ echo "-41 173 0 2016.5" | PROJ_NETWORK=ON src/cct -d 8 +proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=axisswap +order=2,1 +step +proj=defmodel +model=nz_linz_nzgd2000-20180701.json +step +proj=axisswap +order=2,1 +step +proj=unitconvert +xy_in=rad +xy_out=deg
 -40.99999402   172.99999938    0.00130333     2016.5000
```

```
$ echo "-41 173 0 2016.5" | PROJ_NETWORK=ON src/cs2cs -f "%.8f" EPSG:4959 EPSG:7907
-40.99999402	172.99999938 0.00130333 2016.5
```
---
 data/sql/customizations.sql | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

(limited to 'data/sql/customizations.sql')

diff --git a/data/sql/customizations.sql b/data/sql/customizations.sql
index efb0a4bc..1556bf62 100644
--- a/data/sql/customizations.sql
+++ b/data/sql/customizations.sql
@@ -25,6 +25,31 @@ INSERT INTO "geodetic_crs" VALUES('OGC','CRS84','WGS 84 (CRS84)',NULL,NULL,'geog
 
 INSERT INTO "other_transformation" VALUES('PROJ','CRS84_TO_EPSG_4326','OGC:CRS84 to WGS 84',NULL,NULL,'EPSG','9843','Axis Order Reversal (2D)','OGC','CRS84','EPSG','4326','EPSG','1262',0.0,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);
 
+-- Temporary entry for NZGD2000 deformation model
+INSERT INTO other_transformation VALUES(
+    'PROJ','NZGD2000-20180701','NZGD2000 to ITRF96',
+    'New Zealand Deformation Model. Defines the secular model (National Deformation Model) and patches for significant deformation events since 2000', NULL,
+    'PROJ', 'PROJString',
+    '+proj=pipeline ' ||
+        '+step +proj=unitconvert +xy_in=deg +xy_out=rad ' ||
+        '+step +proj=axisswap +order=2,1 ' ||
+        '+step +proj=defmodel +model=nz_linz_nzgd2000-20180701.json ' ||
+        '+step +proj=axisswap +order=2,1 ' ||
+        '+step +proj=unitconvert +xy_in=rad +xy_out=deg',
+    'EPSG','4959',
+    'EPSG','7907',
+    'EPSG','1175',
+    NULL, --accuracy
+    NULL,NULL,NULL,NULL,NULL,NULL, -- param1
+    NULL,NULL,NULL,NULL,NULL,NULL, -- param2
+    NULL,NULL,NULL,NULL,NULL,NULL, -- param3
+    NULL,NULL,NULL,NULL,NULL,NULL, -- param4
+    NULL,NULL,NULL,NULL,NULL,NULL, -- param5
+    NULL,NULL,NULL,NULL,NULL,NULL, -- param6
+    NULL,NULL,NULL,NULL,NULL,NULL, -- param7
+    '20180701', -- operation version
+    0);
+
 -- alias of EPSG:3857
 INSERT INTO "projected_crs" VALUES('EPSG','900913','Google Maps Global Mercator',NULL,NULL,'EPSG','4499','EPSG','4326','EPSG','3856','EPSG','3544',NULL,1);
 
-- 
cgit v1.2.3

