Skip to content

Commit

Permalink
Adopt use of the noop conversion in ISO19111 code
Browse files Browse the repository at this point in the history
  • Loading branch information
kbevers committed Mar 29, 2019
1 parent 3d670b8 commit 47dd4db
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 22 deletions.
3 changes: 1 addition & 2 deletions src/iso19111/c_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@ static PJ *pj_obj_create(PJ_CONTEXT *ctx, const IdentifiedObjectNNPtr &objIn) {
auto formatter = PROJStringFormatter::create(
PROJStringFormatter::Convention::PROJ_5, dbContext);
auto projString = coordop->exportToPROJString(formatter.get());
auto pj = pj_create_internal(
ctx, projString.empty() ? "+proj=affine" : projString.c_str());
auto pj = pj_create_internal(ctx, projString.c_str());
if (pj) {
pj->iso_obj = objIn;
return pj;
Expand Down
5 changes: 5 additions & 0 deletions src/iso19111/io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5342,6 +5342,11 @@ const std::string &PROJStringFormatter::toString() const {
}
}
}

if (d->result_.empty()) {
d->appendToResult("+proj=noop");
}

return d->result_;
}

Expand Down
4 changes: 2 additions & 2 deletions test/cli/testprojinfo_out.dist
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ Operation n°1:
unknown id, Ballpark geographic offset from NAD27 to NAD83, unknown accuracy, World, has ballpark transformation

PROJ string:

+proj=noop

WKT2_2018 string:
COORDINATEOPERATION["Ballpark geographic offset from NAD27 to NAD83",
Expand Down Expand Up @@ -540,7 +540,7 @@ Operation n°7:
unknown id, Ballpark geographic offset from NAD27 to NAD83, unknown accuracy, World, has ballpark transformation

PROJ string:

+proj=noop

WKT2_2018 string:
COORDINATEOPERATION["Ballpark geographic offset from NAD27 to NAD83",
Expand Down
4 changes: 2 additions & 2 deletions test/unit/test_datum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ TEST(datum, prime_meridian_to_PROJString) {

EXPECT_EQ(PrimeMeridian::GREENWICH->exportToPROJString(
PROJStringFormatter::create().get()),
"");
"+proj=noop");

EXPECT_EQ(PrimeMeridian::PARIS->exportToPROJString(
PROJStringFormatter::create().get()),
Expand All @@ -195,7 +195,7 @@ TEST(datum, prime_meridian_to_PROJString) {
PropertyMap().set(IdentifiedObject::NAME_KEY, "Origin meridian"),
Angle(0))
->exportToPROJString(PROJStringFormatter::create().get()),
"");
"+proj=noop");

EXPECT_TRUE(PrimeMeridian::GREENWICH->isEquivalentTo(
PrimeMeridian::GREENWICH.get()));
Expand Down
12 changes: 6 additions & 6 deletions test/unit/test_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6541,7 +6541,7 @@ TEST(io, projstringformatter_helmert_3_param_noop) {
fmt->addParam("x", 0);
fmt->addParam("y", 0);
fmt->addParam("z", 0);
EXPECT_EQ(fmt->toString(), "");
EXPECT_EQ(fmt->toString(), "+proj=noop");
}

// ---------------------------------------------------------------------------
Expand All @@ -6557,7 +6557,7 @@ TEST(io, projstringformatter_helmert_7_param_noop) {
fmt->addParam("rz", 0);
fmt->addParam("s", 0);
fmt->addParam("convention", "position_vector");
EXPECT_EQ(fmt->toString(), "");
EXPECT_EQ(fmt->toString(), "+proj=noop");
}

// ---------------------------------------------------------------------------
Expand Down Expand Up @@ -6587,7 +6587,7 @@ TEST(io, projstringformatter_merge_consecutive_helmert_3_param_noop) {
fmt->addParam("x", -10);
fmt->addParam("y", -20);
fmt->addParam("z", -30);
EXPECT_EQ(fmt->toString(), "");
EXPECT_EQ(fmt->toString(), "+proj=noop");
}

// ---------------------------------------------------------------------------
Expand All @@ -6599,7 +6599,7 @@ TEST(io, projstringformatter_cart_grs80_wgs84) {
fmt->addStep("cart");
fmt->setCurrentStepInverted(true);
fmt->addParam("ellps", "GRS80");
EXPECT_EQ(fmt->toString(), "");
EXPECT_EQ(fmt->toString(), "+proj=noop");
}

// ---------------------------------------------------------------------------
Expand Down Expand Up @@ -7334,7 +7334,7 @@ TEST(io, projparse_longlat_axis_neu) {
auto op = CoordinateOperationFactory::create()->createOperation(
GeographicCRS::EPSG_4326, NN_NO_CHECK(crs));
ASSERT_TRUE(op != nullptr);
EXPECT_EQ(op->exportToPROJString(PROJStringFormatter::create().get()), "");
EXPECT_EQ(op->exportToPROJString(PROJStringFormatter::create().get()), "+proj=noop");
}

// ---------------------------------------------------------------------------
Expand Down Expand Up @@ -7437,7 +7437,7 @@ TEST(io, projparse_longlat_axisswap) {
EXPECT_EQ(
op->exportToPROJString(PROJStringFormatter::create().get()),
(atoi(order1) == 2 && atoi(order2) == 1)
? ""
? "+proj=noop"
: "+proj=pipeline +step +proj=axisswap +order=2,1 "
"+step +proj=axisswap +order=" +
std::string(order1) + "," + order2);
Expand Down
20 changes: 10 additions & 10 deletions test/unit/test_operation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ TEST(operation, transformation_createGeocentricTranslations_null) {

EXPECT_EQ(transf->inverse()->exportToPROJString(
PROJStringFormatter::create().get()),
"");
"+proj=noop");
}

// ---------------------------------------------------------------------------
Expand Down Expand Up @@ -956,7 +956,7 @@ TEST(operation, transformation_successive_helmert_noop) {
std::vector<PositionalAccuracyNNPtr>{});

EXPECT_EQ(concat->exportToPROJString(PROJStringFormatter::create().get()),
"");
"+proj=noop");
}

// ---------------------------------------------------------------------------
Expand Down Expand Up @@ -4131,7 +4131,7 @@ TEST(operation, PROJ_based_empty) {
SingleOperation::createPROJBased(PropertyMap(), "", nullptr, nullptr);

EXPECT_EQ(conv->exportToPROJString(PROJStringFormatter::create().get()),
"");
"+proj=noop");

EXPECT_EQ(conv->exportToWKT(WKTFormatter::create().get()),
"CONVERSION[\"PROJ-based coordinate operation\",\n"
Expand All @@ -4144,7 +4144,7 @@ TEST(operation, PROJ_based_empty) {

EXPECT_EQ(conv->inverse()->exportToPROJString(
PROJStringFormatter::create().get()),
"");
"+proj=noop");
}

// ---------------------------------------------------------------------------
Expand Down Expand Up @@ -4328,7 +4328,7 @@ TEST(operation, geogCRS_to_geogCRS_context_filter_bbox) {
ASSERT_EQ(list.size(), 1U);
EXPECT_EQ(
list[0]->exportToPROJString(PROJStringFormatter::create().get()),
"");
"+proj=noop");
}
}

Expand All @@ -4344,7 +4344,7 @@ TEST(operation, geogCRS_to_geogCRS_context_incompatible_area) {
ctxt);
ASSERT_EQ(list.size(), 1U);
EXPECT_EQ(list[0]->exportToPROJString(PROJStringFormatter::create().get()),
"");
"+proj=noop");
}

// ---------------------------------------------------------------------------
Expand Down Expand Up @@ -4504,7 +4504,7 @@ TEST(operation, geogCRS_to_geogCRS_noop) {
GeographicCRS::EPSG_4326, GeographicCRS::EPSG_4326);
ASSERT_TRUE(op != nullptr);
EXPECT_EQ(op->nameStr(), "Null geographic offset from WGS 84 to WGS 84");
EXPECT_EQ(op->exportToPROJString(PROJStringFormatter::create().get()), "");
EXPECT_EQ(op->exportToPROJString(PROJStringFormatter::create().get()), "+proj=noop");
EXPECT_EQ(op->inverse()->nameStr(), op->nameStr());
}

Expand Down Expand Up @@ -4651,7 +4651,7 @@ TEST(operation, geogCRS_to_geogCRS_CH1903_to_CH1903plus_context) {
EXPECT_EQ(list[0]->nameStr(),
"CH1903 to ETRS89 (1) + Inverse of CH1903+ to ETRS89 (1)");
EXPECT_EQ(list[0]->exportToPROJString(PROJStringFormatter::create().get()),
"");
"+proj=noop");

EXPECT_EQ(list[1]->nameStr(), "CH1903 to CH1903+ (1)");
EXPECT_EQ(list[1]->exportToPROJString(PROJStringFormatter::create().get()),
Expand Down Expand Up @@ -4799,7 +4799,7 @@ TEST(operation, geocentricCRS_to_geocentricCRS_noop) {
ASSERT_TRUE(op != nullptr);
EXPECT_EQ(op->nameStr(),
"Ballpark geocentric translation from WGS 84 to WGS 84");
EXPECT_EQ(op->exportToPROJString(PROJStringFormatter::create().get()), "");
EXPECT_EQ(op->exportToPROJString(PROJStringFormatter::create().get()), "+proj=noop");
EXPECT_EQ(op->inverse()->nameStr(), op->nameStr());
}

Expand Down Expand Up @@ -6449,7 +6449,7 @@ TEST(operation, compoundCRS_to_geogCRS_3D_context) {
PROJStringFormatter::Convention::PROJ_5,
authFactory->databaseContext())
.get()),
"");
"+proj=noop");
}
}

Expand Down

0 comments on commit 47dd4db

Please sign in to comment.