diff options
| -rw-r--r-- | scripts/reference_exported_symbols.txt | 17 | ||||
| -rw-r--r-- | src/Makefile.am | 4 | ||||
| -rw-r--r-- | src/apps/proj.cpp | 18 | ||||
| -rw-r--r-- | src/init.cpp | 97 | ||||
| -rw-r--r-- | src/proj_internal.h | 32 | ||||
| -rw-r--r-- | src/projections/ob_tran.cpp | 9 | ||||
| -rw-r--r-- | src/tests/test228.cpp | 109 | ||||
| -rw-r--r-- | test/cli/Makefile.am | 6 |
8 files changed, 34 insertions, 258 deletions
diff --git a/scripts/reference_exported_symbols.txt b/scripts/reference_exported_symbols.txt index ee734297..167b8a27 100644 --- a/scripts/reference_exported_symbols.txt +++ b/scripts/reference_exported_symbols.txt @@ -743,44 +743,27 @@ osgeo::proj::VerticalShiftGridSet::~VerticalShiftGridSet() osgeo::proj::VerticalShiftGridSet::VerticalShiftGridSet() osgeo::proj::VerticalShiftGrid::~VerticalShiftGrid() osgeo::proj::VerticalShiftGrid::VerticalShiftGrid(std::string const&, int, int, osgeo::proj::ExtentAndRes const&) -pj_acquire_lock() pj_add_type_crs_if_needed(std::string const&) pj_approx_2D_trans(PJconsts*, PJ_DIRECTION, PJ_COORD) pj_approx_3D_trans(PJconsts*, PJ_DIRECTION, PJ_COORD) pj_atof(char const*) pj_chomp(char*) -pj_cleanup_lock() -pj_clear_initcache() pj_context_get_grid_cache_filename(pj_ctx*) pj_context_set_user_writable_directory(pj_ctx*, std::string const&) pj_ell_set(pj_ctx*, ARG_list*, double*, double*) -pj_find_file(pj_ctx*, char const*, char*, unsigned long) -pj_fwd3d(PJ_LPZ, PJconsts*) pj_fwd(PJ_LP, PJconsts*) -pj_get_ctx(PJconsts*) pj_get_datums_ref() pj_get_default_ctx() pj_get_default_searchpaths(pj_ctx*) -pj_get_def(PJconsts*, int) pj_get_relative_share_proj(pj_ctx*) pj_get_release() -pj_has_inverse(PJconsts*) -pj_init_ctx(pj_ctx*, int, char**) -pj_init(int, char**) -pj_init_plus(char const*) -pj_init_plus_ctx(pj_ctx*, char const*) -pj_inv3d(PJ_XYZ, PJconsts*) pj_inv(PJ_XY, PJconsts*) -pj_log(pj_ctx*, int, char const*, ...) pj_mkparam(char const*) pj_param_exists(ARG_list*, char const*) pj_param(pj_ctx*, ARG_list*, char const*) pj_phi2(pj_ctx*, double, double) pj_pr_list(PJconsts*) -pj_release_lock() pj_shrink(char*) -pj_stderr_logger(void*, int, char const*) -pj_strdup(char const*) proj_alter_id proj_alter_name proj_angular_input diff --git a/src/Makefile.am b/src/Makefile.am index 4f3db3ed..1d772207 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,6 +1,6 @@ AM_CFLAGS = @C_WFLAGS@ -EXTRA_PROGRAMS = multistresstest test228 +EXTRA_PROGRAMS = multistresstest TESTS = geodtest check_PROGRAMS = geodtest @@ -36,7 +36,6 @@ bin_PROGRAMS = proj geod cs2cs gie cct projinfo $(PROJSYNC_BIN) gie_SOURCES = apps/gie.cpp apps/proj_strtod.cpp apps/proj_strtod.h apps/optargpm.h multistresstest_SOURCES = tests/multistresstest.cpp -test228_SOURCES = tests/test228.cpp geodtest_SOURCES = tests/geodtest.cpp cct_LDADD = libproj.la @@ -47,7 +46,6 @@ projinfo_LDADD = libproj.la gie_LDADD = libproj.la multistresstest_LDADD = libproj.la @THREAD_LIB@ -test228_LDADD = libproj.la @THREAD_LIB@ geodtest_LDADD = libproj.la lib_LTLIBRARIES = libproj.la diff --git a/src/apps/proj.cpp b/src/apps/proj.cpp index a5c917f6..0108cb74 100644 --- a/src/apps/proj.cpp +++ b/src/apps/proj.cpp @@ -9,6 +9,8 @@ #include "emess.h" #include "utils.h" +#include <vector> + #if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__WIN32__) # include <fcntl.h> # include <io.h> @@ -292,10 +294,10 @@ static void vprocess(FILE *fid) { int main(int argc, char **argv) { char *arg; - char *pargv[MAX_PARGS] = {}; + std::vector<char*> argvVector; char **eargv = argv; FILE *fid; - int pargc = 0, eargc = 0, mon = 0; + int eargc = 0, mon = 0; if ( (emess_dat.Prog_name = strrchr(*argv,DIR_CHAR)) != nullptr) ++emess_dat.Prog_name; @@ -450,10 +452,7 @@ int main(int argc, char **argv) { } break; } else if (**argv == '+') { /* + argument */ - if (pargc < MAX_PARGS) - pargv[pargc++] = *argv + 1; - else - emess(1,"overflowed + argument table"); + argvVector.push_back(*argv + 1); } else /* assumed to be input file name(s) */ eargv[eargc++] = *argv; } @@ -473,7 +472,12 @@ int main(int argc, char **argv) { postscale = 0; fscale = 1./fscale; } - if (!(Proj = pj_init(pargc, pargv))) + proj_context_use_proj4_init_rules(nullptr, true); + + // proj historically ignores any datum shift specifier, like nadgrids, towgs84, etc + argvVector.push_back(const_cast<char*>("break_cs2cs_recursion")); + + if (!(Proj = proj_create_argv(nullptr, static_cast<int>(argvVector.size()), argvVector.data()))) emess(3,"projection initialization failure\ncause: %s", proj_errno_string(proj_context_errno(nullptr))); diff --git a/src/init.cpp b/src/init.cpp index 7b614c5f..1e89402d 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -400,90 +400,6 @@ paralist *pj_expand_init(PJ_CONTEXT *ctx, paralist *init) { /************************************************************************/ -/* pj_init_plus() */ -/* */ -/* Same as pj_init() except it takes one argument string with */ -/* individual arguments preceded by '+', such as "+proj=utm */ -/* +zone=11 +ellps=WGS84". */ -/************************************************************************/ - -PJ * -pj_init_plus( const char *definition ) - -{ - return pj_init_plus_ctx( pj_get_default_ctx(), definition ); -} - -PJ * -pj_init_plus_ctx( PJ_CONTEXT *ctx, const char *definition ) -{ -#define MAX_ARG 200 - char *argv[MAX_ARG]; - char *defn_copy; - int argc = 0, i, blank_count = 0; - PJ *result = nullptr; - - /* make a copy that we can manipulate */ - defn_copy = (char *) malloc( strlen(definition)+1 ); - if (!defn_copy) - return nullptr; - strcpy( defn_copy, definition ); - - /* split into arguments based on '+' and trim white space */ - - for( i = 0; defn_copy[i] != '\0'; i++ ) - { - switch( defn_copy[i] ) - { - case '+': - if( i == 0 || defn_copy[i-1] == '\0' || blank_count > 0 ) - { - /* trim trailing spaces from the previous param */ - if( blank_count > 0 ) - { - defn_copy[i - blank_count] = '\0'; - blank_count = 0; - } - - if( argc+1 == MAX_ARG ) - { - free( defn_copy ); - proj_context_errno_set( ctx, PJD_ERR_UNPARSEABLE_CS_DEF ); - return nullptr; - } - - argv[argc++] = defn_copy + i + 1; - } - break; - - case ' ': - case '\t': - case '\n': - /* trim leading spaces from the current param */ - if( i == 0 || defn_copy[i-1] == '\0' || argc == 0 || argv[argc-1] == defn_copy + i ) - defn_copy[i] = '\0'; - else - blank_count++; - break; - - default: - /* reset blank_count */ - blank_count = 0; - } - } - /* trim trailing spaces from the last param */ - defn_copy[i - blank_count] = '\0'; - - /* perform actual initialization */ - result = pj_init_ctx( ctx, argc, argv ); - - free( defn_copy ); - return result; -} - - - -/************************************************************************/ /* pj_init() */ /* */ /* Main entry point for initialing a PJ projections */ @@ -492,11 +408,6 @@ pj_init_plus_ctx( PJ_CONTEXT *ctx, const char *definition ) /* large enough to hold projection specific parameters. */ /************************************************************************/ -PJ * -pj_init(int argc, char **argv) { - return pj_init_ctx( pj_get_default_ctx(), argc, argv ); -} - static PJ_CONSTRUCTOR locate_constructor (const char *name) { int i; @@ -511,14 +422,6 @@ static PJ_CONSTRUCTOR locate_constructor (const char *name) { PJ * -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); -} - - -PJ * pj_init_ctx_with_allow_init_epsg(PJ_CONTEXT *ctx, int argc, char **argv, int allow_init_epsg) { const char *s; char *name; diff --git a/src/proj_internal.h b/src/proj_internal.h index 234ff80e..32aaa1ec 100644 --- a/src/proj_internal.h +++ b/src/proj_internal.h @@ -934,35 +934,31 @@ extern char const PROJ_DLL pj_release[]; /* global release id string */ /* procedure prototypes */ PJ_CONTEXT PROJ_DLL *pj_get_default_ctx(void); -PJ_CONTEXT PROJ_DLL *pj_get_ctx( PJ *); +PJ_CONTEXT *pj_get_ctx( PJ *); PJ_XY PROJ_DLL pj_fwd(PJ_LP, PJ *); PJ_LP PROJ_DLL pj_inv(PJ_XY, PJ *); -PJ_XYZ PROJ_DLL pj_fwd3d(PJ_LPZ, PJ *); -PJ_LPZ PROJ_DLL pj_inv3d(PJ_XYZ, PJ *); +PJ_XYZ pj_fwd3d(PJ_LPZ, PJ *); +PJ_LPZ pj_inv3d(PJ_XYZ, PJ *); -void PROJ_DLL pj_clear_initcache(void); -void PROJ_DLL pj_pr_list(PJ *); -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); -int PROJ_DLL pj_has_inverse(PJ *); +void pj_clear_initcache(void); +void PROJ_DLL pj_pr_list(PJ *); /* used by proj.cpp */ +char *pj_get_def(PJ *, int); +int pj_has_inverse(PJ *); -char PROJ_DLL *pj_strdup(const char *str); +char *pj_strdup(const char *str); const char PROJ_DLL *pj_get_release(void); -void PROJ_DLL pj_acquire_lock(void); -void PROJ_DLL pj_release_lock(void); -void PROJ_DLL pj_cleanup_lock(void); +void pj_acquire_lock(void); +void pj_release_lock(void); +void pj_cleanup_lock(void); -void PROJ_DLL pj_log( PJ_CONTEXT * ctx, int level, const char *fmt, ... ); -void PROJ_DLL pj_stderr_logger( void *, int, const char * ); +void pj_log( PJ_CONTEXT * ctx, int level, const char *fmt, ... ); +void pj_stderr_logger( void *, int, const char * ); -int PROJ_DLL pj_find_file(PJ_CONTEXT * 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); diff --git a/src/projections/ob_tran.cpp b/src/projections/ob_tran.cpp index 4990ab2a..86798e0a 100644 --- a/src/projections/ob_tran.cpp +++ b/src/projections/ob_tran.cpp @@ -141,14 +141,15 @@ static ARGS ob_tran_target_params (paralist *params) { if (argc < 2) return args; - /* all args except the proj_ob_tran */ + /* all args except the proj=ob_tran */ args.argv = static_cast<char**>(calloc (argc - 1, sizeof (char *))); if (nullptr==args.argv) return args; - /* Copy all args *except* the proj=ob_tran arg to the argv array */ + /* Copy all args *except* the proj=ob_tran or inv arg to the argv array */ for (i = 0; params != nullptr; params = params->next) { - if (0==strcmp (params->param, "proj=ob_tran")) + if (0==strcmp (params->param, "proj=ob_tran") || + 0==strcmp (params->param, "inv") ) continue; args.argv[i++] = params->param; } @@ -194,7 +195,7 @@ PJ *PROJECTION(ob_tran) { if (args.argv == nullptr ) { return destructor(P, PJD_ERR_FAILED_TO_FIND_PROJ); } - R = pj_init_ctx (pj_get_ctx(P), args.argc, args.argv); + R = proj_create_argv (P->ctx, args.argc, args.argv); free (args.argv); if (nullptr==R) diff --git a/src/tests/test228.cpp b/src/tests/test228.cpp deleted file mode 100644 index ae2eb9cc..00000000 --- a/src/tests/test228.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/****************************************************************************** - * - * Project: PROJ - * Purpose: Test - * Author: Even Rouault <even dot rouault at spatialys dot com> - * - ****************************************************************************** - * Copyright (c) 2014, Even Rouault <even dot rouault at spatialys dot com> - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - ****************************************************************************/ - -#include "proj_internal.h" -#include <stdio.h> /* for printf declaration */ - - -#ifdef _WIN32 - -int main(int argc, char* argv[]) -{ - printf("Test not yet ported on Win32\n"); - return 0; -} - -#else - -#include <pthread.h> -#include <stdio.h> -#include <assert.h> -#include <unistd.h> - -static volatile int run = 0; -static volatile int started = 0; - -static void* thread_main(void* unused) -{ - PJ_CONTEXT *p_proj_ctxt; - PJ *p_WGS84_proj; - PJ * p_OSGB36_proj; - (void)unused; - - __sync_add_and_fetch(&started, 1); - while(run == 0); - - p_proj_ctxt=pj_ctx_alloc(); - p_WGS84_proj=pj_init_plus_ctx(p_proj_ctxt,"+proj=longlat " - "+ellps=WGS84 +datum=WGS84"); - p_OSGB36_proj=pj_init_plus_ctx(p_proj_ctxt, - "+proj=longlat +ellps=airy +datum=OSGB36 +nadgrids=OSTN15_NTv2_OSGBtoETRS.gsb"); - - while(run) - { - double x, y; - int proj_ret; - - x = -5.2*DEG_TO_RAD; - y = 50*DEG_TO_RAD; - proj_ret = pj_transform(p_WGS84_proj, - p_OSGB36_proj, 1, 1, &x, &y, nullptr ); - x *= RAD_TO_DEG; - y *= RAD_TO_DEG; - /*printf("%.18f %.18f\n", x, y); */ - assert(proj_ret == 0); - assert(fabs(x - -5.198965207267856492) < 1e-15); - assert(fabs(y - 49.999396074140378232) < 1e-15); - } - - pj_free (p_OSGB36_proj); - pj_free (p_WGS84_proj); - return nullptr; -} - -int main() -{ - int i; - - pthread_t tid1, tid2; - pthread_attr_t attr1, attr2; - - pthread_attr_init(&attr1); - pthread_attr_init(&attr2); - - pthread_create(&tid1, &attr1, thread_main, nullptr); - pthread_create(&tid2, &attr2, thread_main, nullptr); - while(started != 2); - run = 1; - for(i=0;i<2;i++) - sleep(1); - run = 0; - return 0; -} - -#endif /* _WIN32 */ diff --git a/test/cli/Makefile.am b/test/cli/Makefile.am index 4d11eaf3..46d9d36c 100644 --- a/test/cli/Makefile.am +++ b/test/cli/Makefile.am @@ -35,13 +35,13 @@ testprojinfo-check: PROJ_SKIP_READ_USER_WRITABLE_DIRECTORY=YES PROJ_LIB=$(PROJ_LIB) $(TESTPROJINFO) $(PROJINFOEXE) test27-check: - $(TEST27) $(PROJEXE) + PROJ_LIB=$(PROJ_LIB) $(TEST27) $(PROJEXE) test83-check: - $(TEST83) $(PROJEXE) + PROJ_LIB=$(PROJ_LIB) $(TEST83) $(PROJEXE) testproj-check: - $(TESTPROJ) $(PROJEXE) + PROJ_LIB=$(PROJ_LIB) $(TESTPROJ) $(PROJEXE) testvarious-check: PROJ_SKIP_READ_USER_WRITABLE_DIRECTORY=YES PROJ_LIB=$(PROJ_LIB) $(TESTVARIOUS) $(CS2CSEXE) |
