diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2020-01-27 20:38:40 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2020-01-27 20:38:40 +0100 |
| commit | 15814256e2fbbc2702422fd3d09d3a0f6be60006 (patch) | |
| tree | 93b2016db24e875ccebb43abcd2de43a41d1f698 /src | |
| parent | ea6245ea32f0b0ee414c22951b1f5dc4048782de (diff) | |
| download | PROJ-15814256e2fbbc2702422fd3d09d3a0f6be60006.tar.gz PROJ-15814256e2fbbc2702422fd3d09d3a0f6be60006.zip | |
projinfo: add --remote-data switch
Diffstat (limited to 'src')
| -rw-r--r-- | src/apps/projinfo.cpp | 23 | ||||
| -rw-r--r-- | src/filemanager.cpp | 3 | ||||
| -rw-r--r-- | src/proj_internal.h | 3 |
3 files changed, 25 insertions, 4 deletions
diff --git a/src/apps/projinfo.cpp b/src/apps/projinfo.cpp index 360aafc4..9cd9b2ee 100644 --- a/src/apps/projinfo.cpp +++ b/src/apps/projinfo.cpp @@ -98,9 +98,9 @@ static void usage() { << std::endl << " [--identify] [--3d]" << std::endl << " [--c-ify] [--single-line]" << std::endl - << " --searchpaths | {object_definition} | (-s " - "{srs_def} -t {srs_def})" - << std::endl; + << " --searchpaths | --remote-data | " + "{object_definition} |" + << " (-s {srs_def} -t {srs_def})" << std::endl; std::cerr << std::endl; std::cerr << "-o: formats is a comma separated combination of: " "all,default,PROJ,WKT_ALL,WKT2:2015,WKT2:2019,WKT1:GDAL," @@ -1069,6 +1069,23 @@ int main(int argc, char **argv) { std::cout << path << std::endl; } std::exit(0); + } else if (ci_equal(arg, "--remote-data")) { +#ifdef CURL_ENABLED + if (pj_context_is_network_enabled(nullptr)) { + std::cout << "Status: enabled" << std::endl; + std::cout << "URL: " << pj_context_get_url_endpoint(nullptr) + << std::endl; + } else { + std::cout << "Status: disabled" << std::endl; + std::cout << "Reason: not enabled in proj.ini or " + "PROJ_NETWORK=ON not specified" + << std::endl; + } +#else + std::cout << "Status: disabled" << std::endl; + std::cout << "Reason: build without Curl support" << std::endl; +#endif + std::exit(0); } else if (arg == "-?" || arg == "--help") { usage(); } else if (arg[0] == '-') { diff --git a/src/filemanager.cpp b/src/filemanager.cpp index b38aeb5a..9263e9fe 100644 --- a/src/filemanager.cpp +++ b/src/filemanager.cpp @@ -1595,6 +1595,9 @@ int pj_find_file(projCtx ctx, const char *short_filename, /************************************************************************/ std::string pj_context_get_url_endpoint(PJ_CONTEXT *ctx) { + if (ctx == nullptr) { + ctx = pj_get_default_ctx(); + } if (!ctx->endpoint.empty()) { return ctx->endpoint; } diff --git a/src/proj_internal.h b/src/proj_internal.h index a587c037..69d583fc 100644 --- a/src/proj_internal.h +++ b/src/proj_internal.h @@ -863,7 +863,8 @@ PJ *pj_create_argv_internal (PJ_CONTEXT *ctx, int argc, char **argv); // For use by projinfo bool PROJ_DLL pj_context_is_network_enabled(PJ_CONTEXT* ctx); -std::string pj_context_get_url_endpoint(PJ_CONTEXT* ctx); +// For use by projinfo +std::string PROJ_DLL pj_context_get_url_endpoint(PJ_CONTEXT* ctx); void pj_load_ini(PJ_CONTEXT* ctx); |
