aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Evers <kristianevers@gmail.com>2019-02-18 09:45:47 +0100
committerKristian Evers <kristianevers@gmail.com>2019-02-18 09:45:47 +0100
commitf61aa8a01961cff194fcf49c66e4ca9b4bd68052 (patch)
tree189e5bc87ac99a73f515b3800c2e1898c732f7b3
parent24ce8716974020600aa22fe7334628a29f578774 (diff)
parent4277e15cefae5bb1d49312498e0f626b652e7524 (diff)
downloadPROJ-f61aa8a01961cff194fcf49c66e4ca9b4bd68052.tar.gz
PROJ-f61aa8a01961cff194fcf49c66e4ca9b4bd68052.zip
Merge remote-tracking branch 'osgeo/master' into 6.0
-rw-r--r--docs/source/apps/projinfo.rst11
-rw-r--r--include/proj/coordinateoperation.hpp17
-rw-r--r--include/proj/crs.hpp7
-rw-r--r--src/apps/projinfo.cpp50
-rw-r--r--src/iso19111/c_api.cpp44
-rw-r--r--src/iso19111/coordinateoperation.cpp36
-rw-r--r--src/iso19111/crs.cpp9
-rw-r--r--src/proj.h15
-rw-r--r--test/unit/Makefile.am2
-rw-r--r--test/unit/test_c_api.cpp4
-rw-r--r--test/unit/test_crs.cpp66
-rw-r--r--test/unit/test_factory.cpp15
-rw-r--r--test/unit/test_operation.cpp114
-rw-r--r--test/unit/test_primitives.hpp99
14 files changed, 356 insertions, 133 deletions
diff --git a/docs/source/apps/projinfo.rst b/docs/source/apps/projinfo.rst
index cbfd44d4..af9ed171 100644
--- a/docs/source/apps/projinfo.rst
+++ b/docs/source/apps/projinfo.rst
@@ -21,7 +21,7 @@ Synopsis
| [--spatial-test contains|intersects]
| [--crs-extent-use none|both|intersection|smallest]
| [--grid-check none|discard_missing|sort] [--show-superseded]
- | [--pivot-crs none|{auth:code[,auth:code]*}]
+ | [--pivot-crs always|if_no_direct_transformation|never|{auth:code[,auth:code]*}]
| [--boundcrs-to-wgs84]
| [--main-db-path path] [--aux-db-path path]*
| [--identify]
@@ -157,13 +157,16 @@ The following control parameters can appear in any order:
.. note:: only used for coordinate operation computation
-.. option:: --pivot-crs none|{auth:code[,auth:code]*}
+.. option:: --pivot-crs always|if_no_direct_transformation|never|{auth:code[,auth:code]*}
Determine if intermediate (pivot) CRS can be used when researching coordinate
operation between 2 CRS. A typical example is the WGS84 pivot. By default,
- projinfo will consider any potential pivot. If using the ``none`` strategy,
+ projinfo will consider any potential pivot if there is no direct transformation
+ ( ``if_no_direct_transformation``). If using the ``never`` strategy,
only direct transformations between the source and target CRS will be
- used. It is also possible to restrict the pivot CRS to consider by specifying
+ used. If using the ``always`` strategy, intermediate CRS will be considered
+ even if there are direct transformations.
+ It is also possible to restrict the pivot CRS to consider by specifying
one or several CRS by their AUTHORITY:CODE.
.. note:: only used for coordinate operation computation
diff --git a/include/proj/coordinateoperation.hpp b/include/proj/coordinateoperation.hpp
index 6b32e24d..92b655f9 100644
--- a/include/proj/coordinateoperation.hpp
+++ b/include/proj/coordinateoperation.hpp
@@ -1726,9 +1726,22 @@ class PROJ_GCC_DLL CoordinateOperationContext {
PROJ_DLL GridAvailabilityUse getGridAvailabilityUse() const;
- PROJ_DLL void setAllowUseIntermediateCRS(bool use);
+ /** Describe if and how intermediate CRS should be used */
+ enum class IntermediateCRSUse {
+ /** Always search for intermediate CRS. */
+ ALWAYS,
- PROJ_DLL bool getAllowUseIntermediateCRS() const;
+ /** Only attempt looking for intermediate CRS if there is no direct
+ * transformation available. */
+ IF_NO_DIRECT_TRANSFORMATION,
+
+ /* Do not attempt looking for intermediate CRS. */
+ NEVER,
+ };
+
+ PROJ_DLL void setAllowUseIntermediateCRS(IntermediateCRSUse use);
+
+ PROJ_DLL IntermediateCRSUse getAllowUseIntermediateCRS() const;
PROJ_DLL void
setIntermediateCRS(const std::vector<std::pair<std::string, std::string>>
diff --git a/include/proj/crs.hpp b/include/proj/crs.hpp
index 6a09ea78..fb34d3b7 100644
--- a/include/proj/crs.hpp
+++ b/include/proj/crs.hpp
@@ -92,9 +92,10 @@ class PROJ_GCC_DLL CRS : public common::ObjectUsage {
PROJ_DLL GeodeticCRSPtr extractGeodeticCRS() const;
PROJ_DLL GeographicCRSPtr extractGeographicCRS() const;
PROJ_DLL VerticalCRSPtr extractVerticalCRS() const;
- PROJ_DLL CRSNNPtr
- createBoundCRSToWGS84IfPossible(const io::DatabaseContextPtr &dbContext,
- bool allowIntermediateCRS) const;
+ PROJ_DLL CRSNNPtr createBoundCRSToWGS84IfPossible(
+ const io::DatabaseContextPtr &dbContext,
+ operation::CoordinateOperationContext::IntermediateCRSUse
+ allowIntermediateCRSUse) const;
PROJ_DLL CRSNNPtr stripVerticalComponent() const;
PROJ_DLL const BoundCRSPtr &canonicalBoundCRS() PROJ_PURE_DECL;
diff --git a/src/apps/projinfo.cpp b/src/apps/projinfo.cpp
index 29cf5fc3..9f908c8a 100644
--- a/src/apps/projinfo.cpp
+++ b/src/apps/projinfo.cpp
@@ -88,8 +88,8 @@ static void usage() {
<< " [--grid-check none|discard_missing|sort] "
"[--show-superseded]"
<< std::endl
- << " [--pivot-crs none|{auth:code[,auth:code]*}]"
- << std::endl
+ << " [--pivot-crs always|if_no_direct_transformation|"
+ << "never|{auth:code[,auth:code]*}]" << std::endl
<< " [--boundcrs-to-wgs84]" << std::endl
<< " [--main-db-path path] [--aux-db-path path]*"
<< std::endl
@@ -139,7 +139,7 @@ static std::string c_ify_string(const std::string &str) {
static BaseObjectNNPtr buildObject(DatabaseContextPtr dbContext,
const std::string &user_string,
bool kindIsCRS, const std::string &context,
- bool buildBoundCRSToWGS84, bool allowPivots,
+ bool buildBoundCRSToWGS84, CoordinateOperationContext::IntermediateCRSUse allowUseIntermediateCRS,
bool quiet) {
BaseObjectPtr obj;
@@ -213,7 +213,7 @@ static BaseObjectNNPtr buildObject(DatabaseContextPtr dbContext,
if (buildBoundCRSToWGS84) {
auto crs = std::dynamic_pointer_cast<CRS>(obj);
if (crs) {
- obj = crs->createBoundCRSToWGS84IfPossible(dbContext, allowPivots)
+ obj = crs->createBoundCRSToWGS84IfPossible(dbContext, allowUseIntermediateCRS)
.as_nullable();
}
}
@@ -224,7 +224,7 @@ static BaseObjectNNPtr buildObject(DatabaseContextPtr dbContext,
// ---------------------------------------------------------------------------
static void outputObject(DatabaseContextPtr dbContext, BaseObjectNNPtr obj,
- bool allowPivots, const OutputOptions &outputOpt) {
+ CoordinateOperationContext::IntermediateCRSUse allowUseIntermediateCRS, const OutputOptions &outputOpt) {
auto identified = dynamic_cast<const IdentifiedObject *>(obj.get());
if (!outputOpt.quiet && identified && identified->isDeprecated()) {
@@ -272,7 +272,7 @@ static void outputObject(DatabaseContextPtr dbContext, BaseObjectNNPtr obj,
objToExport =
nn_dynamic_pointer_cast<IPROJStringExportable>(
crs->createBoundCRSToWGS84IfPossible(dbContext,
- allowPivots));
+ allowUseIntermediateCRS));
}
if (!objToExport) {
objToExport = projStringExportable;
@@ -412,7 +412,7 @@ static void outputObject(DatabaseContextPtr dbContext, BaseObjectNNPtr obj,
if (crs) {
objToExport = nn_dynamic_pointer_cast<IWKTExportable>(
crs->createBoundCRSToWGS84IfPossible(dbContext,
- allowPivots));
+ allowUseIntermediateCRS));
}
if (!objToExport) {
objToExport = wktExportable;
@@ -516,12 +516,14 @@ static void outputOperations(
CoordinateOperationContext::SpatialCriterion spatialCriterion,
CoordinateOperationContext::SourceTargetCRSExtentUse crsExtentUse,
CoordinateOperationContext::GridAvailabilityUse gridAvailabilityUse,
- bool allowPivots,
+ CoordinateOperationContext::IntermediateCRSUse allowUseIntermediateCRS,
const std::vector<std::pair<std::string, std::string>> &pivots,
const std::string &authority, bool usePROJGridAlternatives,
bool showSuperseded, const OutputOptions &outputOpt, bool summary) {
auto sourceObj = buildObject(dbContext, sourceCRSStr, true, "source CRS",
- false, false, outputOpt.quiet);
+ false,
+ CoordinateOperationContext::IntermediateCRSUse::NEVER,
+ outputOpt.quiet);
auto sourceCRS = nn_dynamic_pointer_cast<CRS>(sourceObj);
if (!sourceCRS) {
std::cerr << "source CRS string is not a CRS" << std::endl;
@@ -529,7 +531,9 @@ static void outputOperations(
}
auto targetObj = buildObject(dbContext, targetCRSStr, true, "target CRS",
- false, false, outputOpt.quiet);
+ false,
+ CoordinateOperationContext::IntermediateCRSUse::NEVER,
+ outputOpt.quiet);
auto targetCRS = nn_dynamic_pointer_cast<CRS>(targetObj);
if (!targetCRS) {
std::cerr << "target CRS string is not a CRS" << std::endl;
@@ -548,7 +552,7 @@ static void outputOperations(
ctxt->setSpatialCriterion(spatialCriterion);
ctxt->setSourceAndTargetCRSExtentUse(crsExtentUse);
ctxt->setGridAvailabilityUse(gridAvailabilityUse);
- ctxt->setAllowUseIntermediateCRS(allowPivots);
+ ctxt->setAllowUseIntermediateCRS(allowUseIntermediateCRS);
ctxt->setIntermediateCRS(pivots);
ctxt->setUsePROJAlternativeGridNames(usePROJGridAlternatives);
ctxt->setDiscardSuperseded(!showSuperseded);
@@ -560,7 +564,7 @@ static void outputOperations(
std::exit(1);
}
if (outputOpt.quiet && !list.empty()) {
- outputObject(dbContext, list[0], allowPivots, outputOpt);
+ outputObject(dbContext, list[0], allowUseIntermediateCRS, outputOpt);
return;
}
if (summary) {
@@ -586,7 +590,7 @@ static void outputOperations(
}
outputOperationSummary(op);
std::cout << std::endl;
- outputObject(dbContext, op, allowPivots, outputOpt);
+ outputObject(dbContext, op, allowUseIntermediateCRS, outputOpt);
}
}
}
@@ -617,7 +621,8 @@ int main(int argc, char **argv) {
bool buildBoundCRSToWGS84 = false;
CoordinateOperationContext::GridAvailabilityUse gridAvailabilityUse =
CoordinateOperationContext::GridAvailabilityUse::USE_FOR_SORTING;
- bool allowPivots = true;
+ CoordinateOperationContext::IntermediateCRSUse allowUseIntermediateCRS =
+ CoordinateOperationContext::IntermediateCRSUse::IF_NO_DIRECT_TRANSFORMATION;
std::vector<std::pair<std::string, std::string>> pivots;
bool usePROJGridAlternatives = true;
std::string mainDBPath;
@@ -814,8 +819,15 @@ int main(int argc, char **argv) {
} else if (arg == "--pivot-crs" && i + 1 < argc) {
i++;
auto value(argv[i]);
- if (ci_equal(std::string(value), "none")) {
- allowPivots = false;
+ if (ci_equal(std::string(value), "always")) {
+ allowUseIntermediateCRS =
+ CoordinateOperationContext::IntermediateCRSUse::ALWAYS;
+ } else if (ci_equal(std::string(value), "if_no_direct_transformation")) {
+ allowUseIntermediateCRS =
+ CoordinateOperationContext::IntermediateCRSUse::IF_NO_DIRECT_TRANSFORMATION;
+ } else if (ci_equal(std::string(value), "never")) {
+ allowUseIntermediateCRS =
+ CoordinateOperationContext::IntermediateCRSUse::NEVER;
} else {
auto splitValue(split(value, ','));
for (const auto &v : splitValue) {
@@ -915,7 +927,7 @@ int main(int argc, char **argv) {
if (!user_string.empty()) {
auto obj(buildObject(dbContext, user_string, kindIsCRS, "input string",
- buildBoundCRSToWGS84, allowPivots,
+ buildBoundCRSToWGS84, allowUseIntermediateCRS,
outputOpt.quiet));
if (guessDialect) {
auto dialect = WKTParser().guessDialect(user_string);
@@ -933,7 +945,7 @@ int main(int argc, char **argv) {
}
std::cout << std::endl;
}
- outputObject(dbContext, obj, allowPivots, outputOpt);
+ outputObject(dbContext, obj, allowUseIntermediateCRS, outputOpt);
if (identify) {
auto crs = dynamic_cast<CRS *>(obj.get());
if (crs) {
@@ -1043,7 +1055,7 @@ int main(int argc, char **argv) {
outputOperations(
dbContext, sourceCRSStr, targetCRSStr, bboxFilter, spatialCriterion,
- crsExtentUse, gridAvailabilityUse, allowPivots, pivots, authority,
+ crsExtentUse, gridAvailabilityUse, allowUseIntermediateCRS, pivots, authority,
usePROJGridAlternatives, showSuperseded, outputOpt, summary);
}
diff --git a/src/iso19111/c_api.cpp b/src/iso19111/c_api.cpp
index 79732bab..b3f200fe 100644
--- a/src/iso19111/c_api.cpp
+++ b/src/iso19111/c_api.cpp
@@ -1475,7 +1475,8 @@ PJ *proj_crs_create_bound_crs(PJ_CONTEXT *ctx, const PJ *base_crs,
* @param options null-terminated list of options, or NULL. Currently
* supported options are:
* <ul>
- * <li>ALLOW_INTERMEDIATE_CRS=YES/NO. Defaults to NO. When set to YES,
+ * <li>ALLOW_INTERMEDIATE_CRS=ALWAYS/IF_NO_DIRECT_TRANSFORMATION/NEVER. Defaults
+ * to NEVER. When set to ALWAYS/IF_NO_DIRECT_TRANSFORMATION,
* intermediate CRS may be considered when computing the possible
* transformations. Slower.</li>
* </ul>
@@ -1493,11 +1494,18 @@ PJ *proj_crs_create_bound_crs_to_WGS84(PJ_CONTEXT *ctx, const PJ *crs,
}
auto dbContext = getDBcontextNoException(ctx, __FUNCTION__);
try {
- bool allowIntermediateCRS = false;
+ CoordinateOperationContext::IntermediateCRSUse allowIntermediateCRS =
+ CoordinateOperationContext::IntermediateCRSUse::NEVER;
for (auto iter = options; iter && iter[0]; ++iter) {
const char *value;
if ((value = getOptionValue(*iter, "ALLOW_INTERMEDIATE_CRS="))) {
- allowIntermediateCRS = ci_equal(value, "YES");
+ if (ci_equal(value, "YES") || ci_equal(value, "ALWAYS")) {
+ allowIntermediateCRS =
+ CoordinateOperationContext::IntermediateCRSUse::ALWAYS;
+ } else if (ci_equal(value, "IF_NO_DIRECT_TRANSFORMATION")) {
+ allowIntermediateCRS = CoordinateOperationContext::
+ IntermediateCRSUse::IF_NO_DIRECT_TRANSFORMATION;
+ }
} else {
std::string msg("Unknown option :");
msg += *iter;
@@ -6378,22 +6386,36 @@ void proj_operation_factory_context_set_use_proj_alternative_grid_names(
* The current implementation is limited to researching one intermediate
* step.
*
- * By default, all potential C candidates will be used.
- * proj_operation_factory_context_set_allowed_intermediate_crs()
- * can be used to restrict them.
- *
- * The default is true.
+ * By default, with the IF_NO_DIRECT_TRANSFORMATION stratgey, all potential
+ * C candidates will be used if there is no direct tranformation.
*
* @param ctx PROJ context, or NULL for default context
* @param factory_ctx Operation factory context. must not be NULL
- * @param allow whether intermediate CRS may be used.
+ * @param use whether and how intermediate CRS may be used.
*/
void proj_operation_factory_context_set_allow_use_intermediate_crs(
- PJ_CONTEXT *ctx, PJ_OPERATION_FACTORY_CONTEXT *factory_ctx, int allow) {
+ PJ_CONTEXT *ctx, PJ_OPERATION_FACTORY_CONTEXT *factory_ctx,
+ PROJ_INTERMEDIATE_CRS_USE use) {
SANITIZE_CTX(ctx);
assert(factory_ctx);
try {
- factory_ctx->operationContext->setAllowUseIntermediateCRS(allow != 0);
+ switch (use) {
+ case PROJ_INTERMEDIATE_CRS_USE_ALWAYS:
+ factory_ctx->operationContext->setAllowUseIntermediateCRS(
+ CoordinateOperationContext::IntermediateCRSUse::ALWAYS);
+ break;
+
+ case PROJ_INTERMEDIATE_CRS_USE_IF_NO_DIRECT_TRANSFORMATION:
+ factory_ctx->operationContext->setAllowUseIntermediateCRS(
+ CoordinateOperationContext::IntermediateCRSUse::
+ IF_NO_DIRECT_TRANSFORMATION);
+ break;
+
+ case PROJ_INTERMEDIATE_CRS_USE_NEVER:
+ factory_ctx->operationContext->setAllowUseIntermediateCRS(
+ CoordinateOperationContext::IntermediateCRSUse::NEVER);
+ break;
+ }
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
}
diff --git a/src/iso19111/coordinateoperation.cpp b/src/iso19111/coordinateoperation.cpp
index d964cdc1..2128124b 100644
--- a/src/iso19111/coordinateoperation.cpp
+++ b/src/iso19111/coordinateoperation.cpp
@@ -9242,7 +9242,8 @@ struct CoordinateOperationContext::Private {
bool usePROJNames_ = true;
GridAvailabilityUse gridAvailabilityUse_ =
GridAvailabilityUse::USE_FOR_SORTING;
- bool allowUseIntermediateCRS_ = true;
+ IntermediateCRSUse allowUseIntermediateCRS_ = CoordinateOperationContext::
+ IntermediateCRSUse::IF_NO_DIRECT_TRANSFORMATION;
std::vector<std::pair<std::string, std::string>>
intermediateCRSAuthCodes_{};
bool discardSuperseded_ = true;
@@ -9436,18 +9437,17 @@ CoordinateOperationContext::getGridAvailabilityUse() const {
*
* Concretely if in the database there is an operation from A to C
* (or C to A), and another one from C to B (or B to C), but no direct
- * operation between A and B, setting this parameter to true, allow
- * chaining both operations.
+ * operation between A and B, setting this parameter to
+ * ALWAYS/IF_NO_DIRECT_TRANSFORMATION, allow chaining both operations.
*
* The current implementation is limited to researching one intermediate
* step.
*
- * By default, all potential C candidates will be used. setIntermediateCRS()
- * can be used to restrict them.
- *
- * The default is true.
+ * By default, with the IF_NO_DIRECT_TRANSFORMATION stratgey, all potential
+ * C candidates will be used if there is no direct tranformation.
*/
-void CoordinateOperationContext::setAllowUseIntermediateCRS(bool use) {
+void CoordinateOperationContext::setAllowUseIntermediateCRS(
+ IntermediateCRSUse use) {
d->allowUseIntermediateCRS_ = use;
}
@@ -9458,12 +9458,13 @@ void CoordinateOperationContext::setAllowUseIntermediateCRS(bool use) {
*
* Concretely if in the database there is an operation from A to C
* (or C to A), and another one from C to B (or B to C), but no direct
- * operation between A and B, setting this parameter to true, allow
- * chaining both operations.
+ * operation between A and B, setting this parameter to
+ * ALWAYS/IF_NO_DIRECT_TRANSFORMATION, allow chaining both operations.
*
- * The default is true.
+ * The default is IF_NO_DIRECT_TRANSFORMATION.
*/
-bool CoordinateOperationContext::getAllowUseIntermediateCRS() const {
+CoordinateOperationContext::IntermediateCRSUse
+CoordinateOperationContext::getAllowUseIntermediateCRS() const {
return d->allowUseIntermediateCRS_;
}
@@ -10401,9 +10402,6 @@ findOpsInRegistryDirect(const crs::CRSNNPtr &sourceCRS,
static std::vector<CoordinateOperationNNPtr> findsOpsInRegistryWithIntermediate(
const crs::CRSNNPtr &sourceCRS, const crs::CRSNNPtr &targetCRS,
const CoordinateOperationContextNNPtr &context) {
- if (!context->getAllowUseIntermediateCRS()) {
- return std::vector<CoordinateOperationNNPtr>();
- }
const auto &authFactory = context->getAuthorityFactory();
assert(authFactory);
@@ -11215,7 +11213,13 @@ CoordinateOperationFactory::Private::createOperations(
// NAD27 to NAD83 has tens of results already. No need to look
// for a pivot
- if (res.size() < 5 || getenv("PROJ_FORCE_SEARCH_PIVOT")) {
+ if ((res.empty() &&
+ context.context->getAllowUseIntermediateCRS() ==
+ CoordinateOperationContext::IntermediateCRSUse::
+ IF_NO_DIRECT_TRANSFORMATION) ||
+ context.context->getAllowUseIntermediateCRS() ==
+ CoordinateOperationContext::IntermediateCRSUse::ALWAYS ||
+ getenv("PROJ_FORCE_SEARCH_PIVOT")) {
auto resWithIntermediate = findsOpsInRegistryWithIntermediate(
sourceCRS, targetCRS, context.context);
res.insert(res.end(), resWithIntermediate.begin(),
diff --git a/src/iso19111/crs.cpp b/src/iso19111/crs.cpp
index ebbed7a1..01a588e3 100644
--- a/src/iso19111/crs.cpp
+++ b/src/iso19111/crs.cpp
@@ -375,9 +375,10 @@ VerticalCRSPtr CRS::extractVerticalCRS() const {
*
* @return a CRS.
*/
-CRSNNPtr
-CRS::createBoundCRSToWGS84IfPossible(const io::DatabaseContextPtr &dbContext,
- bool allowIntermediateCRS) const {
+CRSNNPtr CRS::createBoundCRSToWGS84IfPossible(
+ const io::DatabaseContextPtr &dbContext,
+ operation::CoordinateOperationContext::IntermediateCRSUse
+ allowIntermediateCRSUse) const {
auto thisAsCRS = NN_NO_CHECK(
std::static_pointer_cast<CRS>(shared_from_this().as_nullable()));
auto boundCRS = util::nn_dynamic_pointer_cast<BoundCRS>(thisAsCRS);
@@ -442,7 +443,7 @@ CRS::createBoundCRSToWGS84IfPossible(const io::DatabaseContextPtr &dbContext,
authority == "any" ? std::string() : authority);
auto ctxt = operation::CoordinateOperationContext::create(
authFactory, extent, 0.0);
- ctxt->setAllowUseIntermediateCRS(allowIntermediateCRS);
+ ctxt->setAllowUseIntermediateCRS(allowIntermediateCRSUse);
// ctxt->setSpatialCriterion(
// operation::CoordinateOperationContext::SpatialCriterion::PARTIAL_INTERSECTION);
auto list =
diff --git a/src/proj.h b/src/proj.h
index f25c3228..af22c341 100644
--- a/src/proj.h
+++ b/src/proj.h
@@ -629,6 +629,19 @@ typedef enum {
PROJ_SPATIAL_CRITERION_PARTIAL_INTERSECTION
} PROJ_SPATIAL_CRITERION;
+ /** Describe if and how intermediate CRS should be used */
+typedef enum {
+ /** Always search for intermediate CRS. */
+ PROJ_INTERMEDIATE_CRS_USE_ALWAYS,
+
+ /** Only attempt looking for intermediate CRS if there is no direct
+ * transformation available. */
+ PROJ_INTERMEDIATE_CRS_USE_IF_NO_DIRECT_TRANSFORMATION,
+
+ /* Do not attempt looking for intermediate CRS. */
+ PROJ_INTERMEDIATE_CRS_USE_NEVER,
+} PROJ_INTERMEDIATE_CRS_USE;
+
/** Type of coordinate system. */
typedef enum
{
@@ -906,7 +919,7 @@ void PROJ_DLL proj_operation_factory_context_set_use_proj_alternative_grid_names
void PROJ_DLL proj_operation_factory_context_set_allow_use_intermediate_crs(
PJ_CONTEXT *ctx,
PJ_OPERATION_FACTORY_CONTEXT *factory_ctx,
- int allow);
+ PROJ_INTERMEDIATE_CRS_USE use);
void PROJ_DLL proj_operation_factory_context_set_allowed_intermediate_crs(
PJ_CONTEXT *ctx,
diff --git a/test/unit/Makefile.am b/test/unit/Makefile.am
index 210bdc90..57a03ca8 100644
--- a/test/unit/Makefile.am
+++ b/test/unit/Makefile.am
@@ -2,7 +2,7 @@ AUTOMAKE_OPTIONS = subdir-objects
EXTRA_DIST = CMakeLists.txt
-noinst_HEADERS = gtest_include.h
+noinst_HEADERS = gtest_include.h test_primitives.hpp
AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/include -I$(top_srcdir)/test @GTEST_CFLAGS@ @SQLITE3_CFLAGS@
AM_CXXFLAGS = @CXX_WFLAGS@ @NO_ZERO_AS_NULL_POINTER_CONSTANT_FLAG@
diff --git a/test/unit/test_c_api.cpp b/test/unit/test_c_api.cpp
index 273a04e6..6205a9b8 100644
--- a/test/unit/test_c_api.cpp
+++ b/test/unit/test_c_api.cpp
@@ -1389,7 +1389,7 @@ TEST_F(CApi, proj_create_operations_with_pivot) {
ASSERT_NE(ctxt, nullptr);
ContextKeeper keeper_ctxt(ctxt);
proj_operation_factory_context_set_allow_use_intermediate_crs(
- m_ctxt, ctxt, false);
+ m_ctxt, ctxt, PROJ_INTERMEDIATE_CRS_USE_NEVER);
auto res = proj_create_operations(m_ctxt, source_crs, target_crs, ctxt);
ASSERT_NE(res, nullptr);
@@ -1444,6 +1444,8 @@ TEST_F(CApi, proj_create_operations_with_pivot) {
m_ctxt, ctxt, PROJ_SPATIAL_CRITERION_PARTIAL_INTERSECTION);
proj_operation_factory_context_set_grid_availability_use(
m_ctxt, ctxt, PROJ_GRID_AVAILABILITY_IGNORED);
+ proj_operation_factory_context_set_allow_use_intermediate_crs(
+ m_ctxt, ctxt, PROJ_INTERMEDIATE_CRS_USE_ALWAYS);
auto res = proj_create_operations(m_ctxt, source_crs, target_crs, ctxt);
ASSERT_NE(res, nullptr);
diff --git a/test/unit/test_crs.cpp b/test/unit/test_crs.cpp
index 26bcf621..4953529c 100644
--- a/test/unit/test_crs.cpp
+++ b/test/unit/test_crs.cpp
@@ -3436,8 +3436,12 @@ TEST(crs, boundCRS_crs_link) {
EXPECT_TRUE(baseCRS->isEquivalentTo(GeographicCRS::EPSG_4267.get()));
EXPECT_TRUE(baseCRS->canonicalBoundCRS() != nullptr);
- EXPECT_TRUE(baseCRS->createBoundCRSToWGS84IfPossible(nullptr, false)
- ->isEquivalentTo(baseCRS->canonicalBoundCRS().get()));
+ EXPECT_TRUE(
+ baseCRS
+ ->createBoundCRSToWGS84IfPossible(
+ nullptr,
+ CoordinateOperationContext::IntermediateCRSUse::NEVER)
+ ->isEquivalentTo(baseCRS->canonicalBoundCRS().get()));
}
{
@@ -4725,27 +4729,35 @@ TEST(crs, crs_createBoundCRSToWGS84IfPossible) {
auto factory = AuthorityFactory::create(dbContext, "EPSG");
{
auto crs_4326 = factory->createCoordinateReferenceSystem("4326");
- EXPECT_EQ(crs_4326->createBoundCRSToWGS84IfPossible(dbContext, false),
+ EXPECT_EQ(crs_4326->createBoundCRSToWGS84IfPossible(
+ dbContext,
+ CoordinateOperationContext::IntermediateCRSUse::NEVER),
crs_4326);
}
{
auto crs_32631 = factory->createCoordinateReferenceSystem("32631");
- EXPECT_EQ(crs_32631->createBoundCRSToWGS84IfPossible(dbContext, false),
+ EXPECT_EQ(crs_32631->createBoundCRSToWGS84IfPossible(
+ dbContext,
+ CoordinateOperationContext::IntermediateCRSUse::NEVER),
crs_32631);
}
{
// Pulkovo 42 East Germany
auto crs_5670 = factory->createCoordinateReferenceSystem("5670");
- EXPECT_EQ(crs_5670->createBoundCRSToWGS84IfPossible(dbContext, false),
+ EXPECT_EQ(crs_5670->createBoundCRSToWGS84IfPossible(
+ dbContext,
+ CoordinateOperationContext::IntermediateCRSUse::NEVER),
crs_5670);
}
{
// Pulkovo 42 Romania
auto crs_3844 = factory->createCoordinateReferenceSystem("3844");
- auto bound =
- crs_3844->createBoundCRSToWGS84IfPossible(dbContext, false);
+ auto bound = crs_3844->createBoundCRSToWGS84IfPossible(
+ dbContext, CoordinateOperationContext::IntermediateCRSUse::NEVER);
EXPECT_NE(bound, crs_3844);
- EXPECT_EQ(bound->createBoundCRSToWGS84IfPossible(dbContext, false),
+ EXPECT_EQ(bound->createBoundCRSToWGS84IfPossible(
+ dbContext,
+ CoordinateOperationContext::IntermediateCRSUse::NEVER),
bound);
auto boundCRS = nn_dynamic_pointer_cast<BoundCRS>(bound);
ASSERT_TRUE(boundCRS != nullptr);
@@ -4759,10 +4771,12 @@ TEST(crs, crs_createBoundCRSToWGS84IfPossible) {
{
// Pulkovo 42 Poland
auto crs_2171 = factory->createCoordinateReferenceSystem("2171");
- auto bound =
- crs_2171->createBoundCRSToWGS84IfPossible(dbContext, false);
+ auto bound = crs_2171->createBoundCRSToWGS84IfPossible(
+ dbContext, CoordinateOperationContext::IntermediateCRSUse::NEVER);
EXPECT_NE(bound, crs_2171);
- EXPECT_EQ(bound->createBoundCRSToWGS84IfPossible(dbContext, false),
+ EXPECT_EQ(bound->createBoundCRSToWGS84IfPossible(
+ dbContext,
+ CoordinateOperationContext::IntermediateCRSUse::NEVER),
bound);
auto boundCRS = nn_dynamic_pointer_cast<BoundCRS>(bound);
ASSERT_TRUE(boundCRS != nullptr);
@@ -4776,10 +4790,12 @@ TEST(crs, crs_createBoundCRSToWGS84IfPossible) {
{
// NTF (Paris)
auto crs_4807 = factory->createCoordinateReferenceSystem("4807");
- auto bound =
- crs_4807->createBoundCRSToWGS84IfPossible(dbContext, false);
+ auto bound = crs_4807->createBoundCRSToWGS84IfPossible(
+ dbContext, CoordinateOperationContext::IntermediateCRSUse::NEVER);
EXPECT_NE(bound, crs_4807);
- EXPECT_EQ(bound->createBoundCRSToWGS84IfPossible(dbContext, false),
+ EXPECT_EQ(bound->createBoundCRSToWGS84IfPossible(
+ dbContext,
+ CoordinateOperationContext::IntermediateCRSUse::NEVER),
bound);
auto boundCRS = nn_dynamic_pointer_cast<BoundCRS>(bound);
ASSERT_TRUE(boundCRS != nullptr);
@@ -4791,10 +4807,12 @@ TEST(crs, crs_createBoundCRSToWGS84IfPossible) {
{
// NTF (Paris) / Lambert zone II + NGF-IGN69 height
auto crs_7421 = factory->createCoordinateReferenceSystem("7421");
- auto bound =
- crs_7421->createBoundCRSToWGS84IfPossible(dbContext, false);
+ auto bound = crs_7421->createBoundCRSToWGS84IfPossible(
+ dbContext, CoordinateOperationContext::IntermediateCRSUse::NEVER);
EXPECT_NE(bound, crs_7421);
- EXPECT_EQ(bound->createBoundCRSToWGS84IfPossible(dbContext, false),
+ EXPECT_EQ(bound->createBoundCRSToWGS84IfPossible(
+ dbContext,
+ CoordinateOperationContext::IntermediateCRSUse::NEVER),
bound);
auto boundCRS = nn_dynamic_pointer_cast<BoundCRS>(bound);
ASSERT_TRUE(boundCRS != nullptr);
@@ -4807,13 +4825,17 @@ TEST(crs, crs_createBoundCRSToWGS84IfPossible) {
}
{
auto crs = createVerticalCRS();
- EXPECT_EQ(crs->createBoundCRSToWGS84IfPossible(dbContext, false), crs);
+ EXPECT_EQ(crs->createBoundCRSToWGS84IfPossible(
+ dbContext,
+ CoordinateOperationContext::IntermediateCRSUse::NEVER),
+ crs);
}
{
auto factoryIGNF =
AuthorityFactory::create(DatabaseContext::create(), "IGNF");
auto crs = factoryIGNF->createCoordinateReferenceSystem("TERA50STEREO");
- auto bound = crs->createBoundCRSToWGS84IfPossible(dbContext, false);
+ auto bound = crs->createBoundCRSToWGS84IfPossible(
+ dbContext, CoordinateOperationContext::IntermediateCRSUse::NEVER);
EXPECT_NE(bound, crs);
auto boundCRS = nn_dynamic_pointer_cast<BoundCRS>(bound);
ASSERT_TRUE(boundCRS != nullptr);
@@ -4827,7 +4849,8 @@ TEST(crs, crs_createBoundCRSToWGS84IfPossible) {
auto factoryIGNF =
AuthorityFactory::create(DatabaseContext::create(), "IGNF");
auto crs = factoryIGNF->createCoordinateReferenceSystem("PGP50");
- auto bound = crs->createBoundCRSToWGS84IfPossible(dbContext, false);
+ auto bound = crs->createBoundCRSToWGS84IfPossible(
+ dbContext, CoordinateOperationContext::IntermediateCRSUse::NEVER);
EXPECT_NE(bound, crs);
auto boundCRS = nn_dynamic_pointer_cast<BoundCRS>(bound);
ASSERT_TRUE(boundCRS != nullptr);
@@ -4838,7 +4861,8 @@ TEST(crs, crs_createBoundCRSToWGS84IfPossible) {
}
{
auto crs = factory->createCoordinateReferenceSystem("4269"); // NAD83
- auto bound = crs->createBoundCRSToWGS84IfPossible(dbContext, false);
+ auto bound = crs->createBoundCRSToWGS84IfPossible(
+ dbContext, CoordinateOperationContext::IntermediateCRSUse::NEVER);
EXPECT_EQ(bound, crs);
}
}
diff --git a/test/unit/test_factory.cpp b/test/unit/test_factory.cpp
index 40728f96..80de017f 100644
--- a/test/unit/test_factory.cpp
+++ b/test/unit/test_factory.cpp
@@ -28,6 +28,8 @@
#include "gtest_include.h"
+#include "test_primitives.hpp"
+
#include "proj/common.hpp"
#include "proj/coordinateoperation.hpp"
#include "proj/coordinatesystem.hpp"
@@ -991,10 +993,12 @@ TEST(factory, AuthorityFactory_test_uom_9110) {
auto factory = AuthorityFactory::create(DatabaseContext::create(), "EPSG");
// This tests conversion from unit of measure EPSG:9110 DDD.MMSSsss
auto crs = factory->createProjectedCRS("2172");
- EXPECT_EQ(crs->exportToPROJString(PROJStringFormatter::create().get()),
- "+proj=sterea +lat_0=53.0019444444444 +lon_0=21.5027777777778 "
- "+k=0.9998 +x_0=4603000 +y_0=5806000 +ellps=krass +units=m "
- "+no_defs +type=crs");
+ EXPECT_PRED_FORMAT2(
+ ComparePROJString,
+ crs->exportToPROJString(PROJStringFormatter::create().get()),
+ "+proj=sterea +lat_0=53.0019444444444 +lon_0=21.5027777777778 "
+ "+k=0.9998 +x_0=4603000 +y_0=5806000 +ellps=krass +units=m "
+ "+no_defs +type=crs");
}
// ---------------------------------------------------------------------------
@@ -1612,7 +1616,8 @@ class FactoryWithTmpDatabase : public ::testing::Test {
{
auto ctxt =
CoordinateOperationContext::create(factory, nullptr, 0);
- ctxt->setAllowUseIntermediateCRS(false);
+ ctxt->setAllowUseIntermediateCRS(
+ CoordinateOperationContext::IntermediateCRSUse::NEVER);
res = CoordinateOperationFactory::create()->createOperations(
srcCRS, targetCRS, ctxt);
EXPECT_EQ(res.size(), 1U);
diff --git a/test/unit/test_operation.cpp b/test/unit/test_operation.cpp
index 103b856c..90deb661 100644
--- a/test/unit/test_operation.cpp
+++ b/test/unit/test_operation.cpp
@@ -28,8 +28,12 @@
#include "gtest_include.h"
+#include "test_primitives.hpp"
+
// to be able to use internal::replaceAll
+#ifndef FROM_PROJ_CPP
#define FROM_PROJ_CPP
+#endif
#include "proj/common.hpp"
#include "proj/coordinateoperation.hpp"
@@ -4181,7 +4185,8 @@ TEST(operation, geogCRS_to_geogCRS_context_default) {
auto ctxt = CoordinateOperationContext::create(authFactory, nullptr, 0);
ctxt->setSpatialCriterion(
CoordinateOperationContext::SpatialCriterion::PARTIAL_INTERSECTION);
- ctxt->setAllowUseIntermediateCRS(false);
+ ctxt->setAllowUseIntermediateCRS(
+ CoordinateOperationContext::IntermediateCRSUse::NEVER);
// Directly found in database
{
@@ -4237,7 +4242,8 @@ TEST(operation, geogCRS_to_geogCRS_context_match_by_name) {
auto ctxt = CoordinateOperationContext::create(authFactory, nullptr, 0);
ctxt->setSpatialCriterion(
CoordinateOperationContext::SpatialCriterion::PARTIAL_INTERSECTION);
- ctxt->setAllowUseIntermediateCRS(false);
+ ctxt->setAllowUseIntermediateCRS(
+ CoordinateOperationContext::IntermediateCRSUse::NEVER);
auto NAD27 = GeographicCRS::create(
PropertyMap().set(IdentifiedObject::NAME_KEY,
GeographicCRS::EPSG_4267->nameStr()),
@@ -4577,6 +4583,8 @@ TEST(operation, geogCRS_to_geogCRS_context_concatenated_operation) {
auto authFactory =
AuthorityFactory::create(DatabaseContext::create(), "EPSG");
auto ctxt = CoordinateOperationContext::create(authFactory, nullptr, 0.0);
+ ctxt->setAllowUseIntermediateCRS(
+ CoordinateOperationContext::IntermediateCRSUse::ALWAYS);
auto list = CoordinateOperationFactory::create()->createOperations(
authFactory->createCoordinateReferenceSystem("4807"), // NTF(Paris)
authFactory->createCoordinateReferenceSystem("4171"), // RGF93
@@ -4640,6 +4648,8 @@ TEST(operation, geogCRS_to_geogCRS_CH1903_to_CH1903plus_context) {
auto authFactory =
AuthorityFactory::create(DatabaseContext::create(), "EPSG");
auto ctxt = CoordinateOperationContext::create(authFactory, nullptr, 0.0);
+ ctxt->setAllowUseIntermediateCRS(
+ CoordinateOperationContext::IntermediateCRSUse::ALWAYS);
auto list = CoordinateOperationFactory::create()->createOperations(
authFactory->createCoordinateReferenceSystem("4149"), // CH1903
authFactory->createCoordinateReferenceSystem("4150"), // CH1903+
@@ -4861,11 +4871,13 @@ TEST(operation, geocentricCRS_to_geocentricCRS_different_datum_context) {
authFactory->createCoordinateReferenceSystem("4896"), ctxt);
ASSERT_EQ(list.size(), 1U);
EXPECT_EQ(list[0]->nameStr(), "ITRF2000 to ITRF2005 (1)");
- EXPECT_EQ(list[0]->exportToPROJString(PROJStringFormatter::create().get()),
- "+proj=helmert +x=-0.0001 "
- "+y=0.0008 +z=0.0058 +rx=0 +ry=0 +rz=0 +s=-0.0004 +dx=0.0002 "
- "+dy=-0.0001 +dz=0.0018 +drx=0 +dry=0 +drz=0 +ds=-8e-05 "
- "+t_epoch=2000 +convention=position_vector");
+ EXPECT_PRED_FORMAT2(
+ ComparePROJString,
+ list[0]->exportToPROJString(PROJStringFormatter::create().get()),
+ "+proj=helmert +x=-0.0001 "
+ "+y=0.0008 +z=0.0058 +rx=0 +ry=0 +rz=0 +s=-0.0004 +dx=0.0002 "
+ "+dy=-0.0001 +dz=0.0018 +drx=0 +dry=0 +drz=0 +ds=-8e-05 "
+ "+t_epoch=2000 +convention=position_vector");
}
// ---------------------------------------------------------------------------
@@ -4904,15 +4916,17 @@ TEST(operation,
"Conversion from ITRF2000 (geog3D) to ITRF2000 (geocentric) + "
"ITRF2000 to ITRF2005 (1) + "
"Conversion from ITRF2005 (geocentric) to ITRF2005 (geog3D)");
- EXPECT_EQ(list[0]->exportToPROJString(PROJStringFormatter::create().get()),
- "+proj=pipeline +step +proj=axisswap +order=2,1 +step "
- "+proj=unitconvert +xy_in=deg +z_in=m +xy_out=rad +z_out=m "
- "+step +proj=cart +ellps=GRS80 +step +proj=helmert +x=-0.0001 "
- "+y=0.0008 +z=0.0058 +rx=0 +ry=0 +rz=0 +s=-0.0004 +dx=0.0002 "
- "+dy=-0.0001 +dz=0.0018 +drx=0 +dry=0 +drz=0 +ds=-8e-05 "
- "+t_epoch=2000 +convention=position_vector +step +inv "
- "+proj=cart +ellps=GRS80 +step +proj=unitconvert +xy_in=rad "
- "+z_in=m +xy_out=deg +z_out=m +step +proj=axisswap +order=2,1");
+ EXPECT_PRED_FORMAT2(
+ ComparePROJString,
+ list[0]->exportToPROJString(PROJStringFormatter::create().get()),
+ "+proj=pipeline +step +proj=axisswap +order=2,1 +step "
+ "+proj=unitconvert +xy_in=deg +z_in=m +xy_out=rad +z_out=m "
+ "+step +proj=cart +ellps=GRS80 +step +proj=helmert +x=-0.0001 "
+ "+y=0.0008 +z=0.0058 +rx=0 +ry=0 +rz=0 +s=-0.0004 +dx=0.0002 "
+ "+dy=-0.0001 +dz=0.0018 +drx=0 +dry=0 +drz=0 +ds=-8e-05 "
+ "+t_epoch=2000 +convention=position_vector +step +inv "
+ "+proj=cart +ellps=GRS80 +step +proj=unitconvert +xy_in=rad "
+ "+z_in=m +xy_out=deg +z_out=m +step +proj=axisswap +order=2,1");
}
// ---------------------------------------------------------------------------
@@ -4930,13 +4944,15 @@ TEST(operation, geogCRS_to_geocentricCRS_different_datum_context) {
EXPECT_EQ(list[0]->nameStr(),
"Conversion from ITRF2000 (geog3D) to ITRF2000 (geocentric) + "
"ITRF2000 to ITRF2005 (1)");
- EXPECT_EQ(list[0]->exportToPROJString(PROJStringFormatter::create().get()),
- "+proj=pipeline +step +proj=axisswap +order=2,1 +step "
- "+proj=unitconvert +xy_in=deg +z_in=m +xy_out=rad +z_out=m "
- "+step +proj=cart +ellps=GRS80 +step +proj=helmert +x=-0.0001 "
- "+y=0.0008 +z=0.0058 +rx=0 +ry=0 +rz=0 +s=-0.0004 +dx=0.0002 "
- "+dy=-0.0001 +dz=0.0018 +drx=0 +dry=0 +drz=0 +ds=-8e-05 "
- "+t_epoch=2000 +convention=position_vector");
+ EXPECT_PRED_FORMAT2(
+ ComparePROJString,
+ list[0]->exportToPROJString(PROJStringFormatter::create().get()),
+ "+proj=pipeline +step +proj=axisswap +order=2,1 +step "
+ "+proj=unitconvert +xy_in=deg +z_in=m +xy_out=rad +z_out=m "
+ "+step +proj=cart +ellps=GRS80 +step +proj=helmert +x=-0.0001 "
+ "+y=0.0008 +z=0.0058 +rx=0 +ry=0 +rz=0 +s=-0.0004 +dx=0.0002 "
+ "+dy=-0.0001 +dz=0.0018 +drx=0 +dry=0 +drz=0 +ds=-8e-05 "
+ "+t_epoch=2000 +convention=position_vector");
}
// ---------------------------------------------------------------------------
@@ -4954,13 +4970,15 @@ TEST(operation, geocentricCRS_to_geogCRS_different_datum_context) {
EXPECT_EQ(list[0]->nameStr(),
"ITRF2000 to ITRF2005 (1) + "
"Conversion from ITRF2005 (geocentric) to ITRF2005 (geog3D)");
- EXPECT_EQ(list[0]->exportToPROJString(PROJStringFormatter::create().get()),
- "+proj=pipeline +step +proj=helmert +x=-0.0001 "
- "+y=0.0008 +z=0.0058 +rx=0 +ry=0 +rz=0 +s=-0.0004 +dx=0.0002 "
- "+dy=-0.0001 +dz=0.0018 +drx=0 +dry=0 +drz=0 +ds=-8e-05 "
- "+t_epoch=2000 +convention=position_vector +step +inv "
- "+proj=cart +ellps=GRS80 +step +proj=unitconvert +xy_in=rad "
- "+z_in=m +xy_out=deg +z_out=m +step +proj=axisswap +order=2,1");
+ EXPECT_PRED_FORMAT2(
+ ComparePROJString,
+ list[0]->exportToPROJString(PROJStringFormatter::create().get()),
+ "+proj=pipeline +step +proj=helmert +x=-0.0001 "
+ "+y=0.0008 +z=0.0058 +rx=0 +ry=0 +rz=0 +s=-0.0004 +dx=0.0002 "
+ "+dy=-0.0001 +dz=0.0018 +drx=0 +dry=0 +drz=0 +ds=-8e-05 "
+ "+t_epoch=2000 +convention=position_vector +step +inv "
+ "+proj=cart +ellps=GRS80 +step +proj=unitconvert +xy_in=rad "
+ "+z_in=m +xy_out=deg +z_out=m +step +proj=axisswap +order=2,1");
}
// ---------------------------------------------------------------------------
@@ -4984,21 +5002,23 @@ TEST(operation, esri_projectedCRS_to_geogCRS_with_ITRF_intermediate_context) {
"(geocentric) + Inverse of ITRF2000 to NAD83(CORS96) (1) + "
"ITRF2000 to ITRF2005 (1) + "
"Conversion from ITRF2005 (geocentric) to ITRF2005 (geog3D)");
- EXPECT_EQ(list[0]->exportToPROJString(PROJStringFormatter::create().get()),
- "+proj=pipeline +step +proj=unitconvert +xy_in=us-ft +z_in=us-ft "
- "+xy_out=m +z_out=m +step +inv +proj=lcc +lat_0=33.75 +lon_0=-79 "
- "+lat_1=34.3333333333333 +lat_2=36.1666666666667 "
- "+x_0=609601.219202438 +y_0=0 +ellps=GRS80 +step +proj=cart "
- "+ellps=GRS80 +step +inv +proj=helmert +x=0.9956 +y=-1.9013 "
- "+z=-0.5215 +rx=0.025915 +ry=0.009426 +rz=0.011599 +s=0.00062 "
- "+dx=0.0007 +dy=-0.0007 +dz=0.0005 +drx=6.7e-05 +dry=-0.000757 "
- "+drz=-5.1e-05 +ds=-0.00018 +t_epoch=1997 "
- "+convention=coordinate_frame +step +proj=helmert +x=-0.0001 "
- "+y=0.0008 +z=0.0058 +rx=0 +ry=0 +rz=0 +s=-0.0004 +dx=0.0002 "
- "+dy=-0.0001 +dz=0.0018 +drx=0 +dry=0 +drz=0 +ds=-8e-05 "
- "+t_epoch=2000 +convention=position_vector +step +inv +proj=cart "
- "+ellps=GRS80 +step +proj=unitconvert +xy_in=rad +z_in=m "
- "+xy_out=deg +z_out=m +step +proj=axisswap +order=2,1");
+ EXPECT_PRED_FORMAT2(
+ ComparePROJString,
+ list[0]->exportToPROJString(PROJStringFormatter::create().get()),
+ "+proj=pipeline +step +proj=unitconvert +xy_in=us-ft +z_in=us-ft "
+ "+xy_out=m +z_out=m +step +inv +proj=lcc +lat_0=33.75 +lon_0=-79 "
+ "+lat_1=34.3333333333333 +lat_2=36.1666666666667 "
+ "+x_0=609601.219202438 +y_0=0 +ellps=GRS80 +step +proj=cart "
+ "+ellps=GRS80 +step +inv +proj=helmert +x=0.9956 +y=-1.9013 "
+ "+z=-0.5215 +rx=0.025915 +ry=0.009426 +rz=0.011599 +s=0.00062 "
+ "+dx=0.0007 +dy=-0.0007 +dz=0.0005 +drx=6.7e-05 +dry=-0.000757 "
+ "+drz=-5.1e-05 +ds=-0.00018 +t_epoch=1997 "
+ "+convention=coordinate_frame +step +proj=helmert +x=-0.0001 "
+ "+y=0.0008 +z=0.0058 +rx=0 +ry=0 +rz=0 +s=-0.0004 +dx=0.0002 "
+ "+dy=-0.0001 +dz=0.0018 +drx=0 +dry=0 +drz=0 +ds=-8e-05 "
+ "+t_epoch=2000 +convention=position_vector +step +inv +proj=cart "
+ "+ellps=GRS80 +step +proj=unitconvert +xy_in=rad +z_in=m "
+ "+xy_out=deg +z_out=m +step +proj=axisswap +order=2,1");
}
// ---------------------------------------------------------------------------
@@ -5113,6 +5133,8 @@ TEST(operation,
auto authFactory =
AuthorityFactory::create(DatabaseContext::create(), "EPSG");
auto ctxt = CoordinateOperationContext::create(authFactory, nullptr, 0.0);
+ ctxt->setAllowUseIntermediateCRS(
+ CoordinateOperationContext::IntermediateCRSUse::ALWAYS);
auto list = CoordinateOperationFactory::create()->createOperations(
authFactory->createCoordinateReferenceSystem("4807"), // NTF(Paris)
authFactory->createCoordinateReferenceSystem("32631"), // UTM31 WGS84
@@ -6191,6 +6213,8 @@ TEST(operation, IGNF_LAMB1_TO_EPSG_4326) {
auto authFactory =
AuthorityFactory::create(DatabaseContext::create(), std::string());
auto ctxt = CoordinateOperationContext::create(authFactory, nullptr, 0.0);
+ ctxt->setAllowUseIntermediateCRS(
+ CoordinateOperationContext::IntermediateCRSUse::ALWAYS);
auto list = CoordinateOperationFactory::create()->createOperations(
AuthorityFactory::create(DatabaseContext::create(), "IGNF")
->createCoordinateReferenceSystem("LAMB1"),
diff --git a/test/unit/test_primitives.hpp b/test/unit/test_primitives.hpp
new file mode 100644
index 00000000..86e52d0a
--- /dev/null
+++ b/test/unit/test_primitives.hpp
@@ -0,0 +1,99 @@
+/******************************************************************************
+ *
+ * Project: PROJ
+ * Purpose: Test ISO19111:2018 implementation
+ * Author: Even Rouault <even dot rouault at spatialys dot com>
+ *
+ ******************************************************************************
+ * Copyright (c) 2018, Even Rouault <even dot rouault at spatialys dot com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ ****************************************************************************/
+
+#include "gtest_include.h"
+
+#ifndef FROM_PROJ_CPP
+#define FROM_PROJ_CPP
+#endif
+
+#include "proj/internal/internal.hpp"
+
+#include <cmath>
+#include <cstdlib>
+
+using namespace osgeo::proj::internal;
+
+static ::testing::AssertionResult ComparePROJString(const char* m_expr,
+ const char* n_expr,
+ const std::string& m,
+ const std::string& n) {
+ //if (m == n) return ::testing::AssertionSuccess();
+ auto mTokens = split(m, ' ');
+ auto nTokens = split(n, ' ');
+ if( mTokens.size() == nTokens.size() )
+ {
+ bool success = true;
+ for( size_t i = 0; i < mTokens.size(); i++ )
+ {
+ auto mSubTokens = split(mTokens[i], '=');
+ auto nSubTokens = split(nTokens[i], '=');
+ if( mSubTokens.size() != nSubTokens.size() ) {
+ success = false;
+ break;
+ }
+ if( mSubTokens.size() == 2 && nSubTokens.size() == 2 ) {
+ if( mSubTokens[0] != nSubTokens[0] ) {
+ success = false;
+ break;
+ }
+ double mValue = 0.0;
+ bool mIsDouble = false;
+ try {
+ mValue = c_locale_stod(mSubTokens[1]);
+ mIsDouble = true;
+ } catch( const std::exception &) {}
+ double nValue = 0.0;
+ bool nIsDouble = false;
+ try {
+ nValue = c_locale_stod(nSubTokens[1]);
+ nIsDouble = true;
+ } catch( const std::exception &) {}
+ if( mIsDouble != nIsDouble ) {
+ success = false;
+ break;
+ }
+ if( mIsDouble ) {
+ success = std::abs(mValue - nValue) <= 1e-14 * std::abs(mValue);
+ } else {
+ success = mSubTokens[1] == nSubTokens[1];
+ }
+ if( !success ) {
+ break;
+ }
+ }
+ }
+
+ if( success ) {
+ return ::testing::AssertionSuccess();
+ }
+ }
+
+ return ::testing::AssertionFailure() << m_expr << " and " << n_expr
+ << " (" << m << " and " << n << ") are different";
+}