]>
Commit | Line | Data |
---|---|---|
7c673cae | 1 | // Boost.Geometry (aka GGL, Generic Geometry Library) |
1e59de90 | 2 | |
7c673cae | 3 | // Copyright (c) 2011-2015 Barend Gehrels, Amsterdam, the Netherlands. |
1e59de90 TL |
4 | |
5 | // This file was modified by Oracle on 2021. | |
6 | // Modifications copyright (c) 2021, Oracle and/or its affiliates. | |
7 | // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle | |
8 | ||
7c673cae FG |
9 | // Use, modification and distribution is subject to the Boost Software License, |
10 | // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
11 | // http://www.boost.org/LICENSE_1_0.txt) | |
12 | ||
13 | #include <geometry_test_common.hpp> | |
14 | ||
1e59de90 TL |
15 | #include <boost/range/empty.hpp> |
16 | ||
7c673cae FG |
17 | #include <boost/geometry/algorithms/clear.hpp> |
18 | #include <boost/geometry/algorithms/num_points.hpp> | |
19 | ||
20 | #include <boost/geometry/io/wkt/wkt.hpp> | |
21 | ||
1e59de90 | 22 | #include <boost/geometry/geometries/adapted/boost_variant.hpp> |
7c673cae | 23 | #include <boost/geometry/geometries/geometries.hpp> |
1e59de90 | 24 | #include <boost/geometry/geometries/geometry_collection.hpp> |
7c673cae FG |
25 | #include <boost/geometry/geometries/point_xy.hpp> |
26 | ||
7c673cae FG |
27 | |
28 | template <typename Geometry> | |
1e59de90 | 29 | void test_geometry(std::string const& wkt, std::size_t expected_before, std::size_t expected_after) |
7c673cae FG |
30 | { |
31 | Geometry geometry; | |
32 | bg::read_wkt(wkt, geometry); | |
33 | boost::variant<Geometry> variant_geometry(geometry); | |
1e59de90 | 34 | bg::model::geometry_collection<boost::variant<Geometry>> gc{ variant_geometry }; |
7c673cae | 35 | |
1e59de90 | 36 | BOOST_CHECK_EQUAL(bg::num_points(geometry), expected_before); |
7c673cae | 37 | bg::clear(geometry); |
1e59de90 | 38 | BOOST_CHECK_EQUAL(bg::num_points(geometry), expected_after); |
7c673cae | 39 | |
1e59de90 | 40 | BOOST_CHECK_EQUAL(bg::num_points(variant_geometry), expected_before); |
7c673cae | 41 | bg::clear(variant_geometry); |
1e59de90 TL |
42 | BOOST_CHECK_EQUAL(bg::num_points(variant_geometry), expected_after); |
43 | ||
44 | BOOST_CHECK(! boost::empty(gc)); | |
45 | bg::clear(gc); | |
46 | BOOST_CHECK(boost::empty(gc)); | |
7c673cae FG |
47 | } |
48 | ||
49 | ||
50 | template <typename Point> | |
51 | void test_all() | |
52 | { | |
53 | typedef bg::model::polygon<Point> poly; | |
54 | typedef bg::model::linestring<Point> ls; | |
55 | typedef bg::model::multi_point<Point> mpoint; | |
56 | typedef bg::model::multi_linestring<ls> mls; | |
57 | typedef bg::model::multi_polygon<poly> mpoly; | |
58 | ||
1e59de90 TL |
59 | test_geometry<Point>("POINT(0 0)", 1, 1); |
60 | test_geometry<ls>("LINESTRING(0 0,0 1)", 2, 0); | |
61 | test_geometry<poly>("POLYGON((0 0,0 1,1 0,0 0))", 4, 0); | |
62 | test_geometry<mpoint>("MULTIPOINT((0 0),(0 1),(1 0),(0 0))", 4, 0); | |
63 | test_geometry<mls>("MULTILINESTRING((0 0,0 1),(1 0,0 0))", 4, 0); | |
64 | test_geometry<mpoly>("MULTIPOLYGON(((0 0,0 1,1 0,0 0)),((10 0,10 1,11 0,10 0)))", 8, 0); | |
7c673cae FG |
65 | } |
66 | ||
67 | ||
68 | int test_main( int , char* [] ) | |
69 | { | |
70 | test_all<bg::model::d2::point_xy<double> >(); | |
71 | ||
7c673cae FG |
72 | return 0; |
73 | } |