// 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 #include #include #include #include #include #include #include #include #include #include #include #include BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(cs::cartesian) BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian) BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED(std::vector) BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED(std::deque) //#define TEST_FAIL_CLEAR //#define TEST_FAIL_APPEND // ---------------------------------------------------------------------------- // First custom linestring, requires ONLY one traits: to register itself as a linestring template struct custom_linestring1 : std::vector

{}; namespace boost { namespace geometry { namespace traits { template struct tag< custom_linestring1

> { typedef linestring_tag type; }; }}} // namespace bg::traits // ---------------------------------------------------------------------------- // Second custom linestring, decides to implement all edit operations itself // by specializing the "use_std" traits to false. // It should therefore implement the traits:: clear / append_point template struct custom_linestring2 : std::deque

// std::pair::const_iterator, typename std::vector

::const_iterator> { }; namespace boost { namespace geometry { namespace traits { template struct tag< custom_linestring2

> { typedef linestring_tag type; }; #if ! defined(TEST_FAIL_CLEAR) template struct clear< custom_linestring2

> { // does not use std::vector

.clear() but something else. static inline void apply(custom_linestring2

& ls) { ls.resize(0); } }; #endif }}} // namespace bg::traits // ---------------------------------------------------------------------------- template void test_linestring() { BOOST_CONCEPT_ASSERT( (bg::concepts::Linestring) ); BOOST_CONCEPT_ASSERT( (bg::concepts::ConstLinestring) ); G geometry; typedef typename bg::point_type::type P; bg::clear(geometry); BOOST_CHECK_EQUAL(boost::size(geometry), 0u); bg::append(geometry, bg::make_zero

()); BOOST_CHECK_EQUAL(boost::size(geometry), 1u); //std::cout << geometry << std::endl; bg::clear(geometry); BOOST_CHECK_EQUAL(boost::size(geometry), 0u); //P p = boost::range::front(geometry); } template void test_all() { test_linestring >(); test_linestring >(); test_linestring >(); test_linestring >(); test_linestring >(); test_linestring >(); test_linestring >(); //test_linestring >(); } int test_main(int, char* []) { test_all(); test_all >(); test_all >(); test_all >(); test_all >(); return 0; }