diff --git a/Build.ps1 b/Build.ps1 index ef8916a8..7d8e922e 100644 --- a/Build.ps1 +++ b/Build.ps1 @@ -56,7 +56,7 @@ foreach($arch in $("win32", "x64")) cp -Force ..\build-$arch\src\lrit\Release\*.dll bin/ cp ..\..\README.md . - cp $vcpkg\installed\x64-windows\share\proj\proj.db . + cp $vcpkg\installed\x64-windows\share\proj\proj.db bin/ cp -r ..\..\share . cp -r ..\..\LICENSES . cp -r ..\..\config . diff --git a/src/goesproc/goesproc.cc b/src/goesproc/goesproc.cc index 5848ac96..bf3de7eb 100644 --- a/src/goesproc/goesproc.cc +++ b/src/goesproc/goesproc.cc @@ -8,6 +8,10 @@ #include #include +#ifdef HAS_PROJ +#include +#endif + #include #include "lib/file_reader.h" @@ -49,6 +53,20 @@ int main(int argc, char** argv) { if (opts.force) { fileWriter->setForce(true); } + +#ifdef HAS_PROJ + //Force proj to look in the same directory as the exe for proj.db and cwd + char file_path[MAX_PATH], cwd[MAX_PATH]; + GetModuleFileName(NULL, file_path, MAX_PATH); + std::string exe_path(file_path); + exe_path = exe_path.substr(0, exe_path.find_last_of("/\\")); + GetCurrentDirectory(MAX_PATH, cwd); + + const char *proj_paths[2]; + proj_paths[0] = exe_path.c_str(); + proj_paths[1] = cwd; + proj_context_set_search_paths(NULL, 2, proj_paths); +#endif // Construct list of file handlers std::vector > handlers;