diff options
34 files changed, 137 insertions, 234 deletions
diff --git a/src/4D_api.cpp b/src/4D_api.cpp index 86c0e071..70b04bf1 100644 --- a/src/4D_api.cpp +++ b/src/4D_api.cpp @@ -1363,7 +1363,7 @@ int proj_errno (const PJ *P) { /****************************************************************************** Read an error level from the context of a PJ. ******************************************************************************/ - return pj_ctx_get_errno (pj_get_ctx ((PJ *) P)); + return proj_context_errno (pj_get_ctx ((PJ *) P)); } /*****************************************************************************/ @@ -1374,7 +1374,7 @@ int proj_context_errno (PJ_CONTEXT *ctx) { ******************************************************************************/ if (nullptr==ctx) ctx = pj_get_default_ctx(); - return pj_ctx_get_errno (ctx); + return ctx->last_errno; } /*****************************************************************************/ @@ -1389,6 +1389,7 @@ int proj_errno_set (const PJ *P, int err) { /* For P==0 err goes to the default context */ proj_context_errno_set (pj_get_ctx ((PJ *) P), err); errno = err; + return err; } @@ -1439,7 +1440,7 @@ int proj_errno_reset (const PJ *P) { int last_errno; last_errno = proj_errno (P); - pj_ctx_set_errno (pj_get_ctx ((PJ *) P), 0); + proj_context_errno_set (pj_get_ctx ((PJ *) P), 0); errno = 0; pj_errno = 0; return last_errno; @@ -1448,7 +1449,7 @@ int proj_errno_reset (const PJ *P) { /* Create a new context based on the default context */ PJ_CONTEXT *proj_context_create (void) { - return pj_ctx_alloc (); + return new (std::nothrow) pj_ctx(*pj_get_default_ctx()); } @@ -1460,7 +1461,7 @@ PJ_CONTEXT *proj_context_destroy (PJ_CONTEXT *ctx) { if (pj_get_default_ctx ()==ctx) return nullptr; - pj_ctx_free (ctx); + delete ctx; return nullptr; } @@ -1746,7 +1747,7 @@ PJ_INIT_INFO proj_init_info(const char *initname){ if( strcmp(initname, "epsg") == 0 || strcmp(initname, "EPSG") == 0 ) { const char* val; - pj_ctx_set_errno( ctx, 0 ); + proj_context_errno_set( ctx, 0 ); strncpy (ininfo.name, initname, sizeof(ininfo.name) - 1); strcpy(ininfo.origin, "EPSG"); @@ -1764,7 +1765,7 @@ PJ_INIT_INFO proj_init_info(const char *initname){ if( strcmp(initname, "IGNF") == 0 ) { const char* val; - pj_ctx_set_errno( ctx, 0 ); + proj_context_errno_set( ctx, 0 ); strncpy (ininfo.name, initname, sizeof(ininfo.name) - 1); strcpy(ininfo.origin, "IGNF"); diff --git a/src/aasincos.cpp b/src/aasincos.cpp index c3229d39..c4314c67 100644 --- a/src/aasincos.cpp +++ b/src/aasincos.cpp @@ -14,7 +14,7 @@ aasin(PJ_CONTEXT *ctx,double v) { if ((av = fabs(v)) >= 1.) { if (av > ONE_TOL) - pj_ctx_set_errno( ctx, PJD_ERR_ACOS_ASIN_ARG_TOO_LARGE ); + proj_context_errno_set( ctx, PJD_ERR_ACOS_ASIN_ARG_TOO_LARGE ); return (v < 0. ? -M_HALFPI : M_HALFPI); } return asin(v); @@ -26,7 +26,7 @@ aacos(PJ_CONTEXT *ctx, double v) { if ((av = fabs(v)) >= 1.) { if (av > ONE_TOL) - pj_ctx_set_errno( ctx, PJD_ERR_ACOS_ASIN_ARG_TOO_LARGE ); + proj_context_errno_set( ctx, PJD_ERR_ACOS_ASIN_ARG_TOO_LARGE ); return (v < 0. ? M_PI : 0.); } return acos(v); diff --git a/src/apps/cs2cs.cpp b/src/apps/cs2cs.cpp index 1a33d444..92e4441e 100644 --- a/src/apps/cs2cs.cpp +++ b/src/apps/cs2cs.cpp @@ -468,10 +468,23 @@ int main(int argc, char **argv) { reverseout = 1; continue; case 'D': /* set debug level */ + { if (--argc <= 0) goto noargument; - pj_ctx_set_debug(pj_get_default_ctx(), atoi(*++argv)); + int log_level = atoi(*++argv); + if (log_level <= 0) { + proj_log_level(pj_get_default_ctx(), PJ_LOG_NONE); + } else if (log_level == 1) { + proj_log_level(pj_get_default_ctx(), PJ_LOG_ERROR); + } else if (log_level == 2) { + proj_log_level(pj_get_default_ctx(), PJ_LOG_DEBUG); + } else if (log_level == 3) { + proj_log_level(pj_get_default_ctx(), PJ_LOG_TRACE); + } else { + proj_log_level(pj_get_default_ctx(), PJ_LOG_TELL); + } continue; + } case 'd': if (--argc <= 0) goto noargument; diff --git a/src/ctx.cpp b/src/ctx.cpp index d3eee39f..8e25db2a 100644 --- a/src/ctx.cpp +++ b/src/ctx.cpp @@ -54,13 +54,17 @@ PJ_CONTEXT* pj_get_ctx( PJ *pj ) } /************************************************************************/ -/* pj_set_ctx() */ -/* */ -/* Note we do not deallocate the old context! */ +/* proj_assign_context() */ /************************************************************************/ -void pj_set_ctx( PJ *pj, PJ_CONTEXT *ctx ) - +/** \brief Re-assign a context to a PJ* object. + * + * This may be useful if the PJ* has been created with a context that is + * thread-specific, and is later used in another thread. In that case, + * the user may want to assign another thread-specific context to the + * object. + */ +void proj_assign_context( PJ* pj, PJ_CONTEXT *ctx ) { if (pj==nullptr) return; @@ -71,24 +75,9 @@ void pj_set_ctx( PJ *pj, PJ_CONTEXT *ctx ) } for( const auto &alt: pj->alternativeCoordinateOperations ) { - pj_set_ctx(alt.pj, ctx); + proj_assign_context(alt.pj, ctx); } -} -/************************************************************************/ -/* proj_assign_context() */ -/************************************************************************/ - -/** \brief Re-assign a context to a PJ* object. - * - * This may be useful if the PJ* has been created with a context that is - * thread-specific, and is later used in another thread. In that case, - * the user may want to assign another thread-specific context to the - * object. - */ -void proj_assign_context( PJ* pj, PJ_CONTEXT *ctx ) -{ - pj_set_ctx( pj, ctx ); } /************************************************************************/ @@ -213,16 +202,6 @@ pj_ctx::~pj_ctx() } /************************************************************************/ -/* pj_ctx_alloc() */ -/************************************************************************/ - -PJ_CONTEXT* pj_ctx_alloc() - -{ - return new (std::nothrow) pj_ctx(*pj_get_default_ctx()); -} - -/************************************************************************/ /* proj_context_clone() */ /* Create a new context based on a custom context */ /************************************************************************/ @@ -230,93 +209,9 @@ PJ_CONTEXT* pj_ctx_alloc() PJ_CONTEXT* proj_context_clone (PJ_CONTEXT *ctx) { if (nullptr==ctx) - return pj_ctx_alloc (); + return proj_context_create(); return new (std::nothrow) pj_ctx(*ctx); } -/************************************************************************/ -/* pj_ctx_free() */ -/************************************************************************/ - -void pj_ctx_free( PJ_CONTEXT *ctx ) - -{ - delete ctx; -} - -/************************************************************************/ -/* pj_ctx_get_errno() */ -/************************************************************************/ - -int pj_ctx_get_errno( PJ_CONTEXT *ctx ) -{ - if (nullptr==ctx) - return pj_get_default_ctx ()->last_errno; - return ctx->last_errno; -} - -/************************************************************************/ -/* pj_ctx_set_errno() */ -/* */ -/* Also sets the global errno */ -/************************************************************************/ - -void pj_ctx_set_errno( PJ_CONTEXT *ctx, int new_errno ) - -{ - ctx->last_errno = new_errno; - if( new_errno == 0 ) - return; - errno = new_errno; - pj_errno = new_errno; -} - -/************************************************************************/ -/* pj_ctx_set_debug() */ -/************************************************************************/ - -void pj_ctx_set_debug( PJ_CONTEXT *ctx, int new_debug ) - -{ - if (nullptr==ctx) - return; - ctx->debug_level = new_debug; -} - -/************************************************************************/ -/* pj_ctx_set_logger() */ -/************************************************************************/ - -void pj_ctx_set_logger( PJ_CONTEXT *ctx, void (*new_logger)(void*,int,const char*) ) - -{ - if (nullptr==ctx) - return; - ctx->logger = new_logger; -} - -/************************************************************************/ -/* pj_ctx_set_app_data() */ -/************************************************************************/ - -void pj_ctx_set_app_data( PJ_CONTEXT *ctx, void *new_app_data ) - -{ - if (nullptr==ctx) - return; - ctx->logger_app_data = new_app_data; -} - -/************************************************************************/ -/* pj_ctx_get_app_data() */ -/************************************************************************/ - -void *pj_ctx_get_app_data( PJ_CONTEXT *ctx ) - -{ - if (nullptr==ctx) - return nullptr; - return ctx->logger_app_data; -} diff --git a/src/datum_set.cpp b/src/datum_set.cpp index cc6f3dbe..398d85cd 100644 --- a/src/datum_set.cpp +++ b/src/datum_set.cpp @@ -71,7 +71,7 @@ int pj_datum_set(PJ_CONTEXT *ctx, paralist *pl, PJ *projdef) for (i = 0; (s = pj_datums[i].id) && strcmp(name, s) ; ++i) {} if (!s) { - pj_ctx_set_errno(ctx, PJD_ERR_UNKNOWN_ELLP_PARAM); + proj_context_errno_set(ctx, PJD_ERR_UNKNOWN_ELLP_PARAM); return 1; } @@ -87,7 +87,7 @@ int pj_datum_set(PJ_CONTEXT *ctx, paralist *pl, PJ *projdef) curr = curr->next = pj_mkparam(entry); if (nullptr == curr) { - pj_ctx_set_errno(ctx, ENOMEM); + proj_context_errno_set(ctx, ENOMEM); return 1; } } @@ -97,7 +97,7 @@ int pj_datum_set(PJ_CONTEXT *ctx, paralist *pl, PJ *projdef) curr = curr->next = pj_mkparam(pj_datums[i].defn); if (nullptr == curr) { - pj_ctx_set_errno(ctx, ENOMEM); + proj_context_errno_set(ctx, ENOMEM); return 1; } } diff --git a/src/dmstor.cpp b/src/dmstor.cpp index e72d9930..24887a11 100644 --- a/src/dmstor.cpp +++ b/src/dmstor.cpp @@ -61,7 +61,7 @@ dmstor_ctx(PJ_CONTEXT *ctx, const char *is, char **rs) { n = 2; break; case 'r': case 'R': if (nl) { - pj_ctx_set_errno( ctx, PJD_ERR_WRONG_FORMAT_DMS_VALUE ); + proj_context_errno_set( ctx, PJD_ERR_WRONG_FORMAT_DMS_VALUE ); return HUGE_VAL; } ++s; @@ -73,7 +73,7 @@ dmstor_ctx(PJ_CONTEXT *ctx, const char *is, char **rs) { continue; } if (n < nl) { - pj_ctx_set_errno( ctx, PJD_ERR_WRONG_FORMAT_DMS_VALUE ); + proj_context_errno_set( ctx, PJD_ERR_WRONG_FORMAT_DMS_VALUE ); return HUGE_VAL; } v += tv * vm[n]; diff --git a/src/ell_set.cpp b/src/ell_set.cpp index ec3e03eb..c7cbeb48 100644 --- a/src/ell_set.cpp +++ b/src/ell_set.cpp @@ -552,7 +552,7 @@ int pj_calc_ellipsoid_params (PJ *P, double a, double es) { if (0==P->f) P->f = 1 - cos (P->alpha); /* = 1 - sqrt (1 - PIN->es); */ if (P->f == 1.0) { - pj_ctx_set_errno( P->ctx, PJD_ERR_INVALID_ECCENTRICITY); + proj_context_errno_set( P->ctx, PJD_ERR_INVALID_ECCENTRICITY); return PJD_ERR_INVALID_ECCENTRICITY; } P->rf = P->f != 0.0 ? 1.0/P->f: HUGE_VAL; @@ -573,7 +573,7 @@ int pj_calc_ellipsoid_params (PJ *P, double a, double es) { P->one_es = 1. - P->es; if (P->one_es == 0.) { - pj_ctx_set_errno( P->ctx, PJD_ERR_INVALID_ECCENTRICITY); + proj_context_errno_set( P->ctx, PJD_ERR_INVALID_ECCENTRICITY); return PJD_ERR_INVALID_ECCENTRICITY; } @@ -630,7 +630,7 @@ int pj_ell_set (PJ_CONTEXT *ctx, paralist *pl, double *a, double *es) { paralist *start = 0; /* clear any previous error */ - pj_ctx_set_errno(ctx,0); + proj_context_errno_set(ctx,0); /* check for varying forms of ellipsoid input */ *a = *es = 0.; @@ -648,7 +648,7 @@ int pj_ell_set (PJ_CONTEXT *ctx, paralist *pl, double *a, double *es) { for (start = pl; start && start->next ; start = start->next) ; for (i = 0; (s = pj_ellps[i].id) && strcmp(name, s) ; ++i) ; if (!s) { - pj_ctx_set_errno( ctx, PJD_ERR_UNKNOWN_ELLP_PARAM); + proj_context_errno_set( ctx, PJD_ERR_UNKNOWN_ELLP_PARAM); return 1; } start->next = pj_mkparam(pj_ellps[i].major); @@ -662,14 +662,14 @@ int pj_ell_set (PJ_CONTEXT *ctx, paralist *pl, double *a, double *es) { else if (pj_param(ctx,pl, "te").i) { /* eccentricity */ e = pj_param(ctx,pl, "de").f; if (e < 0) { - pj_ctx_set_errno(ctx, PJD_ERR_INVALID_ECCENTRICITY); + proj_context_errno_set(ctx, PJD_ERR_INVALID_ECCENTRICITY); return 1; } *es = e * e; } else if (pj_param(ctx,pl, "trf").i) { /* recip flattening */ *es = pj_param(ctx,pl, "drf").f; if (*es == 0.0) { - pj_ctx_set_errno(ctx, PJD_ERR_REV_FLATTENING_IS_ZERO); + proj_context_errno_set(ctx, PJD_ERR_REV_FLATTENING_IS_ZERO); goto bomb; } *es = 1./ *es; @@ -700,7 +700,7 @@ int pj_ell_set (PJ_CONTEXT *ctx, paralist *pl, double *a, double *es) { *es = 0.; } else if (pj_param(ctx,pl, "bR_h").i) { /* sphere--harmonic mean */ if ( (*a + b) == 0.0) { - pj_ctx_set_errno(ctx, PJD_ERR_TOLERANCE_CONDITION); + proj_context_errno_set(ctx, PJD_ERR_TOLERANCE_CONDITION); goto bomb; } *a = 2. * *a * b / (*a + b); @@ -711,7 +711,7 @@ int pj_ell_set (PJ_CONTEXT *ctx, paralist *pl, double *a, double *es) { tmp = sin(pj_param(ctx,pl, i ? "rR_lat_a" : "rR_lat_g").f); if (fabs(tmp) > M_HALFPI) { - pj_ctx_set_errno(ctx, PJD_ERR_REF_RAD_LARGER_THAN_90); + proj_context_errno_set(ctx, PJD_ERR_REF_RAD_LARGER_THAN_90); goto bomb; } tmp = 1. - *es * tmp * tmp; @@ -730,15 +730,15 @@ bomb: } /* some remaining checks */ if (*es < 0.) { - pj_ctx_set_errno(ctx, PJD_ERR_ES_LESS_THAN_ZERO); + proj_context_errno_set(ctx, PJD_ERR_ES_LESS_THAN_ZERO); return 1; } if (*es >= 1.) { - pj_ctx_set_errno(ctx, PJD_ERR_INVALID_ECCENTRICITY); + proj_context_errno_set(ctx, PJD_ERR_INVALID_ECCENTRICITY); return 1; } if (*a <= 0.) { - pj_ctx_set_errno(ctx, PJD_ERR_MAJOR_AXIS_NOT_GIVEN); + proj_context_errno_set(ctx, PJD_ERR_MAJOR_AXIS_NOT_GIVEN); return 1; } return 0; diff --git a/src/filemanager.cpp b/src/filemanager.cpp index 66a8faf8..dbcb8ddc 100644 --- a/src/filemanager.cpp +++ b/src/filemanager.cpp @@ -1491,7 +1491,7 @@ pj_open_lib_internal(PJ_CONTEXT *ctx, const char *name, const char *mode, } if (ctx->last_errno == 0 && errno != 0) - pj_ctx_set_errno(ctx, errno); + proj_context_errno_set(ctx, errno); pj_log(ctx, PJ_LOG_DEBUG_MAJOR, "pj_open_lib(%s): call fopen(%s) - %s", name, sysname, fid == nullptr ? "failed" : "succeeded"); @@ -1591,7 +1591,7 @@ NS_PROJ::FileManager::open_resource_file(PJ_CONTEXT *ctx, const char *name) { pj_open_file_with_manager, nullptr, 0))); if (file) { - pj_ctx_set_errno(ctx, 0); + proj_context_errno_set(ctx, 0); } else { // For final network access attempt, use the new // name. @@ -1621,7 +1621,7 @@ NS_PROJ::FileManager::open_resource_file(PJ_CONTEXT *ctx, const char *name) { pj_open_file_with_manager, nullptr, 0))); if (file) { - pj_ctx_set_errno(ctx, 0); + proj_context_errno_set(ctx, 0); } } } catch (const std::exception &e) { @@ -1646,7 +1646,7 @@ NS_PROJ::FileManager::open_resource_file(PJ_CONTEXT *ctx, const char *name) { if (file) { pj_log(ctx, PJ_LOG_DEBUG_MAJOR, "Using %s", remote_file.c_str()); - pj_ctx_set_errno(ctx, 0); + proj_context_errno_set(ctx, 0); } } } diff --git a/src/gauss.cpp b/src/gauss.cpp index 54dff5a8..96bd5166 100644 --- a/src/gauss.cpp +++ b/src/gauss.cpp @@ -109,6 +109,6 @@ PJ_LP pj_inv_gauss(PJ_CONTEXT *ctx, PJ_LP slp, const void *data) { } /* convergence failed */ if (!i) - pj_ctx_set_errno(ctx, PJD_ERR_NON_CONV_INV_MERI_DIST); + proj_context_errno_set(ctx, PJD_ERR_NON_CONV_INV_MERI_DIST); return (elp); } diff --git a/src/generic_inverse.cpp b/src/generic_inverse.cpp index a15cfae1..ddd5060b 100644 --- a/src/generic_inverse.cpp +++ b/src/generic_inverse.cpp @@ -109,6 +109,6 @@ PJ_LP pj_generic_inverse_2d(PJ_XY xy, PJ *P, PJ_LP lpInitial) { lp.phi = M_HALFPI; } } - pj_ctx_set_errno(P->ctx, PJD_ERR_NON_CONVERGENT); + proj_context_errno_set(P->ctx, PJD_ERR_NON_CONVERGENT); return lp; } diff --git a/src/grids.cpp b/src/grids.cpp index 8c1bc4cc..671485d7 100644 --- a/src/grids.cpp +++ b/src/grids.cpp @@ -197,7 +197,7 @@ GTXVerticalShiftGrid *GTXVerticalShiftGrid::open(PJ_CONTEXT *ctx, /* Read the header. */ /* -------------------------------------------------------------------- */ if (fp->read(header, sizeof(header)) != sizeof(header)) { - pj_ctx_set_errno(ctx, PJD_ERR_FAILED_TO_LOAD_GRID); + proj_context_errno_set(ctx, PJD_ERR_FAILED_TO_LOAD_GRID); return nullptr; } @@ -223,7 +223,7 @@ GTXVerticalShiftGrid *GTXVerticalShiftGrid::open(PJ_CONTEXT *ctx, if (xorigin < -360 || xorigin > 360 || yorigin < -90 || yorigin > 90) { pj_log(ctx, PJ_LOG_ERROR, "gtx file header has invalid extents, corrupt?"); - pj_ctx_set_errno(ctx, PJD_ERR_FAILED_TO_LOAD_GRID); + proj_context_errno_set(ctx, PJD_ERR_FAILED_TO_LOAD_GRID); return nullptr; } @@ -258,7 +258,7 @@ bool GTXVerticalShiftGrid::valueAt(int x, int y, float &out) const { m_fp->seek(40 + sizeof(float) * (y * m_width + x)); if (m_fp->read(&out, sizeof(out)) != sizeof(out)) { - pj_ctx_set_errno(m_ctx, PJD_ERR_FAILED_TO_LOAD_GRID); + proj_context_errno_set(m_ctx, PJD_ERR_FAILED_TO_LOAD_GRID); return false; } if (IS_LSB) { @@ -1389,7 +1389,7 @@ VerticalShiftGridSet::open(PJ_CONTEXT *ctx, const std::string &filename) { auto set = std::unique_ptr<VerticalShiftGridSet>( GTiffVGridShiftSet::open(ctx, std::move(fp), actualName)); if (!set) - pj_ctx_set_errno(ctx, PJD_ERR_FAILED_TO_LOAD_GRID); + proj_context_errno_set(ctx, PJD_ERR_FAILED_TO_LOAD_GRID); return set; #else pj_log(ctx, PJ_LOG_ERROR, @@ -1570,7 +1570,7 @@ NTv1Grid *NTv1Grid::open(PJ_CONTEXT *ctx, std::unique_ptr<File> fp, /* Read the header. */ /* -------------------------------------------------------------------- */ if (fp->read(header, sizeof(header)) != sizeof(header)) { - pj_ctx_set_errno(ctx, PJD_ERR_FAILED_TO_LOAD_GRID); + proj_context_errno_set(ctx, PJD_ERR_FAILED_TO_LOAD_GRID); return nullptr; } @@ -1590,7 +1590,7 @@ NTv1Grid *NTv1Grid::open(PJ_CONTEXT *ctx, std::unique_ptr<File> fp, if (*((int *)(header + 8)) != 12) { pj_log(ctx, PJ_LOG_ERROR, "NTv1 grid shift file has wrong record count, corrupt?"); - pj_ctx_set_errno(ctx, PJD_ERR_FAILED_TO_LOAD_GRID); + proj_context_errno_set(ctx, PJD_ERR_FAILED_TO_LOAD_GRID); return nullptr; } @@ -1609,7 +1609,7 @@ NTv1Grid *NTv1Grid::open(PJ_CONTEXT *ctx, std::unique_ptr<File> fp, extent.resY > 1e-10)) { pj_log(ctx, PJ_LOG_ERROR, "Inconsistent georeferencing for %s", filename.c_str()); - pj_ctx_set_errno(ctx, PJD_ERR_FAILED_TO_LOAD_GRID); + proj_context_errno_set(ctx, PJD_ERR_FAILED_TO_LOAD_GRID); return nullptr; } const int columns = static_cast<int>( @@ -1631,7 +1631,7 @@ bool NTv1Grid::valueAt(int x, int y, bool compensateNTConvention, m_fp->seek(192 + 2 * sizeof(double) * (y * m_width + m_width - 1 - x)); if (m_fp->read(&two_doubles[0], sizeof(two_doubles)) != sizeof(two_doubles)) { - pj_ctx_set_errno(m_ctx, PJD_ERR_FAILED_TO_LOAD_GRID); + proj_context_errno_set(m_ctx, PJD_ERR_FAILED_TO_LOAD_GRID); return false; } if (IS_LSB) { @@ -1692,7 +1692,7 @@ CTable2Grid *CTable2Grid::open(PJ_CONTEXT *ctx, std::unique_ptr<File> fp, /* Read the header. */ /* -------------------------------------------------------------------- */ if (fp->read(header, sizeof(header)) != sizeof(header)) { - pj_ctx_set_errno(ctx, PJD_ERR_FAILED_TO_LOAD_GRID); + proj_context_errno_set(ctx, PJD_ERR_FAILED_TO_LOAD_GRID); return nullptr; } @@ -1718,7 +1718,7 @@ CTable2Grid *CTable2Grid::open(PJ_CONTEXT *ctx, std::unique_ptr<File> fp, extent.resX > 1e-10 && extent.resY > 1e-10)) { pj_log(ctx, PJ_LOG_ERROR, "Inconsistent georeferencing for %s", filename.c_str()); - pj_ctx_set_errno(ctx, PJD_ERR_FAILED_TO_LOAD_GRID); + proj_context_errno_set(ctx, PJD_ERR_FAILED_TO_LOAD_GRID); return nullptr; } int width; @@ -1726,7 +1726,7 @@ CTable2Grid *CTable2Grid::open(PJ_CONTEXT *ctx, std::unique_ptr<File> fp, memcpy(&width, header + 128, 4); memcpy(&height, header + 132, 4); if (width <= 0 || height <= 0) { - pj_ctx_set_errno(ctx, PJD_ERR_FAILED_TO_LOAD_GRID); + proj_context_errno_set(ctx, PJD_ERR_FAILED_TO_LOAD_GRID); return nullptr; } extent.east = extent.west + (width - 1) * extent.resX; @@ -1744,7 +1744,7 @@ bool CTable2Grid::valueAt(int x, int y, bool compensateNTConvention, float two_floats[2]; m_fp->seek(160 + 2 * sizeof(float) * (y * m_width + x)); if (m_fp->read(&two_floats[0], sizeof(two_floats)) != sizeof(two_floats)) { - pj_ctx_set_errno(m_ctx, PJD_ERR_FAILED_TO_LOAD_GRID); + proj_context_errno_set(m_ctx, PJD_ERR_FAILED_TO_LOAD_GRID); return false; } if (!IS_LSB) { @@ -1828,7 +1828,7 @@ bool NTv2Grid::valueAt(int x, int y, bool compensateNTConvention, 4 * sizeof(float) * (static_cast<unsigned long long>(y) * m_width + m_width - 1 - x)); if (m_fp->read(&two_float[0], sizeof(two_float)) != sizeof(two_float)) { - pj_ctx_set_errno(m_ctx, PJD_ERR_FAILED_TO_LOAD_GRID); + proj_context_errno_set(m_ctx, PJD_ERR_FAILED_TO_LOAD_GRID); return false; } if (m_mustSwap) { @@ -1862,14 +1862,14 @@ std::unique_ptr<NTv2GridSet> NTv2GridSet::open(PJ_CONTEXT *ctx, /* Read the header. */ /* -------------------------------------------------------------------- */ if (fpRaw->read(header, sizeof(header)) != sizeof(header)) { - pj_ctx_set_errno(ctx, PJD_ERR_FAILED_TO_LOAD_GRID); + proj_context_errno_set(ctx, PJD_ERR_FAILED_TO_LOAD_GRID); return nullptr; } constexpr int OFFSET_GS_TYPE = 56; if (memcmp(header + OFFSET_GS_TYPE, "SECONDS", 7) != 0) { pj_log(ctx, PJ_LOG_ERROR, "Only GS_TYPE=SECONDS is supported"); - pj_ctx_set_errno(ctx, PJD_ERR_FAILED_TO_LOAD_GRID); + proj_context_errno_set(ctx, PJD_ERR_FAILED_TO_LOAD_GRID); return nullptr; } @@ -1899,12 +1899,12 @@ std::unique_ptr<NTv2GridSet> NTv2GridSet::open(PJ_CONTEXT *ctx, for (unsigned subfile = 0; subfile < num_subfiles; subfile++) { // Read header if (fpRaw->read(header, sizeof(header)) != sizeof(header)) { - pj_ctx_set_errno(ctx, PJD_ERR_FAILED_TO_LOAD_GRID); + proj_context_errno_set(ctx, PJD_ERR_FAILED_TO_LOAD_GRID); return nullptr; } if (strncmp(header, "SUB_NAME", 8) != 0) { - pj_ctx_set_errno(ctx, PJD_ERR_FAILED_TO_LOAD_GRID); + proj_context_errno_set(ctx, PJD_ERR_FAILED_TO_LOAD_GRID); return nullptr; } @@ -1946,7 +1946,7 @@ std::unique_ptr<NTv2GridSet> NTv2GridSet::open(PJ_CONTEXT *ctx, extent.resY > 1e-10)) { pj_log(ctx, PJ_LOG_ERROR, "Inconsistent georeferencing for %s", filename.c_str()); - pj_ctx_set_errno(ctx, PJD_ERR_FAILED_TO_LOAD_GRID); + proj_context_errno_set(ctx, PJD_ERR_FAILED_TO_LOAD_GRID); return nullptr; } const int columns = static_cast<int>( @@ -1966,7 +1966,7 @@ std::unique_ptr<NTv2GridSet> NTv2GridSet::open(PJ_CONTEXT *ctx, pj_log(ctx, PJ_LOG_ERROR, "GS_COUNT(%u) does not match expected cells (%dx%d)", gs_count, columns, rows); - pj_ctx_set_errno(ctx, PJD_ERR_FAILED_TO_LOAD_GRID); + proj_context_errno_set(ctx, PJD_ERR_FAILED_TO_LOAD_GRID); return nullptr; } @@ -2367,7 +2367,7 @@ HorizontalShiftGridSet::open(PJ_CONTEXT *ctx, const std::string &filename) { auto set = std::unique_ptr<HorizontalShiftGridSet>( GTiffHGridShiftSet::open(ctx, std::move(fp), actualName)); if (!set) - pj_ctx_set_errno(ctx, PJD_ERR_FAILED_TO_LOAD_GRID); + proj_context_errno_set(ctx, PJD_ERR_FAILED_TO_LOAD_GRID); return set; #else pj_log(ctx, PJ_LOG_ERROR, @@ -2703,7 +2703,7 @@ GenericShiftGridSet::open(PJ_CONTEXT *ctx, const std::string &filename) { auto set = std::unique_ptr<GenericShiftGridSet>( GTiffGenericGridShiftSet::open(ctx, std::move(fp), actualName)); if (!set) - pj_ctx_set_errno(ctx, PJD_ERR_FAILED_TO_LOAD_GRID); + proj_context_errno_set(ctx, PJD_ERR_FAILED_TO_LOAD_GRID); return set; #else pj_log(ctx, PJ_LOG_ERROR, @@ -2786,11 +2786,11 @@ ListOfGenericGrids pj_generic_grid_init(PJ *P, const char *gridkey) { if (!gridSet) { if (!canFail) { if (proj_context_errno(P->ctx) != PJD_ERR_NETWORK_ERROR) { - pj_ctx_set_errno(P->ctx, PJD_ERR_FAILED_TO_LOAD_GRID); + proj_context_errno_set(P->ctx, PJD_ERR_FAILED_TO_LOAD_GRID); } return {}; } - pj_ctx_set_errno(P->ctx, 0); // don't treat as a persistent error + proj_context_errno_set(P->ctx, 0); // don't treat as a persistent error } else { grids.emplace_back(std::move(gridSet)); } @@ -2830,11 +2830,11 @@ static ListOfHGrids getListOfGridSets(PJ_CONTEXT *ctx, const char *grids) { if (!gridSet) { if (!canFail) { if (proj_context_errno(ctx) != PJD_ERR_NETWORK_ERROR) { - pj_ctx_set_errno(ctx, PJD_ERR_FAILED_TO_LOAD_GRID); + proj_context_errno_set(ctx, PJD_ERR_FAILED_TO_LOAD_GRID); } return {}; } - pj_ctx_set_errno(ctx, 0); // don't treat as a persistent error + proj_context_errno_set(ctx, 0); // don't treat as a persistent error } else { list.emplace_back(std::move(gridSet)); } @@ -3066,7 +3066,7 @@ PJ_LP pj_hgrid_apply(PJ_CONTEXT *ctx, const ListOfHGrids &grids, PJ_LP lp, HorizontalShiftGridSet *gridset = nullptr; const auto grid = findGrid(grids, lp, gridset); if (!grid) { - pj_ctx_set_errno(ctx, PJD_ERR_GRID_AREA); + proj_context_errno_set(ctx, PJD_ERR_GRID_AREA); return out; } if (grid->isNullGrid()) { @@ -3082,7 +3082,7 @@ PJ_LP pj_hgrid_apply(PJ_CONTEXT *ctx, const ListOfHGrids &grids, PJ_LP lp, } if (out.lam == HUGE_VAL || out.phi == HUGE_VAL) - pj_ctx_set_errno(ctx, PJD_ERR_GRID_AREA); + proj_context_errno_set(ctx, PJD_ERR_GRID_AREA); return out; } @@ -3098,7 +3098,7 @@ PJ_LP pj_hgrid_value(PJ *P, const ListOfHGrids &grids, PJ_LP lp) { HorizontalShiftGridSet *gridset = nullptr; const auto grid = findGrid(grids, lp, gridset); if (!grid) { - pj_ctx_set_errno(P->ctx, PJD_ERR_GRID_AREA); + proj_context_errno_set(P->ctx, PJD_ERR_GRID_AREA); return out; } @@ -3107,7 +3107,7 @@ PJ_LP pj_hgrid_value(PJ *P, const ListOfHGrids &grids, PJ_LP lp) { if (!extent.isGeographic) { pj_log(P->ctx, PJ_LOG_ERROR, "Can only handle grids referenced in a geographic CRS"); - pj_ctx_set_errno(P->ctx, PJD_ERR_FAILED_TO_LOAD_GRID); + proj_context_errno_set(P->ctx, PJD_ERR_FAILED_TO_LOAD_GRID); return out; } @@ -3130,7 +3130,7 @@ PJ_LP pj_hgrid_value(PJ *P, const ListOfHGrids &grids, PJ_LP lp) { } if (out.lam == HUGE_VAL || out.phi == HUGE_VAL) { - pj_ctx_set_errno(P->ctx, PJD_ERR_GRID_AREA); + proj_context_errno_set(P->ctx, PJD_ERR_GRID_AREA); } return out; @@ -3157,7 +3157,7 @@ static double read_vgrid_value(PJ_CONTEXT *ctx, const ListOfVGrids &grids, } } if (!grid) { - pj_ctx_set_errno(ctx, PJD_ERR_GRID_AREA); + proj_context_errno_set(ctx, PJD_ERR_GRID_AREA); return HUGE_VAL; } if (grid->isNullGrid()) { @@ -3168,7 +3168,7 @@ static double read_vgrid_value(PJ_CONTEXT *ctx, const ListOfVGrids &grids, if (!extent.isGeographic) { pj_log(ctx, PJ_LOG_ERROR, "Can only handle grids referenced in a geographic CRS"); - pj_ctx_set_errno(ctx, PJD_ERR_FAILED_TO_LOAD_GRID); + proj_context_errno_set(ctx, PJD_ERR_FAILED_TO_LOAD_GRID); return HUGE_VAL; } @@ -3200,7 +3200,7 @@ static double read_vgrid_value(PJ_CONTEXT *ctx, const ListOfVGrids &grids, if (!(grid_ix >= 0 && grid_ix < grid->width())) { // in the unlikely case we end up here... pj_log(ctx, PJ_LOG_ERROR, "grid_ix not in grid"); - pj_ctx_set_errno(ctx, PJD_ERR_GRID_AREA); + proj_context_errno_set(ctx, PJD_ERR_GRID_AREA); return HUGE_VAL; } int grid_iy = static_cast<int>(lround(floor(grid_y))); @@ -3309,11 +3309,11 @@ ListOfVGrids pj_vgrid_init(PJ *P, const char *gridkey) { if (!gridSet) { if (!canFail) { if (proj_context_errno(P->ctx) != PJD_ERR_NETWORK_ERROR) { - pj_ctx_set_errno(P->ctx, PJD_ERR_FAILED_TO_LOAD_GRID); + proj_context_errno_set(P->ctx, PJD_ERR_FAILED_TO_LOAD_GRID); } return {}; } - pj_ctx_set_errno(P->ctx, 0); // don't treat as a persistent error + proj_context_errno_set(P->ctx, 0); // don't treat as a persistent error } else { grids.emplace_back(std::move(gridSet)); } @@ -3377,7 +3377,7 @@ bool pj_bilinear_interpolation_three_samples( if (!extent.isGeographic) { pj_log(ctx, PJ_LOG_ERROR, "Can only handle grids referenced in a geographic CRS"); - pj_ctx_set_errno(ctx, PJD_ERR_FAILED_TO_LOAD_GRID); + proj_context_errno_set(ctx, PJD_ERR_FAILED_TO_LOAD_GRID); return false; } @@ -3459,7 +3459,7 @@ int pj_apply_gridshift(PJ_CONTEXT *ctx, const char *nadgrids, int inverse, { auto hgrids = NS_PROJ::getListOfGridSets(ctx, nadgrids); if (hgrids.empty()) { - pj_ctx_set_errno(ctx, PJD_ERR_FAILED_TO_LOAD_GRID); + proj_context_errno_set(ctx, PJD_ERR_FAILED_TO_LOAD_GRID); return 1; } diff --git a/src/init.cpp b/src/init.cpp index a42bf963..2d679618 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -257,7 +257,7 @@ Expand key from buffer or (if not in buffer) from init file PJ* src; const char* proj_string; - pj_ctx_set_errno( ctx, 0 ); + proj_context_errno_set( ctx, 0 ); if( !allow_init_epsg ) { pj_log (ctx, PJ_LOG_TRACE, "%s expansion disallowed", xkey); @@ -448,7 +448,7 @@ pj_init_plus_ctx( PJ_CONTEXT *ctx, const char *definition ) if( argc+1 == MAX_ARG ) { pj_dalloc( defn_copy ); - pj_ctx_set_errno( ctx, PJD_ERR_UNPARSEABLE_CS_DEF ); + proj_context_errno_set( ctx, PJD_ERR_UNPARSEABLE_CS_DEF ); return nullptr; } @@ -538,7 +538,7 @@ pj_init_ctx_with_allow_init_epsg(PJ_CONTEXT *ctx, int argc, char **argv, int all ctx->last_errno = 0; if (argc <= 0) { - pj_ctx_set_errno (ctx, PJD_ERR_NO_ARGS); + proj_context_errno_set (ctx, PJD_ERR_NO_ARGS); return nullptr; } @@ -552,13 +552,13 @@ pj_init_ctx_with_allow_init_epsg(PJ_CONTEXT *ctx, int argc, char **argv, int all /* can't have nested pipelines directly */ if (n_pipelines > 1) { - pj_ctx_set_errno (ctx, PJD_ERR_MALFORMED_PIPELINE); + proj_context_errno_set (ctx, PJD_ERR_MALFORMED_PIPELINE); return nullptr; } /* don't allow more than one +init in non-pipeline operations */ if (n_pipelines == 0 && n_inits > 1) { - pj_ctx_set_errno (ctx, PJD_ERR_TOO_MANY_INITS); + proj_context_errno_set (ctx, PJD_ERR_TOO_MANY_INITS); return nullptr; } diff --git a/src/internal.cpp b/src/internal.cpp index 32dc1bba..c1ffc408 100644 --- a/src/internal.cpp +++ b/src/internal.cpp @@ -141,15 +141,15 @@ Check if a a PJ has an inverse. void proj_context_set (PJ *P, PJ_CONTEXT *ctx) { if (nullptr==ctx) ctx = pj_get_default_ctx (); - pj_set_ctx (P, ctx); + proj_assign_context (P, ctx); } void proj_context_inherit (PJ *parent, PJ *child) { if (nullptr==parent) - pj_set_ctx (child, pj_get_default_ctx()); + proj_assign_context (child, pj_get_default_ctx()); else - pj_set_ctx (child, pj_get_ctx(parent)); + proj_assign_context (child, pj_get_ctx(parent)); } @@ -411,7 +411,11 @@ to that context. ******************************************************************************/ if (nullptr==ctx) ctx = pj_get_default_ctx(); - pj_ctx_set_errno (ctx, err); + ctx->last_errno = err; + if( err == 0 ) + return; + errno = err; + pj_errno = err; } /* logging */ diff --git a/src/iso19111/c_api.cpp b/src/iso19111/c_api.cpp index cbbdcaa8..d6308c49 100644 --- a/src/iso19111/c_api.cpp +++ b/src/iso19111/c_api.cpp @@ -79,10 +79,10 @@ static void PROJ_NO_INLINE proj_log_error(PJ_CONTEXT *ctx, const char *function, msg += ": "; msg += text; ctx->logger(ctx->logger_app_data, PJ_LOG_ERROR, msg.c_str()); - auto previous_errno = pj_ctx_get_errno(ctx); + auto previous_errno = proj_context_errno(ctx); if (previous_errno == 0) { // only set errno if it wasn't set deeper down the call stack - pj_ctx_set_errno(ctx, PJD_ERR_GENERIC_ERROR); + proj_context_errno_set(ctx, PJD_ERR_GENERIC_ERROR); } } diff --git a/src/iso19111/datum.cpp b/src/iso19111/datum.cpp index 4d7e78d3..60244779 100644 --- a/src/iso19111/datum.cpp +++ b/src/iso19111/datum.cpp @@ -417,7 +417,7 @@ std::string PrimeMeridian::getPROJStringWellKnownName(const common::Angle &angle) { const double valRad = angle.getSIValue(); std::string projPMName; - PJ_CONTEXT *ctxt = pj_ctx_alloc(); + PJ_CONTEXT *ctxt = proj_context_create(); auto proj_pm = proj_list_prime_meridians(); for (int i = 0; proj_pm[i].id != nullptr; ++i) { double valRefRad = dmstor_ctx(ctxt, proj_pm[i].defn, nullptr); @@ -426,7 +426,7 @@ PrimeMeridian::getPROJStringWellKnownName(const common::Angle &angle) { break; } } - pj_ctx_free(ctxt); + proj_context_destroy(ctxt); return projPMName; } //! @endcond diff --git a/src/malloc.cpp b/src/malloc.cpp index eb64023f..b1bcea1d 100644 --- a/src/malloc.cpp +++ b/src/malloc.cpp @@ -166,7 +166,7 @@ void *pj_dealloc_params (PJ_CONTEXT *ctx, paralist *start, int errlev) { n = t->next; pj_dealloc(t); } - pj_ctx_set_errno (ctx, errlev); + proj_context_errno_set (ctx, errlev); return (void *) nullptr; } @@ -218,7 +218,7 @@ PJ *pj_default_destructor (PJ *P, int errlev) { /* Destructor */ /* Note that both, in the multithreaded case, may then contain undefined */ /* values. This is expected behavior. For MT have one ctx per thread */ if (0!=errlev) - pj_ctx_set_errno (pj_get_ctx(P), errlev); + proj_context_errno_set (pj_get_ctx(P), errlev); if (nullptr==P) return nullptr; diff --git a/src/mlfn.hpp b/src/mlfn.hpp index e7138c63..228c65a4 100644 --- a/src/mlfn.hpp +++ b/src/mlfn.hpp @@ -66,7 +66,7 @@ inline_pj_inv_mlfn(PJ_CONTEXT *ctx, double arg, double es, const double *en, } *sinphi = s; *cosphi = c; - pj_ctx_set_errno( ctx, PJD_ERR_NON_CONV_INV_MERI_DIST ); + proj_context_errno_set( ctx, PJD_ERR_NON_CONV_INV_MERI_DIST ); return phi; } diff --git a/src/networkfilemanager.cpp b/src/networkfilemanager.cpp index f6521ed2..9edffaad 100644 --- a/src/networkfilemanager.cpp +++ b/src/networkfilemanager.cpp @@ -1315,7 +1315,7 @@ std::unique_ptr<File> NetworkFile::open(PJ_CONTEXT *ctx, const char *filename) { errorBuffer.resize(strlen(errorBuffer.data())); pj_log(ctx, PJ_LOG_ERROR, "Cannot open %s: %s", filename, errorBuffer.c_str()); - pj_ctx_set_errno(ctx, PJD_ERR_NETWORK_ERROR); + proj_context_errno_set(ctx, PJD_ERR_NETWORK_ERROR); } bool ok = false; @@ -1404,7 +1404,7 @@ size_t NetworkFile::read(void *buffer, size_t sizeBytes) { &nRead, errorBuffer.size(), &errorBuffer[0], m_ctx->networking.user_data); if (!m_handle) { - pj_ctx_set_errno(m_ctx, PJD_ERR_NETWORK_ERROR); + proj_context_errno_set(m_ctx, PJD_ERR_NETWORK_ERROR); return 0; } } else { @@ -1420,7 +1420,7 @@ size_t NetworkFile::read(void *buffer, size_t sizeBytes) { pj_log(m_ctx, PJ_LOG_ERROR, "Cannot read in %s: %s", m_url.c_str(), errorBuffer.c_str()); } - pj_ctx_set_errno(m_ctx, PJD_ERR_NETWORK_ERROR); + proj_context_errno_set(m_ctx, PJD_ERR_NETWORK_ERROR); return 0; } diff --git a/src/param.cpp b/src/param.cpp index 9a3888e1..3e13b391 100644 --- a/src/param.cpp +++ b/src/param.cpp @@ -220,7 +220,7 @@ PROJVALUE pj_param (PJ_CONTEXT *ctx, paralist *pl, const char *opt) { value.i = 1; break; default: - pj_ctx_set_errno (ctx, PJD_ERR_INVALID_BOOLEAN_PARAM); + proj_context_errno_set (ctx, PJD_ERR_INVALID_BOOLEAN_PARAM); value.i = 0; break; } diff --git a/src/phi2.cpp b/src/phi2.cpp index 214d1058..2f258e47 100644 --- a/src/phi2.cpp +++ b/src/phi2.cpp @@ -103,7 +103,7 @@ double pj_sinhpsi2tanphi(PJ_CONTEXT *ctx, const double taup, const double e) { break; } if (i == 0) - pj_ctx_set_errno(ctx, PJD_ERR_NON_CONV_SINHPSI2TANPHI); + proj_context_errno_set(ctx, PJD_ERR_NON_CONV_SINHPSI2TANPHI); return tau; } diff --git a/src/proj_internal.h b/src/proj_internal.h index 3c1571eb..d9b01ab2 100644 --- a/src/proj_internal.h +++ b/src/proj_internal.h @@ -976,16 +976,6 @@ void PROJ_DLL pj_acquire_lock(void); void PROJ_DLL pj_release_lock(void); void PROJ_DLL pj_cleanup_lock(void); -void PROJ_DLL pj_set_ctx( PJ *, PJ_CONTEXT * ); -PJ_CONTEXT PROJ_DLL *pj_ctx_alloc(void); -void PROJ_DLL pj_ctx_free( PJ_CONTEXT * ); -int PROJ_DLL pj_ctx_get_errno( PJ_CONTEXT * ); -void PROJ_DLL pj_ctx_set_errno( PJ_CONTEXT *, int ); -void PROJ_DLL pj_ctx_set_debug( PJ_CONTEXT *, int ); -void PROJ_DLL pj_ctx_set_logger( PJ_CONTEXT *, void (*)(void *, int, const char *) ); -void PROJ_DLL pj_ctx_set_app_data( PJ_CONTEXT *, void * ); -void PROJ_DLL *pj_ctx_get_app_data( PJ_CONTEXT * ); - void PROJ_DLL pj_log( PJ_CONTEXT * ctx, int level, const char *fmt, ... ); void PROJ_DLL pj_stderr_logger( void *, int, const char * ); diff --git a/src/proj_mdist.cpp b/src/proj_mdist.cpp index 086521b7..ed07ffd1 100644 --- a/src/proj_mdist.cpp +++ b/src/proj_mdist.cpp @@ -124,6 +124,6 @@ proj_inv_mdist(PJ_CONTEXT *ctx, double dist, const void *data) { return phi; } /* convergence failed */ - pj_ctx_set_errno(ctx, PJD_ERR_NON_CONV_INV_MERI_DIST); + proj_context_errno_set(ctx, PJD_ERR_NON_CONV_INV_MERI_DIST); return phi; } diff --git a/src/projections/aitoff.cpp b/src/projections/aitoff.cpp index 7920309c..d02e7761 100644 --- a/src/projections/aitoff.cpp +++ b/src/projections/aitoff.cpp @@ -170,7 +170,7 @@ static PJ_LP aitoff_s_inverse (PJ_XY xy, PJ *P) { /* Spheroidal, inver if (iter == MAXITER && round == MAXROUND) { - pj_ctx_set_errno( P->ctx, PJD_ERR_NON_CONVERGENT ); + proj_context_errno_set( P->ctx, PJD_ERR_NON_CONVERGENT ); /* fprintf(stderr, "Warning: Accuracy of 1e-12 not reached. Last increments: dlat=%e and dlon=%e\n", dp, dl); */ } diff --git a/src/projections/comill.cpp b/src/projections/comill.cpp index 189e583e..44524990 100644 --- a/src/projections/comill.cpp +++ b/src/projections/comill.cpp @@ -66,7 +66,7 @@ static PJ_LP comill_s_inverse (PJ_XY xy, PJ *P) { /* Spheroidal, inver } } if( i == 0 ) - pj_ctx_set_errno( P->ctx, PJD_ERR_NON_CONVERGENT ); + proj_context_errno_set( P->ctx, PJD_ERR_NON_CONVERGENT ); lp.phi = yc; /* longitude */ diff --git a/src/projections/eqearth.cpp b/src/projections/eqearth.cpp index 832c9444..60effde0 100644 --- a/src/projections/eqearth.cpp +++ b/src/projections/eqearth.cpp @@ -110,7 +110,7 @@ static PJ_LP eqearth_e_inverse (PJ_XY xy, PJ *P) { /* Ellipsoidal/sphe } if( i == 0 ) { - pj_ctx_set_errno( P->ctx, PJD_ERR_NON_CONVERGENT ); + proj_context_errno_set( P->ctx, PJD_ERR_NON_CONVERGENT ); return lp; } diff --git a/src/projections/healpix.cpp b/src/projections/healpix.cpp index aab5c41e..5a06125d 100644 --- a/src/projections/healpix.cpp +++ b/src/projections/healpix.cpp @@ -524,7 +524,7 @@ static PJ_LP s_healpix_inverse(PJ_XY xy, PJ *P) { /* sphere */ PJ_LP lp; lp.lam = HUGE_VAL; lp.phi = HUGE_VAL; - pj_ctx_set_errno(P->ctx, PJD_ERR_INVALID_X_OR_Y); + proj_context_errno_set(P->ctx, PJD_ERR_INVALID_X_OR_Y); return lp; } return healpix_spherhealpix_e_inverse(xy); @@ -540,7 +540,7 @@ static PJ_LP e_healpix_inverse(PJ_XY xy, PJ *P) { /* ellipsoid */ if (in_image(xy.x, xy.y, 0, 0, 0) == 0) { lp.lam = HUGE_VAL; lp.phi = HUGE_VAL; - pj_ctx_set_errno(P->ctx, PJD_ERR_INVALID_X_OR_Y); + proj_context_errno_set(P->ctx, PJD_ERR_INVALID_X_OR_Y); return lp; } lp = healpix_spherhealpix_e_inverse(xy); @@ -574,7 +574,7 @@ static PJ_LP s_rhealpix_inverse(PJ_XY xy, PJ *P) { /* sphere */ PJ_LP lp; lp.lam = HUGE_VAL; lp.phi = HUGE_VAL; - pj_ctx_set_errno(P->ctx, PJD_ERR_INVALID_X_OR_Y); + proj_context_errno_set(P->ctx, PJD_ERR_INVALID_X_OR_Y); return lp; } xy = combine_caps(xy.x, xy.y, Q->north_square, Q->south_square, 1); @@ -590,7 +590,7 @@ static PJ_LP e_rhealpix_inverse(PJ_XY xy, PJ *P) { /* ellipsoid */ if (in_image(xy.x, xy.y, 1, Q->north_square, Q->south_square) == 0) { lp.lam = HUGE_VAL; lp.phi = HUGE_VAL; - pj_ctx_set_errno(P->ctx, PJD_ERR_INVALID_X_OR_Y); + proj_context_errno_set(P->ctx, PJD_ERR_INVALID_X_OR_Y); return lp; } xy = combine_caps(xy.x, xy.y, Q->north_square, Q->south_square, 1); diff --git a/src/projections/krovak.cpp b/src/projections/krovak.cpp index aef44d42..3e6a5c30 100644 --- a/src/projections/krovak.cpp +++ b/src/projections/krovak.cpp @@ -181,7 +181,7 @@ static PJ_LP krovak_e_inverse (PJ_XY xy, PJ *P) { /* Ellipsoidal, fi1 = lp.phi; } if( i == 0 ) - pj_ctx_set_errno( P->ctx, PJD_ERR_NON_CONVERGENT ); + proj_context_errno_set( P->ctx, PJD_ERR_NON_CONVERGENT ); lp.lam -= P->lam0; diff --git a/src/projections/natearth.cpp b/src/projections/natearth.cpp index 5c096605..e1f71089 100644 --- a/src/projections/natearth.cpp +++ b/src/projections/natearth.cpp @@ -82,7 +82,7 @@ static PJ_LP natearth_s_inverse (PJ_XY xy, PJ *P) { /* Spheroidal, inv } } if( i == 0 ) - pj_ctx_set_errno( P->ctx, PJD_ERR_NON_CONVERGENT ); + proj_context_errno_set( P->ctx, PJD_ERR_NON_CONVERGENT ); lp.phi = yc; /* longitude */ diff --git a/src/projections/natearth2.cpp b/src/projections/natearth2.cpp index d149ca85..e4516a0a 100644 --- a/src/projections/natearth2.cpp +++ b/src/projections/natearth2.cpp @@ -76,7 +76,7 @@ static PJ_LP natearth2_s_inverse (PJ_XY xy, PJ *P) { /* Spheroidal, in } } if( i == 0 ) - pj_ctx_set_errno( P->ctx, PJD_ERR_NON_CONVERGENT ); + proj_context_errno_set( P->ctx, PJD_ERR_NON_CONVERGENT ); lp.phi = yc; /* longitude */ diff --git a/src/projections/ortho.cpp b/src/projections/ortho.cpp index 8dcfb53c..d9c84dba 100644 --- a/src/projections/ortho.cpp +++ b/src/projections/ortho.cpp @@ -273,7 +273,7 @@ static PJ_LP ortho_e_inverse (PJ_XY xy, PJ *P) { /* Ellipsoidal, inver return lp; } } - pj_ctx_set_errno(P->ctx, PJD_ERR_NON_CONVERGENT); + proj_context_errno_set(P->ctx, PJD_ERR_NON_CONVERGENT); return lp; } diff --git a/src/projections/patterson.cpp b/src/projections/patterson.cpp index 71099cdb..32544580 100644 --- a/src/projections/patterson.cpp +++ b/src/projections/patterson.cpp @@ -100,7 +100,7 @@ static PJ_LP patterson_s_inverse (PJ_XY xy, PJ *P) { /* Spheroidal, in } } if( i == 0 ) - pj_ctx_set_errno( P->ctx, PJD_ERR_NON_CONVERGENT ); + proj_context_errno_set( P->ctx, PJD_ERR_NON_CONVERGENT ); lp.phi = yc; /* longitude */ diff --git a/src/projections/robin.cpp b/src/projections/robin.cpp index 8b646502..6a1405b6 100644 --- a/src/projections/robin.cpp +++ b/src/projections/robin.cpp @@ -138,7 +138,7 @@ static PJ_LP robin_s_inverse (PJ_XY xy, PJ *P) { /* Spheroidal, invers break; } if( iters == 0 ) - pj_ctx_set_errno( P->ctx, PJD_ERR_NON_CONVERGENT ); + proj_context_errno_set( P->ctx, PJD_ERR_NON_CONVERGENT ); lp.phi = (5 * i + t) * DEG_TO_RAD; if (xy.y < 0.) lp.phi = -lp.phi; lp.lam /= V(X[i], t); diff --git a/src/projections/tmerc.cpp b/src/projections/tmerc.cpp index 69f4d352..ff1bc2a5 100644 --- a/src/projections/tmerc.cpp +++ b/src/projections/tmerc.cpp @@ -89,7 +89,7 @@ static PJ_XY approx_e_fwd (PJ_LP lp, PJ *P) if( lp.lam < -M_HALFPI || lp.lam > M_HALFPI ) { xy.x = HUGE_VAL; xy.y = HUGE_VAL; - pj_ctx_set_errno( P->ctx, PJD_ERR_LAT_OR_LON_EXCEED_LIMIT ); + proj_context_errno_set( P->ctx, PJD_ERR_LAT_OR_LON_EXCEED_LIMIT ); return xy; } @@ -130,7 +130,7 @@ static PJ_XY approx_s_fwd (PJ_LP lp, PJ *P) { if( lp.lam < -M_HALFPI || lp.lam > M_HALFPI ) { xy.x = HUGE_VAL; xy.y = HUGE_VAL; - pj_ctx_set_errno( P->ctx, PJD_ERR_LAT_OR_LON_EXCEED_LIMIT ); + proj_context_errno_set( P->ctx, PJD_ERR_LAT_OR_LON_EXCEED_LIMIT ); return xy; } @@ -679,7 +679,7 @@ static bool getAlgoFromParams(PJ* P, TMercAlgo& algo) else { pj_load_ini(P->ctx); // if not already done - pj_ctx_set_errno(P->ctx, 0); // reset error in case proj.ini couldn't be found + proj_context_errno_set(P->ctx, 0); // reset error in case proj.ini couldn't be found algo = P->ctx->defaultTmercAlgo; } diff --git a/src/utils.cpp b/src/utils.cpp index d3ec7e35..82449617 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -117,7 +117,7 @@ PJ *pj_latlong_from_proj( PJ *pj_in ) } else { - pj_ctx_set_errno( pj_in->ctx, PJD_ERR_MAJOR_AXIS_NOT_GIVEN ); + proj_context_errno_set( pj_in->ctx, PJD_ERR_MAJOR_AXIS_NOT_GIVEN ); return nullptr; } |
