aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2020-12-15 18:30:24 +0100
committerEven Rouault <even.rouault@spatialys.com>2020-12-15 18:30:24 +0100
commite5706305795ed822a5197bda51e75a44ec14728b (patch)
treee4ddb5beb06bfe7fe09d497775b476a26371126c
parenta27c0255e7b8e6aab1b91e49fd7870d1ee4e1a80 (diff)
downloadPROJ-e5706305795ed822a5197bda51e75a44ec14728b.tar.gz
PROJ-e5706305795ed822a5197bda51e75a44ec14728b.zip
projinfo: add a --accuracy option to define the minimum accuracy
-rw-r--r--docs/source/apps/projinfo.rst10
-rw-r--r--src/apps/projinfo.cpp27
-rwxr-xr-xtest/cli/testprojinfo4
-rw-r--r--test/cli/testprojinfo_out.dist3
4 files changed, 34 insertions, 10 deletions
diff --git a/docs/source/apps/projinfo.rst b/docs/source/apps/projinfo.rst
index 803c0a65..f0f66620 100644
--- a/docs/source/apps/projinfo.rst
+++ b/docs/source/apps/projinfo.rst
@@ -22,7 +22,7 @@ Synopsis
| [--crs-extent-use none|both|intersection|smallest]
| [--grid-check none|discard_missing|sort|known_available]
| [--pivot-crs always|if_no_direct_transformation|never|{auth:code[,auth:code]*}]
- | [--show-superseded] [--hide-ballpark]
+ | [--show-superseded] [--hide-ballpark] [--accuracy {accuracy}]
| [--allow-ellipsoidal-height-as-vertical-crs]
| [--boundcrs-to-wgs84]
| [--main-db-path path] [--aux-db-path path]*
@@ -213,6 +213,14 @@ The following control parameters can appear in any order:
.. note:: only used for coordinate operation computation
+.. option:: --accuracy {accuracy}
+
+ .. versionadded:: 8.0
+
+ Sets the minimum desired accuracy for returned coordinate operations.
+
+ .. note:: only used for coordinate operation computation
+
.. option:: --allow-ellipsoidal-height-as-vertical-crs
.. versionadded:: 8.0
diff --git a/src/apps/projinfo.cpp b/src/apps/projinfo.cpp
index da885fbb..8d389019 100644
--- a/src/apps/projinfo.cpp
+++ b/src/apps/projinfo.cpp
@@ -95,7 +95,9 @@ static void usage() {
<< std::endl
<< " [--pivot-crs always|if_no_direct_transformation|"
<< "never|{auth:code[,auth:code]*}]" << std::endl
- << " [--show-superseded] [--hide-ballpark]" << std::endl
+ << " [--show-superseded] [--hide-ballpark] "
+ "[--accuracy {accuracy}]"
+ << std::endl
<< " [--allow-ellipsoidal-height-as-vertical-crs]"
<< std::endl
<< " [--boundcrs-to-wgs84]" << std::endl
@@ -672,8 +674,8 @@ static void outputOperations(
CoordinateOperationContext::IntermediateCRSUse allowUseIntermediateCRS,
const std::vector<std::pair<std::string, std::string>> &pivots,
const std::string &authority, bool usePROJGridAlternatives,
- bool showSuperseded, bool promoteTo3D, const OutputOptions &outputOpt,
- bool summary) {
+ bool showSuperseded, bool promoteTo3D, double minimumAccuracy,
+ const OutputOptions &outputOpt, bool summary) {
auto sourceObj =
buildObject(dbContext, sourceCRSStr, "crs", "source CRS", false,
CoordinateOperationContext::IntermediateCRSUse::NEVER,
@@ -715,6 +717,9 @@ static void outputOperations(
ctxt->setUsePROJAlternativeGridNames(usePROJGridAlternatives);
ctxt->setDiscardSuperseded(!showSuperseded);
ctxt->setAllowBallparkTransformations(outputOpt.ballparkAllowed);
+ if (minimumAccuracy >= 0) {
+ ctxt->setDesiredAccuracy(minimumAccuracy);
+ }
list = CoordinateOperationFactory::create()->createOperations(
nnSourceCRS, nnTargetCRS, ctxt);
if (!spatialCriterionExplicitlySpecified &&
@@ -819,6 +824,7 @@ int main(int argc, char **argv) {
bool identify = false;
bool showSuperseded = false;
bool promoteTo3D = false;
+ double minimumAccuracy = -1;
for (int i = 1; i < argc; i++) {
std::string arg(argv[i]);
@@ -934,6 +940,9 @@ int main(int argc, char **argv) {
<< ", " << e.what() << std::endl;
usage();
}
+ } else if (arg == "--accuracy" && i + 1 < argc) {
+ i++;
+ minimumAccuracy = c_locale_stod(argv[i]);
} else if (arg == "--area" && i + 1 < argc) {
i++;
area = argv[i];
@@ -1338,12 +1347,12 @@ int main(int argc, char **argv) {
}
try {
- outputOperations(dbContext, sourceCRSStr, targetCRSStr, bboxFilter,
- spatialCriterion,
- spatialCriterionExplicitlySpecified, crsExtentUse,
- gridAvailabilityUse, allowUseIntermediateCRS,
- pivots, authority, usePROJGridAlternatives,
- showSuperseded, promoteTo3D, outputOpt, summary);
+ outputOperations(
+ dbContext, sourceCRSStr, targetCRSStr, bboxFilter,
+ spatialCriterion, spatialCriterionExplicitlySpecified,
+ crsExtentUse, gridAvailabilityUse, allowUseIntermediateCRS,
+ pivots, authority, usePROJGridAlternatives, showSuperseded,
+ promoteTo3D, minimumAccuracy, outputOpt, summary);
} catch (const std::exception &e) {
std::cerr << "outputOperations() failed with: " << e.what()
<< std::endl;
diff --git a/test/cli/testprojinfo b/test/cli/testprojinfo
index c31cfef0..ee1b27f5 100755
--- a/test/cli/testprojinfo
+++ b/test/cli/testprojinfo
@@ -213,6 +213,10 @@ fi
rm testprojinfo_out_remotedata.txt
unset PROJ_NETWORK
+echo 'Testing --accuracy 0.05 -s EPSG:4326 -t EPSG:4258' >> ${OUT}
+$EXE --accuracy 0.05 -s EPSG:4326 -t EPSG:4258 >>${OUT} 2>&1
+echo "" >>${OUT}
+
######################
# NZGD2000 -> ITRFxx #
######################
diff --git a/test/cli/testprojinfo_out.dist b/test/cli/testprojinfo_out.dist
index 8e8ef294..829c914c 100644
--- a/test/cli/testprojinfo_out.dist
+++ b/test/cli/testprojinfo_out.dist
@@ -1384,6 +1384,9 @@ DATUM["World Geodetic System 1984",
LENGTHUNIT["metre",1]],
ID["EPSG",6326]]
+Testing --accuracy 0.05 -s EPSG:4326 -t EPSG:4258
+Candidate operations found: 0
+
Testing -s NZGD2000 -t ITRF96 -o PROJ -q
+proj=pipeline
+step +proj=unitconvert +xy_in=deg +xy_out=rad