From 3ef083767eaf975399243246605fddc40cc097f9 Mon Sep 17 00:00:00 2001 From: Aaron Puchert Date: Thu, 19 Oct 2017 14:04:35 +0200 Subject: Prevent crashes and leaks on allocation failure (#606) * Prevent crashes and leaks on allocation failure Memory allocation can fail. We need to gracefully handle this case and prevent dereferencing null pointers. * Make NULL checks consistent within a file * Properly report allocation errors * Improve cleanup in pj_gc_reader.c * Implement pj_strdup and use instead of strdup The function strdup is not part of ANSI C 89, but a POSIX extension. Therefore we can not rely on it being available on all platforms. --- src/projects.h | 1 - 1 file changed, 1 deletion(-) (limited to 'src/projects.h') diff --git a/src/projects.h b/src/projects.h index 9391835d..2af382e5 100644 --- a/src/projects.h +++ b/src/projects.h @@ -93,7 +93,6 @@ extern double hypot(double, double); # include # define rewind wceex_rewind # define getenv wceex_getenv -# define strdup _strdup # define hypot _hypot #endif -- cgit v1.2.3 From 9311b85611ad78158dfc62098e96e45930b5d825 Mon Sep 17 00:00:00 2001 From: Kristian Evers Date: Fri, 20 Oct 2017 22:11:18 +0200 Subject: Addition of an "area of use" argument to proj_transform_crs_to_crs (#565) In anticipation of a late-binding implementation of the proj_transform_crs_to_crs function an area argument is added to the function prototype. The PJ_AREA struct is not in use yet, but will be when the function is more tightly coupled to the EPSG database in the future. --- src/projects.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/projects.h') diff --git a/src/projects.h b/src/projects.h index 2af382e5..cbb980ca 100644 --- a/src/projects.h +++ b/src/projects.h @@ -200,6 +200,12 @@ struct PJ_REGION_S { double ur_lat; }; +struct PJ_AREA { + int id; /* Area ID in the EPSG database */ + LP ll; /* Lower left corner of bounding box */ + LP ur; /* Upper right corner of bounding box */ + char descr[64]; /* text representation of area */ +}; struct projCtx_t; typedef struct projCtx_t projCtx_t; -- cgit v1.2.3 From a3fa749bc4f378d005c9e3fd809c0be25de5ffb2 Mon Sep 17 00:00:00 2001 From: Thomas Knudsen Date: Wed, 25 Oct 2017 10:39:56 +0200 Subject: Remove PJ_OBS from the API surface, rename pj_obs_api.c to pj_4D_api.c (#625) * Remove PJ_OBS from the API surface, rename pj_obs_api.c to pj_4D_api.c * Repair proj.def --- src/projects.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/projects.h') diff --git a/src/projects.h b/src/projects.h index cbb980ca..b9d88cf3 100644 --- a/src/projects.h +++ b/src/projects.h @@ -174,6 +174,9 @@ typedef struct { double u, v, w; } UVW; /* Forward declarations and typedefs for stuff needed inside the PJ object */ struct PJconsts; struct PJ_OBS; +#ifndef PROJ_INTERNAL_H +typedef struct PJ_OBS PJ_OBS; +#endif union PJ_COORD; struct geod_geodesic; struct pj_opaque; @@ -189,7 +192,6 @@ enum pj_io_units { }; #ifndef PROJ_H typedef struct PJconsts PJ; /* the PJ object herself */ -typedef struct PJ_OBS PJ_OBS; typedef union PJ_COORD PJ_COORD; #endif @@ -259,7 +261,7 @@ struct PJconsts { void (*spc)(LP, PJ *, struct FACTORS *); void *(*destructor)(PJ *, int); - + /************************************************************************************* -- cgit v1.2.3 From 5646ff12f32adf78e2bc187e6557ce64e4e04b39 Mon Sep 17 00:00:00 2001 From: Thomas Knudsen Date: Fri, 27 Oct 2017 22:50:40 +0200 Subject: Linguistics: Clarify this and that, here and there (#632) * Linguistics: Clarify this and that, here and there * Revert nullification of PJ_cart->fwd, inv --- src/projects.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/projects.h') diff --git a/src/projects.h b/src/projects.h index b9d88cf3..1fe595bc 100644 --- a/src/projects.h +++ b/src/projects.h @@ -186,7 +186,7 @@ struct PJ_REGION_S; typedef struct PJ_REGION_S PJ_Region; typedef struct ARG_list paralist; /* parameter list */ enum pj_io_units { - PJ_IO_UNITS_CLASSIC = 0, /* LEFT: Radians RIGHT: Scaled meters */ + PJ_IO_UNITS_CLASSIC = 0, /* Scaled meters (right) */ PJ_IO_UNITS_METERS = 1, /* Meters */ PJ_IO_UNITS_RADIANS = 2 /* Radians */ }; -- cgit v1.2.3 From 0d0beff91ddfc2cc4d195a141524a139f3afb756 Mon Sep 17 00:00:00 2001 From: Kristian Evers Date: Sat, 28 Oct 2017 15:42:00 +0200 Subject: Allow nested pipelines. (#629) Allow nested pipelines when wrapped in +init's. The previous behaviour was to quit pipeline initialization when encountering a nested pipeline definition. With this commit that behaviour is changed so that it is possible to nest pipelines as long as they are defined elsewhere in a init-file. This is useful in init-files where steps in complicated transformations can be grouped in "sub-pipelines". These "sub-pipelines" can then be used as individual steps in a larger and more complicated pipeline. Nested pipelines are governed by the following rules: 1. You can't have more than one literal +proj=pipeline in a proj-string 2. Pipelines can be nested if they are wrapped up in a +init 3. More than one +init is disallowed in non-pipeline proj-strings 4. +inits are expanded as late as possible, that is they will only be expanded in single operations (that can be a part of a pipeline) --- src/projects.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/projects.h') diff --git a/src/projects.h b/src/projects.h index 1fe595bc..6ea0c914 100644 --- a/src/projects.h +++ b/src/projects.h @@ -532,6 +532,7 @@ struct FACTORS { #define PJD_ERR_MISSING_ARGS -54 #define PJD_ERR_LAT_0_IS_ZERO -55 #define PJD_ERR_ELLIPSOIDAL_UNSUPPORTED -56 +#define PJD_ERR_TOO_MANY_INITS -57 struct projFileAPI_t; -- cgit v1.2.3 From 98078be18bcb0d515362ecc8f122eeca0c3a4b26 Mon Sep 17 00:00:00 2001 From: Thomas Knudsen Date: Sun, 5 Nov 2017 16:48:49 +0100 Subject: Pipeline cleanup (WIP) (#637) * Remove a number of debugging calls and memory management from the inner loop of the pipeline drivers * An attempt at handling inverted steps in a more straightforward way --- src/projects.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/projects.h') diff --git a/src/projects.h b/src/projects.h index 6ea0c914..a7763dd1 100644 --- a/src/projects.h +++ b/src/projects.h @@ -231,6 +231,7 @@ struct PJconsts { paralist *params; /* Parameter list */ struct geod_geodesic *geod; /* For geodesic computations */ struct pj_opaque *opaque; /* Projection specific parameters, Defined in PJ_*.c */ + int inverted; /* Tell high level API functions to swap inv/fwd */ /************************************************************************************* -- cgit v1.2.3 From 4446aa8fbce9d31ab1bf1f9a4138b3d76cf55e84 Mon Sep 17 00:00:00 2001 From: Thomas Knudsen Date: Sun, 5 Nov 2017 16:51:04 +0100 Subject: Improve ISO 19000 alignment (#639) * Discern between conversions and transformations --- src/projects.h | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'src/projects.h') diff --git a/src/projects.h b/src/projects.h index a7763dd1..0631924c 100644 --- a/src/projects.h +++ b/src/projects.h @@ -328,6 +328,7 @@ struct PJconsts { int geoc; /* Geocentric latitude flag */ int is_latlong; /* proj=latlong ... not really a projection at all */ int is_geocent; /* proj=geocent ... not really a projection at all */ + int need_ellps; /* 0 for operations that are purely cartesian */ enum pj_io_units left; /* Flags for input/output coordinate types */ enum pj_io_units right; @@ -584,12 +585,14 @@ extern struct PJ_PRIME_MERIDIANS pj_prime_meridians[]; #ifdef PJ_LIB__ #define PROJ_HEAD(id, name) static const char des_##id [] = name - -#define PROJECTION(name) \ +#define OPERATION(name, NEED_ELLPS) \ + \ pj_projection_specific_setup_##name (PJ *P); \ -C_NAMESPACE_VAR const char * const pj_s_##name = des_##name; \ C_NAMESPACE PJ *pj_##name (PJ *P); \ int pj_ ## name ## _selftest (void); \ + \ +C_NAMESPACE_VAR const char * const pj_s_##name = des_##name; \ + \ C_NAMESPACE PJ *pj_##name (PJ *P) { \ if (P) \ return pj_projection_specific_setup_##name (P); \ @@ -598,14 +601,27 @@ C_NAMESPACE PJ *pj_##name (PJ *P) { \ return 0; \ P->destructor = pj_default_destructor; \ P->descr = des_##name; \ + P->need_ellps = NEED_ELLPS; \ P->left = PJ_IO_UNITS_RADIANS; \ P->right = PJ_IO_UNITS_CLASSIC; \ return P; \ } \ + \ PJ *pj_projection_specific_setup_##name (PJ *P) + +/* In ISO19000 lingo, an operation is either a conversion or a transformation */ +#define CONVERSION(name, need_ellps) OPERATION (name, need_ellps) +#define TRANSFORMATION(name, need_ellps) OPERATION (name, need_ellps) + +/* In PROJ.4 a projection is a conversion taking angular input and giving scaled linear output */ +#define PROJECTION(name) CONVERSION (name, 1) + #endif /* def PJ_LIB__ */ + + + int pj_generic_selftest ( char *e_args, char *s_args, -- cgit v1.2.3 From 8eb82852f5f7d23994839ba5d032edc76eab2250 Mon Sep 17 00:00:00 2001 From: Thomas Knudsen Date: Mon, 6 Nov 2017 10:02:05 +0100 Subject: Eliminate the last traces of PJ_OBS (#643) PJ_OBS eliminated, API adjusted to reflect that we now have only one 4D data type. 2 new API functions added to determine output types of a PJ. --- src/projects.h | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src/projects.h') diff --git a/src/projects.h b/src/projects.h index 0631924c..fad5c7bc 100644 --- a/src/projects.h +++ b/src/projects.h @@ -173,10 +173,7 @@ typedef struct { double u, v, w; } UVW; /* Forward declarations and typedefs for stuff needed inside the PJ object */ struct PJconsts; -struct PJ_OBS; -#ifndef PROJ_INTERNAL_H -typedef struct PJ_OBS PJ_OBS; -#endif + union PJ_COORD; struct geod_geodesic; struct pj_opaque; @@ -212,6 +209,7 @@ struct PJ_AREA { struct projCtx_t; typedef struct projCtx_t projCtx_t; + /* base projection data structure */ struct PJconsts { @@ -254,10 +252,9 @@ struct PJconsts { LP (*inv)(XY, PJ *); XYZ (*fwd3d)(LPZ, PJ *); LPZ (*inv3d)(XYZ, PJ *); - PJ_OBS (*fwdobs)(PJ_OBS, PJ *); - PJ_OBS (*invobs)(PJ_OBS, PJ *); - PJ_COORD (*fwdcoord)(PJ_COORD, PJ *); - PJ_COORD (*invcoord)(PJ_COORD, PJ *); + PJ_COORD (*fwd4d)(PJ_COORD, PJ *); + PJ_COORD (*inv4d)(PJ_COORD, PJ *); + void (*spc)(LP, PJ *, struct FACTORS *); -- cgit v1.2.3 From 70550ae21c653cceefc2142fa89d0fb6c99101d9 Mon Sep 17 00:00:00 2001 From: Thomas Knudsen Date: Wed, 8 Nov 2017 12:41:09 +0100 Subject: minor clean ups in and around proj_4D_api (#649) --- src/projects.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/projects.h') diff --git a/src/projects.h b/src/projects.h index fad5c7bc..a43826d2 100644 --- a/src/projects.h +++ b/src/projects.h @@ -182,11 +182,13 @@ struct FACTORS; struct PJ_REGION_S; typedef struct PJ_REGION_S PJ_Region; typedef struct ARG_list paralist; /* parameter list */ +#ifndef PROJ_INTERNAL_H enum pj_io_units { PJ_IO_UNITS_CLASSIC = 0, /* Scaled meters (right) */ PJ_IO_UNITS_METERS = 1, /* Meters */ PJ_IO_UNITS_RADIANS = 2 /* Radians */ }; +#endif #ifndef PROJ_H typedef struct PJconsts PJ; /* the PJ object herself */ typedef union PJ_COORD PJ_COORD; -- cgit v1.2.3 From e09999127da8dea56d9af52bc346cf7cc6613547 Mon Sep 17 00:00:00 2001 From: Kristian Evers Date: Tue, 7 Nov 2017 20:45:43 +0100 Subject: Use HAVE_C99_MATH instead of _WIN32_ and __ANSI__ HAVE_C99_MATH was recently added to the build system as a safer way to determine if non-ansi math functions are available on the current system. Previously different combinations of tests including _WIN32_ and __ANSI__ have been in use, but cases where that strategy has failed is known. Hence this change to a hopefully more robust check of math function availability. --- src/projects.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/projects.h') diff --git a/src/projects.h b/src/projects.h index fad5c7bc..9ff24f71 100644 --- a/src/projects.h +++ b/src/projects.h @@ -84,7 +84,7 @@ extern "C" { #endif /* prototype hypot for systems where absent */ -#if !defined(_WIN32) || !defined(__ANSI__) +#if !(defined(HAVE_C99_MATH) && HAVE_C99_MATH) extern double hypot(double, double); #endif -- cgit v1.2.3 From 06b2f944d7844bb898ace8a7973f9182aa2234b1 Mon Sep 17 00:00:00 2001 From: Thomas Knudsen Date: Mon, 13 Nov 2017 00:33:40 +0100 Subject: Removed remaining traces of the built in selftest system (#661) * Removed remaining traces of the builtin selftest system. Moved all functionality to test/gie * Updated Appveyor and Travis build scripts * Another appveyor script update --- src/projects.h | 24 ------------------------ 1 file changed, 24 deletions(-) (limited to 'src/projects.h') diff --git a/src/projects.h b/src/projects.h index a28c08d1..1d4fff50 100644 --- a/src/projects.h +++ b/src/projects.h @@ -561,7 +561,6 @@ struct PJ_LIST { #ifndef USE_PJ_LIST_H extern struct PJ_LIST pj_list[]; -extern struct PJ_SELFTEST_LIST pj_selftest_list[]; #endif #ifndef PJ_ELLPS__ @@ -588,7 +587,6 @@ extern struct PJ_PRIME_MERIDIANS pj_prime_meridians[]; \ pj_projection_specific_setup_##name (PJ *P); \ C_NAMESPACE PJ *pj_##name (PJ *P); \ -int pj_ ## name ## _selftest (void); \ \ C_NAMESPACE_VAR const char * const pj_s_##name = des_##name; \ \ @@ -618,27 +616,6 @@ PJ *pj_projection_specific_setup_##name (PJ *P) #endif /* def PJ_LIB__ */ - - - -int pj_generic_selftest ( - char *e_args, - char *s_args, - double tolerance_xy, - double tolerance_lp, - int n_fwd, - int n_inv, - LP *fwd_in, - XY *e_fwd_expect, - XY *s_fwd_expect, - XY *inv_in, - LP *e_inv_expect, - LP *s_inv_expect -); - - - - #define MAX_TAB_ID 80 typedef struct { float lam, phi; } FLP; typedef struct { int lam, phi; } ILP; @@ -816,7 +793,6 @@ struct PJ_ELLPS *pj_get_ellps_ref( void ); struct PJ_DATUMS *pj_get_datums_ref( void ); struct PJ_UNITS *pj_get_units_ref( void ); struct PJ_LIST *pj_get_list_ref( void ); -struct PJ_SELFTEST_LIST *pj_get_selftest_list_ref ( void ); struct PJ_PRIME_MERIDIANS *pj_get_prime_meridians_ref( void ); void *pj_default_destructor (PJ *P, int errlev); -- cgit v1.2.3 From 7aeb1fb3aaf5a7c14ba2a0513d5eca13a9ddd9d0 Mon Sep 17 00:00:00 2001 From: Thomas Knudsen Date: Wed, 15 Nov 2017 09:03:39 +0100 Subject: Support numerical factors only (#664) * Support numerical factors only * Make sure h positive. Improve some comments * Let pole overshoot check have effect even for geocentric latitudes * Factor-typological constants, now all returning false, for backwards compatibility --- src/projects.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/projects.h') diff --git a/src/projects.h b/src/projects.h index 1d4fff50..32b74b08 100644 --- a/src/projects.h +++ b/src/projects.h @@ -257,9 +257,6 @@ struct PJconsts { PJ_COORD (*fwd4d)(PJ_COORD, PJ *); PJ_COORD (*inv4d)(PJ_COORD, PJ *); - - void (*spc)(LP, PJ *, struct FACTORS *); - void *(*destructor)(PJ *, int); @@ -460,14 +457,17 @@ struct FACTORS { double conv; /* convergence */ double s; /* areal scale factor */ double a, b; /* max-min scale error */ - int code; /* info as to analytics, see following */ + int code; /* always 0 */ +}; + +enum deprecated_constants_for_now_dropped_analytical_factors { + IS_ANAL_XL_YL = 01, /* derivatives of lon analytic */ + IS_ANAL_XP_YP = 02, /* derivatives of lat analytic */ + IS_ANAL_HK = 04, /* h and k analytic */ + IS_ANAL_CONV = 010 /* convergence analytic */ }; -#define IS_ANAL_XL_YL 01 /* derivatives of lon analytic */ -#define IS_ANAL_XP_YP 02 /* derivatives of lat analytic */ -#define IS_ANAL_HK 04 /* h and k analytic */ -#define IS_ANAL_CONV 010 /* convergence analytic */ /* datum_type values */ #define PJD_UNKNOWN 0 -- cgit v1.2.3