diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2019-01-17 17:01:20 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2019-01-17 21:57:27 +0100 |
| commit | c0ac895d77e823fe9a9458d013eb0f6378f39060 (patch) | |
| tree | 9e7641cda61a75c3a6209d17dad6fa7c8448cd44 /src/4D_api.cpp | |
| parent | 3121d9bc309b439adcc2ab9743a3d2b3a8f48296 (diff) | |
| download | PROJ-c0ac895d77e823fe9a9458d013eb0f6378f39060.tar.gz PROJ-c0ac895d77e823fe9a9458d013eb0f6378f39060.zip | |
Remove proj_create_from_proj_string() and proj_create_from_user_input(), and make proj_create() do more or less what proj_create_from_user_input() did before (fixes #1214)
Diffstat (limited to 'src/4D_api.cpp')
| -rw-r--r-- | src/4D_api.cpp | 57 |
1 files changed, 40 insertions, 17 deletions
diff --git a/src/4D_api.cpp b/src/4D_api.cpp index 710b59e3..5502c96f 100644 --- a/src/4D_api.cpp +++ b/src/4D_api.cpp @@ -462,7 +462,7 @@ Returns 1 on success, 0 on failure if (nullptr==def) return 0; sprintf (def, "break_cs2cs_recursion proj=axisswap axis=%s", P->axis); - Q = proj_create (P->ctx, def); + Q = pj_create_internal (P->ctx, def); free (def); if (nullptr==Q) return 0; @@ -477,7 +477,7 @@ Returns 1 on success, 0 on failure if (nullptr==def) return 0; sprintf (def, "break_cs2cs_recursion proj=vgridshift grids=%s", gridnames); - Q = proj_create (P->ctx, def); + Q = pj_create_internal (P->ctx, def); free (def); if (nullptr==Q) return 0; @@ -492,7 +492,7 @@ Returns 1 on success, 0 on failure if (nullptr==def) return 0; sprintf (def, "break_cs2cs_recursion proj=hgridshift grids=%s", gridnames); - Q = proj_create (P->ctx, def); + Q = pj_create_internal (P->ctx, def); free (def); if (nullptr==Q) return 0; @@ -524,7 +524,7 @@ Returns 1 on success, 0 on failure if (nullptr==def) return 0; sprintf (def, "break_cs2cs_recursion proj=helmert exact %s convention=position_vector", s); - Q = proj_create (P->ctx, def); + Q = pj_create_internal (P->ctx, def); free(def); if (nullptr==Q) return 0; @@ -550,14 +550,14 @@ Returns 1 on success, 0 on failure *next_pos = '.'; } } - Q = proj_create (P->ctx, def); + Q = pj_create_internal (P->ctx, def); if (nullptr==Q) return 0; P->cart = skip_prep_fin (Q); if (!P->is_geocent) { sprintf (def, "break_cs2cs_recursion proj=cart ellps=WGS84"); - Q = proj_create (P->ctx, def); + Q = pj_create_internal (P->ctx, def); if (nullptr==Q) return 0; P->cart_wgs84 = skip_prep_fin (Q); @@ -568,9 +568,10 @@ Returns 1 on success, 0 on failure } - /*************************************************************************************/ -PJ *proj_create (PJ_CONTEXT *ctx, const char *definition) { +PJ *pj_create_internal (PJ_CONTEXT *ctx, const char *definition) { +/*************************************************************************************/ + /************************************************************************************** Create a new PJ object in the context ctx, using the given definition. If ctx==0, the default context is used, if definition==0, or invalid, a null-pointer is @@ -623,8 +624,6 @@ PJ *proj_create (PJ_CONTEXT *ctx, const char *definition) { return P; } - - /*************************************************************************************/ PJ *proj_create_argv (PJ_CONTEXT *ctx, int argc, char **argv) { /************************************************************************************** @@ -657,6 +656,34 @@ indicator, as in {"+proj=utm", "+zone=32"}, or leave it out, as in {"proj=utm", return P; } +/*************************************************************************************/ +PJ *pj_create_argv_internal (PJ_CONTEXT *ctx, int argc, char **argv) { +/************************************************************************************** +Same as proj_create_argv() but calls pj_create_internal() instead of proj_create() internally +**************************************************************************************/ + PJ *P; + const char *c; + + if (nullptr==ctx) + ctx = pj_get_default_ctx (); + if (nullptr==argv) { + proj_context_errno_set(ctx, PJD_ERR_NO_ARGS); + return nullptr; + } + + /* We assume that free format is used, and build a full proj_create compatible string */ + c = pj_make_args (argc, argv); + if (nullptr==c) { + proj_context_errno_set(ctx, ENOMEM); + return nullptr; + } + + P = pj_create_internal (ctx, c); + + pj_dealloc ((char *) c); + return P; +} + /** Create an area of use */ PJ_AREA * proj_area_create(void) { return static_cast<PJ_AREA*>(pj_calloc(1, sizeof(PJ_AREA))); @@ -761,7 +788,7 @@ PJ *proj_create_crs_to_crs (PJ_CONTEXT *ctx, const char *source_crs, const char - a PROJ string, like "+proj=longlat +datum=WGS84". When using that syntax, the axis order and unit for geographic CRS will be longitude, latitude, and the unit degrees. - - more generally any string accepted by proj_create_from_user_input() + - more generally any string accepted by proj_create() An "area of use" can be specified in area. When it is supplied, the more accurate transformation between two given systems can be chosen. @@ -772,27 +799,23 @@ PJ *proj_create_crs_to_crs (PJ_CONTEXT *ctx, const char *source_crs, const char ******************************************************************************/ const char* proj_string; - const char* const optionsProj4Mode[] = { "USE_PROJ4_INIT_RULES=YES", nullptr }; if( !ctx ) { ctx = pj_get_default_ctx(); } - const char* const* optionsImportCRS = - proj_context_get_use_proj4_init_rules(ctx, FALSE) ? optionsProj4Mode : nullptr; - try { std::string source_crs_modified(pj_add_type_crs_if_needed(source_crs)); std::string target_crs_modified(pj_add_type_crs_if_needed(target_crs)); - auto src = proj_create_from_user_input(ctx, source_crs_modified.c_str(), optionsImportCRS); + auto src = proj_create(ctx, source_crs_modified.c_str()); if( !src ) { proj_context_log_debug(ctx, "Cannot instantiate source_crs"); return nullptr; } - auto dst = proj_create_from_user_input(ctx, target_crs_modified.c_str(), optionsImportCRS); + auto dst = proj_create(ctx, target_crs_modified.c_str()); if( !dst ) { proj_context_log_debug(ctx, "Cannot instantiate target_crs"); proj_destroy(src); |
