Skip to content

Commit dadc2ad

Browse files
authored
Merge pull request #2006 from GenericMappingTools/a-fix-for-proj.db
Call OSRSetPROJSearchPaths to prevent proj.db to be foundable via PROJ_LIB env var
2 parents d8c8180 + 3c3f4f8 commit dadc2ad

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/gdal/gdal.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,7 @@ OSRImportFromWkt(a1, a2) = acare(ccall((:OSRImportFromWkt, libgdal), Cint, (pVoi
433433
OSRImportFromProj4(a1, a2) = acare(ccall((:OSRImportFromProj4, libgdal), Cint, (pVoid, Cstring), a1, a2))
434434
OSRImportFromEPSG(a1, a2) = acare(ccall((:OSRImportFromEPSG, libgdal), Cint, (pVoid, Cint), a1, a2))
435435
OSRNewSpatialReference(a1) = acare(ccall((:OSRNewSpatialReference, libgdal), pVoid, (Cstring,), a1))
436+
OSRSetPROJSearchPaths(a1) = acare(ccall((:OSRSetPROJSearchPaths, libgdal), Cvoid, (Ptr{Cstring},), a1))
436437

437438
function OSRSetAxisMappingStrategy(hSRS, strategy)
438439
#(Gdal.GDALVERSION[] < v"3.0.0") && return # This breakes precompile if called from one PrecompileTools call
@@ -2680,6 +2681,14 @@ end
26802681
CPLSetConfigOption("GDAL_HTTP_UNSAFESSL", "YES")
26812682
isdir(GDAL_DATA_DIR) && CPLSetConfigOption("GDAL_DATA", GDAL_DATA_DIR)
26822683
#CPLSetConfigOption("GDAL_NUM_THREADS", "ALL_CPUS")
2684+
2685+
# set PROJ_LIB location, this overrides setting the environment variable
2686+
if (isJLL)
2687+
PROJ_LIB = Ref{String}(joinpath(GMT.PROJ_jll.artifact_dir, "share", "proj"))
2688+
OSRSetPROJSearchPaths([PROJ_LIB[]])
2689+
#else
2690+
#PROJ_LIB = Ref{String}(dirname(GMT.libproj) * "/../share/proj") # Fails for me because GMTdir is symlink of bin only
2691+
end
26832692
end
26842693

26852694
"""

0 commit comments

Comments
 (0)