aboutsummaryrefslogtreecommitdiff
path: root/src/projects.h
AgeCommit message (Collapse)Author
2018-10-16Move struct definitions for proj_list_* functions to proj.hKristian Evers
With projects.h not being available to outside users anymore we need to define PJ_UNITS, PJ_ELLPS, PJ_PRIME_MERIDIANS and PJ_OPERATIONS elsewhere. Related pj_get_*_ref() functions have been removed in favour of their proj_ namespaced counterparts. char pointers have been changed to const char pointers. Resolves #983 Resolved #1147 Make char pointers const
2018-10-16Change pj_mkparam to take const char pointerKristian Evers
pj_mkparam() and pj_mkparam_ws() doesn't alter the input string should therefore be const. This will be useful when making other changes to the code base later.
2018-09-21Remove misspelled-constant PJD_ERR_UNKNOW_UNIT_IDKristian Evers
Closes #853
2018-09-18Only allow usage of proj_api.h if explicit consent was givenKristian Evers
We want to flag that proj_api_h is now deprecated. With this commit it is now mandatory to #define ACCEPT_USE_OF_DEPRECATED_PROJ_API_H before proj_api.h can be included. proj_api.h is used internally a bunch of places. Therefore ACCEPT_USE_OF_DEPRECATED_PROJ_API_H has been defined in projects.h and a few other necessary files to ensure that PROJ compiles. Closes #836
2018-08-11projects.h: use param[] variable-length member syntax with GCC >= 8 to fix ↵Even Rouault
optimization issue with gcc 8.2 (fixes #1084)
2018-08-11Fix wrong behaviour of torad_coord() with gcc 8.1 -O2 (fixes #1084)Even Rouault
torad_coord() of gie.c has this sequence: ``` if( cond ) axis = l->param + strlen ("axis="); n = strlen (axis); ``` When the if branch is evaluated, n is always zero even if on inspection axis is non empty The reason is that the struct ARG_list which is the type of l use a variable-length array for the param member struct ARG_list { paralist *next; char used; char param[1]; }; But this is not a proper way of declaring it, and gcc 8 has apparently optimizations to detect that l->param + 5 points out of the array, hence it optimizes strlen() to 0. Reported as https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86914 According to https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html, the proper way of declaring such arrays is to use [0]
2018-06-21Add support for deg, rad and grad in unitconvert (fixes #1052), and document ↵Even Rouault
that it supports numeric factors (refs #1053)
2018-05-30Fix warnings found by clang with new warning flags to be added in later commitEven Rouault
Fixes consist in: - no use of comma operator for multi statement purpose - avoid confusing comma in for loops first and third clauses - avoid implicit long to int casts by storing to long, or explicit bound checking before cast
2018-04-16Collect custom C99 math functions in proj_math.hKristian Evers
We are relying more and more on C99 math functions. On C89 systems where those functions are not available our own custom versions of those functions are used instead. So far these has been spread across the code base. This commit gathers them in the same file and introduces the proj_math.h header. The build system checks for C99 math functions. If not found the proj_math.h header make sure that C99 functions are defined as their pj_ equivalent. Ideally proj_math.h is included instead of math.h. This removes the need for any checks against HAVE_C99_MATH in the code making it easier to read. For this commit the functions hypot, log1p and asinh has been taken care of.
2018-03-11typo fix: Rename PJD_ERR_UNKNOW_UNIT_ID as PJD_ERR_UNKNOWN_UNIT_IDEven Rouault
Original mispelled constant kept for backward compatibility.
2018-02-12typedef some recurring function signaturesThomas Knudsen
2018-02-09Avoid XY, LP and UV datatype clashes with other libraries.Kristian Evers
Remove unnecessary definitions of UV and UVW from project.h that collides with external libraries. To prevent similar problems in the future the datatypes XY, LP, UV, XYZ, LPZ and UVW has been prefixed by PJ_ in proj.h and proj_internal.h
2018-02-07Shrink PJ_XXX_INFO structs, but keep same syntax. (#775)Thomas Knudsen
* Shrink PJ_XXX_INFO structs, but keep same syntax. A number of the fixed length strings in the INFO structs are simply reflections of material that already exists as static strings at a number of places in the library (or in the case of PJ_INFO, really *should* exist, and now is implemented). This PR replaces these cases of constant length strings with const char pointers. The usage syntax is unchanged, and so is the nice property of having the return value allocated on the stack, and hence not requiring explicit memory management by the caller. proj_info now only does setup once - and the searchpath entry of PJ_INFO is not arbitrarily truncated at 512 bytes. Repeated calls simply returns a copy of already prepared material. The id, description and definition entries of PJ_PROJ_INFO are now also guaranteed to hold the entire text of the corresponding static string, by being represented by a const char pointer to that actual static string. PJ_GRID_INFO and PJ_INIT_INFO (i.e. the two smallest INFO structs) are unchanged. * Eliminate pj_strlcpy - not needed anymore: Remining calls could safely be replaced by strncpy. * Extend PROJ_INFO with paths from pj_set_searchpath. NOTE: Need to call pj_set_searchpath before first call to proj_info Huge thanks to Kristian Evers and Even Rouault for comments, debugging and advice.
2018-02-01Remove Windows CE cruft (wince/msvc80)Mateusz Loskot
Closes #582
2018-02-01Remove unnecessary functions and restructure proj.def. Closes #728Kristian Evers
2018-01-31Renamed PJ_IO_UNITS_RADIANS to PJ_IO_UNITS_ANGULARThomas Knudsen
2018-01-31Introduce compatibility for cs2cs-style proj-strings into the 4D API.Thomas Knudsen
Parameters such as towgs84, nadgrids and geoidgrids was previously only handled by pj_transform(). This commit add a compatibility layer in proj_create() by calling the pj_cs2cs_emulation_setup() function. This function sets up a handful of predefined transformation objects on the PJ object that is being created. Each of these transformation objects are related to the cs2cs-style parameters we are trying to emulate in the 4D API. That is, if the +towgs84 parameters is used we create P->helmert with the parameters specified in +towgs84. Similarly for +axis, +nadgrids and +geoidgrids. When these transformation objects exists we use them in the prepare and finalize functions in pj_fwd/ pj_inv. If no cs2cs-style parametes are specified we skip those parts of the prepare and finalizing steps. Co-authored-by:Thomas Knudsen <thokn@sdfe.dk> Co-authored-by:Kristian Evers <kristianevers@gmail.com>
2018-01-08Discern between 2D projected and 3D cartesian linear units (#732)Thomas Knudsen
2018-01-03Introduce preparation/finalization steps in fwd/inv subsystem, supporting ↵Thomas Knudsen
arbitrary dimensionality in test code * Call trans func of same dimensionality as input in gie * Refactor prep/fin code for pj_fwd/pj_inv 2D,3D,4D * Remove prime meridian handling from pj_transform (now handled in pj_fwd_prepare/pj_inv_finalize) * Introduce prep/fin skips, mostly in support of axisswap and pipeline drivers * Refactor fwd/inv subsystem * pj_transform: Let pj_fwd/inv handle scaling * Let pj_fwd/inv3d fall back to 2D eventually
2017-12-17Declare non-local variables as const where possibleAaron Puchert
Having non-const variables of static lifetime or even global scope is usually a bad idea. These variables are inherently constants, and this should be enforced. This required marking some functions as not modifying input parameters and marking some pointers as pointers to const. One advantage is that the compiler usually puts const static variables in a read-only code segment, so they can't be modified physically. This can be verified with `nm` (on POSIX systems). To avoid changes to the public API, functions returning non-const pointers to data tables were left intact, but the returned data may not be modified. Internally we prefer using the proj_list_* functions over the pj_get_*_ref functions, because the former return const pointers.
2017-12-17Free format everywhere (#693)Thomas Knudsen
* Free format now in cmd lines, in gie, and in init files * Corrected handling of defaults * Add demo of integrated definition and validation * Repair stack-smashing memmove in get_init * repair paralist corruption, clean up debug output * Install test files for nmake builds * Add many improvements following suggestions by @schwehr * Be consistent in requiring lower case everywhere in gie.c Also, this Fixes #703 and Fixes #697
2017-11-27Replace some asserts by compile-time assertionsAaron Puchert
Decisions regarding the size of certain types are always made at compile time, hence this is where the assertion should take place. If the assertions fail, there is now a compiler error.
2017-11-25Improve API (#683)Thomas Knudsen
Increase the focus on PJ_COORD as primary datatype: Eliminate use of PJ_TRIPLET etc. Trim proj.h by removing material that has become unnecessary. Improve constness Make proj_factors work in proj.h space, by providing a trimmed down PJ_FACTORS (which even has more meaningful field names)
2017-11-22Avoid div-by-zero in rf setupThomas Knudsen
2017-11-20Replace pj_ell_set with reimplementation... (#675)Thomas Knudsen
* Replace pj_ell_set with reimplementation supporting ellipsoid inheritance * remove unreachable code from pj_ell_set.c * Swap steps, so ellps args are read first, in accordance with historical behaviour * Add ellipsoid tests to CI targets * Reduce some optimistic tolerances OS/X appears to have a slightly off float handling, resulting in differences at the nanometer level. Switching to 10 nm.
2017-11-15Support numerical factors only (#664)Thomas Knudsen
* 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
2017-11-13Removed remaining traces of the built in selftest system (#661)Thomas Knudsen
* Removed remaining traces of the builtin selftest system. Moved all functionality to test/gie * Updated Appveyor and Travis build scripts * Another appveyor script update
2017-11-11Merge pull request #647 from kbevers/use_have_c99_mathKristian Evers
Use HAVE_C99_MATH instead of _WIN32_ and __ANSI__
2017-11-10Use HAVE_C99_MATH instead of _WIN32_ and __ANSI__Kristian Evers
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.
2017-11-08minor clean ups in and around proj_4D_api (#649)Thomas Knudsen
2017-11-06Eliminate the last traces of PJ_OBS (#643)Thomas Knudsen
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.
2017-11-05Improve ISO 19000 alignment (#639)Thomas Knudsen
* Discern between conversions and transformations
2017-11-05Pipeline cleanup (WIP) (#637)Thomas Knudsen
* 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
2017-10-28Allow nested pipelines. (#629)Kristian Evers
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)
2017-10-27Linguistics: Clarify this and that, here and there (#632)Thomas Knudsen
* Linguistics: Clarify this and that, here and there * Revert nullification of PJ_cart->fwd, inv
2017-10-25Remove PJ_OBS from the API surface, rename pj_obs_api.c to pj_4D_api.c (#625)Thomas Knudsen
* Remove PJ_OBS from the API surface, rename pj_obs_api.c to pj_4D_api.c * Repair proj.def
2017-10-20Addition of an "area of use" argument to proj_transform_crs_to_crs (#565)Kristian Evers
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.
2017-10-19Prevent crashes and leaks on allocation failure (#606)Aaron Puchert
* 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.
2017-10-06Change PJ.left default from PJ_CLASSIC to PJ_RADIANSThomas Knudsen
2017-10-06Enable default destructor for all PJ objects.Thomas Knudsen
In most cases memory deallocation is completely removed from the code since it can be handled by the default destructor. In a few special cases a local destructor overrides the default destructor and makes sure that locally allocated memored is cleaned up correctly. Move all deallocation from pj_free to pj_default_destructor Rename pj_latlong.c to fit with the conventional format PJ_latlong.c - freeup was missed here due to wrong naming Clean up pj_init to avoid double deallocation; Also resolve #576 by adding z_0 and t_0 options in pj_init, while cleaning Add a prototype for dealloc_params Added missing errno.h include in pj_ctx.c Temporarily removing ob_tran from testvarious, to be sure that is where the trouble is Make PJ_ob_tran.c use proper initialization for the chained projection proj=ob_tran: make it clear, that we disallow ellipsoidal projections, and, for improved backwards compatibility, turns off default settings, which could inject unwanted ellipsoid definitions ... then also remove the ellipsoid definition from the testvarious test case - which is probably buggy anyway Work around cs2cs spherical init bug in testvarious; Forbid defs for ob_tran in pj_init
2017-09-28Add PJD_ERR_* aliases for error numbers without oneKristian Evers
2017-09-28Support a default destructor for PJ objectsThomas Knudsen
2017-08-07Adding info functions to proj.h API. (#551)Kristian Evers
* Adding info functions to proj.h API. Four new functions are added with this commit: proj_info(), proj_pj_info(), proj_grid_info() and proj_init_info(). Additionally four new data types are added: PJ_INFO, PJ_PROJ_INFO, PJ_GRID_INFO and PJ_INIT_INFO. The functions return the corresponding data types. These functions allows users of the PROJ.4 library to get information about various PROJ.4 entities and the library itself. The new data types are structs that contain specific information about either the library instance, a PJ instance, a grid or an init file. Together the four new functions cover a big part of the functionality in the semi-public projects.h API and should hopefully make it easier for user to migrate their code to the proj.h API in the future. Besides covering already existing functionality in the old API, this commit introduces the ability to add metadata to init-files. This is primarily added to give users a way of knowing which version of the EPSG database they are using, but it also comes in handy for other init-files. The init-file metadata is added directly to the init-file as a special "projection" called "metadata". The info projection of the epsg init-file is thus described as: <metadata> +version=9.0.0 +origin=EPSG +lastupdate=2017-01-10 The proj_init_info() function uses the internal pj_param() to read the metadata. As a consequence, "metadata" will not be available as a the name of a projection in the future. This is a reasonable price to pay considering the ease of the implementation of adding metadata to init-files this way, and of course that "metadata" is a very unlikely name for a projection in any case. A metadata tag has been added to all init-files in the nad-directory. For most only a subset of the possible parameters has been added. * Replaced calls to sprintf and strncpy with safer options. Added pj_strlcpy for internal use. * Fail gracefully when getting non-initialized PJ in proj_pj_info() * Change length of filename member in PJ_INIT_INFO and PJ_GRID_INFO to 260 (MAX_PATH)
2017-07-18Merge pull request #548 from kbevers/remove-error-macrosKristian Evers
Eliminated *_ERROR* macros.
2017-07-18Expanded *_ERROR* macros.Kristian Evers
Expanded *_ERROR* macros with calls to proj_errno_set() and proper returns when necessary. Defined a bunch of new PJD_ERR_ constants in projects.h that corresponds to the error numbers in pj_strerrno.c. A few unknown error numbers were replaced by existing ones in pj_strerrno.c.
2017-07-14Make sure to use custom hypot() when building as ANSI C (not defined before ↵Kristian Evers
C99).
2017-07-10Introducing the Molodensky transform (#541)Kristian Evers
2017-07-07obs_api revision and improvements: new namespace etc. (#530)Thomas Knudsen
* obs_api revision and improvements: new namespace etc. * Minor corrections: use unused functions, add missing prototype, added fwd/invcoord to PJ * Minor correction: MSVC barfs on va_arg type specification. Trying once more with added parens * Reverting paren correction, which appears to be a non-solution * Significant improvements to the OBS_API, plus a number of corrections, mostly in test code, to reflect API changes * Added two missing prototypes * Adding the proj_transform function and some related checks * Improvements to proj_transform etc. based on suggestions from Even Rouault * Reducing the libc include footprint of proj.h - again based on suggestions from Even Rouault * A few minor corrections * Eliminate a MSVC warning about non-initialized usage. Not an actual issue, as another check has locked the path, but at least this should calm down MSVC * Improved support for the errno reset/restore paradigm * Introduced the internal header proj_internal.h; Moved most non-API stuff from pj_obs_api.c to pj_internal.c * Adding proj_internal.h to HEADERS_LIBPROJ to solve build problems * Correcting a few pj...proj blunders in PJ_pipeline.c * Correcting a few additional blunders in PJ_pipeline.c * Changed angle-brackets to quotation marks in includes of proj_internal.h * Some minor build system repairs * Some PJ_CONTEXT usage simplifications following suggestions by Kristian Evers @kbevers * Added version numbering to proj.h - Fixes #529 * remove proj_errno_restore macro, provide function implementation * Add proj_get_definition. Fixes #538 * Added library specific deallocator proj_buffer_free, eliminating a potential cross heap issues on Windows. Thx to Even Rouault for spotting this * Got rid of a meaningless cast in proj_buffer_free * Added some missing functions to proj.def (again spotted by @rouault); removed some not-yet-implemented material from proj.h * Renamed proj_get_definition/proj_buffer_free to proj_definition_create/proj_definition_destroy, for symmetry and clarity * Renaming the definition handlers to proj_definition_retrieve / proj_free * Renaming proj_free to proj_release
2017-06-08PJ_comill.c: avoid infinite loop in inverse method. Credit to OSS FuzzEven Rouault
2017-06-02Disallow usage of m<0 and n<0 in gn_sinu.Kristian Evers
Negative values of m and n are not valid. Can for certain values of m and n result in zero division. An error is raised at projection setup if m or n is negative. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1836 Credit to OSS-Fuzz.