diff options
Diffstat (limited to 'test/unit/gie_self_tests.cpp')
| -rw-r--r-- | test/unit/gie_self_tests.cpp | 95 |
1 files changed, 52 insertions, 43 deletions
diff --git a/test/unit/gie_self_tests.cpp b/test/unit/gie_self_tests.cpp index 23684e68..71df8fe1 100644 --- a/test/unit/gie_self_tests.cpp +++ b/test/unit/gie_self_tests.cpp @@ -892,7 +892,7 @@ TEST(gie, proj_trans_generic) { TEST(gie, proj_create_crs_to_crs_from_pj_force_over) { - PJ_CONTEXT* ctx; + PJ_CONTEXT *ctx; ctx = proj_context_create(); ASSERT_TRUE(ctx != nullptr); @@ -902,26 +902,27 @@ TEST(gie, proj_create_crs_to_crs_from_pj_force_over) { auto epsg4326 = proj_create(ctx, "EPSG:4326"); ASSERT_TRUE(epsg4326 != nullptr); - + auto epsg3857 = proj_create(ctx, "EPSG:3857"); ASSERT_TRUE(epsg3857 != nullptr); { - const char* const options[] = { "FORCE_OVER=YES", nullptr }; - auto P = proj_create_crs_to_crs_from_pj(ctx, epsg4326, epsg3857, nullptr, options); + const char *const options[] = {"FORCE_OVER=YES", nullptr}; + auto P = proj_create_crs_to_crs_from_pj(ctx, epsg4326, epsg3857, + nullptr, options); ASSERT_TRUE(P != nullptr); ASSERT_TRUE(P->over); PJ_COORD input; PJ_COORD input_over; - //Test a point along the equator. - //The same point, but in two different representations. - input.xyz.x = 0; // Lat in deg - input.xyz.y = 140; // Long in deg + // Test a point along the equator. + // The same point, but in two different representations. + input.xyz.x = 0; // Lat in deg + input.xyz.y = 140; // Long in deg input.xyz.z = 0; - input_over.xyz.x = 0; // Lat in deg - input_over.xyz.y = -220; // Long in deg + input_over.xyz.x = 0; // Lat in deg + input_over.xyz.y = -220; // Long in deg input_over.xyz.z = 0; auto output = proj_trans(P, PJ_FWD, input); @@ -930,22 +931,24 @@ TEST(gie, proj_create_crs_to_crs_from_pj_force_over) { auto input_inv = proj_trans(P, PJ_INV, output); auto input_over_inv = proj_trans(P, PJ_INV, output_over); - //Web Mercator x's between 0 and 180 longitude come out positive. - //But when forcing the over flag, the -220 calculation makes it flip. + // Web Mercator x's between 0 and 180 longitude come out positive. + // But when forcing the over flag, the -220 calculation makes it flip. EXPECT_GT(output.xyz.x, 0); EXPECT_LT(output_over.xyz.x, 0); EXPECT_NEAR(output.xyz.x, 15584728.711058298, 1e-8); EXPECT_NEAR(output_over.xyz.x, -24490287.974520184, 1e-8); - //The distance from 140 to 180 and -220 to -180 should be pretty much the same. + // The distance from 140 to 180 and -220 to -180 should be pretty much + // the same. auto dx_o = fabs(output.xyz.x - 20037508.342789244); auto dx_over = fabs(output_over.xyz.x + 20037508.342789244); auto dx = fabs(dx_o - dx_over); EXPECT_NEAR(dx, 0, 1e-8); - //Check the inverse operations get us back close to our original input values. + // Check the inverse operations get us back close to our original input + // values. EXPECT_NEAR(input.xyz.x, input_inv.xyz.x, 1e-8); EXPECT_NEAR(input.xyz.y, input_inv.xyz.y, 1e-8); EXPECT_NEAR(input_over.xyz.x, input_over_inv.xyz.x, 1e-8); @@ -955,20 +958,22 @@ TEST(gie, proj_create_crs_to_crs_from_pj_force_over) { } { - //Try again with force over set to anything but YES to verify it didn't do anything. - const char* const options[] = { "FORCE_OVER=NO", nullptr }; - auto P = proj_create_crs_to_crs_from_pj(ctx, epsg4326, epsg3857, nullptr, options); + // Try again with force over set to anything but YES to verify it didn't + // do anything. + const char *const options[] = {"FORCE_OVER=NO", nullptr}; + auto P = proj_create_crs_to_crs_from_pj(ctx, epsg4326, epsg3857, + nullptr, options); ASSERT_TRUE(P != nullptr); ASSERT_FALSE(P->over); PJ_COORD input; PJ_COORD input_notOver; - input.xyz.x = 0; // Lat in deg - input.xyz.y = 140; // Long in deg + input.xyz.x = 0; // Lat in deg + input.xyz.y = 140; // Long in deg input.xyz.z = 0; - input_notOver.xyz.x = 0; // Lat in deg - input_notOver.xyz.y = -220; // Long in deg + input_notOver.xyz.x = 0; // Lat in deg + input_notOver.xyz.y = -220; // Long in deg input_notOver.xyz.z = 0; auto output = proj_trans(P, PJ_FWD, input); @@ -984,19 +989,20 @@ TEST(gie, proj_create_crs_to_crs_from_pj_force_over) { } { - //Try again with no options to verify it didn't do anything. - auto P = proj_create_crs_to_crs_from_pj(ctx, epsg4326, epsg3857, nullptr, nullptr); + // Try again with no options to verify it didn't do anything. + auto P = proj_create_crs_to_crs_from_pj(ctx, epsg4326, epsg3857, + nullptr, nullptr); ASSERT_TRUE(P != nullptr); ASSERT_FALSE(P->over); PJ_COORD input; PJ_COORD input_notOver; - input.xyz.x = 0; // Lat in deg - input.xyz.y = 140; // Long in deg + input.xyz.x = 0; // Lat in deg + input.xyz.y = 140; // Long in deg input.xyz.z = 0; - input_notOver.xyz.x = 0; // Lat in deg - input_notOver.xyz.y = -220; // Long in deg + input_notOver.xyz.x = 0; // Lat in deg + input_notOver.xyz.y = -220; // Long in deg input_notOver.xyz.z = 0; auto output = proj_trans(P, PJ_FWD, input); @@ -1012,49 +1018,52 @@ TEST(gie, proj_create_crs_to_crs_from_pj_force_over) { } { - //EPSG:4326 -> EPSG:27700 has more than one coordinate operation candidate. - const char* const options[] = { "FORCE_OVER=YES", nullptr }; - auto P = proj_create_crs_to_crs_from_pj(ctx, epsg4326, epsg27700, nullptr, options); + // EPSG:4326 -> EPSG:27700 has more than one coordinate operation + // candidate. + const char *const options[] = {"FORCE_OVER=YES", nullptr}; + auto P = proj_create_crs_to_crs_from_pj(ctx, epsg4326, epsg27700, + nullptr, options); ASSERT_TRUE(P != nullptr); ASSERT_TRUE(P->over); PJ_COORD input; PJ_COORD input_over; - input.xyz.x = 0; // Lat in deg - input.xyz.y = 140; // Long in deg + input.xyz.x = 0; // Lat in deg + input.xyz.y = 140; // Long in deg input.xyz.z = 0; - input_over.xyz.x = 0; // Lat in deg - input_over.xyz.y = -220; // Long in deg + input_over.xyz.x = 0; // Lat in deg + input_over.xyz.y = -220; // Long in deg input_over.xyz.z = 0; auto output = proj_trans(P, PJ_FWD, input); auto output_over = proj_trans(P, PJ_FWD, input_over); - //Doesn't actually change the result for this tmerc transformation. + // Doesn't actually change the result for this tmerc transformation. EXPECT_NEAR(output.xyz.x, 4980122.749364435, 1e-8); EXPECT_NEAR(output.xyz.y, 14467212.882603768, 1e-8); EXPECT_NEAR(output_over.xyz.x, 4980122.749364435, 1e-8); EXPECT_NEAR(output_over.xyz.y, 14467212.882603768, 1e-8); - + proj_destroy(P); } { - //Negative test for 27700. - const char* const options[] = { "FORCE_OVER=NO", nullptr }; - auto P = proj_create_crs_to_crs_from_pj(ctx, epsg4326, epsg27700, nullptr, options); + // Negative test for 27700. + const char *const options[] = {"FORCE_OVER=NO", nullptr}; + auto P = proj_create_crs_to_crs_from_pj(ctx, epsg4326, epsg27700, + nullptr, options); ASSERT_TRUE(P != nullptr); ASSERT_FALSE(P->over); PJ_COORD input; PJ_COORD input_over; - input.xyz.x = 0; // Lat in deg - input.xyz.y = 140; // Long in deg + input.xyz.x = 0; // Lat in deg + input.xyz.y = 140; // Long in deg input.xyz.z = 0; - input_over.xyz.x = 0; // Lat in deg - input_over.xyz.y = -220; // Long in deg + input_over.xyz.x = 0; // Lat in deg + input_over.xyz.y = -220; // Long in deg input_over.xyz.z = 0; auto output = proj_trans(P, PJ_FWD, input); |
