diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2019-11-16 11:52:29 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2019-11-16 11:53:17 +0100 |
| commit | 88875c1b191d5e8f98e66a19ffae7420cdf3fe77 (patch) | |
| tree | 48be661b4f419d3abee41e405b65e45b56ff4af1 /src/4D_api.cpp | |
| parent | fab6ae78eaea6881d24d2554be642bc1d2099a7e (diff) | |
| download | PROJ-88875c1b191d5e8f98e66a19ffae7420cdf3fe77.tar.gz PROJ-88875c1b191d5e8f98e66a19ffae7420cdf3fe77.zip | |
proj_create_crs_to_crs(): fix autoselection logic of operation to compute correctly the geographic coordinates of the input coord when the CRS is not Greenwich based
Diffstat (limited to 'src/4D_api.cpp')
| -rw-r--r-- | src/4D_api.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/4D_api.cpp b/src/4D_api.cpp index 71c708de..039788be 100644 --- a/src/4D_api.cpp +++ b/src/4D_api.cpp @@ -949,7 +949,7 @@ static PJ* add_coord_op_to_list(PJ* op, } /*****************************************************************************/ -static PJ* create_operation_to_base_geog_crs(PJ_CONTEXT* ctx, const PJ* crs) { +static PJ* create_operation_to_geog_crs(PJ_CONTEXT* ctx, const PJ* crs) { /*****************************************************************************/ // Create a geographic 2D long-lat degrees CRS that is related to the // CRS @@ -969,9 +969,19 @@ static PJ* create_operation_to_base_geog_crs(PJ_CONTEXT* ctx, const PJ* crs) { { auto cs = proj_create_ellipsoidal_2D_cs( ctx, PJ_ELLPS2D_LONGITUDE_LATITUDE, nullptr, 0); - auto temp = proj_create_geographic_crs_from_datum( - ctx,"unnamed", datum, cs); + auto ellps = proj_get_ellipsoid(ctx, datum); proj_destroy(datum); + double semi_major_metre = 0; + double inv_flattening = 0; + proj_ellipsoid_get_parameters(ctx, ellps, &semi_major_metre, + nullptr, nullptr, &inv_flattening); + auto temp = proj_create_geographic_crs( + ctx, "unnamed crs", "unnamed datum", + proj_get_name(ellps), + semi_major_metre, inv_flattening, + "Reference prime meridian", 0, nullptr, 0, + cs); + proj_destroy(ellps); proj_destroy(cs); proj_destroy(geodetic_crs); geodetic_crs = temp; @@ -1114,7 +1124,7 @@ PJ *proj_create_crs_to_crs_from_pj (PJ_CONTEXT *ctx, const PJ *source_crs, cons return P; } - auto pjGeogToSrc = create_operation_to_base_geog_crs(ctx, source_crs); + auto pjGeogToSrc = create_operation_to_geog_crs(ctx, source_crs); if( !pjGeogToSrc ) { proj_list_destroy(op_list); @@ -1125,7 +1135,7 @@ PJ *proj_create_crs_to_crs_from_pj (PJ_CONTEXT *ctx, const PJ *source_crs, cons return nullptr; } - auto pjGeogToDst = create_operation_to_base_geog_crs(ctx, target_crs); + auto pjGeogToDst = create_operation_to_geog_crs(ctx, target_crs); if( !pjGeogToDst ) { proj_list_destroy(op_list); |
