Skip to content

Commit

Permalink
Merge pull request #1826 from rouault/rfc4_code_review
Browse files Browse the repository at this point in the history
[RFC4_dev] Address code review comments
  • Loading branch information
rouault authored Jan 20, 2020
2 parents f1209ff + 90b6685 commit a6390b5
Show file tree
Hide file tree
Showing 35 changed files with 1,974 additions and 945 deletions.
12 changes: 8 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,15 @@ ENDIF()
# Check for libtiff
################################################################################

option(DISABLE_TIFF_IS_STRONGLY_DISCOURAGED "Disable TIFF support (strongly discouraged !)" OFF)
mark_as_advanced(DISABLE_TIFF_IS_STRONGLY_DISCOURAGED)
if(NOT DISABLE_TIFF_IS_STRONGLY_DISCOURAGED)
option(DISABLE_TIFF "Disable TIFF support" OFF)
mark_as_advanced(DISABLE_TIFF)
if(DISABLE_TIFF)
message(WARNING "TIFF support has been disabled and will result in the inability to read some grids")
else()
find_package(TIFF REQUIRED)
if(NOT TIFF_FOUND)
if(TIFF_FOUND)
boost_report_value(TIFF_FOUND)
else()
message(SEND_ERROR "libtiff dependency not found!")
endif()
add_definitions(-DTIFF_ENABLED)
Expand Down
8 changes: 4 additions & 4 deletions cmake/ProjTest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ function(proj_add_test_script_sh SH_NAME BIN_USE)
)
if(MSVC)
set_tests_properties( ${testname}
PROPERTIES ENVIRONMENT "PROJ_LIB=${PROJECT_BINARY_DIR}/data\\;${PROJECT_SOURCE_DIR}/data")
PROPERTIES ENVIRONMENT "PROJ_IGNORE_USER_WRITABLE_DIRECTORY=YES;PROJ_LIB=${PROJECT_BINARY_DIR}/data\\;${PROJECT_SOURCE_DIR}/data")
else()
set_tests_properties( ${testname}
PROPERTIES ENVIRONMENT "PROJ_LIB=${PROJECT_BINARY_DIR}/data:${PROJECT_SOURCE_DIR}/data")
PROPERTIES ENVIRONMENT "PROJ_IGNORE_USER_WRITABLE_DIRECTORY=YES;PROJ_LIB=${PROJECT_BINARY_DIR}/data:${PROJECT_SOURCE_DIR}/data")
endif()
endif()

Expand All @@ -51,10 +51,10 @@ function(proj_add_gie_test TESTNAME TESTCASE)

if(MSVC)
set_tests_properties( ${TESTNAME}
PROPERTIES ENVIRONMENT "PROJ_LIB=${PROJECT_BINARY_DIR}/data\\;${PROJECT_SOURCE_DIR}/data")
PROPERTIES ENVIRONMENT "PROJ_IGNORE_USER_WRITABLE_DIRECTORY=YES;PROJ_LIB=${PROJECT_BINARY_DIR}/data\\;${PROJECT_SOURCE_DIR}/data")
else()
set_tests_properties( ${TESTNAME}
PROPERTIES ENVIRONMENT "PROJ_LIB=${PROJECT_BINARY_DIR}/data:${PROJECT_SOURCE_DIR}/data")
PROPERTIES ENVIRONMENT "PROJ_IGNORE_USER_WRITABLE_DIRECTORY=YES;PROJ_LIB=${PROJECT_BINARY_DIR}/data:${PROJECT_SOURCE_DIR}/data")
endif()


Expand Down
2 changes: 1 addition & 1 deletion docs/source/operations/transformations/deformation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Parameters

.. option:: +xy_grids=<list>

Comma-separated list of grids to load. If a grid is prefixed by an `@` the
Comma-separated list of grids to load. If a grid is prefixed by an ``@`` the
grid is considered optional and PROJ will the not complain if the grid is
not available.

Expand Down
8 changes: 4 additions & 4 deletions docs/source/operations/transformations/xyzgridshift.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ translation values from a grid. The grid is referenced against either the
2D geographic CRS corresponding to the input (or sometimes output) CRS.

This method is described (in French) in :cite:`NTF_88`
and as EPSG operation methode code 9655 in :cite:`IOGP2018` (§2.4.4.1.1
and as EPSG operation method code 9655 in :cite:`IOGP2018` (§2.4.4.1.1
France geocentric interpolation).

The translation in the grids are added to the input coordinates in the forward direction,
and subtracted in the reverse direction.
By default (if grid_ref=input_crs), in the forward direction, the input coordinates
By default (if ``grid_ref=input_crs``), in the forward direction, the input coordinates
are converted to their geographic equivalent to directly read and interpolate from
the grid. In the reverse direction, an iterative method is used to be able to find
the grid locations to read.
If grid_ref=output_crs is used, then the reverse strategy is applied: iterative
If ``grid_ref=output_crs`` is used, then the reverse strategy is applied: iterative
method in the forward direction, and direct read in the reverse direction.

Example
Expand Down Expand Up @@ -62,7 +62,7 @@ Required

.. option:: +grids=<list>

Comma-separated list of grids to load. If a grid is prefixed by an `@` the
Comma-separated list of grids to load. If a grid is prefixed by an ``@`` the
grid is considered optional and PROJ will the not complain if the grid is
not available.

Expand Down
2 changes: 1 addition & 1 deletion docs/source/references.bib
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ @InProceedings{LambersKolb2012
}

@TechReport{NTF_88,
Title = {Grille de parametres de transformation de coordonnees - GR3DF97A - Notice d'utilisation},
Title = {Grille de parametres de transformation de coordonnees - {GR3DF97A} - Notice d'utilisation},
Author = {IGN},
Institution = {Service de Geodesie et Nivellement, Institut Geographique National},
Year = {1997},
Expand Down
19 changes: 19 additions & 0 deletions docs/source/resource_files.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,34 @@ The following paths are checked in order:

- For transformation grids that have an explict relative or absolute path,
the directory specified in the grid filename.

- Path resolved by the callback function set with
the :c:func:`proj_context_set_file_finder`. If it is set, the next tests
will not be run.

- Path(s) set with the :c:func:`proj_context_set_search_paths`. If set, the
next tests will not be run.

- The PROJ user writable directory, which is :

* on Windows, ${LOCALAPPDATA}/proj
* on MacOSX, ${HOME}/Library/Logs/proj
* on other platforms (Linux), ${XDG_DATA_HOME}/proj if :envvar:`XDG_DATA_HOME`
is defined. Else ${HOME}/.local/share/proj

- Path(s) set with by the environment variable :envvar:`PROJ_LIB`.
On Linux/MacOSX/Unix, use ``:`` to separate paths. On Windows, ``;``

- On Windows, the *..\\share\\proj\\* and its contents are found automatically
at run-time if the installation respects the build structure. That is, the
binaries and proj.dll are installed under *..\\bin\\*, and resource files
are in *..\\share\\proj\\*.

- A path built into PROJ as its resource installation directory (whose value is
$(pkgdatadir)), for builds using the Makefile build system. Note, however,
that since this is a hard-wired path setting, it only works if the whole
PROJ installation is not moved somewhere else.

- The current directory

When networking capabilities are enabled, either by API with the
Expand Down Expand Up @@ -77,6 +90,12 @@ Its default content is:
; Can be overriden with the PROJ_NETWORK_ENDPOINT environment variable.
cdn_endpoint = https://cdn.proj.org

cache_enabled = on

cache_size_MB = 100

cache_ttl_sec = 86400


Transformation grids
-------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion docs/source/usage/environmentvars.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@ done by setting the variable with no content::
.. versionadded:: 7.0.0

Define the endpoint of the CDN storage. Normally defined through the proj.ini
configuration file locale in PROJ_LIB.
configuration file locale in :envvar:`PROJ_LIB`.
Alternatively, the :c:func:`proj_context_set_url_endpoint` function can
be used.
3 changes: 3 additions & 0 deletions scripts/reference_exported_symbols.txt
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,7 @@ pj_cleanup_lock
pj_clear_initcache
pj_compare_datums
pj_context_get_grid_cache_filename(projCtx_t*)
pj_context_get_user_writable_directory(projCtx_t*, bool)
pj_context_is_network_enabled(projCtx_t*)
pj_ctx_alloc
pj_ctx_fclose
Expand Down Expand Up @@ -930,6 +931,7 @@ proj_cs_get_axis_info
proj_cs_get_type
proj_destroy
proj_dmstor
proj_download_file
proj_ellipsoid_get_parameters
proj_errno
proj_errno_reset
Expand Down Expand Up @@ -969,6 +971,7 @@ proj_int_list_destroy
proj_is_crs
proj_is_deprecated
proj_is_derived_crs
proj_is_download_needed
proj_is_equivalent_to
proj_list_angular_units
proj_list_destroy
Expand Down
11 changes: 11 additions & 0 deletions src/4D_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include <math.h>
#include "geodesic.h"
#include "grids.hpp"
#include "filemanager.hpp"

#include "proj/common.hpp"
#include "proj/coordinateoperation.hpp"
Expand Down Expand Up @@ -1450,6 +1451,16 @@ PJ_INFO proj_info (void) {
/* build search path string */
auto ctx = pj_get_default_ctx();
if (!ctx || ctx->search_paths.empty()) {
// Env var mostly for testing purposes and being independent from
// an existing installation
const char* ignoreUserWritableDirectory =
getenv("PROJ_IGNORE_USER_WRITABLE_DIRECTORY");
if( ignoreUserWritableDirectory == nullptr ||
ignoreUserWritableDirectory[0] == '\0' ) {
buf = path_append(buf,
pj_context_get_user_writable_directory(ctx, false).c_str(),
&buf_size);
}
const char *envPROJ_LIB = getenv("PROJ_LIB");
buf = path_append(buf, envPROJ_LIB, &buf_size);
#ifdef PROJ_LIB
Expand Down
4 changes: 2 additions & 2 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ libproj_la_SOURCES = \
release.cpp gauss.cpp \
fileapi.cpp \
\
apply_gridshift.cpp datums.cpp datum_set.cpp transform.cpp \
datums.cpp datum_set.cpp transform.cpp \
geocent.cpp geocent.h utils.cpp \
jniproj.cpp mutex.cpp initcache.cpp apply_vgridshift.cpp geodesic.c \
jniproj.cpp mutex.cpp initcache.cpp geodesic.c \
strtod.cpp \
\
4D_api.cpp pipeline.cpp \
Expand Down
Loading

0 comments on commit a6390b5

Please sign in to comment.