aboutsummaryrefslogtreecommitdiff
path: root/src/proj_4D_api.c
AgeCommit message (Collapse)Author
2018-12-26cpp conversion: minimal steps to fix compilation errors, not warningsEven Rouault
2018-12-14C API: rename recently added _unref and _free functions as _destroy (fixes ↵Even Rouault
#1198)
2018-11-30C API: do not 'cache' PROJ context in PJ_OBJ objectsEven Rouault
We store the PJ_CONTEXT* in the PJ_OBJ objects, but this might cause issues in multi-threaded uses. For example, before this change, let's imagie: - a PJ_OBJ is created in thread A with a PJ_CONTEXT that is specific to this thread A - PJ_OBJ is transfered to another thread that operates on it. It might thus use the PJ_CONTEXT that was TLS(A) - in the meantime thread A does completely different things, but still operate on its PJ_CONTEXT. We might get a concurrent use of the PJ_CONTEXT despite working on different PJ_OBJ Another situation is when using constructor functions that take two PJ_OBJ. Up to now, we arbitrarily selected the context of one of the arguments to attach it to the new object. So better be explicit on which context is used. For reference, in those wrappers of the C++ API, the context is mostly used for two things: - reporting C++ exceptions as PROJ errors with the error handler attached to the PJ_CONTEXT - using the database handle that is associated with the PJ_CONTEXT.
2018-11-29proj_create_crs_to_crs(): rename arguments, update doc, and add a few test casesEven Rouault
2018-11-29Redirect epsg:XXXX and IGNF:XXXX CRS expansions to the database, and remove ↵Even Rouault
the data/epsg and data/IGNF files
2018-11-29cs2cs: upgrade to use proj_create_crs_to_crs()Even Rouault
2018-11-22Make proj_create_crs_to_crs() use proj_obj_create_operations() and use area ↵Even Rouault
of use argument, and make createFromUserInput() recognize init=epsg: / init=IGNF: in legacy mode, that is when proj_context_get_use_proj4_init_rules() is used
2018-11-10Remove proj_geocentric_latitude from public APIKristian Evers
Closes #1107
2018-09-27cs2cs_emulation_setup: fix issue with non C-localeEven Rouault
in +towgs84 case, we use sprintf() with floating-point formatter to output the ellipsoid parameters. For a locale with decimal separtor != dot, the resulting string will not be parsed correctly by proj_atof(), leading to wrong numeric result. The fix is similar to the one done in pj_latlong_from_proj() Note for later: if using C++, we could use a locale-independent formatting solution to avoid such issue.
2018-08-24proj_4D_api.c: fix potential null pointer dereference. Fixes ↵Even Rouault
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=10033. Credit to OSS Fuzz. master only
2018-08-21[BREAKING] Hermert: add +convention=position_vector/coordinate_frame, ↵Even Rouault
forbids +transpose (fixes #1091) As identified in #1091, Helmert implementation in PROJ 5.0 and 5.1 is confusing. It happens that by default it used the coordinate_frame convention, contrary to the position_vector convention used traditionaly for +towgs84. The documentation of Helmert was also wrongly specifying that the default convention was position_vector. This commit: - bans the confusing +transpose parameter - removes the concept of a default convention, since in practice both are equally found, and requires +convention as soon as a rotational term parameter is present. For translation only, convention is ignored and optional, as having no effect. - fixes all the identified uses of proj=helmert in code, doc and tests This is obviously a breaking change: - users will have to adapt their pipeline expressions - in particular, init files that would use helmert must be adapted However, as designed, the break will be explicit, and not silent.
2018-06-18Set error codes in proj_create and proj_create_argvAaron Puchert
When there are no arguments, we set PJD_ERR_NO_ARGS, just like the old API does in that case. On allocation failure we set ENOMEM as usual.
2018-06-01Do not pivot over WGS84 when doing cs2cs-emulation with geocentKristian Evers
2018-05-30Replace suspicious use of strncat(), despite correct in that particular case ↵Even Rouault
(detected by gcc 8.1)
2018-05-15IWYU: Partial PJ_natearth.c..rtodms.cKurt Schwehr
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-04-07Pipeline: make sure geocentric/cartesian space transform is done with ↵Even Rouault
original ellipsoid parameters (before any projection mess with them)
2018-03-21Take into account +towgs84=0,0,0 in pipeline to still imply ↵Even Rouault
geodetic->cartesian->geodetic (fixes #881)
2018-03-20Add 'exact' flag to Helmert operation when doing cs2cs emulation. Fixes ↵Kristian Evers
#871. (#873)
2018-03-14Add comment to justify 718495c62ed00d6bf2a60be3b67ecf7e2e8da2d2Even Rouault
2018-03-12Fix 'bufferAccessOutOfBounds,Buffer is accessed out of bounds' cppcheck warningsEven Rouault
2018-03-11Merge pull request #852 from kbevers/remove-pj_-prefix-from-static-functionsKristian Evers
Remove 'pj_' prefix from static functions
2018-03-11Various typo fixesEven Rouault
2018-03-11Remove 'pj_' prefix from static functionsKristian Evers
Functions should only be prefixed with 'pj_' when they can be used in other parts of the code base and not just within a single file. Takes care of the last step in #675.
2018-03-11Remove angle brackets for proj headers (#849)Thomas Knudsen
* Avoid using angle brackets for PROJ headers. Switching from #include <proj.h> to #include "proj.h", and correspondingly for projects.h and proj_api.h, reduces the risk of accidentally picking up a system installed older version of the header while building a new version of PROJ. * Also handle geodesic.h
2018-03-08Use consistent names for PJ_COORD's in declarationsKristian Evers
Changes use of 'PJ_COORD coo' to 'PJ_COORD coord' so that variable names in public function prototypes are consistent. Closes #842.
2018-02-19proj_errno_reset: Also reset pj_errnoRaul Marin
2018-02-12Ensure cs2cs emulation gets correct ellipsoid defn (#798)Thomas Knudsen
Copy ellipsoid definition for proj=cart directly into the proj_create call, rather than calling pj_inherit_ellipsoid_def afterwards. Previously, the ellipsoid definition was left out from the call. pj_init_ctx would then pick up WGS84 from proj_def.dat, and the init would succeed (and the possibly wrong ellipsoid definition would later on be overwritten with the correct values by pj_inherit_ellipsoid_def. But if PROJ_LIB was not set or proj_def.dat was inaccessible for other reasons, things went wrong.
2018-02-11Add proj_context_errno to API and missing proj_geod to proj.def (#791)Thomas Knudsen
2018-02-10Make the 4D API fully 4D (#788)Thomas Knudsen
Make 4D API fully 4D: Remove PJ_XY, PJ_LP, PJ_XYZ, PJ_LPZ etc. from the API surface and make all formal parameters of the API fully 4D PJ_COORD. This operation primarily influences the proj_XXX_dist functions, which mostly work by calling Charles Karney's geodesic subsystem, keeping the distance, and throwing away the start and end azimuths for the geodesic computed. Also a PJ_GEOD(esic) persona is introduced for the PJ_COORD type. The proj_geod function returns a PJ_GEOD, representing the geodesic between the points represented by its PJ_COORD arguments. Finally, the proj_factors functions had its lp argument changed from PJ_LP to PJ_COORD.
2018-02-10Fix numerous bugs in the cs2cs emulationThomas Knudsen
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-02Avoid buffer overflow - OSSFuzz issue 5903Thomas Knudsen
2018-02-01expand proj_geoc_lat to proj_geocentric_latitude (#751)Thomas Knudsen
2018-02-01make local derivatives available in PJ_FACTORThomas Knudsen
2018-01-31Renamed PJ_IO_UNITS_RADIANS to PJ_IO_UNITS_ANGULARThomas Knudsen
2018-01-31proj_roundtrip: simplify control logicThomas 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-31Add pj_has_inverse().Kristian Evers
With the introduction of the "inverted" flag on PJ objects you can no longer rely on checking that the inv, inv3d and inv4d functions are available on said PJ object. The function is used internally a few places and otherwise exposed in proj_api.h to ensure that users of the old programming interface can safely check if an operation has an inverse.
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-28Free formatting of PROJ key=value pairsThomas Knudsen
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-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-16Introduce geodetic-geocentric conversions ... (#669)Thomas Knudsen
* Introduce geodetic-geocentric conversions, as PJ_xxx style conversion step and as API entry points * minor improvements and minor bug squashing
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-12Poder autochecking again (WIP) (#652)Thomas Knudsen
* Poder dual autochecking implementation * Debugging aid: Improvements in PJ_vgridshift.c and gie.c * Most likely, the bugbeing tripped is in the gridshift code, so. uncomment suspicious lines in deformation.gie and merge this to support the debugging effort
2017-11-10Do not require needless plusses (#651)Thomas Knudsen
proj_create is now indifferent whether or not proj definition terms start with a '+' character. Also, improve gie to support testing this.
2017-11-08minor clean ups in and around proj_4D_api (#649)Thomas Knudsen