// Boost.Geometry // Unit Test // Copyright (c) 2018, Oracle and/or its affiliates. // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle // Licensed under the Boost Software License version 1.0. // http://www.boost.org/users/license.html #include #include #include #include #include #include #include #include #include #include #include #include #include template void check_points(P const& p0, P const& p1) { double p00 = bg::get<0>(p0); double p10 = bg::get<0>(p1); BOOST_CHECK_CLOSE(p00, p10, 0.0000001); double p01 = bg::get<1>(p0); double p11 = bg::get<1>(p1); BOOST_CHECK_CLOSE(p01, p11, 0.0000001); } template inline void test(std::string const& wkt1, double fraction, std::string const& wkt2) { G g; bg::read_wkt(wkt1, g); P o; bg::read_wkt(wkt2, o); P p; bg::line_interpolate_point(g, fraction, p); check_points(p, o); } template void test_all() { typedef bg::model::segment

s_t; typedef bg::model::linestring

ls_t; test("LINESTRING(0 0, 1 0, 1 1, 0 1, 0 2)", 0, "POINT(0 0)"); test("LINESTRING(0 0, 1 0, 1 1, 0 1, 0 2)", 0.1, "POINT(0.4 0)"); test("LINESTRING(0 0, 1 0, 1 1, 0 1, 0 2)", 0.2, "POINT(0.8 0)"); test("LINESTRING(0 0, 1 0, 1 1, 0 1, 0 2)", 0.3, "POINT(1 0.2)"); test("LINESTRING(0 0, 1 0, 1 1, 0 1, 0 2)", 0.4, "POINT(1 0.6)"); test("LINESTRING(0 0, 1 0, 1 1, 0 1, 0 2)", 0.5, "POINT(1 1)"); test("LINESTRING(0 0, 1 0, 1 1, 0 1, 0 2)", 0.6, "POINT(0.6 1)"); test("LINESTRING(0 0, 1 0, 1 1, 0 1, 0 2)", 0.7, "POINT(0.2 1)"); test("LINESTRING(0 0, 1 0, 1 1, 0 1, 0 2)", 0.8, "POINT(0 1.2)"); test("LINESTRING(0 0, 1 0, 1 1, 0 1, 0 2)", 0.9, "POINT(0 1.6)"); test("LINESTRING(0 0, 1 0, 1 1, 0 1, 0 2)", 1, "POINT(0 2)"); } int test_main(int, char* []) { test_all< bg::model::point >(); //test_all< bg::model::point > >(); //test_all< bg::model::point > >(); return 0; }