From c72dabdc3f1fd5e09c750b8965768b1b5b686798 Mon Sep 17 00:00:00 2001
From: Even Rouault <even.rouault@spatialys.com>
Date: Tue, 9 Feb 2021 19:46:25 +0100
Subject: Database: update to EPSG v10.013

---
 data/sql/customizations.sql | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

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

diff --git a/data/sql/customizations.sql b/data/sql/customizations.sql
index ef3b6929..10c671e8 100644
--- a/data/sql/customizations.sql
+++ b/data/sql/customizations.sql
@@ -307,6 +307,7 @@ INSERT INTO "unit_of_measure" VALUES('PROJ','US_YD','US survey yard','length',0.
 INSERT INTO "unit_of_measure" VALUES('PROJ','IND_CH','Indian chain','length',20.11669506,'ind-ch',0);
 
 -- Deal with grid_transformation using EPSG:1088 'Geog3D to Geog2D+GravityRelatedHeight (gtx)' method
+-- and similar ones
 -- We derive records using the more classic 'Geographic3D to GravityRelatedHeight' method
 -- We could probably do that at runtime too, but more simple and efficient to create records
 
@@ -340,7 +341,7 @@ FROM grid_transformation gt
 JOIN compound_crs c ON gt.target_crs_code = c.code AND gt.target_crs_auth_name = c.auth_name
 JOIN geodetic_crs gcrs ON gt.source_crs_auth_name = gcrs.auth_name AND gt.source_crs_code = gcrs.code
 JOIN vertical_crs vcrs on vcrs.auth_name = c.vertical_crs_auth_name AND vcrs.code = c.vertical_crs_code
-WHERE method_auth_name = 'EPSG' AND method_code = '1088' AND gt.deprecated = 0;
+WHERE method_auth_name = 'EPSG' AND method_code IN ('1088', '1089', '1090', '1091', '1092', '1093', '1094', '1095', '1096', '1097', '1098', '1103') AND gt.deprecated = 0;
 
 INSERT INTO "usage"
 SELECT
@@ -355,4 +356,6 @@ SELECT
     u.scope_code
 FROM grid_transformation gt
 JOIN usage u ON u.object_auth_name = gt.auth_name AND u.object_code = gt.code AND u.object_table_name = 'grid_transformation'
-WHERE method_auth_name = 'EPSG' AND method_code = '1088' AND gt.deprecated = 0;
+WHERE method_auth_name = 'EPSG' AND method_code IN ('1088', '1089', '1090', '1091', '1092', '1093', '1094', '1095', '1096', '1097', '1098', '1103') AND gt.deprecated = 0
+      AND EXISTS (SELECT 1 FROM compound_crs c WHERE target_crs_code = c.code AND target_crs_auth_name = c.auth_name) -- clause because of buggy entries in EPSG 10.013
+      ;
-- 
cgit v1.2.3

