33#include < proj.h>
44#include " Log.h"
55#include " Point.h"
6+ #include " Settings.h"
67#include " unstable.h"
78#include " Util.h"
89namespace fs
910{
11+ PJ_CONTEXT* get_context ()
12+ {
13+ auto pjc = proj_context_create ();
14+ string db_path = Settings::getRoot () + " proj.db" ;
15+ logging::debug (" Trying to set db path to %s" , db_path.c_str ());
16+ if (!proj_context_set_database_path (pjc, db_path.c_str (), NULL , NULL ))
17+ {
18+ logging::fatal (" Can't set proj.db path" );
19+ }
20+ logging::verbose (" Succeeded trying to set db path to %s" , db_path.c_str ());
21+ return pjc;
22+ }
1023class Point ;
1124PJ* normalized_context (PJ_CONTEXT* C, const string_view proj4_from, const string_view proj4_to)
1225{
@@ -25,7 +38,7 @@ void from_lat_long(const string_view proj4, const fs::Point& point, MathSize* x,
2538{
2639 // see https://proj.org/en/stable/development/quickstart.html
2740 // do this in a function so we can hide and clean up intial context
28- PJ_CONTEXT* C = proj_context_create ();
41+ PJ_CONTEXT* C = get_context ();
2942 auto P = normalized_context (C, " EPSG:4326" , proj4);
3043 // Given that we have used proj_normalize_for_visualization(), the order
3144 // of coordinates is longitude, latitude, and values are expressed in
@@ -56,7 +69,7 @@ fs::Point to_lat_long(const string_view proj4, const MathSize x, const MathSize
5669{
5770 // see https://proj.org/en/stable/development/quickstart.html
5871 // do this in a function so we can hide and clean up intial context
59- PJ_CONTEXT* C = proj_context_create ();
72+ PJ_CONTEXT* C = get_context ();
6073 auto P = normalized_context (C, proj4, " EPSG:4326" );
6174 // Given that we have used proj_normalize_for_visualization(), the order
6275 // of coordinates is longitude, latitude, and values are expressed in
0 commit comments