1// Boost.Geometry
2
3// Copyright (c) 2022 Oracle and/or its affiliates.
4// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
5
6// Use, modification and distribution is subject to the Boost Software License,
7// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8// http://www.boost.org/LICENSE_1_0.txt)
9
10#include "test_within.hpp"
11
12#include <boost/geometry/geometries/geometries.hpp>
13
14using pt_t = bg::model::point<double, 2, bg::cs::cartesian>;
15using ls_t = bg::model::linestring<pt_t>;
16using po_t = bg::model::polygon<pt_t>;
17using mpt_t = bg::model::multi_point<pt_t>;
18using mls_t = bg::model::multi_linestring<ls_t>;
19using mpo_t = bg::model::multi_polygon<po_t>;
20using var_t = boost::variant<pt_t, ls_t, po_t, mpt_t, mls_t, mpo_t>;
21//using var_t = boost::variant2::variant<pt_t, ls_t, po_t, mpt_t, mls_t, mpo_t>;
22using gc_t = bg::model::geometry_collection<var_t>;
23
24void test_gc()
25{
26 test_geometry<gc_t, gc_t>(wkt1: "GEOMETRYCOLLECTION(POLYGON((0 0,0 5,5 5,5 0,0 0)), LINESTRING(1 1, 4 4))",
27 wkt2: "GEOMETRYCOLLECTION(POLYGON((0 0,0 5,5 5,5 0,0 0)), LINESTRING(1 4, 4 1))",
28 expected: true);
29 test_geometry<gc_t, gc_t>(wkt1: "GEOMETRYCOLLECTION(POLYGON((0 0,0 5,5 5,5 0,0 0)), LINESTRING(1 1, 6 6))",
30 wkt2: "GEOMETRYCOLLECTION(POLYGON((0 0,0 5,5 5,5 0,0 0)), LINESTRING(1 4, 4 1))",
31 expected: false);
32 test_geometry<gc_t, gc_t>(wkt1: "GEOMETRYCOLLECTION(POLYGON((0 0,0 5,5 5,5 0,0 0)), LINESTRING(1 4, 4 1))",
33 wkt2: "GEOMETRYCOLLECTION(POLYGON((0 0,0 5,5 5,5 0,0 0)), LINESTRING(1 1, 6 6))",
34 expected: true);
35 test_geometry<gc_t, gc_t>(wkt1: "GEOMETRYCOLLECTION(POLYGON((0 0,0 5,5 5,5 0,0 0)), LINESTRING(1 1, 6 6))",
36 wkt2: "GEOMETRYCOLLECTION(POLYGON((0 0,0 5,5 5,5 0,0 0)), LINESTRING(5 5, 6 6))",
37 expected: true);
38 test_geometry<gc_t, gc_t>(wkt1: "GEOMETRYCOLLECTION(POLYGON((0 0,0 5,5 5,5 0,0 0)), LINESTRING(1 1, 6 6), POINT(0 6))",
39 wkt2: "GEOMETRYCOLLECTION(POLYGON((0 0,0 5,5 5,5 0,0 0)), LINESTRING(5 5, 6 6))",
40 expected: false);
41 test_geometry<gc_t, gc_t>(wkt1: "GEOMETRYCOLLECTION(POLYGON((0 0,0 5,5 5,5 0,0 0)), LINESTRING(5 5, 6 6))",
42 wkt2: "GEOMETRYCOLLECTION(POLYGON((0 0,0 5,5 5,5 0,0 0)), LINESTRING(1 1, 6 6), POINT(0 6))",
43 expected: true);
44 test_geometry<gc_t, gc_t>(wkt1: "GEOMETRYCOLLECTION(POLYGON((0 0,0 5,5 5,5 0,0 0)), LINESTRING(1 1, 6 6), POINT(0 6))",
45 wkt2: "GEOMETRYCOLLECTION(POLYGON((0 0,0 5,5 5,5 0,0 0)), LINESTRING(5 5, 6 6), POINT(0 6))",
46 expected: true);
47
48
49 test_geometry<po_t, gc_t>(wkt1: "POLYGON((0 0,0 5,5 5,5 0,0 0))",
50 wkt2: "GEOMETRYCOLLECTION(POLYGON((0 0,0 5,5 5,5 0,0 0)), LINESTRING(1 1, 4 4))",
51 expected: true);
52 test_geometry<gc_t, po_t>(wkt1: "GEOMETRYCOLLECTION(POLYGON((0 0,0 5,5 5,5 0,0 0)), LINESTRING(1 1, 6 6))",
53 wkt2: "POLYGON((0 0,0 5,5 5,5 0,0 0))",
54 expected: false);
55}
56
57int test_main(int , char* [])
58{
59 test_gc();
60
61 return 0;
62}
63

source code of boost/libs/geometry/test/algorithms/within/within_gc.cpp