@@ -1424,3 +1424,106 @@ def test_tiff_srs_build_compd_crs_name_without_citation():
1424
1424
1425
1425
ds = gdal .Open ("data/gtiff/compdcrs_no_citation.tif" )
1426
1426
assert ds .GetSpatialRef ().GetName () == "WGS 84 / UTM zone 17N + EGM2008 height"
1427
+
1428
+
1429
+ def test_tiff_srs_read_epsg_27563_allgeokeys ():
1430
+
1431
+ ds = gdal .Open ("data/gtiff/epsg_27563_allgeokeys.tif" )
1432
+ srs = ds .GetSpatialRef ()
1433
+ wkt = srs .ExportToWkt (["FORMAT=WKT2_2019" ])
1434
+ # deal with differences of precision according to PROJ version
1435
+ wkt = wkt .replace ("49.0000000000001" , "49" )
1436
+ wkt = wkt .replace ("49.0000000000002" , "49" )
1437
+ assert 'PARAMETER["Latitude of natural origin",49,ANGLEUNIT["grad"' in wkt
1438
+ assert (
1439
+ srs .ExportToProj4 ()
1440
+ == "+proj=lcc +lat_1=44.1 +lat_0=44.1 +lon_0=0 +k_0=0.999877499 +x_0=600000 +y_0=200000 +ellps=clrk80ign +pm=paris +towgs84=-168,-60,320,0,0,0,0 +units=m +no_defs"
1441
+ )
1442
+
1443
+
1444
+ def test_tiff_srs_write_read_epsg_27563_only_code (tmp_vsimem ):
1445
+
1446
+ filename = str (tmp_vsimem / "test.tif" )
1447
+ srs = osr .SpatialReference ()
1448
+ srs .ImportFromEPSG (27563 )
1449
+ ds = gdal .GetDriverByName ("GTiff" ).Create (filename , 1 , 1 )
1450
+ ds .SetSpatialRef (srs )
1451
+ ds = None
1452
+
1453
+ ds = gdal .Open (filename )
1454
+ srs = ds .GetSpatialRef ()
1455
+ assert (
1456
+ 'PARAMETER["Latitude of natural origin",49,ANGLEUNIT["grad"'
1457
+ in srs .ExportToWkt (["FORMAT=WKT2_2019" ])
1458
+ )
1459
+ assert (
1460
+ srs .ExportToProj4 ()
1461
+ == "+proj=lcc +lat_1=44.1 +lat_0=44.1 +lon_0=0 +k_0=0.999877499 +x_0=600000 +y_0=200000 +ellps=clrk80ign +pm=paris +towgs84=-168,-60,320,0,0,0,0 +units=m +no_defs"
1462
+ )
1463
+
1464
+
1465
+ @pytest .mark .parametrize (
1466
+ "config_options" ,
1467
+ [
1468
+ {},
1469
+ {
1470
+ "GTIFF_WRITE_ANGULAR_PARAMS_IN_DEGREE" : "YES" ,
1471
+ "GTIFF_READ_ANGULAR_PARAMS_IN_DEGREE" : "YES" ,
1472
+ },
1473
+ ],
1474
+ )
1475
+ def test_tiff_srs_write_read_epsg_27563_full_def (tmp_vsimem , config_options ):
1476
+
1477
+ with gdal .config_options (config_options ):
1478
+ filename = str (tmp_vsimem / "test.tif" )
1479
+ srs = osr .SpatialReference ()
1480
+ srs .SetFromUserInput (
1481
+ """PROJCRS["NTF (Paris) / Lambert Sud France",
1482
+ BASEGEOGCRS["NTF (Paris)",
1483
+ DATUM["Nouvelle Triangulation Francaise (Paris)",
1484
+ ELLIPSOID["Clarke 1880 (IGN)",6378249.2,293.466021293627,
1485
+ LENGTHUNIT["metre",1]]],
1486
+ PRIMEM["Paris",2.5969213,
1487
+ ANGLEUNIT["grad",0.0157079632679489]],
1488
+ ID["EPSG",4807]],
1489
+ CONVERSION["Lambert Sud France",
1490
+ METHOD["Lambert Conic Conformal (1SP)",
1491
+ ID["EPSG",9801]],
1492
+ PARAMETER["Latitude of natural origin",49,
1493
+ ANGLEUNIT["grad",0.0157079632679489],
1494
+ ID["EPSG",8801]],
1495
+ PARAMETER["Longitude of natural origin",0,
1496
+ ANGLEUNIT["grad",0.0157079632679489],
1497
+ ID["EPSG",8802]],
1498
+ PARAMETER["Scale factor at natural origin",0.999877499,
1499
+ SCALEUNIT["unity",1],
1500
+ ID["EPSG",8805]],
1501
+ PARAMETER["False easting",600000,
1502
+ LENGTHUNIT["metre",1],
1503
+ ID["EPSG",8806]],
1504
+ PARAMETER["False northing",200000,
1505
+ LENGTHUNIT["metre",1],
1506
+ ID["EPSG",8807]]],
1507
+ CS[Cartesian,2],
1508
+ AXIS["easting (X)",east,
1509
+ ORDER[1],
1510
+ LENGTHUNIT["metre",1]],
1511
+ AXIS["northing (Y)",north,
1512
+ ORDER[2],
1513
+ LENGTHUNIT["metre",1]]]"""
1514
+ )
1515
+ ds = gdal .GetDriverByName ("GTiff" ).Create (filename , 1 , 1 )
1516
+ ds .SetSpatialRef (srs )
1517
+ ds = None
1518
+
1519
+ ds = gdal .Open (filename )
1520
+ srs = ds .GetSpatialRef ()
1521
+ wkt = srs .ExportToWkt (["FORMAT=WKT2_2019" ])
1522
+ # deal with differences of precision according to PROJ version
1523
+ wkt = wkt .replace ("49.0000000000001" , "49" )
1524
+ wkt = wkt .replace ("49.0000000000002" , "49" )
1525
+ assert 'PARAMETER["Latitude of natural origin",49,ANGLEUNIT["grad"' in wkt
1526
+ assert (
1527
+ srs .ExportToProj4 ()
1528
+ == "+proj=lcc +lat_1=44.1 +lat_0=44.1 +lon_0=0 +k_0=0.999877499 +x_0=600000 +y_0=200000 +ellps=clrk80ign +pm=paris +units=m +no_defs"
1529
+ )
0 commit comments