aboutsummaryrefslogtreecommitdiff
path: root/test
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 /test
parent24ce8716974020600aa22fe7334628a29f578774 (diff)
parent4277e15cefae5bb1d49312498e0f626b652e7524 (diff)
downloadPROJ-f61aa8a01961cff194fcf49c66e4ca9b4bd68052.tar.gz
PROJ-f61aa8a01961cff194fcf49c66e4ca9b4bd68052.zip
Merge remote-tracking branch 'osgeo/master' into 6.0
Diffstat (limited to 'test')
-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
6 files changed, 227 insertions, 73 deletions
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";
+}