• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 // Unit Test
3 
4 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
5 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
6 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
7 
8 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
9 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
10 
11 // Use, modification and distribution is subject to the Boost Software License,
12 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
13 // http://www.boost.org/LICENSE_1_0.txt)
14 
15 
16 #include <sstream>
17 
18 #include <geometry_test_common.hpp>
19 
20 #include <boost/geometry/io/dsv/write.hpp>
21 
22 
23 #include <boost/geometry/geometries/geometries.hpp>
24 
25 #include <boost/geometry/io/wkt/read.hpp>
26 
27 
28 
29 template <typename G>
test_dsv(std::string const & wkt,std::string const & dsv)30 void test_dsv(std::string const& wkt, std::string const& dsv)
31 {
32     G geometry;
33 
34     bg::read_wkt(wkt, geometry);
35 
36     std::ostringstream out;
37     out << bg::dsv(geometry);
38     BOOST_CHECK_EQUAL(out.str(), dsv);
39 }
40 
41 
42 #ifndef GEOMETRY_TEST_MULTI
43 template <typename T>
test_all()44 void test_all()
45 {
46     using namespace boost::geometry;
47     typedef model::point<T, 2, cs::cartesian> P;
48 
49     test_dsv<P >("POINT(1 2)", "(1, 2)");
50     test_dsv<model::linestring<P> >(
51         "LINESTRING(1 1,2 2,3 3)",
52         "((1, 1), (2, 2), (3, 3))");
53     test_dsv<model::polygon<P> >("POLYGON((0 0,0 4,4 4,4 0,0 0))",
54         "(((0, 0), (0, 4), (4, 4), (4, 0), (0, 0)))");
55 
56     test_dsv<model::ring<P> >("POLYGON((0 0,0 4,4 4,4 0,0 0))",
57         "((0, 0), (0, 4), (4, 4), (4, 0), (0, 0))");
58 
59     test_dsv<model::box<P> >("BOX(0 0,1 1)",
60         "((0, 0), (1, 1))");
61 }
62 #endif
63 
64 
test_main(int,char * [])65 int test_main(int, char* [])
66 {
67     test_all<double>();
68     test_all<int>();
69 
70 
71     return 0;
72 }
73 
74