]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/geometry/test/algorithms/perimeter/perimeter.cpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / libs / geometry / test / algorithms / perimeter / perimeter.cpp
CommitLineData
7c673cae
FG
1// Boost.Geometry (aka GGL, Generic Geometry Library)
2// Unit Test
3
4// Copyright (c) 2016 Oracle and/or its affiliates.
5// Contributed and/or modified by Vissarion Fisikopoulos, on behalf of Oracle
6
7// Use, modification and distribution is subject to the Boost Software License,
8// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
9// http://www.boost.org/LICENSE_1_0.txt)
10
11#include <algorithms/test_perimeter.hpp>
12
13#include <boost/geometry/geometries/geometries.hpp>
14#include <boost/geometry/geometries/point_xy.hpp>
15
16template <typename P>
17void test_all()
18{
19 // Simple
20 test_geometry<bg::model::polygon<P> >("POLYGON((0 0,3 4,4 3,0 0))",
21 5 + sqrt(2.0) + 5);
22 // Non-simple
23 test_geometry<bg::model::polygon<P> >("POLYGON((0 0,3 4,4 3,0 3,0 0))",
24 5 + sqrt(2.0) + 4 + 3);
25 // With holes
26 test_geometry<bg::model::polygon<P> >("POLYGON((0 0,3 4,4 3,0 0),\
27 (2 2,3 4,3 3,2 2))",
28 5 + sqrt(2.0) + 5 +
29 sqrt(5.0) + 1 + sqrt(2.0));
30 // Repeated points
31 test_geometry<bg::model::polygon<P> >("POLYGON((0 0,3 4,3 4,3 4,4 3,4 3,\
32 4 3,4 3,4 3,4 3,0 3,0 0))",
33 5 + sqrt(2.0) + 4 + 3);
34 // Multipolygon
35 test_geometry<bg::model::multi_polygon<bg::model::polygon<P> > >
36 (
37 "MULTIPOLYGON(((0 0,3 4,4 3,0 0)), ((0 0,3 4,4 3,0 3,0 0)))",
38 5 + sqrt(2.0) + 5 + 5 + sqrt(2.0) + 4 + 3
39 );
40
41 // Geometries with perimeter zero
42 test_geometry<P>("POINT(0 0)", 0);
43 test_geometry<bg::model::linestring<P> >("LINESTRING(0 0,3 4,4 3)", 0);
44}
45
46template <typename P>
47void test_empty_input()
48{
49 test_empty_input(bg::model::polygon<P>());
50 test_empty_input(bg::model::multi_polygon<bg::model::polygon<P> >());
51}
52
53int test_main(int, char* [])
54{
55 test_all<bg::model::d2::point_xy<int> >();
56 test_all<bg::model::d2::point_xy<float> >();
57 test_all<bg::model::d2::point_xy<double> >();
58
7c673cae
FG
59 // test_empty_input<bg::model::d2::point_xy<int> >();
60
61 return 0;
62}