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 | |
| parent | ea6245ea32f0b0ee414c22951b1f5dc4048782de (diff) | |
| download | PROJ-15814256e2fbbc2702422fd3d09d3a0f6be60006.tar.gz PROJ-15814256e2fbbc2702422fd3d09d3a0f6be60006.zip | |
projinfo: add --remote-data switch
| -rw-r--r-- | docs/source/apps/projinfo.rst | 10 | ||||
| -rw-r--r-- | scripts/reference_exported_symbols.txt | 1 | ||||
| -rw-r--r-- | src/apps/projinfo.cpp | 23 | ||||
| -rw-r--r-- | src/filemanager.cpp | 3 | ||||
| -rw-r--r-- | src/proj_internal.h | 3 | ||||
| -rwxr-xr-x | test/cli/testprojinfo | 18 |
6 files changed, 53 insertions, 5 deletions
diff --git a/docs/source/apps/projinfo.rst b/docs/source/apps/projinfo.rst index f0a2ae08..0b65b8a0 100644 --- a/docs/source/apps/projinfo.rst +++ b/docs/source/apps/projinfo.rst @@ -26,7 +26,8 @@ Synopsis | [--main-db-path path] [--aux-db-path path]* | [--identify] [--3d] | [--c-ify] [--single-line] - | --searchpaths | {object_definition} | {object_reference} | (-s {srs_def} -t {srs_def}) + | --searchpaths | --remote-data | {object_definition} | + | {object_reference} | (-s {srs_def} -t {srs_def}) | where {object_definition} or {srs_def} is @@ -256,6 +257,13 @@ The following control parameters can appear in any order: (if not using C API such as :cpp:func:`proj_context_set_search_paths` that will override them. +.. option:: --remote-data + + .. versionadded:: 7.0 + + Display information regarding if :ref:`network` is enabled, and the + related URL. + Examples ******** diff --git a/scripts/reference_exported_symbols.txt b/scripts/reference_exported_symbols.txt index 07043504..ee174da9 100644 --- a/scripts/reference_exported_symbols.txt +++ b/scripts/reference_exported_symbols.txt @@ -739,6 +739,7 @@ pj_cleanup_lock pj_clear_initcache pj_compare_datums pj_context_get_grid_cache_filename(projCtx_t*) +pj_context_get_url_endpoint(projCtx_t*) pj_context_get_user_writable_directory(projCtx_t*, bool) pj_context_is_network_enabled(projCtx_t*) pj_ctx_alloc 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); diff --git a/test/cli/testprojinfo b/test/cli/testprojinfo index 5cc425c5..4ec1bdbb 100755 --- a/test/cli/testprojinfo +++ b/test/cli/testprojinfo @@ -183,6 +183,24 @@ fi # Hard to test content of testprojinfo_out_searchpaths.txt rm testprojinfo_out_searchpaths.txt +# Testing --remote-data +if ! $EXE --remote-data > testprojinfo_out_remotedata.txt; then + echo "--remote-data failed" + exit 100 +fi +# Hard to test content of testprojinfo_out_remotedata.txt +rm testprojinfo_out_remotedata.txt + +# Testing --remote-data +export PROJ_NETWORK=ON +if ! $EXE --remote-data > testprojinfo_out_remotedata.txt; then + echo "--remote-data failed" + exit 100 +fi +# Hard to test content of testprojinfo_out_remotedata.txt +rm testprojinfo_out_remotedata.txt +unset PROJ_NETWORK + # do 'diff' with distribution results echo "diff ${OUT} with testprojinfo_out.dist" diff -u ${OUT} ${TEST_CLI_DIR}/testprojinfo_out.dist |
