Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue when transforming between COMPD_CS with PROJ4D_GRIDS in VERT_CS #2720

Closed
aharondavid opened this issue May 11, 2021 · 1 comment · Fixed by #2721
Closed

Issue when transforming between COMPD_CS with PROJ4D_GRIDS in VERT_CS #2720

aharondavid opened this issue May 11, 2021 · 1 comment · Fixed by #2721
Labels
Milestone

Comments

@aharondavid
Copy link

Code Example

    char *p = "COMPD_CS[\"WGS84 Coordinate System + EGM96 geoid height\",GEOGCS[\"WGS84 Coordinate System\",DATUM[\"WGS 1984\",SPHEROID[\"WGS 1984\",6378137,298.257223563],TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433],AUTHORITY[\"EPSG\",\"4326\"],AUTHORITY[\"SBMG\",\"LAT-LONG,LAT-LONG,WGS84,METERS\"]],VERT_CS[\"EGM96 geoid height\",VERT_DATUM[\"EGM96 geoid\",2005,EXTENSION[\"PROJ4_GRIDS\",\"egm96_15.gtx\"],AUTHORITY[\"EPSG\",\"5171\"]],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AXIS[\"Up\",UP],AUTHORITY[\"EPSG\",\"5773\"]]]";
    char* p2 = "COMPD_CS[\"Orthographic (-86.7740944444444000,36.1754430555555000) + EGM96 geoid height\",PROJCS[\"Orthographic (-86.7740944444444000,36.1754430555555000)\",GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_unknown\",SPHEROID[\"WGS84\",6378137,298.257223563]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.017453292519943295]],PROJECTION[\"Orthographic\"],PARAMETER[\"Latitude_Of_Center\",36.1754430555555000],PARAMETER[\"Longitude_Of_Center\",-86.7740944444444000],PARAMETER[\"false_easting\",0],PARAMETER[\"false_northing\",0],UNIT[\"Meter\",1]],VERT_CS[\"EGM96 geoid height\",VERT_DATUM[\"EGM96 geoid\",2005,EXTENSION[\"PROJ4_GRIDS\",\"egm96_15.gtx\"],AUTHORITY[\"EPSG\",\"5171\"]],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AXIS[\"Up\",UP],AUTHORITY[\"EPSG\",\"5773\"]]]";
    OGRErr error;

    OGRSpatialReference DestSRS;
    OGRErr error1 = DestSRS.importFromWkt(&p);
#if GDAL_VERSION_NUM > 3000000
    DestSRS.PromoteTo3D(NULL);
#endif

    OGRSpatialReference SourceSRS;
    OGRErr error2 = SourceSRS.importFromWkt(&p2);
#if GDAL_VERSION_NUM > 3000000
    SourceSRS.PromoteTo3D(NULL);
#endif
 

    OGRCoordinateTransformation *ct = OGRCreateCoordinateTransformation(&SourceSRS, &DestSRS);
    double px[4], py[4], pz[4] = {108.0,108.0 ,179.0,179.0 };
    px[0] = -3889.2358257064002;
    px[1] = 3794.7820422121999;
    px[2] = 3794.7820422121999;
    px[3] = -3889.2358257064002;


    py[0] = -612.30228532449996;
    py[1] = -612.30228532449996;
    py[2] = 800.32060197140004;
    py[3] = 800.32060197140004;

    BOOL bRet = ct->Transform(4, px, py);// , pz);// , pz);

//bRet is false in GDAL >3 and true in GDAL <3




#### Expected Output

should be succeed in GDAL > 3, due to of using in PromoteTo3D  
 
#### Environment Information
 - PROJ 8.0
 - GDAL 3.1.2
 - Windows 10
@rouault
Copy link
Member

rouault commented May 11, 2021

The use of PromoteTo3D() is useless here, as they are already 3D CRS. Seems to be more a PROJ issue with COMPD_CS / PROJ4D_GRIDS in VERT_CS:

$ src/projinfo -s "COMPD_CS[\"Orthographic (-86.7740944444444000,36.1754430555555000) + EGM96 geoid height\",PROJCS[\"Orthographic (-86.7740944444444000,36.1754430555555000)\",GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_unknown\",SPHEROID[\"WGS84\",6378137,298.257223563]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.017453292519943295]],PROJECTION[\"Orthographic\"],PARAMETER[\"Latitude_Of_Center\",36.1754430555555000],PARAMETER[\"Longitude_Of_Center\",-86.7740944444444000],PARAMETER[\"false_easting\",0],PARAMETER[\"false_northing\",0],UNIT[\"Meter\",1]],VERT_CS[\"EGM96 geoid height\",VERT_DATUM[\"EGM96 geoid\",2005,EXTENSION[\"PROJ4_GRIDS\",\"egm96_15.gtx\"],AUTHORITY[\"EPSG\",\"5171\"]],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AXIS[\"Up\",UP],AUTHORITY[\"EPSG\",\"5773\"]]]" -t "COMPD_CS[\"WGS84 Coordinate System + EGM96 geoid height\",GEOGCS[\"WGS84 Coordinate System\",DATUM[\"WGS 1984\",SPHEROID[\"WGS 1984\",6378137,298.257223563],TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433],AUTHORITY[\"EPSG\",\"4326\"],AUTHORITY[\"SBMG\",\"LAT-LONG,LAT-LONG,WGS84,METERS\"]],VERT_CS[\"EGM96 geoid height\",VERT_DATUM[\"EGM96 geoid\",2005,EXTENSION[\"PROJ4_GRIDS\",\"egm96_15.gtx\"],AUTHORITY[\"EPSG\",\"5171\"]],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AXIS[\"Up\",UP],AUTHORITY[\"EPSG\",\"5773\"]]]"
Warning: Parsing error : syntax error, unexpected ',', expecting ']' or ')'. Error occurred around:
74532925199433],AUTHORITY["EPSG","4326"],AUTHORITY["SBMG","LAT-LONG,LAT-LONG,WGS
                                        ^
Candidate operations found: 1
-------------------------------------
Operation No. 1:

unknown id, Inverse of unnamed + Ballpark geographic offset from WGS 84 to WGS84 Coordinate System, unknown accuracy, World, has ballpark transformation

PROJ string:
Error when exporting to PROJ string: Can apply Geographic 2D offsets only to GeographicCRS

@rouault rouault changed the title Transform failed in GDAL 3 despite of using in PromoteTo3D Issue when transforming between COMPD_CS with PROJ4D_GRIDS in VERT_CS May 11, 2021
rouault added a commit to rouault/PROJ that referenced this issue May 12, 2021
@rouault rouault added this to the 8.1.0 milestone May 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants