]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/geometry/test/io/wkt/wkt_multi.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / geometry / test / io / wkt / wkt_multi.cpp
CommitLineData
7c673cae
FG
1// Boost.Geometry (aka GGL, Generic Geometry Library)
2// Unit Test
3
4// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
5// Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
6// Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
7
8// This file was modified by Oracle on 2014, 2015.
9// Modifications copyright (c) 2014-2015 Oracle and/or its affiliates.
10
11// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
12
13// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
14// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
15
16// Use, modification and distribution is subject to the Boost Software License,
17// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
18// http://www.boost.org/LICENSE_1_0.txt)
19
20//#include <iostream>
21#include <sstream>
22#include <string>
23
24#include <boost/algorithm/string.hpp>
25#include <boost/concept/requires.hpp>
26
27#include <boost/test/floating_point_comparison.hpp>
28#include <boost/test/included/test_exec_monitor.hpp>
29
30#include <boost/geometry/geometries/geometries.hpp>
31
32#include <boost/geometry/io/wkt/wkt.hpp>
33
34template <typename T>
35void test_all();
36
37
38// Include the single test
39#define GEOMETRY_TEST_MULTI
40#include "io/wkt/wkt.cpp"
41
42template <typename T>
43void test_order_closure()
44{
45 using namespace boost::geometry;
46 typedef bg::model::point<T, 2, bg::cs::cartesian> Pt;
47 typedef bg::model::polygon<Pt, true, true> PCWC;
48 typedef bg::model::polygon<Pt, true, false> PCWO;
49 typedef bg::model::polygon<Pt, false, true> PCCWC;
50 typedef bg::model::polygon<Pt, false, false> PCCWO;
51 typedef bg::model::multi_polygon<PCWC> MPCWC;
52 typedef bg::model::multi_polygon<PCWO> MPCWO;
53 typedef bg::model::multi_polygon<PCCWC> MPCCWC;
54 typedef bg::model::multi_polygon<PCCWO> MPCCWO;
55
56 std::string wkt_cwc = "MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0)),((0 0,0 -3,-3 -3,-3 0,0 0),(-1 -1,-2 -1,-2 -2,-1 -2,-1 -1)))";
57 std::string wkt_cwo = "MULTIPOLYGON(((0 0,0 2,2 2,2 0)),((0 0,0 -3,-3 -3,-3 0),(-1 -1,-2 -1,-2 -2,-1 -2)))";
58 std::string wkt_ccwc = "MULTIPOLYGON(((0 0,2 0,2 2,0 2,0 0)),((0 0,-3 0,-3 -3,0 -3,0 0),(-1 -1,-1 -2,-2 -2,-2 -1,-1 -1)))";
59 std::string wkt_ccwo = "MULTIPOLYGON(((0 0,2 0,2 2,0 2)),((0 0,-3 0,-3 -3,0 -3),(-1 -1,-1 -2,-2 -2,-2 -1)))";
60
61 test_wkt<MPCWC>(wkt_cwc, wkt_cwc, 15, 0, 12, 24);
62 test_wkt<MPCWO>(wkt_cwc, wkt_cwc, 12, 0, 12, 24);
63 test_wkt<MPCWO>(wkt_cwo, wkt_cwc, 12, 0, 12, 24);
64 test_wkt<MPCCWC>(wkt_ccwc, wkt_ccwc, 15, 0, 12, 24);
65 test_wkt<MPCCWO>(wkt_ccwc, wkt_ccwc, 12, 0, 12, 24);
66 test_wkt<MPCCWO>(wkt_ccwo, wkt_ccwc, 12, 0, 12, 24);
67}
68
69template <typename T>
70void test_all()
71{
72 using namespace boost::geometry;
73 typedef bg::model::point<T, 2, bg::cs::cartesian> P;
74
75 test_wkt<bg::model::multi_point<P> >("multipoint((1 2),(3 4))", 2);
76 test_wkt<bg::model::multi_linestring<bg::model::linestring<P> > >("multilinestring((1 1,2 2,3 3),(4 4,5 5,6 6))", 6, 4 * sqrt(2.0));
77 test_wkt<bg::model::multi_polygon<bg::model::polygon<P> > >("multipolygon(((0 0,0 2,2 2,2 0,0 0),(1 1,1 2,2 2,2 1,1 1)),((0 0,0 4,4 4,4 0,0 0)))", 15, 0, 21, 28);
78
79 // Support for the official alternative syntax for multipoint
80 // (provided by Aleksey Tulinov):
81 test_relaxed_wkt<bg::model::multi_point<P> >("multipoint(1 2,3 4)", "multipoint((1 2),(3 4))");
82
83 test_wrong_wkt<bg::model::multi_polygon<bg::model::polygon<P> > >(
84 "MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0),(1 1,1 2,2 2,2 1,1 1)),(0 0,0 4,4 4,4 0,0 0)))",
85 "expected '('");
86
87 test_wrong_wkt<bg::model::multi_linestring<bg::model::linestring<P> > >(
88 "MULTILINESTRING ((10 10, 20 20, 10 40), (40 40, 30 30, 40 20, 30 10)), (0 0, 1 1)",
b32b8144 89 "too many tokens at ','");
7c673cae
FG
90
91 test_wrong_wkt<bg::model::multi_point<P> >(
92 "MULTIPOINT((8 9), 10 11)",
93 "expected '(' at '10'");
94 test_wrong_wkt<bg::model::multi_point<P> >(
95 "MULTIPOINT(12 13, (14 15))",
96 "bad lexical cast: source type value could not be interpreted as target at '(' in 'multipoint(12 13, (14 15))'");
97 test_wrong_wkt<bg::model::multi_point<P> >(
98 "MULTIPOINT((16 17), (18 19)",
99 "expected ')' in 'multipoint((16 17), (18 19)'");
100 test_wrong_wkt<bg::model::multi_point<P> >(
101 "MULTIPOINT(16 17), (18 19)",
b32b8144 102 "too many tokens at ',' in 'multipoint(16 17), (18 19)'");
7c673cae
FG
103
104 test_order_closure<T>();
105}
106
107/*
108
109... see comments in "wkt.cpp"
110
111union select 13,'# mpoint',npoints(geomfromtext('MULTIPOINT((1 2),(3 4))'))
112union select 14,'length mpoint',length(geomfromtext('MULTIPOINT((1 2),(3 4))'))
113union select 15,'peri mpoint',perimeter(geomfromtext('MULTIPOINT((1 2),(3 4))'))
114union select 16,'area mpoint',area(geomfromtext('MULTIPOINT((1 2),(3 4))'))
115
116union select 17,'# mls',npoints(geomfromtext('MULTILINESTRING((1 1,2 2,3 3),(4 4,5 5,6 6))'))
117union select 18,'length mls',length(geomfromtext('MULTILINESTRING((1 1,2 2,3 3),(4 4,5 5,6 6))'))
118union select 19,'peri mls',perimeter(geomfromtext('MULTILINESTRING((1 1,2 2,3 3),(4 4,5 5,6 6))'))
119union select 20,'area mls',area(geomfromtext('MULTILINESTRING((1 1,2 2,3 3),(4 4,5 5,6 6))'))
120
121union select 21,'# mpoly',npoints(geomfromtext('MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0),(1 1,1 2,2 2,2 1,1 1)),((0 0,0 4,4 4,4 0,0 0)))'))
122union select 22,'length mpoly',length(geomfromtext('MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0),(1 1,1 2,2 2,2 1,1 1)),((0 0,0 4,4 4,4 0,0 0)))'))
123union select 23,'peri mpoly',perimeter(geomfromtext('MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0),(1 1,1 2,2 2,2 1,1 1)),((0 0,0 4,4 4,4 0,0 0)))'))
124union select 24,'area mpoly',area(geomfromtext('MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0),(1 1,1 2,2 2,2 1,1 1)),((0 0,0 4,4 4,4 0,0 0)))'))
125
126*/