• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1  // Boost.Geometry (aka GGL, Generic Geometry Library)
2  //
3  // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
4  // Use, modification and distribution is subject to the Boost Software License,
5  // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6  // http://www.boost.org/LICENSE_1_0.txt)
7  
8  #include <algorithms/test_convert.hpp>
9  
10  
11  template <typename Point1, typename Point2>
test_mixed_point_types()12  void test_mixed_point_types()
13  {
14      test_mixed_identical_result
15          <
16              bg::model::multi_point<Point1>,
17              bg::model::multi_point<Point2>
18          >
19          ("MULTIPOINT((1 1),(2 2),(3 3))");
20  
21      test_mixed_identical_result
22          <
23              bg::model::multi_linestring<bg::model::linestring<Point1> >,
24              bg::model::multi_linestring<bg::model::linestring<Point2> >
25          >
26          ("MULTILINESTRING((1 1,2 2),(3 3,4 4))");
27  
28      // Single -> multi (always possible)
29      test_mixed
30          <
31              Point1, bg::model::multi_point<Point2>
32          >
33          (
34              "POINT(1 1)",
35              "MULTIPOINT((1 1))",
36              1
37          );
38      test_mixed
39          <
40              bg::model::linestring<Point1>,
41              bg::model::multi_linestring<bg::model::linestring<Point2> >
42          >
43          (
44              "LINESTRING(1 1,2 2)",
45              "MULTILINESTRING((1 1,2 2))",
46              2
47          );
48      test_mixed
49          <
50              bg::model::segment<Point1>,
51              bg::model::multi_linestring<bg::model::linestring<Point2> >
52          >
53          (
54              "LINESTRING(1 1,2 2)",
55              "MULTILINESTRING((1 1,2 2))",
56              2
57          );
58      test_mixed
59          <
60              bg::model::box<Point1>,
61              bg::model::multi_polygon<bg::model::polygon<Point2> >
62          >
63          (
64              "BOX(0 0,1 1)",
65              "MULTIPOLYGON(((0 0,0 1,1 1,1 0,0 0)))",
66              5
67          );
68      test_mixed
69          <
70              bg::model::ring<Point1, true>,
71              bg::model::multi_polygon<bg::model::polygon<Point2, false> >
72          >
73          (
74              "POLYGON((0 0,0 1,1 1,1 0,0 0))",
75              "MULTIPOLYGON(((0 0,1 0,1 1,0 1,0 0)))",
76              5
77          );
78  
79      // Multi -> single: should not compile (because multi often have 0 or >1 elements)
80  }
81  
82  template <typename Point1, typename Point2>
test_mixed_types()83  void test_mixed_types()
84  {
85      test_mixed_point_types<Point1, Point2>();
86      test_mixed_point_types<Point2, Point1>();
87  }
88  
test_main(int,char * [])89  int test_main( int , char* [] )
90  {
91      test_mixed_types
92          <
93              bg::model::point<int, 2, bg::cs::cartesian>,
94              bg::model::point<double, 2, bg::cs::cartesian>
95          >();
96  
97      return 0;
98  }
99