]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/doc/index/src/examples/rtree/mapped_file.cpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / geometry / doc / index / src / examples / rtree / mapped_file.cpp
1 // Boost.Geometry Index
2 //
3 // Quickbook Examples
4 //
5 // Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland.
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 //[rtree_mapped_file
12
13 #include <iostream>
14
15 #include <boost/interprocess/managed_mapped_file.hpp>
16
17 #include <boost/geometry.hpp>
18 #include <boost/geometry/geometries/point.hpp>
19 #include <boost/geometry/index/rtree.hpp>
20
21 namespace bi = boost::interprocess;
22 namespace bg = boost::geometry;
23 namespace bgm = bg::model;
24 namespace bgi = bg::index;
25
26 int main()
27 {
28 typedef bgm::point<float, 2, bg::cs::cartesian> point_t;
29
30 typedef point_t value_t;
31 typedef bgi::linear<32, 8> params_t;
32 typedef bgi::indexable<value_t> indexable_t;
33 typedef bgi::equal_to<value_t> equal_to_t;
34 typedef bi::allocator<value_t, bi::managed_mapped_file::segment_manager> allocator_t;
35 typedef bgi::rtree<value_t, params_t, indexable_t, equal_to_t, allocator_t> rtree_t;
36
37 {
38 bi::managed_mapped_file file(bi::open_or_create, "data.bin", 1024*1024);
39 allocator_t alloc(file.get_segment_manager());
40 rtree_t * rtree_ptr = file.find_or_construct<rtree_t>("rtree")(params_t(), indexable_t(), equal_to_t(), alloc);
41
42 std::cout << rtree_ptr->size() << std::endl;
43
44 rtree_ptr->insert(point_t(1.0, 1.0));
45 rtree_ptr->insert(point_t(2.0, 2.0));
46
47 std::cout << rtree_ptr->size() << std::endl;
48 }
49
50 {
51 bi::managed_mapped_file file(bi::open_or_create, "data.bin", 1024*1024);
52 allocator_t alloc(file.get_segment_manager());
53 rtree_t * rtree_ptr = file.find_or_construct<rtree_t>("rtree")(params_t(), indexable_t(), equal_to_t(), alloc);
54
55 std::cout << rtree_ptr->size() << std::endl;
56
57 rtree_ptr->insert(point_t(3.0, 3.0));
58 rtree_ptr->insert(point_t(4.0, 4.0));
59
60 std::cout << rtree_ptr->size() << std::endl;
61 }
62
63 return 0;
64 }
65
66 //]