// Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, 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 template void test_mixed_point_types() { // Point test_mixed_identical_result("POINT(1 2)"); // Box test_mixed_identical_result < bg::model::box, bg::model::box > ("POLYGON((1 2,1 4,3 4,3 2,1 2))"); test_mixed_identical_result < bg::model::segment, bg::model::segment > ("LINESTRING(1 1,2 2)"); // Linestring test_mixed_identical_result < bg::model::linestring, bg::model::linestring > ("LINESTRING(1 1,2 2)"); // Ring test_mixed_identical_result < bg::model::ring, bg::model::ring > ("POLYGON((1 1,2 2,3 0,1 1))"); test_mixed_reversible_result < bg::model::ring, bg::model::ring > ( "POLYGON((1 1,2 2,3 0,1 1))", "POLYGON((1 1,3 0,2 2,1 1))" ); test_mixed < bg::model::ring, bg::model::ring > ( "POLYGON((1 1,2 2,3 0,1 1))", "POLYGON((1 1,2 2,3 0))", 3 ); test_mixed < bg::model::ring, bg::model::ring > ( "POLYGON((1 1,2 2,3 0))", "POLYGON((1 1,2 2,3 0,1 1))", 4 ); // Polygon test_mixed_reversible_result < bg::model::polygon, bg::model::polygon > ( "POLYGON((0 0,0 5,5 5,5 0,0 0),(1 1,3 2,2 4,1 1))", "POLYGON((0 0,5 0,5 5,0 5,0 0),(1 1,2 4,3 2,1 1))" ); test_mixed < bg::model::polygon, bg::model::polygon > ( "POLYGON((0 0,0 5,5 5,5 0,0 0),(1 1,3 2,2 4,1 1))", "POLYGON((0 0,5 0,5 5,0 5,0 0),(1 1,2 4,3 2,1 1))", 7 // WKT is closed, polygon is open ); // (polygon uses ring, so other tests omitted here) // Combinations: // ring <-> polygon test_mixed_identical_result < bg::model::polygon, bg::model::ring > ("POLYGON((1 1,2 2,3 0,1 1))"); test_mixed_reversible_result < bg::model::polygon, bg::model::ring > ( "POLYGON((1 1,2 2,3 0,1 1))", "POLYGON((1 1,3 0,2 2,1 1))" ); // Any hole will be omitted going from polygon to ring test_mixed < bg::model::polygon, bg::model::ring > ( "POLYGON((0 0,0 5,5 5,5 0,0 0),(1 1,3 2,2 4,1 1))", "POLYGON((0 0,0 5,5 5,5 0,0 0))", 5 ); // point -> box test_mixed < Point1, bg::model::box > ( "POINT(0 0)", "POLYGON((0 0,0 0,0 0,0 0,0 0))", 4 ); // segment -> line test_mixed < bg::model::segment, bg::model::linestring > ( "LINESTRING(0 0,1 1)", "LINESTRING(0 0,1 1)", 2 ); // box -> ring ( <- is NYI) test_mixed < bg::model::box, bg::model::ring > ( "BOX(0 0,2 2)", "POLYGON((0 0,0 2,2 2,2 0,0 0))", 5 ); test_mixed < bg::model::box, bg::model::ring > ( "BOX(0 0,2 2)", "POLYGON((0 0,2 0,2 2,0 2,0 0))", 5 ); test_mixed < bg::model::box, bg::model::ring > ( "BOX(0 0,2 2)", "POLYGON((0 0,0 2,2 2,2 0))", 4 ); test_mixed < bg::model::box, bg::model::ring > ( "BOX(0 0,2 2)", "POLYGON((0 0,2 0,2 2,0 2))", 4 ); // box -> polygon ( <- is NYI) test_mixed < bg::model::box, bg::model::polygon > ( "BOX(0 0,2 2)", "POLYGON((0 0,0 2,2 2,2 0,0 0))", 5 ); test_mixed < bg::model::box, bg::model::polygon > ( "BOX(0 0,2 2)", "POLYGON((0 0,2 0,2 2,0 2,0 0))", 5 ); test_mixed < bg::model::box, bg::model::polygon > ( "BOX(0 0,2 2)", "POLYGON((0 0,0 2,2 2,2 0,0 0))", 4 // WKT is closed, polygon is open ); test_mixed < bg::model::box, bg::model::polygon > ( "BOX(0 0,2 2)", "POLYGON((0 0,2 0,2 2,0 2,0 0))", 4 // WKT is closed, polygon is open ); } template void test_mixed_point_types_3d() { // Point test_mixed_identical_result("POINT(1 2 3)"); test_mixed_identical_result < bg::model::segment, bg::model::segment > ("LINESTRING(1 2 3,4 5 6)"); // Linestring test_mixed_identical_result < bg::model::linestring, bg::model::linestring > ("LINESTRING(1 2 3,4 5 6,7 8 9)"); // segment -> line test_mixed < bg::model::segment, bg::model::linestring > ( "LINESTRING(1 2 3,4 5 6)", "LINESTRING(1 2 3,4 5 6)", 2 ); } template void test_mixed_types() { test_mixed_point_types(); test_mixed_point_types(); } template void test_mixed_types_3d() { test_mixed_point_types_3d(); test_mixed_point_types_3d(); } void test_array() { int a[2] = {1, 2}; int b[2]; bg::convert(a, b); BOOST_CHECK_EQUAL(b[0], 1); BOOST_CHECK_EQUAL(b[1], 2); } int test_main(int, char* []) { test_mixed_types < bg::model::point, bg::model::point >(); test_mixed_types < boost::tuple, bg::model::point >(); test_mixed_types_3d < boost::tuple, bg::model::point >(); test_array(); return 0; }