From 9a6c7c7814fde397638426565a109adb400f2e0f Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sun, 4 Apr 2021 22:34:26 +0200 Subject: Database: minor refresh of ignf.sql and import script with new locations of resources --- scripts/build_db_create_ignf_from_xml.py | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'scripts') diff --git a/scripts/build_db_create_ignf_from_xml.py b/scripts/build_db_create_ignf_from_xml.py index 013bbd69..f248d9d1 100755 --- a/scripts/build_db_create_ignf_from_xml.py +++ b/scripts/build_db_create_ignf_from_xml.py @@ -34,7 +34,7 @@ import requests import sys # url = "http://librairies.ign.fr/geoportail/resources/IGNF.xml" -url = "https://geodesie.ign.fr/contenu/fichiers/IGNF.v3.1.0.xml" +url = "https://raw.githubusercontent.com/rouault/proj-resources/master/IGNF.v3.1.0.xml" if len(sys.argv) not in (1, 2) or (len(sys.argv) == 2 and sys.argv[1].startswith('-')): print('Usage: build_db_create_ignf.py [path_to_IGNF.xml]') @@ -393,7 +393,11 @@ for node in root.iterfind('.//VerticalCRS'): mapGridURLs = { # France metropole 'http://geodesie.ign.fr/contenu/fichiers/documentation/grilles/RAF09.mnt': - 'http://geodesie.ign.fr/contenu/fichiers/documentation/grilles/metropole/RAF09.mnt', + 'http://geodesie.ign.fr/contenu/fichiers/documentation/grilles/anciennes/RAF09.mnt', + + # France metropole + 'https://geodesie.ign.fr/contenu/fichiers/documentation/grilles/metropole/RAF18.mnt': + 'http://geodesie.ign.fr/contenu/fichiers/documentation/grilles/anciennes/RAF18.mnt', # Corse 'http://geodesie.ign.fr/contenu/fichiers/documentation/grilles/RAC09.mnt': @@ -453,26 +457,26 @@ mapGridURLs = { # Guadeloupe WGS84 'http://geodesie.ign.fr/contenu/fichiers/documentation/grilles/outremer/ggg00.txt': - 'http://geodesie.ign.fr/contenu/fichiers/documentation/grilles/outremer/ggg00v2.mnt', + 'http://geodesie.ign.fr/contenu/fichiers/documentation/grilles/anciennes/ggg00v2.txt', # Les Saintes WGS84 'http://geodesie.ign.fr/contenu/fichiers/documentation/grilles/outremer/ggg00_ls.txt': - 'http://geodesie.ign.fr/contenu/fichiers/documentation/grilles/outremer/ggg00_lsv2.mnt', + 'http://geodesie.ign.fr/contenu/fichiers/documentation/grilles/anciennes/ggg00_lsv2.txt', 'ggg00_lsv2.mnt': - 'http://geodesie.ign.fr/contenu/fichiers/documentation/grilles/outremer/ggg00_lsv2.mnt', + 'http://geodesie.ign.fr/contenu/fichiers/documentation/grilles/anciennes/ggg00_lsv2.txt', # Martinique WGS84 'http://geodesie.ign.fr/contenu/fichiers/documentation/grilles/outremer/ggm00.txt': - 'http://geodesie.ign.fr/contenu/fichiers/documentation/grilles/outremer/ggm00v2.mnt', + 'http://geodesie.ign.fr/contenu/fichiers/documentation/grilles/anciennes/ggm00v2.txt', # Saint Barthelemy WGS84 'http://geodesie.ign.fr/contenu/fichiers/documentation/grilles/outremer/ggg00_sb.txt': - 'http://geodesie.ign.fr/contenu/fichiers/documentation/grilles/outremer/ggg00_sbv2.mnt', + 'http://geodesie.ign.fr/contenu/fichiers/documentation/grilles/anciennes/ggg00_sbv2.txt', # Saint Martin WGS84 'http://geodesie.ign.fr/contenu/fichiers/documentation/grilles/outremer/ggg00_sm.txt': - 'http://geodesie.ign.fr/contenu/fichiers/documentation/grilles/outremer/ggg00_smv2.mnt', + 'http://geodesie.ign.fr/contenu/fichiers/documentation/grilles/anciennes/ggg00_smv2.txt', # La Desirade WGS84 'http://geodesie.ign.fr/contenu/fichiers/documentation/grilles/outremer/ggg00_ld.txt': @@ -532,7 +536,7 @@ for node in root.iterfind('.//Transformation'): print('Fixing URL of ' + filename + ' to ' + mapGridURLs[filename]) filename = mapGridURLs[filename] - if not filename.endswith('RAF09.mnt') and not filename.endswith('ggspm06v1.mnt'): # no longer available + if not filename.endswith('ggspm06v1.mnt'): # no longer available r = requests.head(filename, allow_redirects = True ) if r.status_code not in (200, 302): assert False, (r.status_code, id, name, filename) @@ -1134,12 +1138,16 @@ all_sql.append("""INSERT INTO grid_alternatives(original_grid_name, 'https://cdn.proj.org/fr_ign_ntf_r93.tif', 1, 1, NULL); """) -for grid in setVerticalGrids: +for grid in sorted(setVerticalGrids): original_grid_name = grid old_proj_grid_name = grid[grid.rfind('/')+1:].replace('.txt', '.gtx').replace('.mnt', '.gtx').replace('.gra', '.gtx') gtiff_grid_name = 'fr_ign_' + old_proj_grid_name[0:-4] + '.tif' + proj_cdn_url = 'https://cdn.proj.org/' + gtiff_grid_name + r = requests.head(proj_cdn_url, allow_redirects = True) + assert r.status_code in (200, 302), proj_cdn_url + all_sql.append("""INSERT INTO grid_alternatives(original_grid_name, proj_grid_name, old_proj_grid_name, @@ -1155,7 +1163,7 @@ for grid in setVerticalGrids: 'geoid_like', 0, NULL, - '%s', 1, 1, NULL);""" % (original_grid_name, gtiff_grid_name, old_proj_grid_name, 'https://cdn.proj.org/' + gtiff_grid_name)) + '%s', 1, 1, NULL);""" % (original_grid_name, gtiff_grid_name, old_proj_grid_name, proj_cdn_url)) all_sql.append('') -- cgit v1.2.3 From 59f344df91f1fb720c965dd44f4453833cae44ba Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Tue, 6 Apr 2021 23:20:00 +0200 Subject: Database: do not create Helmert transformations in IGNF between CRS of different nature, and also adjust the method code/name to the nature of the CRS --- scripts/build_db_create_ignf_from_xml.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/build_db_create_ignf_from_xml.py b/scripts/build_db_create_ignf_from_xml.py index f248d9d1..6b659bc2 100755 --- a/scripts/build_db_create_ignf_from_xml.py +++ b/scripts/build_db_create_ignf_from_xml.py @@ -320,7 +320,7 @@ for node in root.iterfind('.//GeographicCRS'): all_sql.append(sql) mapCrsId[id] = ('IGNF', id) - mapGeographicId[id] = ('IGNF', id) + mapGeographicId[id] = ('IGNF', id, type) key = str((mapDatumId[datumCode], extent_auth_and_code)) if key in mapDatumAndAreaToGeographicId: #print('Adding ' + id + ' to ' + str(mapDatumAndAreaToGeographicId[key])) @@ -345,7 +345,7 @@ for node in root.iterfind('.//GeographicCRS'): all_sql.append(sql) mapCrsId[id] = ('IGNF', id) - mapGeographicId[id] = ('IGNF', id) + mapGeographicId[id] = ('IGNF', id, type) key = str((mapDatumId[datumCode], extent_auth_and_code)) if key in mapDatumAndAreaToGeographicId: #print('Adding ' + id + ' to ' + str(mapDatumAndAreaToGeographicId[key])) @@ -665,6 +665,9 @@ for node in root.iterfind('.//Transformation'): method_geog_code = "'9603'" method_geog_name = "'Geocentric translations (geog2D domain)'" + method_geog_3d_code = "'1035'" + method_geog_3d_name = "'Geocentric translations (geog3D domain)'" + else: s = vals[3].find('ParameterValue').find('value').text assert vals[3].find('ParameterValue').find('value').attrib['uom'] == 'UNITE' @@ -689,6 +692,9 @@ for node in root.iterfind('.//Transformation'): method_geog_code = "'9606'" method_geog_name = "'Position Vector transformation (geog2D domain)'" + method_geog_3d_code = "'1037'" + method_geog_3d_name = "'Geocentric translations (geog3D domain)'" + for src in get_alias_of(sourceCRS): for target in get_alias_of(targetCRS): @@ -716,6 +722,11 @@ for node in root.iterfind('.//Transformation'): for sourceGeogId in sourceGeogIdAr: for targetGeogId in targetGeogIdAr: + # Check type + type = mapGeographicId[sourceGeogId][2] + if type != mapGeographicId[targetGeogId][2]: + continue + for src in get_alias_of(sourceGeogId): for target in get_alias_of(targetGeogId): @@ -723,7 +734,7 @@ for node in root.iterfind('.//Transformation'): #sql = """INSERT INTO "coordinate_operation" VALUES('IGNF','%s','helmert_transformation');""" % (id_geog) #all_sql.append(sql) - sql = """INSERT INTO "helmert_transformation" VALUES('IGNF','%s','%s',NULL,'EPSG',%s,%s,'%s','%s','%s','%s',NULL,%s,%s,%s,'EPSG','9001',%s,%s,%s,%s,%s,%s,%s, %s,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'%s',0);""" % (id_geog, name, method_geog_code, method_geog_name, src[0], src[1], target[0], target[1], x, y, z, rx, ry, rz, r_uom_auth_name, r_uom_code, s, s_uom_auth_name, s_uom_code, operation_version) + sql = """INSERT INTO "helmert_transformation" VALUES('IGNF','%s','%s',NULL,'EPSG',%s,%s,'%s','%s','%s','%s',NULL,%s,%s,%s,'EPSG','9001',%s,%s,%s,%s,%s,%s,%s, %s,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'%s',0);""" % (id_geog, name, method_geog_code if type == 'geographic 2D' else method_geog_3d_code, method_geog_name if type == 'geographic 2D' else method_geog_3d_name, src[0], src[1], target[0], target[1], x, y, z, rx, ry, rz, r_uom_auth_name, r_uom_code, s, s_uom_auth_name, s_uom_code, operation_version) all_sql.append(sql) sql = """INSERT INTO "usage" VALUES('IGNF', '%s_USAGE','helmert_transformation','IGNF','%s','%s','%s','%s','%s');""" % (id_geog, id_geog, extent_auth_and_code[0], extent_auth_and_code[1], scope_auth_and_code[0], scope_auth_and_code[1]) all_sql.append(sql) -- cgit v1.2.3