diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/aasincos.cpp | 4 | ||||
| -rw-r--r-- | src/ctx.cpp | 55 | ||||
| -rw-r--r-- | src/datum_set.cpp | 2 | ||||
| -rw-r--r-- | src/dmstor.cpp | 2 | ||||
| -rw-r--r-- | src/ell_set.cpp | 2 | ||||
| -rw-r--r-- | src/fileapi.cpp | 22 | ||||
| -rw-r--r-- | src/filemanager.cpp | 16 | ||||
| -rw-r--r-- | src/gauss.cpp | 4 | ||||
| -rw-r--r-- | src/grids.cpp | 4 | ||||
| -rw-r--r-- | src/init.cpp | 6 | ||||
| -rw-r--r-- | src/internal.cpp | 2 | ||||
| -rw-r--r-- | src/iso19111/datum.cpp | 2 | ||||
| -rw-r--r-- | src/log.cpp | 6 | ||||
| -rw-r--r-- | src/mlfn.cpp | 2 | ||||
| -rw-r--r-- | src/mlfn.hpp | 2 | ||||
| -rw-r--r-- | src/param.cpp | 2 | ||||
| -rw-r--r-- | src/phi2.cpp | 4 | ||||
| -rw-r--r-- | src/proj.h | 6 | ||||
| -rw-r--r-- | src/proj_internal.h | 155 | ||||
| -rw-r--r-- | src/proj_mdist.cpp | 2 | ||||
| -rw-r--r-- | src/projections/chamb.cpp | 4 | ||||
| -rw-r--r-- | src/tests/multistresstest.cpp | 14 | ||||
| -rw-r--r-- | src/tests/test228.cpp | 6 | ||||
| -rw-r--r-- | src/utils.cpp | 2 |
24 files changed, 150 insertions, 176 deletions
diff --git a/src/aasincos.cpp b/src/aasincos.cpp index 398a8cfc..c3229d39 100644 --- a/src/aasincos.cpp +++ b/src/aasincos.cpp @@ -9,7 +9,7 @@ #define ATOL 1e-50 double -aasin(projCtx ctx,double v) { +aasin(PJ_CONTEXT *ctx,double v) { double av; if ((av = fabs(v)) >= 1.) { @@ -21,7 +21,7 @@ aasin(projCtx ctx,double v) { } double -aacos(projCtx ctx, double v) { +aacos(PJ_CONTEXT *ctx, double v) { double av; if ((av = fabs(v)) >= 1.) { diff --git a/src/ctx.cpp b/src/ctx.cpp index 6dbe0de5..24d3773b 100644 --- a/src/ctx.cpp +++ b/src/ctx.cpp @@ -1,6 +1,6 @@ /****************************************************************************** * Project: PROJ.4 - * Purpose: Implementation of the projCtx thread context object. + * Purpose: Implementation of the PJ_CONTEXT thread context object. * Author: Frank Warmerdam, warmerdam@pobox.com * ****************************************************************************** @@ -43,7 +43,7 @@ /* pj_get_ctx() */ /************************************************************************/ -projCtx pj_get_ctx( projPJ pj ) +PJ_CONTEXT* pj_get_ctx( PJ *pj ) { if (nullptr==pj) @@ -59,7 +59,7 @@ projCtx pj_get_ctx( projPJ pj ) /* Note we do not deallocate the old context! */ /************************************************************************/ -void pj_set_ctx( projPJ pj, projCtx ctx ) +void pj_set_ctx( PJ *pj, PJ_CONTEXT *ctx ) { if (pj==nullptr) @@ -86,7 +86,7 @@ void pj_set_ctx( projPJ pj, projCtx ctx ) * the user may want to assign another thread-specific context to the * object. */ -void proj_assign_context( PJ* pj, PJ_CONTEXT* ctx ) +void proj_assign_context( PJ* pj, PJ_CONTEXT *ctx ) { pj_set_ctx( pj, ctx ); } @@ -95,9 +95,9 @@ void proj_assign_context( PJ* pj, PJ_CONTEXT* ctx ) /* createDefault() */ /************************************************************************/ -projCtx_t projCtx_t::createDefault() +pj_ctx pj_ctx::createDefault() { - projCtx_t ctx; + pj_ctx ctx; ctx.debug_level = PJ_LOG_NONE; ctx.logger = pj_stderr_logger; ctx.fileapi_legacy = pj_get_default_fileapi(); @@ -117,7 +117,7 @@ projCtx_t projCtx_t::createDefault() /* get_cpp_context() */ /**************************************************************************/ -projCppContext* projCtx_t::get_cpp_context() +projCppContext* pj_ctx::get_cpp_context() { if (cpp_context == nullptr) { cpp_context = new projCppContext(this); @@ -125,12 +125,11 @@ projCppContext* projCtx_t::get_cpp_context() return cpp_context; } - /**************************************************************************/ /* safeAutoCloseDbIfNeeded() */ /**************************************************************************/ -void projCtx_t::safeAutoCloseDbIfNeeded() +void pj_ctx::safeAutoCloseDbIfNeeded() { if (cpp_context) { cpp_context->autoCloseDbIfNeeded(); @@ -141,7 +140,7 @@ void projCtx_t::safeAutoCloseDbIfNeeded() /* set_search_paths() */ /************************************************************************/ -void projCtx_t::set_search_paths(const std::vector<std::string>& search_paths_in ) +void pj_ctx::set_search_paths(const std::vector<std::string>& search_paths_in ) { search_paths = search_paths_in; delete[] c_compat_paths; @@ -158,16 +157,16 @@ void projCtx_t::set_search_paths(const std::vector<std::string>& search_paths_in /* set_ca_bundle_path() */ /**************************************************************************/ -void projCtx_t::set_ca_bundle_path(const std::string& ca_bundle_path_in) +void pj_ctx::set_ca_bundle_path(const std::string& ca_bundle_path_in) { ca_bundle_path = ca_bundle_path_in; } /************************************************************************/ -/* projCtx_t(const projCtx_t& other) */ +/* pj_ctx(const pj_ctx& other) */ /************************************************************************/ -projCtx_t::projCtx_t(const projCtx_t& other) : +pj_ctx::pj_ctx(const pj_ctx& other) : debug_level(other.debug_level), logger(other.logger), logger_app_data(other.logger_app_data), @@ -197,19 +196,19 @@ projCtx_t::projCtx_t(const projCtx_t& other) : /* pj_get_default_ctx() */ /************************************************************************/ -projCtx pj_get_default_ctx() +PJ_CONTEXT* pj_get_default_ctx() { // C++11 rules guarantee a thread-safe instantiation. - static projCtx_t default_context(projCtx_t::createDefault()); + static pj_ctx default_context(pj_ctx::createDefault()); return &default_context; } /************************************************************************/ -/* ~projCtx_t() */ +/* ~pj_ctx() */ /************************************************************************/ -projCtx_t::~projCtx_t() +pj_ctx::~pj_ctx() { delete[] c_compat_paths; proj_context_delete_cpp_context(cpp_context); @@ -219,10 +218,10 @@ projCtx_t::~projCtx_t() /* pj_ctx_alloc() */ /************************************************************************/ -projCtx pj_ctx_alloc() +PJ_CONTEXT* pj_ctx_alloc() { - return new (std::nothrow) projCtx_t(*pj_get_default_ctx()); + return new (std::nothrow) pj_ctx(*pj_get_default_ctx()); } /************************************************************************/ @@ -230,19 +229,19 @@ projCtx pj_ctx_alloc() /* Create a new context based on a custom context */ /************************************************************************/ -PJ_CONTEXT *proj_context_clone (PJ_CONTEXT *ctx) +PJ_CONTEXT* proj_context_clone (PJ_CONTEXT *ctx) { if (nullptr==ctx) return pj_ctx_alloc (); - return new (std::nothrow) projCtx_t(*ctx); + return new (std::nothrow) pj_ctx(*ctx); } /************************************************************************/ /* pj_ctx_free() */ /************************************************************************/ -void pj_ctx_free( projCtx ctx ) +void pj_ctx_free( PJ_CONTEXT *ctx ) { delete ctx; @@ -252,7 +251,7 @@ void pj_ctx_free( projCtx ctx ) /* pj_ctx_get_errno() */ /************************************************************************/ -int pj_ctx_get_errno( projCtx ctx ) +int pj_ctx_get_errno( PJ_CONTEXT *ctx ) { if (nullptr==ctx) @@ -266,7 +265,7 @@ int pj_ctx_get_errno( projCtx ctx ) /* Also sets the global errno */ /************************************************************************/ -void pj_ctx_set_errno( projCtx ctx, int new_errno ) +void pj_ctx_set_errno( PJ_CONTEXT *ctx, int new_errno ) { ctx->last_errno = new_errno; @@ -280,7 +279,7 @@ void pj_ctx_set_errno( projCtx ctx, int new_errno ) /* pj_ctx_set_debug() */ /************************************************************************/ -void pj_ctx_set_debug( projCtx ctx, int new_debug ) +void pj_ctx_set_debug( PJ_CONTEXT *ctx, int new_debug ) { if (nullptr==ctx) @@ -292,7 +291,7 @@ void pj_ctx_set_debug( projCtx ctx, int new_debug ) /* pj_ctx_set_logger() */ /************************************************************************/ -void pj_ctx_set_logger( projCtx ctx, void (*new_logger)(void*,int,const char*) ) +void pj_ctx_set_logger( PJ_CONTEXT *ctx, void (*new_logger)(void*,int,const char*) ) { if (nullptr==ctx) @@ -304,7 +303,7 @@ void pj_ctx_set_logger( projCtx ctx, void (*new_logger)(void*,int,const char*) ) /* pj_ctx_set_app_data() */ /************************************************************************/ -void pj_ctx_set_app_data( projCtx ctx, void *new_app_data ) +void pj_ctx_set_app_data( PJ_CONTEXT *ctx, void *new_app_data ) { if (nullptr==ctx) @@ -316,7 +315,7 @@ void pj_ctx_set_app_data( projCtx ctx, void *new_app_data ) /* pj_ctx_get_app_data() */ /************************************************************************/ -void *pj_ctx_get_app_data( projCtx ctx ) +void *pj_ctx_get_app_data( PJ_CONTEXT *ctx ) { if (nullptr==ctx) diff --git a/src/datum_set.cpp b/src/datum_set.cpp index 15d51613..cc6f3dbe 100644 --- a/src/datum_set.cpp +++ b/src/datum_set.cpp @@ -38,7 +38,7 @@ /* pj_datum_set() */ /************************************************************************/ -int pj_datum_set(projCtx ctx, paralist *pl, PJ *projdef) +int pj_datum_set(PJ_CONTEXT *ctx, paralist *pl, PJ *projdef) { const char *name, *towgs84, *nadgrids; diff --git a/src/dmstor.cpp b/src/dmstor.cpp index 3ba66030..e72d9930 100644 --- a/src/dmstor.cpp +++ b/src/dmstor.cpp @@ -26,7 +26,7 @@ dmstor(const char *is, char **rs) { } double -dmstor_ctx(projCtx ctx, const char *is, char **rs) { +dmstor_ctx(PJ_CONTEXT *ctx, const char *is, char **rs) { int sign, n, nl; char *s, work[MAX_WORK]; const char* p; diff --git a/src/ell_set.cpp b/src/ell_set.cpp index ddd507ac..ec3e03eb 100644 --- a/src/ell_set.cpp +++ b/src/ell_set.cpp @@ -609,7 +609,7 @@ int pj_ell_set (PJ_CONTEXT *ctx, paralist *pl, double *a, double *es) { /**************************************************************************************/ -int pj_ell_set (projCtx ctx, paralist *pl, double *a, double *es) { +int pj_ell_set (PJ_CONTEXT *ctx, paralist *pl, double *a, double *es) { /*************************************************************************************** Initialize ellipsoidal parameters: This is the original ellipsoid setup function by Gerald Evenden - significantly more compact than pj_ellipsoid and diff --git a/src/fileapi.cpp b/src/fileapi.cpp index 70be2502..0af83926 100644 --- a/src/fileapi.cpp +++ b/src/fileapi.cpp @@ -36,7 +36,7 @@ #include "proj_internal.h" #include "filemanager.hpp" -static PAFile stdio_fopen(projCtx ctx, const char *filename, +static PAFile stdio_fopen(PJ_CONTEXT *ctx, const char *filename, const char *access); static size_t stdio_fread(void *buffer, size_t size, size_t nmemb, PAFile file); @@ -53,7 +53,7 @@ static projFileAPI default_fileapi = { }; typedef struct { - projCtx ctx; + PJ_CONTEXT *ctx; FILE *fp; } stdio_pafile; @@ -70,7 +70,7 @@ projFileAPI *pj_get_default_fileapi(void) /* stdio_fopen() */ /************************************************************************/ -static PAFile stdio_fopen(projCtx ctx, const char *filename, +static PAFile stdio_fopen(PJ_CONTEXT *ctx, const char *filename, const char *access) { stdio_pafile *pafile; @@ -140,7 +140,7 @@ static void stdio_fclose(PAFile file) /* Open a file using the provided file io hooks. */ /************************************************************************/ -PAFile pj_ctx_fopen(projCtx ctx, const char *filename, const char *access) +PAFile pj_ctx_fopen(PJ_CONTEXT *ctx, const char *filename, const char *access) { return ctx->fileapi_legacy->FOpen(ctx, filename, access); } @@ -148,7 +148,7 @@ PAFile pj_ctx_fopen(projCtx ctx, const char *filename, const char *access) /************************************************************************/ /* pj_ctx_fread() */ /************************************************************************/ -size_t pj_ctx_fread(projCtx ctx, void *buffer, size_t size, size_t nmemb, PAFile file) +size_t pj_ctx_fread(PJ_CONTEXT *ctx, void *buffer, size_t size, size_t nmemb, PAFile file) { return ctx->fileapi_legacy->FRead(buffer, size, nmemb, file); } @@ -156,7 +156,7 @@ size_t pj_ctx_fread(projCtx ctx, void *buffer, size_t size, size_t nmemb, PAFile /************************************************************************/ /* pj_ctx_fseek() */ /************************************************************************/ -int pj_ctx_fseek(projCtx ctx, PAFile file, long offset, int whence) +int pj_ctx_fseek(PJ_CONTEXT *ctx, PAFile file, long offset, int whence) { return ctx->fileapi_legacy->FSeek(file, offset, whence); } @@ -164,7 +164,7 @@ int pj_ctx_fseek(projCtx ctx, PAFile file, long offset, int whence) /************************************************************************/ /* pj_ctx_ftell() */ /************************************************************************/ -long pj_ctx_ftell(projCtx ctx, PAFile file) +long pj_ctx_ftell(PJ_CONTEXT *ctx, PAFile file) { return ctx->fileapi_legacy->FTell(file); } @@ -172,7 +172,7 @@ long pj_ctx_ftell(projCtx ctx, PAFile file) /************************************************************************/ /* pj_ctx_fclose() */ /************************************************************************/ -void pj_ctx_fclose(projCtx ctx, PAFile file) +void pj_ctx_fclose(PJ_CONTEXT *ctx, PAFile file) { ctx->fileapi_legacy->FClose(file); } @@ -185,7 +185,7 @@ void pj_ctx_fclose(projCtx ctx, PAFile file) /* taken. */ /************************************************************************/ -char *pj_ctx_fgets(projCtx ctx, char *line, int size, PAFile file) +char *pj_ctx_fgets(PJ_CONTEXT *ctx, char *line, int size, PAFile file) { long start = pj_ctx_ftell(ctx, file); size_t bytes_read; @@ -218,7 +218,7 @@ char *pj_ctx_fgets(projCtx ctx, char *line, int size, PAFile file) /* pj_ctx_set_fileapi() */ /************************************************************************/ -void pj_ctx_set_fileapi( projCtx ctx, projFileAPI *fileapi ) +void pj_ctx_set_fileapi( PJ_CONTEXT *ctx, projFileAPI *fileapi ) { if (nullptr==ctx) @@ -230,7 +230,7 @@ void pj_ctx_set_fileapi( projCtx ctx, projFileAPI *fileapi ) /* pj_ctx_get_fileapi() */ /************************************************************************/ -projFileAPI *pj_ctx_get_fileapi( projCtx ctx ) +projFileAPI *pj_ctx_get_fileapi( PJ_CONTEXT *ctx ) { if (nullptr==ctx) diff --git a/src/filemanager.cpp b/src/filemanager.cpp index e6a9ed95..37dc920e 100644 --- a/src/filemanager.cpp +++ b/src/filemanager.cpp @@ -1445,8 +1445,8 @@ static bool dontReadUserWritableDirectory() { } static void * -pj_open_lib_internal(projCtx ctx, const char *name, const char *mode, - void *(*open_file)(projCtx, const char *, const char *), +pj_open_lib_internal(PJ_CONTEXT *ctx, const char *name, const char *mode, + void *(*open_file)(PJ_CONTEXT *, const char *, const char *), char *out_full_filename, size_t out_full_filename_size) { try { std::string fname; @@ -1617,7 +1617,7 @@ std::vector<std::string> pj_get_default_searchpaths(PJ_CONTEXT *ctx) { /* pj_open_file_with_manager() */ /************************************************************************/ -static void *pj_open_file_with_manager(projCtx ctx, const char *name, +static void *pj_open_file_with_manager(PJ_CONTEXT *ctx, const char *name, const char * /* mode */) { return NS_PROJ::FileManager::open(ctx, name, NS_PROJ::FileAccess::READ_ONLY) .release(); @@ -1639,7 +1639,7 @@ static NS_PROJ::io::DatabaseContextPtr getDBcontext(PJ_CONTEXT *ctx) { /************************************************************************/ std::unique_ptr<NS_PROJ::File> -NS_PROJ::FileManager::open_resource_file(projCtx ctx, const char *name) { +NS_PROJ::FileManager::open_resource_file(PJ_CONTEXT *ctx, const char *name) { if (ctx == nullptr) { ctx = pj_get_default_ctx(); @@ -1735,13 +1735,13 @@ NS_PROJ::FileManager::open_resource_file(projCtx ctx, const char *name) { #ifndef REMOVE_LEGACY_SUPPORT // Used by following legacy function -static void *pj_ctx_fopen_adapter(projCtx ctx, const char *name, +static void *pj_ctx_fopen_adapter(PJ_CONTEXT *ctx, const char *name, const char *mode) { return pj_ctx_fopen(ctx, name, mode); } // Legacy function -PAFile pj_open_lib(projCtx ctx, const char *name, const char *mode) { +PAFile pj_open_lib(PJ_CONTEXT *ctx, const char *name, const char *mode) { return (PAFile)pj_open_lib_internal(ctx, name, mode, pj_ctx_fopen_adapter, nullptr, 0); } @@ -1764,7 +1764,7 @@ PAFile pj_open_lib(projCtx ctx, const char *name, const char *mode) { * @param out_full_filename_size size of out_full_filename. * @return 1 if the file was found, 0 otherwise. */ -int pj_find_file(projCtx ctx, const char *short_filename, +int pj_find_file(PJ_CONTEXT *ctx, const char *short_filename, char *out_full_filename, size_t out_full_filename_size) { auto file = std::unique_ptr<NS_PROJ::File>( reinterpret_cast<NS_PROJ::File *>(pj_open_lib_internal( @@ -1812,7 +1812,7 @@ static std::string trim(const std::string &s) { /* pj_load_ini() */ /************************************************************************/ -void pj_load_ini(projCtx ctx) { +void pj_load_ini(PJ_CONTEXT *ctx) { if (ctx->iniFileLoaded) return; diff --git a/src/gauss.cpp b/src/gauss.cpp index a34a8f5b..54dff5a8 100644 --- a/src/gauss.cpp +++ b/src/gauss.cpp @@ -81,7 +81,7 @@ void *pj_gauss_ini(double e, double phi0, double *chi, double *rc) { return ((void *)en); } -PJ_LP pj_gauss(projCtx ctx, PJ_LP elp, const void *data) { +PJ_LP pj_gauss(PJ_CONTEXT *ctx, PJ_LP elp, const void *data) { const struct GAUSS *en = (const struct GAUSS *)data; PJ_LP slp; (void) ctx; @@ -93,7 +93,7 @@ PJ_LP pj_gauss(projCtx ctx, PJ_LP elp, const void *data) { return(slp); } -PJ_LP pj_inv_gauss(projCtx ctx, PJ_LP slp, const void *data) { +PJ_LP pj_inv_gauss(PJ_CONTEXT *ctx, PJ_LP slp, const void *data) { const struct GAUSS *en = (const struct GAUSS *)data; PJ_LP elp; double num; diff --git a/src/grids.cpp b/src/grids.cpp index 8065813a..8c1bc4cc 100644 --- a/src/grids.cpp +++ b/src/grids.cpp @@ -2948,7 +2948,7 @@ static PJ_LP pj_hgrid_interpolate(PJ_LP t, const HorizontalShiftGrid *grid, #define MAX_ITERATIONS 10 #define TOL 1e-12 -static PJ_LP pj_hgrid_apply_internal(projCtx ctx, PJ_LP in, +static PJ_LP pj_hgrid_apply_internal(PJ_CONTEXT *ctx, PJ_LP in, PJ_DIRECTION direction, const HorizontalShiftGrid *grid, HorizontalShiftGridSet *gridset, @@ -3452,7 +3452,7 @@ NS_PROJ_END /* it to honour our public api. */ /************************************************************************/ -int pj_apply_gridshift(projCtx ctx, const char *nadgrids, int inverse, +int pj_apply_gridshift(PJ_CONTEXT *ctx, const char *nadgrids, int inverse, long point_count, int point_offset, double *x, double *y, double * /*z */) diff --git a/src/init.cpp b/src/init.cpp index 101fc8ad..a42bf963 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -415,7 +415,7 @@ pj_init_plus( const char *definition ) } PJ * -pj_init_plus_ctx( projCtx ctx, const char *definition ) +pj_init_plus_ctx( PJ_CONTEXT *ctx, const char *definition ) { #define MAX_ARG 200 char *argv[MAX_ARG]; @@ -511,7 +511,7 @@ static PJ_CONSTRUCTOR locate_constructor (const char *name) { PJ * -pj_init_ctx(projCtx ctx, int argc, char **argv) { +pj_init_ctx(PJ_CONTEXT *ctx, int argc, char **argv) { /* Legacy interface: allow init=epsg:XXXX syntax by default */ int allow_init_epsg = proj_context_get_use_proj4_init_rules(ctx, TRUE); return pj_init_ctx_with_allow_init_epsg(ctx, argc, argv, allow_init_epsg); @@ -519,7 +519,7 @@ pj_init_ctx(projCtx ctx, int argc, char **argv) { PJ * -pj_init_ctx_with_allow_init_epsg(projCtx ctx, int argc, char **argv, int allow_init_epsg) { +pj_init_ctx_with_allow_init_epsg(PJ_CONTEXT *ctx, int argc, char **argv, int allow_init_epsg) { const char *s; char *name; PJ_CONSTRUCTOR proj; diff --git a/src/internal.cpp b/src/internal.cpp index 91994077..32dc1bba 100644 --- a/src/internal.cpp +++ b/src/internal.cpp @@ -417,7 +417,7 @@ to that context. /* logging */ /* pj_vlog resides in pj_log.c and relates to pj_log as vsprintf relates to sprintf */ -void pj_vlog( projCtx ctx, int level, const char *fmt, va_list args ); +void pj_vlog( PJ_CONTEXT *ctx, int level, const char *fmt, va_list args ); /***************************************************************************************/ diff --git a/src/iso19111/datum.cpp b/src/iso19111/datum.cpp index 28dbc462..4d7e78d3 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; - projCtx ctxt = pj_ctx_alloc(); + PJ_CONTEXT *ctxt = pj_ctx_alloc(); 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); diff --git a/src/log.cpp b/src/log.cpp index 3cc10cfd..c343e65b 100644 --- a/src/log.cpp +++ b/src/log.cpp @@ -48,9 +48,9 @@ void pj_stderr_logger( void *app_data, int level, const char *msg ) /************************************************************************/ /* pj_vlog() */ /************************************************************************/ -void pj_vlog( projCtx ctx, int level, const char *fmt, va_list args ); +void pj_vlog( PJ_CONTEXT *ctx, int level, const char *fmt, va_list args ); /* Workhorse for the log functions - relates to pj_log as vsprintf relates to sprintf */ -void pj_vlog( projCtx ctx, int level, const char *fmt, va_list args ) +void pj_vlog( PJ_CONTEXT *ctx, int level, const char *fmt, va_list args ) { char *msg_buf; @@ -84,7 +84,7 @@ void pj_vlog( projCtx ctx, int level, const char *fmt, va_list args ) /* pj_log() */ /************************************************************************/ -void pj_log( projCtx ctx, int level, const char *fmt, ... ) +void pj_log( PJ_CONTEXT *ctx, int level, const char *fmt, ... ) { va_list args; diff --git a/src/mlfn.cpp b/src/mlfn.cpp index 80f9163b..d4037897 100644 --- a/src/mlfn.cpp +++ b/src/mlfn.cpp @@ -45,7 +45,7 @@ pj_mlfn(double phi, double sphi, double cphi, const double *en) { } double -pj_inv_mlfn(projCtx ctx, double arg, double es, const double *en) { +pj_inv_mlfn(PJ_CONTEXT *ctx, double arg, double es, const double *en) { double sinphi_ignored; double cosphi_ignored; return inline_pj_inv_mlfn(ctx, arg, es, en, &sinphi_ignored, &cosphi_ignored); diff --git a/src/mlfn.hpp b/src/mlfn.hpp index 26a2959f..e7138c63 100644 --- a/src/mlfn.hpp +++ b/src/mlfn.hpp @@ -15,7 +15,7 @@ inline static double inline_pj_mlfn(double phi, double sphi, double cphi, const } inline static double -inline_pj_inv_mlfn(projCtx ctx, double arg, double es, const double *en, +inline_pj_inv_mlfn(PJ_CONTEXT *ctx, double arg, double es, const double *en, double* sinphi, double* cosphi) { const double k = 1./(1.-es); constexpr double INV_MLFN_EPS = 1e-11; diff --git a/src/param.cpp b/src/param.cpp index 289faca3..9a3888e1 100644 --- a/src/param.cpp +++ b/src/param.cpp @@ -151,7 +151,7 @@ paralist *pj_param_exists (paralist *list, const char *parameter) { /* */ /************************************************************************/ -PROJVALUE pj_param (projCtx ctx, paralist *pl, const char *opt) { +PROJVALUE pj_param (PJ_CONTEXT *ctx, paralist *pl, const char *opt) { int type; unsigned l; diff --git a/src/phi2.cpp b/src/phi2.cpp index 1c48d67f..214d1058 100644 --- a/src/phi2.cpp +++ b/src/phi2.cpp @@ -7,7 +7,7 @@ #include "proj.h" #include "proj_internal.h" -double pj_sinhpsi2tanphi(projCtx ctx, const double taup, const double e) { +double pj_sinhpsi2tanphi(PJ_CONTEXT *ctx, const double taup, const double e) { /**************************************************************************** * Convert tau' = sinh(psi) = tan(chi) to tau = tan(phi). The code is taken * from GeographicLib::Math::tauf(taup, e). @@ -108,7 +108,7 @@ double pj_sinhpsi2tanphi(projCtx ctx, const double taup, const double e) { } /*****************************************************************************/ -double pj_phi2(projCtx ctx, const double ts0, const double e) { +double pj_phi2(PJ_CONTEXT *ctx, const double ts0, const double e) { /**************************************************************************** * Determine latitude angle phi-2. * Inputs: @@ -340,9 +340,9 @@ typedef enum PJ_LOG_LEVEL { typedef void (*PJ_LOG_FUNCTION)(void *, int, const char *); -/* The context type - properly namespaced synonym for projCtx */ -struct projCtx_t; -typedef struct projCtx_t PJ_CONTEXT; +/* The context type - properly namespaced synonym for pj_ctx */ +struct pj_ctx; +typedef struct pj_ctx PJ_CONTEXT; /* A P I */ diff --git a/src/proj_internal.h b/src/proj_internal.h index 062f240b..273c1efd 100644 --- a/src/proj_internal.h +++ b/src/proj_internal.h @@ -240,8 +240,6 @@ struct PJ_AREA { double north_lat_degree; }; -struct projCtx_t; -typedef struct projCtx_t projCtx_t; /***************************************************************************** @@ -352,7 +350,7 @@ struct PJconsts { **************************************************************************************/ - projCtx_t *ctx = nullptr; + PJ_CONTEXT *ctx = nullptr; const char *descr = nullptr; /* From pj_list.h or individual PJ_*.c file */ paralist *params = nullptr; /* Parameter list */ char *def_full = nullptr; /* Full textual definition (usually 0 - set by proj_pj_info) */ @@ -393,7 +391,7 @@ struct PJconsts { PJ_OPERATOR inv4d = nullptr; PJ_DESTRUCTOR destructor = nullptr; - void (*reassign_context)(PJ*, projCtx_t *) = nullptr; + void (*reassign_context)(PJ*, PJ_CONTEXT*) = nullptr; /************************************************************************************* @@ -708,7 +706,7 @@ struct projFileApiCallbackAndData }; /* proj thread context */ -struct projCtx_t { +struct pj_ctx{ int last_errno = 0; int debug_level = 0; void (*logger)(void *, int, const char *) = nullptr; @@ -745,18 +743,18 @@ struct projCtx_t { int pipelineInitRecursiongCounter = 0; // to avoid potential infinite recursion in pipeline.cpp - projCtx_t() = default; - projCtx_t(const projCtx_t&); - ~projCtx_t(); + pj_ctx() = default; + pj_ctx(const pj_ctx&); + ~pj_ctx(); - projCtx_t& operator= (const projCtx_t&) = delete; + pj_ctx& operator= (const pj_ctx&) = delete; projCppContext* get_cpp_context(); void safeAutoCloseDbIfNeeded(); void set_search_paths(const std::vector<std::string>& search_paths_in); void set_ca_bundle_path(const std::string& ca_bundle_path_in); - static projCtx_t createDefault(); + static pj_ctx createDefault(); }; /* Generate pj_list external or make list from include file */ @@ -804,41 +802,41 @@ PJ *pj_projection_specific_setup_##name (PJ *P) /* procedure prototypes */ double PROJ_DLL dmstor(const char *, char **); -double dmstor_ctx(projCtx_t *ctx, const char *, char **); +double dmstor_ctx(PJ_CONTEXT *ctx, const char *, char **); void PROJ_DLL set_rtodms(int, int); char PROJ_DLL *rtodms(char *, double, int, int); double PROJ_DLL adjlon(double); -double aacos(projCtx_t *,double); -double aasin(projCtx_t *,double); +double aacos(PJ_CONTEXT *,double); +double aasin(PJ_CONTEXT *,double); double asqrt(double); double aatan2(double, double); -PROJVALUE PROJ_DLL pj_param(projCtx_t *ctx, paralist *, const char *); +PROJVALUE PROJ_DLL pj_param(PJ_CONTEXT *ctx, paralist *, const char *); paralist PROJ_DLL *pj_param_exists (paralist *list, const char *parameter); paralist PROJ_DLL *pj_mkparam(const char *); paralist *pj_mkparam_ws (const char *str, const char **next_str); -int PROJ_DLL pj_ell_set(projCtx_t *ctx, paralist *, double *, double *); -int pj_datum_set(projCtx_t *,paralist *, PJ *); +int PROJ_DLL pj_ell_set(PJ_CONTEXT *ctx, paralist *, double *, double *); +int pj_datum_set(PJ_CONTEXT *,paralist *, PJ *); int pj_angular_units_set(paralist *, PJ *); paralist *pj_clone_paralist( const paralist* ); paralist *pj_search_initcache( const char *filekey ); void pj_insert_initcache( const char *filekey, const paralist *list); -paralist *pj_expand_init(projCtx_t *ctx, paralist *init); +paralist *pj_expand_init(PJ_CONTEXT *ctx, paralist *init); -void *pj_dealloc_params (projCtx_t *ctx, paralist *start, int errlev); +void *pj_dealloc_params (PJ_CONTEXT *ctx, paralist *start, int errlev); double *pj_enfn(double); double pj_mlfn(double, double, double, const double *); -double pj_inv_mlfn(projCtx_t *, double, double, const double *); +double pj_inv_mlfn(PJ_CONTEXT *, double, double, const double *); double pj_qsfn(double, double, double); double pj_tsfn(double, double, double); double pj_msfn(double, double, double); -double PROJ_DLL pj_phi2(projCtx_t *, const double, const double); -double pj_sinhpsi2tanphi(projCtx_t *, const double, const double); +double PROJ_DLL pj_phi2(PJ_CONTEXT *, const double, const double); +double pj_sinhpsi2tanphi(PJ_CONTEXT *, const double, const double); double pj_qsfn_(double, PJ *); double *pj_authset(double); double pj_authlat(double, double *); @@ -851,10 +849,10 @@ int pj_factors(PJ_LP, const PJ *, double, struct FACTORS *); void *proj_mdist_ini(double); double proj_mdist(double, double, double, const void *); -double proj_inv_mdist(projCtx_t *ctx, double, const void *); +double proj_inv_mdist(PJ_CONTEXT *ctx, double, const void *); void *pj_gauss_ini(double, double, double *,double *); -PJ_LP pj_gauss(projCtx_t *, PJ_LP, const void *); -PJ_LP pj_inv_gauss(projCtx_t *, PJ_LP, const void *); +PJ_LP pj_gauss(PJ_CONTEXT *, PJ_LP, const void *); +PJ_LP pj_inv_gauss(PJ_CONTEXT *, PJ_LP, const void *); struct PJ_DATUMS PROJ_DLL *pj_get_datums_ref( void ); @@ -865,7 +863,7 @@ double PROJ_DLL pj_atof( const char* nptr ); double pj_strtod( const char *nptr, char **endptr ); void pj_freeup_plain (PJ *P); -PJ* pj_init_ctx_with_allow_init_epsg( projCtx_t *ctx, int argc, char **argv, int allow_init_epsg ); +PJ* pj_init_ctx_with_allow_init_epsg( PJ_CONTEXT *ctx, int argc, char **argv, int allow_init_epsg ); std::string PROJ_DLL pj_add_type_crs_if_needed(const std::string& str); std::string pj_double_quote_string_param_if_needed(const std::string& str); @@ -921,10 +919,6 @@ PJ_LP pj_generic_inverse_2d(PJ_XY xy, PJ *P, PJ_LP lpInitial); #define DEG_TO_RAD .017453292519943296 -#if defined(PROJ_H) -#define PROJ_API_H_NOT_INVOKED_AS_PRIMARY_API -#endif - extern char const PROJ_DLL pj_release[]; /* global release id string */ @@ -938,33 +932,12 @@ PROJ_DLL extern int pj_errno; /* global error return code */ #define PJ_LOG_DEBUG_MINOR 3 #endif -#ifdef PROJ_API_H_NOT_INVOKED_AS_PRIMARY_API - /* These make the function declarations below conform with classic proj */ - typedef PJ *projPJ; /* projPJ is a pointer to PJ */ - typedef struct projCtx_t *projCtx; /* projCtx is a pointer to projCtx_t */ -# define projXY PJ_XY -# define projLP PJ_LP -# define projXYZ PJ_XYZ -# define projLPZ PJ_LPZ - -#else - /* i.e. proj_api invoked as primary API */ - typedef struct { double u, v; } projUV; - typedef struct { double u, v, w; } projUVW; - typedef void *projPJ; - #define projXY projUV - #define projLP projUV - #define projXYZ projUVW - #define projLPZ projUVW - typedef void *projCtx; -#endif - /* If included *after* proj.h finishes, we have alternative names */ /* file reading api, like stdio */ typedef int *PAFile; typedef struct projFileAPI_t { - PAFile (*FOpen)(projCtx ctx, const char *filename, const char *access); + PAFile (*FOpen)(PJ_CONTEXT * ctx, const char *filename, const char *access); size_t (*FRead)(void *buffer, size_t size, size_t nmemb, PAFile file); int (*FSeek)(PAFile file, long offset, int whence); long (*FTell)(PAFile file); @@ -975,34 +948,34 @@ typedef struct projFileAPI_t { /* procedure prototypes */ -projCtx PROJ_DLL pj_get_default_ctx(void); -projCtx PROJ_DLL pj_get_ctx( projPJ ); +PJ_CONTEXT PROJ_DLL *pj_get_default_ctx(void); +PJ_CONTEXT PROJ_DLL *pj_get_ctx( PJ *); -projXY PROJ_DLL pj_fwd(projLP, projPJ); -projLP PROJ_DLL pj_inv(projXY, projPJ); +PJ_XY PROJ_DLL pj_fwd(PJ_LP, PJ *); +PJ_LP PROJ_DLL pj_inv(PJ_XY, PJ *); -projXYZ PROJ_DLL pj_fwd3d(projLPZ, projPJ); -projLPZ PROJ_DLL pj_inv3d(projXYZ, projPJ); +PJ_XYZ PROJ_DLL pj_fwd3d(PJ_LPZ, PJ *); +PJ_LPZ PROJ_DLL pj_inv3d(PJ_XYZ, PJ *); -int PROJ_DLL pj_apply_gridshift( projCtx, const char *, int, +int PROJ_DLL pj_apply_gridshift( PJ_CONTEXT *, const char *, int, long point_count, int point_offset, double *x, double *y, double *z ); void PROJ_DLL pj_clear_initcache(void); -int PROJ_DLL pj_is_latlong(projPJ); -int PROJ_DLL pj_is_geocent(projPJ); -void PROJ_DLL pj_get_spheroid_defn(projPJ defn, double *major_axis, double *eccentricity_squared); -void PROJ_DLL pj_pr_list(projPJ); -void PROJ_DLL pj_free(projPJ); +int PROJ_DLL pj_is_latlong(PJ *); +int PROJ_DLL pj_is_geocent(PJ *); +void PROJ_DLL pj_get_spheroid_defn(PJ *defn, double *major_axis, double *eccentricity_squared); +void PROJ_DLL pj_pr_list(PJ *); +void PROJ_DLL pj_free(PJ *); void PROJ_DLL pj_set_finder( const char *(*)(const char *) ); void PROJ_DLL pj_set_searchpath ( int count, const char **path ); -projPJ PROJ_DLL pj_init(int, char **); -projPJ PROJ_DLL pj_init_plus(const char *); -projPJ PROJ_DLL pj_init_ctx( projCtx, int, char ** ); -projPJ PROJ_DLL pj_init_plus_ctx( projCtx, const char * ); -char PROJ_DLL *pj_get_def(projPJ, int); -projPJ PROJ_DLL pj_latlong_from_proj( projPJ ); -int PROJ_DLL pj_has_inverse(projPJ); +PJ PROJ_DLL *pj_init(int, char **); +PJ PROJ_DLL *pj_init_plus(const char *); +PJ PROJ_DLL *pj_init_ctx( PJ_CONTEXT *, int, char ** ); +PJ PROJ_DLL *pj_init_plus_ctx( PJ_CONTEXT *, const char * ); +char PROJ_DLL *pj_get_def(PJ *, int); +PJ PROJ_DLL *pj_latlong_from_proj( PJ *); +int PROJ_DLL pj_has_inverse(PJ *); void PROJ_DLL *pj_malloc(size_t); @@ -1017,33 +990,33 @@ 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( projPJ, projCtx ); -projCtx PROJ_DLL pj_ctx_alloc(void); -void PROJ_DLL pj_ctx_free( projCtx ); -int PROJ_DLL pj_ctx_get_errno( projCtx ); -void PROJ_DLL pj_ctx_set_errno( projCtx, int ); -void PROJ_DLL pj_ctx_set_debug( projCtx, int ); -void PROJ_DLL pj_ctx_set_logger( projCtx, void (*)(void *, int, const char *) ); -void PROJ_DLL pj_ctx_set_app_data( projCtx, void * ); -void PROJ_DLL *pj_ctx_get_app_data( projCtx ); -void PROJ_DLL pj_ctx_set_fileapi( projCtx, projFileAPI *); -projFileAPI PROJ_DLL *pj_ctx_get_fileapi( projCtx ); - -void PROJ_DLL pj_log( projCtx ctx, int level, const char *fmt, ... ); +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_ctx_set_fileapi( PJ_CONTEXT *, projFileAPI *); +projFileAPI PROJ_DLL *pj_ctx_get_fileapi( 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 * ); /* file api */ projFileAPI PROJ_DLL *pj_get_default_fileapi(void); -PAFile PROJ_DLL pj_ctx_fopen(projCtx ctx, const char *filename, const char *access); -size_t PROJ_DLL pj_ctx_fread(projCtx ctx, void *buffer, size_t size, size_t nmemb, PAFile file); -int PROJ_DLL pj_ctx_fseek(projCtx ctx, PAFile file, long offset, int whence); -long PROJ_DLL pj_ctx_ftell(projCtx ctx, PAFile file); -void PROJ_DLL pj_ctx_fclose(projCtx ctx, PAFile file); -char PROJ_DLL *pj_ctx_fgets(projCtx ctx, char *line, int size, PAFile file); +PAFile PROJ_DLL pj_ctx_fopen(PJ_CONTEXT * ctx, const char *filename, const char *access); +size_t PROJ_DLL pj_ctx_fread(PJ_CONTEXT * ctx, void *buffer, size_t size, size_t nmemb, PAFile file); +int PROJ_DLL pj_ctx_fseek(PJ_CONTEXT * ctx, PAFile file, long offset, int whence); +long PROJ_DLL pj_ctx_ftell(PJ_CONTEXT * ctx, PAFile file); +void PROJ_DLL pj_ctx_fclose(PJ_CONTEXT * ctx, PAFile file); +char PROJ_DLL *pj_ctx_fgets(PJ_CONTEXT * ctx, char *line, int size, PAFile file); -PAFile PROJ_DLL pj_open_lib(projCtx, const char *, const char *); -int PROJ_DLL pj_find_file(projCtx ctx, const char *short_filename, +PAFile PROJ_DLL pj_open_lib(PJ_CONTEXT *, const char *, const char *); +int PROJ_DLL pj_find_file(PJ_CONTEXT * ctx, const char *short_filename, char* out_full_filename, size_t out_full_filename_size); diff --git a/src/proj_mdist.cpp b/src/proj_mdist.cpp index c515f6c5..086521b7 100644 --- a/src/proj_mdist.cpp +++ b/src/proj_mdist.cpp @@ -107,7 +107,7 @@ proj_mdist(double phi, double sphi, double cphi, const void *data) { return(D + sc * sum); } double -proj_inv_mdist(projCtx ctx, double dist, const void *data) { +proj_inv_mdist(PJ_CONTEXT *ctx, double dist, const void *data) { const struct MDIST *b = (const struct MDIST *)data; double s, t, phi, k; int i; diff --git a/src/projections/chamb.cpp b/src/projections/chamb.cpp index 36609e79..1b926b8a 100644 --- a/src/projections/chamb.cpp +++ b/src/projections/chamb.cpp @@ -29,7 +29,7 @@ PROJ_HEAD(chamb, "Chamberlin Trimetric") "\n\tMisc Sph, no inv" #define TOL 1e-9 /* distance and azimuth from point 1 to point 2 */ -static VECT vect(projCtx ctx, double dphi, double c1, double s1, double c2, double s2, double dlam) { +static VECT vect(PJ_CONTEXT *ctx, double dphi, double c1, double s1, double c2, double s2, double dlam) { VECT v; double cdl, dp, dl; @@ -49,7 +49,7 @@ static VECT vect(projCtx ctx, double dphi, double c1, double s1, double c2, doub } /* law of cosines */ -static double lc(projCtx ctx, double b,double c,double a) { +static double lc(PJ_CONTEXT *ctx, double b,double c,double a) { return aacos(ctx, .5 * (b * b + c * c - a * a) / (b * c)); } diff --git a/src/tests/multistresstest.cpp b/src/tests/multistresstest.cpp index 51720fbd..674f5ded 100644 --- a/src/tests/multistresstest.cpp +++ b/src/tests/multistresstest.cpp @@ -172,7 +172,7 @@ static TestItem test_list[] = { static volatile int active_thread_count = 0; -static projPJ custom_pj_init_plus_ctx(projCtx ctx, const char* def) +static PJ *custom_pj_init_plus_ctx(PJ_CONTEXT *ctx, const char* def) { return pj_init_plus_ctx(ctx, def); } @@ -191,11 +191,12 @@ static void TestThread() /* -------------------------------------------------------------------- */ /* Initialize coordinate system definitions. */ /* -------------------------------------------------------------------- */ - projPJ *src_pj_list, *dst_pj_list; - projCtx ctx = pj_ctx_alloc(); + PJ **src_pj_list; + PJ **dst_pj_list; + PJ_CONTEXT *ctx = pj_ctx_alloc(); - src_pj_list = (projPJ *) calloc(test_count,sizeof(projPJ)); - dst_pj_list = (projPJ *) calloc(test_count,sizeof(projPJ)); + src_pj_list = (PJ **) calloc(test_count,sizeof(PJ)); + dst_pj_list = (PJ **) calloc(test_count,sizeof(PJ)); if(!reinit_every_iteration) { @@ -345,7 +346,8 @@ static int do_main(void) { TestItem *test = test_list + i; - projPJ src_pj, dst_pj; + PJ *src_pj; + PJ *dst_pj; src_pj = custom_pj_init_plus_ctx( pj_get_default_ctx(), test->src_def ); dst_pj = custom_pj_init_plus_ctx( pj_get_default_ctx(), test->dst_def ); diff --git a/src/tests/test228.cpp b/src/tests/test228.cpp index bffb8e79..ae2eb9cc 100644 --- a/src/tests/test228.cpp +++ b/src/tests/test228.cpp @@ -50,9 +50,9 @@ static volatile int started = 0; static void* thread_main(void* unused) { - projCtx p_proj_ctxt; - projPJ p_WGS84_proj; - projPJ p_OSGB36_proj; + PJ_CONTEXT *p_proj_ctxt; + PJ *p_WGS84_proj; + PJ * p_OSGB36_proj; (void)unused; __sync_add_and_fetch(&started, 1); diff --git a/src/utils.cpp b/src/utils.cpp index 9cb13f44..d3ec7e35 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -172,7 +172,7 @@ PJ *pj_latlong_from_proj( PJ *pj_in ) /* b = a * sqrt(1 - es) */ /************************************************************************/ -void pj_get_spheroid_defn(projPJ defn, double *major_axis, double *eccentricity_squared) +void pj_get_spheroid_defn(PJ * defn, double *major_axis, double *eccentricity_squared) { if ( major_axis ) *major_axis = defn->a; |
