Skip to content

Commit

Permalink
Improve proj logic in finding its db
Browse files Browse the repository at this point in the history
  • Loading branch information
JVital2013 committed Jul 16, 2023
1 parent 73e4c99 commit cc9b898
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
Expand Down
18 changes: 18 additions & 0 deletions src/goesproc/goesproc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
#include <windows.h>
#include <io.h>

#ifdef HAS_PROJ
#include <proj.h>
#endif

#include <util/fs.h>

#include "lib/file_reader.h"
Expand Down Expand Up @@ -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<std::unique_ptr<Handler> > handlers;
Expand Down

0 comments on commit cc9b898

Please sign in to comment.