aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/4D_api.cpp2
-rw-r--r--src/filemanager.cpp12
-rw-r--r--src/grids.cpp44
-rw-r--r--src/proj_internal.h2
4 files changed, 35 insertions, 25 deletions
diff --git a/src/4D_api.cpp b/src/4D_api.cpp
index 71393dab..dabd44a0 100644
--- a/src/4D_api.cpp
+++ b/src/4D_api.cpp
@@ -1487,7 +1487,7 @@ PJ_INFO proj_info (void) {
// Env var mostly for testing purposes and being independent from
// an existing installation
const char* ignoreUserWritableDirectory =
- getenv("PROJ_IGNORE_USER_WRITABLE_DIRECTORY");
+ getenv("PROJ_SKIP_READ_USER_WRITABLE_DIRECTORY");
if( ignoreUserWritableDirectory == nullptr ||
ignoreUserWritableDirectory[0] == '\0' ) {
buf = path_append(buf,
diff --git a/src/filemanager.cpp b/src/filemanager.cpp
index 592bada4..005e734b 100644
--- a/src/filemanager.cpp
+++ b/src/filemanager.cpp
@@ -1156,7 +1156,7 @@ std::string pj_context_get_user_writable_directory(PJ_CONTEXT *ctx,
const char *home = getenv("HOME");
if (home) {
#if defined(__MACH__) && defined(__APPLE__)
- path = std::string(home) + "/Library/Logs";
+ path = std::string(home) + "/Library/Application Support";
#else
path = std::string(home) + "/.local/share";
#endif
@@ -1258,13 +1258,11 @@ static const char *proj_lib_name =
nullptr;
#endif
-static bool ignoreUserWritableDirectory() {
+static bool dontReadUserWritableDirectory() {
// Env var mostly for testing purposes and being independent from
// an existing installation
- const char *envVarIgnoreUserWritableDirectory =
- getenv("PROJ_IGNORE_USER_WRITABLE_DIRECTORY");
- return envVarIgnoreUserWritableDirectory != nullptr &&
- envVarIgnoreUserWritableDirectory[0] != '\0';
+ const char *envVar = getenv("PROJ_SKIP_READ_USER_WRITABLE_DIRECTORY");
+ return envVar != nullptr && envVar[0] != '\0';
}
static void *
@@ -1336,7 +1334,7 @@ pj_open_lib_internal(projCtx ctx, const char *name, const char *mode,
}
}
- else if (!ignoreUserWritableDirectory() &&
+ else if (!dontReadUserWritableDirectory() &&
(fid = open_file(
ctx, (pj_context_get_user_writable_directory(ctx, false) +
DIR_CHAR + name)
diff --git a/src/grids.cpp b/src/grids.cpp
index 24fcfe83..68bf8600 100644
--- a/src/grids.cpp
+++ b/src/grids.cpp
@@ -1837,17 +1837,20 @@ std::unique_ptr<NTv2GridSet> NTv2GridSet::open(PJ_CONTEXT *ctx,
pj_ctx_set_errno(ctx, PJD_ERR_FAILED_TO_LOAD_GRID);
return nullptr;
}
- if (memcmp(header + 56, "SECONDS", 7) != 0) {
+
+ constexpr int OFFSET_GS_TYPE = 56;
+ if (memcmp(header + OFFSET_GS_TYPE, "SECONDS", 7) != 0) {
pj_log(ctx, PJ_LOG_ERROR, "Only GS_TYPE=SECONDS is supported");
pj_ctx_set_errno(ctx, PJD_ERR_FAILED_TO_LOAD_GRID);
return nullptr;
}
const bool must_swap = (header[8] == 11) ? !IS_LSB : IS_LSB;
+ constexpr int OFFSET_NUM_SUBFILES = 8 + 32;
if (must_swap) {
// swap_words( header+8, 4, 1 );
// swap_words( header+8+16, 4, 1 );
- swap_words(header + 8 + 32, 4, 1);
+ swap_words(header + OFFSET_NUM_SUBFILES, 4, 1);
// swap_words( header+8+7*16, 8, 1 );
// swap_words( header+8+8*16, 8, 1 );
// swap_words( header+8+9*16, 8, 1 );
@@ -1858,7 +1861,7 @@ std::unique_ptr<NTv2GridSet> NTv2GridSet::open(PJ_CONTEXT *ctx,
/* Get the subfile count out ... all we really use for now. */
/* -------------------------------------------------------------------- */
unsigned int num_subfiles;
- memcpy(&num_subfiles, header + 8 + 32, 4);
+ memcpy(&num_subfiles, header + OFFSET_NUM_SUBFILES, 4);
std::map<std::string, NTv2Grid *> mapGrids;
@@ -1878,25 +1881,31 @@ std::unique_ptr<NTv2GridSet> NTv2GridSet::open(PJ_CONTEXT *ctx,
}
// Byte swap interesting fields if needed.
+ constexpr int OFFSET_GS_COUNT = 8 + 16 * 10;
+ constexpr int OFFSET_SOUTH_LAT = 8 + 16 * 4;
if (must_swap) {
- swap_words(header + 8 + 16 * 4, sizeof(double), 6);
- swap_words(header + 8 + 16 * 10, sizeof(int), 1);
+ // 6 double values: southLat, northLat, eastLon, westLon, resLat,
+ // resLon
+ swap_words(header + OFFSET_SOUTH_LAT, sizeof(double), 6);
+ swap_words(header + OFFSET_GS_COUNT, sizeof(int), 1);
}
std::string gridName;
gridName.append(header + 8, 8);
ExtentAndRes extent;
- extent.westLon =
- -to_double(header + 7 * 16 + 8) * DEG_TO_RAD / 3600.0; /* W_LONG */
- extent.southLat =
- to_double(header + 4 * 16 + 8) * DEG_TO_RAD / 3600.0; /* S_LAT */
- extent.eastLon =
- -to_double(header + 6 * 16 + 8) * DEG_TO_RAD / 3600.0; /* E_LONG */
- extent.northLat =
- to_double(header + 5 * 16 + 8) * DEG_TO_RAD / 3600.0; /* N_LAT */
- extent.resLon = to_double(header + 9 * 16 + 8) * DEG_TO_RAD / 3600.0;
- extent.resLat = to_double(header + 8 * 16 + 8) * DEG_TO_RAD / 3600.0;
+ extent.southLat = to_double(header + OFFSET_SOUTH_LAT) * DEG_TO_RAD /
+ 3600.0; /* S_LAT */
+ extent.northLat = to_double(header + OFFSET_SOUTH_LAT + 16) *
+ DEG_TO_RAD / 3600.0; /* N_LAT */
+ extent.eastLon = -to_double(header + OFFSET_SOUTH_LAT + 16 * 2) *
+ DEG_TO_RAD / 3600.0; /* E_LONG */
+ extent.westLon = -to_double(header + OFFSET_SOUTH_LAT + 16 * 3) *
+ DEG_TO_RAD / 3600.0; /* W_LONG */
+ extent.resLat =
+ to_double(header + OFFSET_SOUTH_LAT + 16 * 4) * DEG_TO_RAD / 3600.0;
+ extent.resLon =
+ to_double(header + OFFSET_SOUTH_LAT + 16 * 5) * DEG_TO_RAD / 3600.0;
if (!(fabs(extent.westLon) <= 4 * M_PI &&
fabs(extent.eastLon) <= 4 * M_PI &&
@@ -1923,7 +1932,7 @@ std::unique_ptr<NTv2GridSet> NTv2GridSet::open(PJ_CONTEXT *ctx,
extent.northLat * RAD_TO_DEG);
unsigned int gs_count;
- memcpy(&gs_count, header + 8 + 16 * 10, 4);
+ memcpy(&gs_count, header + OFFSET_GS_COUNT, 4);
if (gs_count / columns != static_cast<unsigned>(rows)) {
pj_log(ctx, PJ_LOG_ERROR,
"GS_COUNT(%u) does not match expected cells (%dx%d)",
@@ -2845,6 +2854,7 @@ ListOfHGrids pj_hgrid_init(PJ *P, const char *gridkey) {
typedef struct { pj_int32 lam, phi; } ILP;
+// Apply bilinear interpolation for horizontal shift grids
static PJ_LP pj_hgrid_interpolate(PJ_LP t, const HorizontalShiftGrid *grid,
bool compensateNTConvention) {
PJ_LP val, frct;
@@ -3283,6 +3293,8 @@ const GenericShiftGrid *pj_find_generic_grid(const ListOfGenericGrids &grids,
// ---------------------------------------------------------------------------
+// Used by +proj=deformation and +proj=xyzgridshift to do bilinear interpolation
+// on 3 sample values per node.
bool pj_bilinear_interpolation_three_samples(const GenericShiftGrid *grid,
const PJ_LP &lp, int idx1,
int idx2, int idx3, double &v1,
diff --git a/src/proj_internal.h b/src/proj_internal.h
index bb0e3453..a587c037 100644
--- a/src/proj_internal.h
+++ b/src/proj_internal.h
@@ -682,7 +682,7 @@ struct projGridChunkCache
{
bool enabled = true;
std::string filename{};
- long long max_size = 100 * 1024 * 1024;
+ long long max_size = 300 * 1024 * 1024;
int ttl = 86400; // 1 day
};