diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2020-12-16 16:32:13 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2020-12-16 18:48:46 +0100 |
| commit | da066800e59dcd5c3bf5e88ccca1bf1762de74dc (patch) | |
| tree | 506dadd7d34c4d2ed972407f7343548bb95d0a64 | |
| parent | 37755e4edc53e09286cd2bb962299d0f5118fc77 (diff) | |
| download | PROJ-da066800e59dcd5c3bf5e88ccca1bf1762de74dc.tar.gz PROJ-da066800e59dcd5c3bf5e88ccca1bf1762de74dc.zip | |
cs2cs: add --no-ballpark and --accuracy options
| -rw-r--r-- | docs/source/apps/cs2cs.rst | 15 | ||||
| -rw-r--r-- | src/apps/cs2cs.cpp | 33 | ||||
| -rwxr-xr-x | test/cli/testvarious | 12 | ||||
| -rw-r--r-- | test/cli/tv_out.dist | 4 |
4 files changed, 59 insertions, 5 deletions
diff --git a/docs/source/apps/cs2cs.rst b/docs/source/apps/cs2cs.rst index 7df8890f..4706459a 100644 --- a/docs/source/apps/cs2cs.rst +++ b/docs/source/apps/cs2cs.rst @@ -13,7 +13,7 @@ Synopsis | **cs2cs** [**-eEfIlrstvwW** [args]] | [[--area <name_or_code>] | [--bbox <west_long,south_lat,east_long,north_lat>]] - | [--authority <name>] + | [--authority <name>] [--no-ballpark] [--accuracy <accuracy>] | ([*+opt[=arg]* ...] [+to *+opt[=arg]* ...] | {source_crs} {target_crs}) | file ... @@ -166,6 +166,19 @@ The following control parameters can appear in any order: `south_lat` and `north_lat` in the [-90,90]. `west_long` is generally lower than `east_long`, except in the case where the area of interest crosses the antimeridian. +.. option:: --no-ballpark + + .. versionadded:: 8.0.0 + + Disallow any coordinate operation that is, or contains, a + :term:`Ballpark transformation` + +.. option:: --accuracy <accuracy> + + .. versionadded:: 8.0.0 + + Sets the minimum desired accuracy for candidate coordinate operations. + .. option:: --authority <name> .. versionadded:: 8.0.0 diff --git a/src/apps/cs2cs.cpp b/src/apps/cs2cs.cpp index 409a5ef3..5542a282 100644 --- a/src/apps/cs2cs.cpp +++ b/src/apps/cs2cs.cpp @@ -38,6 +38,7 @@ #include <cassert> #include <iostream> #include <string> +#include <vector> #include <proj/io.hpp> #include <proj/metadata.hpp> @@ -77,7 +78,7 @@ static const char *oterr = "*\t*"; /* output line for unprojectable input */ static const char *usage = "%s\nusage: %s [-dDeEfIlrstvwW [args]]\n" " [[--area name_or_code] | [--bbox west_long,south_lat,east_long,north_lat]]\n" - " [--authority {name}]\n" + " [--authority {name}] [--accuracy {accuracy}] [--no-ballpark]\n" " [+opt[=arg] ...] [+to +opt[=arg] ...] [file ...]\n"; static double (*informat)(const char *, @@ -374,6 +375,8 @@ int main(int argc, char **argv) { ExtentPtr bboxFilter; std::string area; const char* authority = nullptr; + double accuracy = -1; + bool allowBallpark = true; /* process run line arguments */ while (--argc > 0) { /* collect run line arguments */ @@ -412,6 +415,15 @@ int main(int argc, char **argv) { std::exit(1); } } + else if (strcmp(*argv, "--accuracy") == 0 ) { + ++argv; + --argc; + if( argc == 0 ) { + emess(1, "missing argument for --accuracy"); + std::exit(1); + } + accuracy = c_locale_stod(*argv); + } else if (strcmp(*argv, "--authority") == 0 ) { ++argv; --argc; @@ -421,6 +433,9 @@ int main(int argc, char **argv) { } authority = *argv; } + else if (strcmp(*argv, "--no-ballpark") == 0 ) { + allowBallpark = false; + } else if (**argv == '-') { for (arg = *argv;;) { switch (*++arg) { @@ -773,14 +788,24 @@ int main(int argc, char **argv) { } std::string authorityOption; /* keep this variable in this outer scope ! */ - const char* options[2] = { nullptr, nullptr }; + std::string accuracyOption; /* keep this variable in this outer scope ! */ + std::vector<const char*> options; if( authority ) { authorityOption = "AUTHORITY="; authorityOption += authority; - options[0] = authorityOption.data(); + options.push_back(authorityOption.data()); + } + if( accuracy >= 0 ) { + accuracyOption = "ACCURACY="; + accuracyOption += toString(accuracy); + options.push_back(accuracyOption.data()); + } + if( !allowBallpark ) { + options.push_back("ALLOW_BALLPARK=NO"); } + options.push_back(nullptr); transformation = proj_create_crs_to_crs_from_pj(nullptr, src, dst, - pj_area, options); + pj_area, options.data()); proj_destroy(src); proj_destroy(dst); diff --git a/test/cli/testvarious b/test/cli/testvarious index 82be4992..a121393c 100755 --- a/test/cli/testvarious +++ b/test/cli/testvarious @@ -1021,6 +1021,18 @@ $EXE --authority EPSG -E +proj=latlong +datum=WGS84 +no_defs +to +init=epsg:6342 -105 40 EOF +echo "##############################################################" >> ${OUT} +echo "Test effect of --accuracy" >> ${OUT} +$EXE -E --accuracy 0.05 EPSG:4326 EPSG:4258 >> ${OUT} <<EOF +49 2 +EOF + +echo "##############################################################" >> ${OUT} +echo "Test effect of --no-ballpark" >> ${OUT} +$EXE -E --no-ballpark EPSG:4267 EPSG:4258 >> ${OUT} <<EOF +49 2 +EOF + # Done! # do 'diff' with distribution results diff --git a/test/cli/tv_out.dist b/test/cli/tv_out.dist index fe1aa452..59129d99 100644 --- a/test/cli/tv_out.dist +++ b/test/cli/tv_out.dist @@ -492,3 +492,7 @@ The first result should use the 'WGS_1984_(ITRF08)_To_NAD_1983_2011' (ESRI:10836 and the second one a no-op -105 40 500000.86 4427756.50 0.00 -105 40 500000.00 4427757.22 0.00 +############################################################## +Test effect of --accuracy +############################################################## +Test effect of --no-ballpark |
