Skip to content

Commit

Permalink
Merge pull request #2867 from rouault/fix_2866
Browse files Browse the repository at this point in the history
proj_normalize_for_visualization(): set input and output units when there are several alternative transformations (fixes #2866)
  • Loading branch information
rouault authored Sep 24, 2021
2 parents 35fe5da + 1d6c202 commit a9ac32e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/iso19111/c_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8711,6 +8711,10 @@ PJ *proj_normalize_for_visualization(PJ_CONTEXT *ctx, const PJ *obj) {
if (!pjNew)
return nullptr;
pjNew->ctx = ctx;
pjNew->descr = "Set of coordinate operations";
pjNew->left = obj->left;
pjNew->right = obj->right;

for (const auto &alt : obj->alternativeCoordinateOperations) {
auto co = dynamic_cast<const CoordinateOperation *>(
alt.pj->iso_obj.get());
Expand Down
9 changes: 9 additions & 0 deletions test/unit/test_c_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3998,6 +3998,9 @@ TEST_F(CApi, proj_normalize_for_visualization) {
EXPECT_EQ(std::string(projstr),
"+proj=pipeline +step +proj=unitconvert +xy_in=deg +xy_out=rad "
"+step +proj=utm +zone=31 +ellps=WGS84");

EXPECT_TRUE(proj_degree_input(Pnormalized, PJ_FWD));
EXPECT_FALSE(proj_degree_output(Pnormalized, PJ_FWD));
}

// ---------------------------------------------------------------------------
Expand All @@ -4011,6 +4014,9 @@ TEST_F(CApi, proj_normalize_for_visualization_with_alternatives) {
ObjectKeeper keeper_Pnormalized(Pnormalized);
ASSERT_NE(Pnormalized, nullptr);

EXPECT_TRUE(proj_degree_input(Pnormalized, PJ_FWD));
EXPECT_FALSE(proj_degree_output(Pnormalized, PJ_FWD));

{
PJ_COORD c;
// Approximately Roma
Expand Down Expand Up @@ -4057,6 +4063,9 @@ TEST_F(CApi, proj_normalize_for_visualization_with_alternatives_reverse) {
ObjectKeeper keeper_Pnormalized(Pnormalized);
ASSERT_NE(Pnormalized, nullptr);

EXPECT_FALSE(proj_degree_input(Pnormalized, PJ_FWD));
EXPECT_TRUE(proj_degree_output(Pnormalized, PJ_FWD));

PJ_COORD c;
// Approximately Roma
c.xyzt.x = 1789912.46264783037;
Expand Down

0 comments on commit a9ac32e

Please sign in to comment.