diff --git a/src/iso19111/io.cpp b/src/iso19111/io.cpp index c4f5c5469ec0..d055dee85003 100644 --- a/src/iso19111/io.cpp +++ b/src/iso19111/io.cpp @@ -18032,6 +18032,7 @@ PROJStringParser::Private::buildProjectedCRS(int iStep, <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD ======= ======= >>>>>>> locationtech-main @@ -18833,6 +18834,12 @@ PROJStringParser::Private::buildProjectedCRS(int iStep, >>>>>>> 885e4882b8 (Merge pull request #3524 from cffk/merid-update-fix) ======= >>>>>>> 0a2f6458d1 (Merge pull request #3524 from cffk/merid-update-fix) +======= + bool foundStrictlyMatchingMapping = false; + if (mappings.size() >= 2) { + // To distinguish for example +ortho from +ortho +f=0 + bool allMappingsHaveAuxParam = true; +>>>>>>> e827708321 (Merge pull request #3523 from rouault/cleanup_aeqd_s_forward) for (const auto *mappingIter : mappings) { if (mappingIter->proj_name_aux == nullptr) { allMappingsHaveAuxParam = false; @@ -18902,6 +18909,7 @@ PROJStringParser::Private::buildProjectedCRS(int iStep, <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD ======= ======= >>>>>>> 885e4882b8 (Merge pull request #3524 from cffk/merid-update-fix) @@ -19458,6 +19466,9 @@ PROJStringParser::Private::buildProjectedCRS(int iStep, ======= if (mapping) { >>>>>>> 0a2f6458d1 (Merge pull request #3524 from cffk/merid-update-fix) +======= + if (mapping && !foundStrictlyMatchingMapping) { +>>>>>>> e827708321 (Merge pull request #3523 from rouault/cleanup_aeqd_s_forward) mapping = selectSphericalOrEllipsoidal(mapping, geodCRS); } diff --git a/src/iso19111/operation/parammappings.cpp b/src/iso19111/operation/parammappings.cpp index d56ae772474d..5de127ecdc55 100644 --- a/src/iso19111/operation/parammappings.cpp +++ b/src/iso19111/operation/parammappings.cpp @@ -5960,6 +5960,7 @@ static const MethodMapping projectionMethodMappings[] = { >>>>>>> 0a2f6458d1 (Merge pull request #3524 from cffk/merid-update-fix) nullptr, paramsLonNatOrigin}, +<<<<<<< HEAD {EPSG_NAME_METHOD_LAMBERT_CYLINDRICAL_EQUAL_AREA_SPHERICAL, EPSG_CODE_METHOD_LAMBERT_CYLINDRICAL_EQUAL_AREA_SPHERICAL, "Cylindrical_Equal_Area", "cea", nullptr, paramsCEA}, @@ -6595,6 +6596,8 @@ static const MethodMapping projectionMethodMappings[] = { ======= >>>>>>> 0a2f6458d1 (Merge pull request #3524 from cffk/merid-update-fix) +======= +>>>>>>> e827708321 (Merge pull request #3523 from rouault/cleanup_aeqd_s_forward) {EPSG_NAME_METHOD_LAMBERT_CYLINDRICAL_EQUAL_AREA, EPSG_CODE_METHOD_LAMBERT_CYLINDRICAL_EQUAL_AREA, "Cylindrical_Equal_Area", "cea", nullptr, paramsCEA}, @@ -6642,6 +6645,7 @@ static const MethodMapping projectionMethodMappings[] = { <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD ======= ======= >>>>>>> 885e4882b8 (Merge pull request #3524 from cffk/merid-update-fix) @@ -6872,6 +6876,8 @@ static const MethodMapping projectionMethodMappings[] = { >>>>>>> 611a44b6fe (Merge pull request #3523 from rouault/cleanup_aeqd_s_forward) ======= >>>>>>> 42d859b743 (Merge pull request #3523 from rouault/cleanup_aeqd_s_forward) +======= +>>>>>>> e827708321 (Merge pull request #3523 from rouault/cleanup_aeqd_s_forward) {EPSG_NAME_METHOD_LAMBERT_CYLINDRICAL_EQUAL_AREA_SPHERICAL, EPSG_CODE_METHOD_LAMBERT_CYLINDRICAL_EQUAL_AREA_SPHERICAL, "Cylindrical_Equal_Area", "cea", "R_A", paramsCEA}, @@ -6906,6 +6912,7 @@ static const MethodMapping projectionMethodMappings[] = { <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD ======= >>>>>>> 0890f076c7 (Merge pull request #3523 from rouault/cleanup_aeqd_s_forward) ======= @@ -7336,6 +7343,8 @@ static const MethodMapping projectionMethodMappings[] = { >>>>>>> 885e4882b8 (Merge pull request #3524 from cffk/merid-update-fix) ======= >>>>>>> 0a2f6458d1 (Merge pull request #3524 from cffk/merid-update-fix) +======= +>>>>>>> e827708321 (Merge pull request #3523 from rouault/cleanup_aeqd_s_forward) {EPSG_NAME_METHOD_CASSINI_SOLDNER, EPSG_CODE_METHOD_CASSINI_SOLDNER, "Cassini_Soldner", "cass", nullptr, paramsNatOrigin}, @@ -8443,6 +8452,7 @@ static const MethodMapping projectionMethodMappings[] = { <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD ======= ======= >>>>>>> 885e4882b8 (Merge pull request #3524 from cffk/merid-update-fix) @@ -8999,6 +9009,9 @@ static const MethodMapping projectionMethodMappings[] = { ======= "Lambert_Azimuthal_Equal_Area", "laea", nullptr, paramsLaea}, >>>>>>> 0a2f6458d1 (Merge pull request #3524 from cffk/merid-update-fix) +======= + "Lambert_Azimuthal_Equal_Area", "laea", "R_A", paramsLaea}, +>>>>>>> e827708321 (Merge pull request #3523 from rouault/cleanup_aeqd_s_forward) {PROJ_WKT2_NAME_METHOD_MILLER_CYLINDRICAL, 0, "Miller_Cylindrical", "mill", "R_A", paramsMiller}, diff --git a/src/projections/aeqd.cpp b/src/projections/aeqd.cpp index 1cfc252ef81f..90a1817189f7 100644 --- a/src/projections/aeqd.cpp +++ b/src/projections/aeqd.cpp @@ -2843,6 +2843,7 @@ static PJ_XY aeqd_s_forward (PJ_LP lp, PJ *P) { /* Spheroidal, forward <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD ======= ======= >>>>>>> locationtech-main @@ -3751,23 +3752,28 @@ static PJ_XY aeqd_s_forward (PJ_LP lp, PJ *P) { /* Spheroidal, forward ======= >>>>>>> 0a2f6458d1 (Merge pull request #3524 from cffk/merid-update-fix) double coslam, cosphi, sinphi; +======= +>>>>>>> e827708321 (Merge pull request #3523 from rouault/cleanup_aeqd_s_forward) + + if (Q->mode == EQUIT) + { + const double cosphi = cos(lp.phi); + const double sinphi = sin(lp.phi); + const double coslam = cos(lp.lam); + const double sinlam = sin(lp.lam); - sinphi = sin(lp.phi); - cosphi = cos(lp.phi); - coslam = cos(lp.lam); - switch (Q->mode) { - case EQUIT: xy.y = cosphi * coslam; - goto oblcon; - case OBLIQ: - xy.y = Q->sinph0 * sinphi + Q->cosph0 * cosphi * coslam; -oblcon: + if (fabs(fabs(xy.y) - 1.) < TOL) <<<<<<< HEAD +<<<<<<< HEAD >>>>>>> 0a2f6458d1 (Merge pull request #3524 from cffk/merid-update-fix) >>>>>>> 885e4882b8 (Merge pull request #3524 from cffk/merid-update-fix) ======= >>>>>>> 0a2f6458d1 (Merge pull request #3524 from cffk/merid-update-fix) +======= + { +>>>>>>> e827708321 (Merge pull request #3523 from rouault/cleanup_aeqd_s_forward) if (xy.y < 0.) { proj_errno_set(P, PROJ_ERR_COORD_TRANSFM_OUTSIDE_PROJECTION_DOMAIN); return xy; @@ -3817,6 +3823,7 @@ static PJ_XY aeqd_s_forward (PJ_LP lp, PJ *P) { /* Spheroidal, forward <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD ======= ======= >>>>>>> locationtech-main @@ -5394,13 +5401,55 @@ static PJ_XY aeqd_s_forward (PJ_LP lp, PJ *P) { /* Spheroidal, forward ======= >>>>>>> 0a2f6458d1 (Merge pull request #3524 from cffk/merid-update-fix) else { +======= + } + else + { +>>>>>>> e827708321 (Merge pull request #3523 from rouault/cleanup_aeqd_s_forward) xy.y = acos(xy.y); xy.y /= sin(xy.y); - xy.x = xy.y * cosphi * sin(lp.lam); - xy.y *= (Q->mode == EQUIT) ? sinphi : - Q->cosph0 * sinphi - Q->sinph0 * cosphi * coslam; + xy.x = xy.y * cosphi * sinlam; + xy.y *= sinphi; + } + } + else if (Q->mode == OBLIQ) + { + const double cosphi = cos(lp.phi); + const double sinphi = sin(lp.phi); + const double coslam = cos(lp.lam); + const double sinlam = sin(lp.lam); + const double cosphi_x_coslam = cosphi * coslam; + + xy.y = Q->sinph0 * sinphi + Q->cosph0 * cosphi_x_coslam; + + if (fabs(fabs(xy.y) - 1.) < TOL) + { + if (xy.y < 0.) { + proj_errno_set(P, PROJ_ERR_COORD_TRANSFM_OUTSIDE_PROJECTION_DOMAIN); + return xy; + } + else + return aeqd_e_forward(lp, P); + } + else + { + xy.y = acos(xy.y); + xy.y /= sin(xy.y); + xy.x = xy.y * cosphi * sinlam; + xy.y *= Q->cosph0 * sinphi - Q->sinph0 * cosphi_x_coslam; + } + } + else + { + double coslam = cos(lp.lam); + double sinlam = sin(lp.lam); + if (Q->mode == N_POLE) + { + lp.phi = -lp.phi; + coslam = -coslam; } <<<<<<< HEAD +<<<<<<< HEAD >>>>>>> 0a2f6458d1 (Merge pull request #3524 from cffk/merid-update-fix) >>>>>>> 885e4882b8 (Merge pull request #3524 from cffk/merid-update-fix) ======= @@ -5837,6 +5886,8 @@ static PJ_XY aeqd_s_forward (PJ_LP lp, PJ *P) { /* Spheroidal, forward >>>>>>> 885e4882b8 (Merge pull request #3524 from cffk/merid-update-fix) ======= >>>>>>> 0a2f6458d1 (Merge pull request #3524 from cffk/merid-update-fix) +======= +>>>>>>> e827708321 (Merge pull request #3523 from rouault/cleanup_aeqd_s_forward) if (fabs(lp.phi - M_HALFPI) < EPS10) { proj_errno_set(P, PROJ_ERR_COORD_TRANSFM_OUTSIDE_PROJECTION_DOMAIN); return xy; @@ -5885,6 +5936,7 @@ static PJ_XY aeqd_s_forward (PJ_LP lp, PJ *P) { /* Spheroidal, forward <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD ======= ======= >>>>>>> 885e4882b8 (Merge pull request #3524 from cffk/merid-update-fix) @@ -6500,6 +6552,10 @@ static PJ_XY aeqd_s_forward (PJ_LP lp, PJ *P) { /* Spheroidal, forward xy.y *= coslam; break; >>>>>>> 0a2f6458d1 (Merge pull request #3524 from cffk/merid-update-fix) +======= + xy.x = xy.y * sinlam; + xy.y *= coslam; +>>>>>>> e827708321 (Merge pull request #3523 from rouault/cleanup_aeqd_s_forward) } return xy; } diff --git a/test/unit/test_io.cpp b/test/unit/test_io.cpp index fdeb4c27b6d9..e17a705606c1 100644 --- a/test/unit/test_io.cpp +++ b/test/unit/test_io.cpp @@ -14347,6 +14347,7 @@ TEST(io, projparse_cea_spherical) { <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD ======= ======= >>>>>>> 885e4882b8 (Merge pull request #3524 from cffk/merid-update-fix) @@ -14872,6 +14873,10 @@ TEST(io, projparse_cea_spherical_on_ellipsoid) { ======= >>>>>>> 9b68b76b81 (Fix build with -DPROJ_INTERNAL_CPP_NAMESPACE) >>>>>>> 26891e6f2b (Fix build with -DPROJ_INTERNAL_CPP_NAMESPACE) +======= +TEST(io, projparse_cea_spherical_on_ellipsoid) { + std::string input("+proj=cea +R_A +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 " +>>>>>>> e827708321 (Merge pull request #3523 from rouault/cleanup_aeqd_s_forward) "+ellps=WGS84 +units=m +no_defs +type=crs"); auto obj = PROJStringParser().createFromPROJString(input); auto crs = nn_dynamic_pointer_cast(obj); @@ -14917,6 +14922,7 @@ TEST(io, projparse_cea_spherical_on_ellipsoid) { <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD ======= >>>>>>> 0890f076c7 (Merge pull request #3523 from rouault/cleanup_aeqd_s_forward) ======= @@ -15347,6 +15353,8 @@ TEST(io, projparse_cea_spherical_on_ellipsoid) { >>>>>>> 885e4882b8 (Merge pull request #3524 from cffk/merid-update-fix) ======= >>>>>>> 0a2f6458d1 (Merge pull request #3524 from cffk/merid-update-fix) +======= +>>>>>>> e827708321 (Merge pull request #3523 from rouault/cleanup_aeqd_s_forward) TEST(io, projparse_cea_ellipsoidal) { auto obj = PROJStringParser().createFromPROJString( "+proj=cea +ellps=GRS80 +type=crs"); @@ -16014,6 +16022,7 @@ TEST(io, projparse_laea_ellipsoidal) { <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD ======= ======= >>>>>>> 885e4882b8 (Merge pull request #3524 from cffk/merid-update-fix) @@ -16244,6 +16253,8 @@ TEST(io, projparse_laea_ellipsoidal) { >>>>>>> 611a44b6fe (Merge pull request #3523 from rouault/cleanup_aeqd_s_forward) ======= >>>>>>> 42d859b743 (Merge pull request #3523 from rouault/cleanup_aeqd_s_forward) +======= +>>>>>>> e827708321 (Merge pull request #3523 from rouault/cleanup_aeqd_s_forward) TEST(io, projparse_laea_spherical_on_ellipsoid) { std::string input("+proj=laea +R_A +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 " "+ellps=WGS84 +units=m +no_defs +type=crs"); @@ -16291,6 +16302,7 @@ TEST(io, projparse_laea_spherical_on_ellipsoid) { <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD ======= >>>>>>> 0890f076c7 (Merge pull request #3523 from rouault/cleanup_aeqd_s_forward) ======= @@ -16721,6 +16733,8 @@ TEST(io, projparse_laea_spherical_on_ellipsoid) { >>>>>>> 885e4882b8 (Merge pull request #3524 from cffk/merid-update-fix) ======= >>>>>>> 0a2f6458d1 (Merge pull request #3524 from cffk/merid-update-fix) +======= +>>>>>>> e827708321 (Merge pull request #3523 from rouault/cleanup_aeqd_s_forward) TEST(io, projparse_eqc_spherical) { auto obj = PROJStringParser().createFromPROJString( "+proj=eqc +R=6371228 +type=crs"); diff --git a/test/unit/test_operation.cpp b/test/unit/test_operation.cpp index 70fad115c4da..86d19f8e26de 100644 --- a/test/unit/test_operation.cpp +++ b/test/unit/test_operation.cpp @@ -2509,6 +2509,7 @@ TEST(operation, lambert_cylindrical_equal_area_spherical_export) { <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD ======= ======= >>>>>>> 885e4882b8 (Merge pull request #3524 from cffk/merid-update-fix) @@ -3065,6 +3066,9 @@ TEST(operation, lambert_cylindrical_equal_area_spherical_export) { ======= "+proj=cea +lat_ts=1 +lon_0=2 +x_0=3 +y_0=4"); >>>>>>> 0a2f6458d1 (Merge pull request #3524 from cffk/merid-update-fix) +======= + "+proj=cea +R_A +lat_ts=1 +lon_0=2 +x_0=3 +y_0=4"); +>>>>>>> e827708321 (Merge pull request #3523 from rouault/cleanup_aeqd_s_forward) EXPECT_EQ(conv->exportToWKT(WKTFormatter::create().get()), "CONVERSION[\"Lambert Cylindrical Equal Area (Spherical)\",\n"