// Boost.Geometry (aka GGL, Generic Geometry Library) // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. // This file was modified by Oracle on 2013, 2014. // Modifications copyright (c) 2013-2014 Oracle and/or its affiliates. // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //TEST #include namespace bgdr = bg::detail::relate; template void check_geometry(Geometry1 const& geometry1, Geometry2 const& geometry2, std::string const& wkt1, std::string const& wkt2, std::string const& expected) { bgdr::result res = bgdr::relate(geometry1, geometry2); std::string res_str(boost::begin(res.get_code()), boost::end(res.get_code())); bool ok = boost::equal(res_str, expected); BOOST_CHECK_MESSAGE(ok, "relate: " << wkt1 << " and " << wkt2 << " -> Expected: " << expected << " detected: " << res_str); } template void test_geometry(std::string const& wkt1, std::string const& wkt2, std::string const& expected) { Geometry1 geometry1; Geometry2 geometry2; bg::read_wkt(wkt1, geometry1); bg::read_wkt(wkt2, geometry2); check_geometry(geometry1, geometry2, wkt1, wkt2, expected); } template void test_linestring_linestring() { typedef bg::model::linestring

ls; test_geometry("LINESTRING(0 0, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 3 2)", "1FFF0FFF2"); test_geometry("LINESTRING(0 0,3 2)", "LINESTRING(0 0, 2 2, 3 2)", "FF1F0F1F2"); test_geometry("LINESTRING(0 0, 1 1, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 3 2)", "1FFF0FFF2"); test_geometry("LINESTRING(3 2, 2 2, 1 1, 0 0)", "LINESTRING(0 0, 2 2, 3 2)", "1FFF0FFF2"); test_geometry("LINESTRING(0 0, 1 1, 2 2, 3 2)", "LINESTRING(3 2, 2 2, 0 0)", "1FFF0FFF2"); test_geometry("LINESTRING(3 2, 2 2, 1 1, 0 0)", "LINESTRING(3 2, 2 2, 0 0)", "1FFF0FFF2"); test_geometry("LINESTRING(3 1, 2 2, 1 1, 0 0)", "LINESTRING(0 0, 2 2, 3 2)", "1F1F00102"); test_geometry("LINESTRING(3 3, 2 2, 1 1, 0 0)", "LINESTRING(0 0, 2 2, 3 2)", "1F1F00102"); test_geometry("LINESTRING(0 0, 1 1, 2 2, 2 3)", "LINESTRING(0 0, 2 2, 2 3)", "1FFF0FFF2"); test_geometry("LINESTRING(2 3, 2 2, 1 1, 0 0)", "LINESTRING(0 0, 2 2, 2 3)", "1FFF0FFF2"); test_geometry("LINESTRING(0 0, 1 1, 2 2, 2 3)", "LINESTRING(2 3, 2 2, 0 0)", "1FFF0FFF2"); test_geometry("LINESTRING(2 3, 2 2, 1 1, 0 0)", "LINESTRING(2 3, 2 2, 0 0)", "1FFF0FFF2"); test_geometry("LINESTRING(1 1, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 4 2)", "1FF0FF102"); test_geometry("LINESTRING(3 2, 2 2, 1 1)", "LINESTRING(0 0, 2 2, 4 2)", "1FF0FF102"); test_geometry("LINESTRING(1 1, 2 2, 3 2)", "LINESTRING(4 2, 2 2, 0 0)", "1FF0FF102"); test_geometry("LINESTRING(3 2, 2 2, 1 1)", "LINESTRING(4 2, 2 2, 0 0)", "1FF0FF102"); // test_geometry("LINESTRING(1 1, 2 2, 2 2)", "LINESTRING(0 0, 2 2, 4 2)", true); // test_geometry("LINESTRING(1 1, 2 2, 3 3)", "LINESTRING(0 0, 2 2, 4 2)", false); // test_geometry("LINESTRING(1 1, 2 2, 3 2, 3 3)", "LINESTRING(0 0, 2 2, 4 2)", false); // test_geometry("LINESTRING(1 1, 2 2, 3 1)", "LINESTRING(0 0, 2 2, 4 2)", false); // test_geometry("LINESTRING(1 1, 2 2, 3 2, 3 1)", "LINESTRING(0 0, 2 2, 4 2)", false); // test_geometry("LINESTRING(0 1, 1 1, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 4 2)", false); // test_geometry("LINESTRING(0 1, 0 0, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 4 2)", false); // test_geometry("LINESTRING(1 0, 1 1, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 4 2)", false); // test_geometry("LINESTRING(1 0, 0 0, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 4 2)", false); // test_geometry("LINESTRING(0 0)", "LINESTRING(0 0)", false); // test_geometry("LINESTRING(1 1)", "LINESTRING(0 0, 2 2)", true); // test_geometry("LINESTRING(0 0)", "LINESTRING(0 0, 2 2)", false); // test_geometry("LINESTRING(0 0, 1 1)", "LINESTRING(0 0)", false); // test_geometry("LINESTRING(0 0,5 0,3 0,6 0)", "LINESTRING(0 0,6 0)", true); // test_geometry("LINESTRING(0 0,2 2,3 3,1 1)", "LINESTRING(0 0,3 3,6 3)", true); test_geometry("LINESTRING(0 0,2 2,3 3,1 1,5 3)", "LINESTRING(0 0,3 3,6 3)", "1F100F102"); test_geometry("LINESTRING(5 3,1 1,3 3,2 2,0 0)", "LINESTRING(0 0,3 3,6 3)", "1F100F102"); test_geometry("LINESTRING(0 0,2 2,3 3,1 1,5 3)", "LINESTRING(6 3,3 3,0 0)", "1F100F102"); test_geometry("LINESTRING(5 3,1 1,3 3,2 2,0 0)", "LINESTRING(6 3,3 3,0 0)", "1F100F102"); // spike test_geometry("LINESTRING(0 0,10 0)", "LINESTRING(1 0,9 0,2 0)", "101FF0FF2"); // loop i/i i/i u/u u/u test_geometry("LINESTRING(0 0,10 0)", "LINESTRING(1 1,1 0,6 0,6 1,4 1,4 0,9 0,9 1)", "1F1FF0102"); // self-touching test_geometry("LINESTRING(0 5,5 5,10 5,10 10,5 10,5 5,5 0)", "LINESTRING(0 5,5 5,5 10,10 10,10 5,5 5,5 0)", "1FFF0FFF2"); test_geometry("LINESTRING(0 0,1 1)", "LINESTRING(0 1,1 0)", "0F1FF0102"); test_geometry("LINESTRING(0 0,1 1)", "LINESTRING(1 1,2 0)", "FF1F00102"); test_geometry("LINESTRING(0 0,1 1)", "LINESTRING(2 0,1 1)", "FF1F00102"); } template void test_all() { test_linestring_linestring

(); } int test_main( int , char* [] ) { test_all >(); test_all >(); #if defined(HAVE_TTMATH) test_all >(); #endif return 0; }