]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/doc/src/examples/algorithms/relation.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / geometry / doc / src / examples / algorithms / relation.cpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 // QuickBook Example
3
4 // Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
5
6 // This file was modified by Oracle on 2015.
7 // Modifications copyright (c) 2015 Oracle and/or its affiliates.
8
9 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
10
11 // Use, modification and distribution is subject to the Boost Software License,
12 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
13 // http://www.boost.org/LICENSE_1_0.txt)
14
15 //[relation
16 //` Shows how to calculate the spatial relation between a point and a polygon
17
18 #include <iostream>
19 #include <string>
20
21 #include <boost/geometry.hpp>
22 #include <boost/geometry/geometries/point_xy.hpp>
23 #include <boost/geometry/geometries/polygon.hpp>
24 /*<-*/ #include "create_svg_two.hpp" /*->*/
25
26 int main()
27 {
28 typedef boost::geometry::model::d2::point_xy<double> point_type;
29 typedef boost::geometry::model::polygon<point_type> polygon_type;
30
31 polygon_type poly;
32 boost::geometry::read_wkt(
33 "POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.1 3,5.3 2.6,5.4 1.2,4.9 0.8,2.9 0.7,2 1.3)"
34 "(4.0 2.0, 4.2 1.4, 4.8 1.9, 4.4 2.2, 4.0 2.0))", poly);
35
36 point_type p(4, 1);
37
38 boost::geometry::de9im::matrix matrix = boost::geometry::relation(p, poly);
39 std::string code = matrix.str();
40
41 std::cout << "relation: " << code << std::endl;
42 /*<-*/ create_svg("relation.svg", poly, p); /*->*/
43 return 0;
44 }
45
46 //]
47
48 //[relation_output
49 /*`
50 Output:
51 [pre
52 relation: 0FFFFF212
53
54 [$img/algorithms/within.png]
55 ]
56
57 */
58 //]