// Boost.Geometry (aka GGL, Generic Geometry Library) // // Copyright Barend Gehrels, Geodan B.V. Amsterdam, the Netherlands. // 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) #include #include template void test_all() { typedef bg::model::box

box; typedef bg::model::ring

ring; typedef bg::model::polygon

polygon; typedef bg::model::linestring

linestring; test_geometry("p1", "POINT(1 1)", "POINT(1 1)", true); test_geometry("p2", "POINT(1 1)", "POINT(1 2)", false); test_geometry("b1", "BOX(1 1,2 2)", "BOX(1 2,2 2)", false); test_geometry("b1", "BOX(1 2,3 4)", "BOX(1 2,3 4)", true); std::string case_p1 = "POLYGON((0 0,0 2,2 2,0 0))"; // Completely equal test_geometry("poly_eq", case_p1, case_p1, true); // Shifted test_geometry("poly_sh", "POLYGON((2 2,0 0,0 2,2 2))", case_p1, true); test_geometry("poly_sh2", case_p1, "POLYGON((0 2,2 2,0 0,0 2))", true); // Extra coordinate test_geometry("poly_extra", case_p1, "POLYGON((0 0,0 2,2 2,1 1,0 0))", true); // Degenerate points test_geometry("poly_degenerate", "POLYGON((0 0,0 2,2 2,2 2,0 0))", "POLYGON((0 0,0 2,0 2,2 2,0 0))", true); // Two different bends, same area, unequal test_geometry("poly_bends", "POLYGON((4 0,5 3,8 4,7 7,4 8,0 4,4 0))", "POLYGON((4 0,7 1,8 4,5 5,4 8,0 4,4 0))", false); // Unequal (but same area) test_geometry("poly_uneq", case_p1, "POLYGON((1 1,1 3,3 3,1 1))", false); // One having hole test_geometry("poly_hole", "POLYGON((0 0,0 4,4 4,0 0))", "POLYGON((0 0,0 4,4 4,0 0),(1 1,2 1,2 2,1 2,1 1))", false); // Both having holes test_geometry("poly_holes", "POLYGON((0 0,0 4,4 4,0 0),(1 1,2 1,2 2,1 2,1 1))", "POLYGON((0 0,0 4,4 4,0 0),(1 1,2 1,2 2,1 2,1 1))", true); // Both having holes, outer equal, inner not equal test_geometry("poly_uneq_holes", "POLYGON((0 0,0 4,4 4,0 0),(1 1,2 1,2 2,1 2,1 1))", "POLYGON((0 0,0 4,4 4,0 0),(2 2,3 2,3 3,2 3,2 2))", false); // Both having 2 holes, equal but in different order test_geometry("poly_holes_diff_order", "POLYGON((0 0,0 4,4 4,0 0),(1 1,2 1,2 2,1 2,1 1),(2 2,3 2,3 3,2 3,2 2))", "POLYGON((0 0,0 4,4 4,0 0),(2 2,3 2,3 3,2 3,2 2),(1 1,2 1,2 2,1 2,1 1))", true); // Both having 3 holes, equal but in different order test_geometry("poly_holes_diff_order_3", "POLYGON((0 0,0 10,10 10,0 0),(1 1,2 1,2 2,1 2,1 1),(4 1,5 1,5 2,4 2,4 1),(2 2,3 2,3 3,2 3,2 2))", "POLYGON((0 0,0 10,10 10,0 0),(4 1,5 1,5 2,4 2,4 1),(2 2,3 2,3 3,2 3,2 2),(1 1,2 1,2 2,1 2,1 1))", true); // polygon/ring vv test_geometry("poly_sh2_pr", case_p1, case_p1, true); test_geometry("poly_sh2_rp", case_p1, case_p1, true); // box/ring/poly test_geometry("boxring1", "BOX(1 1,2 2)", "POLYGON((1 1,1 2,2 2,2 1,1 1))", true); test_geometry("boxring2", "POLYGON((1 1,1 2,2 2,2 1,1 1))", "BOX(1 1,2 2)", true); test_geometry("boxpoly1", "BOX(1 1,2 2)", "POLYGON((1 1,1 2,2 2,2 1,1 1))", true); test_geometry("boxpoly2", "POLYGON((1 1,1 2,2 2,2 1,1 1))", "BOX(1 1,2 2)", true); test_geometry("boxpoly2", "POLYGON((1 1,1 2,2 2,2 1,1 1))", "BOX(1 1,2 3)", false); // linestring/linestring // simplex test_geometry("ls1", "LINESTRING(1 1,2 2)", "LINESTRING(1 1,2 2)", true); // REVERSE linestring // Is this equal? To be decided. //test_geometry("ls1", "LINESTRING(1 1,2 2)", "LINESTRING(2 2,1 1)", true); } int test_main( int , char* [] ) { test_all >(); test_all >(); #if defined(HAVE_TTMATH) test_all >(); #endif return 0; }