Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r83112 - in sandbox-branches/geometry/index/doc: . html html/geometry_index html/geometry_index/r_tree rtree src/examples/rtree
From: adam.wulkiewicz_at_[hidden]
Date: 2013-02-23 22:29:12


Author: awulkiew
Date: 2013-02-23 22:29:11 EST (Sat, 23 Feb 2013)
New Revision: 83112
URL: http://svn.boost.org/trac/boost/changeset/83112

Log:
Added example: index of iterators of a map storing variant geometries,
Interprocess example name changed.
Added:
   sandbox-branches/geometry/index/doc/src/examples/rtree/variants_map.cpp (contents, props changed)
Text files modified:
   sandbox-branches/geometry/index/doc/html/geometry_index/r_tree.html | 5 +
   sandbox-branches/geometry/index/doc/html/geometry_index/r_tree/rtree_examples.html | 148 +++++++++++++++++++++++++++++++++++++++
   sandbox-branches/geometry/index/doc/html/index.html | 2
   sandbox-branches/geometry/index/doc/imports.qbk | 1
   sandbox-branches/geometry/index/doc/rtree/examples.qbk | 6 +
   sandbox-branches/geometry/index/doc/src/examples/rtree/Jamfile.v2 | 2
   6 files changed, 159 insertions(+), 5 deletions(-)

Modified: sandbox-branches/geometry/index/doc/html/geometry_index/r_tree.html
==============================================================================
--- sandbox-branches/geometry/index/doc/html/geometry_index/r_tree.html (original)
+++ sandbox-branches/geometry/index/doc/html/geometry_index/r_tree.html 2013-02-23 22:29:11 EST (Sat, 23 Feb 2013)
@@ -72,7 +72,10 @@
         of polygons stored in vector</a></span></dt>
 <dt><span class="section"><a href="r_tree/rtree_examples.html#geometry_index.r_tree.rtree_examples.index_of_shared_pointers_to_polygons">Index
         of shared pointers to polygons</a></span></dt>
-<dt><span class="section">Interprocess</span></dt>
+<dt><span class="section"><a href="r_tree/rtree_examples.html#geometry_index.r_tree.rtree_examples.index_of_iterators_of_a_map_storing_variant_geometries">Index
+ of iterators of a map storing variant geometries</a></span></dt>
+<dt><span class="section"><a href="r_tree/rtree_examples.html#geometry_index.r_tree.rtree_examples.index_stored_in_shared_memory_using_boost_interprocess">Index
+ stored in shared memory using Boost.Interprocess</a></span></dt>
 </dl></dd>
 <dt><span class="section">Reference</span></dt>
 <dd><dl>

Modified: sandbox-branches/geometry/index/doc/html/geometry_index/r_tree/rtree_examples.html
==============================================================================
--- sandbox-branches/geometry/index/doc/html/geometry_index/r_tree/rtree_examples.html (original)
+++ sandbox-branches/geometry/index/doc/html/geometry_index/r_tree/rtree_examples.html 2013-02-23 22:29:11 EST (Sat, 23 Feb 2013)
@@ -33,7 +33,10 @@
         of polygons stored in vector</a></span></dt>
 <dt><span class="section"><a href="rtree_examples.html#geometry_index.r_tree.rtree_examples.index_of_shared_pointers_to_polygons">Index
         of shared pointers to polygons</a></span></dt>
-<dt><span class="section">Interprocess</span></dt>
+<dt><span class="section"><a href="rtree_examples.html#geometry_index.r_tree.rtree_examples.index_of_iterators_of_a_map_storing_variant_geometries">Index
+ of iterators of a map storing variant geometries</a></span></dt>
+<dt><span class="section"><a href="rtree_examples.html#geometry_index.r_tree.rtree_examples.index_stored_in_shared_memory_using_boost_interprocess">Index
+ stored in shared memory using Boost.Interprocess</a></span></dt>
 </dl></div>
 <div class="section">
 <div class="titlepage"><div><div><h4 class="title">
@@ -284,7 +287,148 @@
 </div>
 <div class="section">
 <div class="titlepage"><div><div><h4 class="title">
-<a name="geometry_index.r_tree.rtree_examples.interprocess"></a><a class="link" href="rtree_examples.html#geometry_index.r_tree.rtree_examples.interprocess" title="Interprocess">Interprocess</a>
+<a name="geometry_index.r_tree.rtree_examples.index_of_iterators_of_a_map_storing_variant_geometries"></a><a class="link" href="rtree_examples.html#geometry_index.r_tree.rtree_examples.index_of_iterators_of_a_map_storing_variant_geometries" title="Index of iterators of a map storing variant geometries">Index
+ of iterators of a map storing variant geometries</a>
+</h4></div></div></div>
+<p>
+</p>
+<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
+<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">/</span><span class="identifier">geometries</span><span class="special">/</span><span class="identifier">point</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
+<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">/</span><span class="identifier">geometries</span><span class="special">/</span><span class="identifier">box</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
+<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">/</span><span class="identifier">geometries</span><span class="special">/</span><span class="identifier">polygon</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
+<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">/</span><span class="identifier">geometries</span><span class="special">/</span><span class="identifier">ring</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
+<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">/</span><span class="identifier">geometries</span><span class="special">/</span><span class="identifier">linestring</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
+
+<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">/</span><span class="identifier">index</span><span class="special">/</span><span class="identifier">rtree</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
+
+<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">cmath</span><span class="special">&gt;</span>
+<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">vector</span><span class="special">&gt;</span>
+<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">map</span><span class="special">&gt;</span>
+<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">iostream</span><span class="special">&gt;</span>
+<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">foreach</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
+<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">variant</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
+
+<span class="keyword">namespace</span> <span class="identifier">bg</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">;</span>
+<span class="keyword">namespace</span> <span class="identifier">bgi</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">index</span><span class="special">;</span>
+
+<span class="keyword">typedef</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">model</span><span class="special">::</span><span class="identifier">point</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">,</span> <span class="number">2</span><span class="special">,</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">cs</span><span class="special">::</span><span class="identifier">cartesian</span><span class="special">&gt;</span> <span class="identifier">point</span><span class="special">;</span>
+<span class="keyword">typedef</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">model</span><span class="special">::</span><span class="identifier">box</span><span class="special">&lt;</span><span class="identifier">point</span><span class="special">&gt;</span> <span class="identifier">box</span><span class="special">;</span>
+<span class="keyword">typedef</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">model</span><span class="special">::</span><span class="identifier">polygon</span><span class="special">&lt;</span><span class="identifier">point</span><span class="special">,</span> <span class="keyword">false</span><span class="special">,</span> <span class="keyword">false</span><span class="special">&gt;</span> <span class="identifier">polygon</span><span class="special">;</span> <span class="comment">// ccw, open polygon</span>
+<span class="keyword">typedef</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">model</span><span class="special">::</span><span class="identifier">ring</span><span class="special">&lt;</span><span class="identifier">point</span><span class="special">,</span> <span class="keyword">false</span><span class="special">,</span> <span class="keyword">false</span><span class="special">&gt;</span> <span class="identifier">ring</span><span class="special">;</span> <span class="comment">// ccw, open ring</span>
+<span class="keyword">typedef</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">model</span><span class="special">::</span><span class="identifier">linestring</span><span class="special">&lt;</span><span class="identifier">point</span><span class="special">&gt;</span> <span class="identifier">linestring</span><span class="special">;</span>
+<span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">variant</span><span class="special">&lt;</span><span class="identifier">polygon</span><span class="special">,</span> <span class="identifier">ring</span><span class="special">,</span> <span class="identifier">linestring</span><span class="special">&gt;</span> <span class="identifier">geometry</span><span class="special">;</span>
+
+<span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special">&lt;</span><span class="keyword">unsigned</span><span class="special">,</span> <span class="identifier">geometry</span><span class="special">&gt;</span> <span class="identifier">map</span><span class="special">;</span>
+<span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special">&lt;</span><span class="identifier">box</span><span class="special">,</span> <span class="identifier">map</span><span class="special">::</span><span class="identifier">iterator</span><span class="special">&gt;</span> <span class="identifier">value</span><span class="special">;</span>
+
+<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Container</span><span class="special">&gt;</span>
+<span class="keyword">void</span> <span class="identifier">fill</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="identifier">i</span><span class="special">,</span> <span class="identifier">Container</span> <span class="special">&amp;</span> <span class="identifier">container</span><span class="special">)</span>
+<span class="special">{</span>
+ <span class="keyword">for</span> <span class="special">(</span> <span class="keyword">float</span> <span class="identifier">a</span> <span class="special">=</span> <span class="number">0</span> <span class="special">;</span> <span class="identifier">a</span> <span class="special">&lt;</span> <span class="number">6.28316f</span> <span class="special">;</span> <span class="identifier">a</span> <span class="special">+=</span> <span class="number">1.04720f</span> <span class="special">)</span>
+ <span class="special">{</span>
+ <span class="keyword">float</span> <span class="identifier">x</span> <span class="special">=</span> <span class="identifier">i</span> <span class="special">+</span> <span class="keyword">int</span><span class="special">(</span><span class="number">10</span><span class="special">*::</span><span class="identifier">cos</span><span class="special">(</span><span class="identifier">a</span><span class="special">))*</span><span class="number">0.1f</span><span class="special">;</span>
+ <span class="keyword">float</span> <span class="identifier">y</span> <span class="special">=</span> <span class="identifier">i</span> <span class="special">+</span> <span class="keyword">int</span><span class="special">(</span><span class="number">10</span><span class="special">*::</span><span class="identifier">sin</span><span class="special">(</span><span class="identifier">a</span><span class="special">))*</span><span class="number">0.1f</span><span class="special">;</span>
+ <span class="identifier">container</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">point</span><span class="special">(</span><span class="identifier">x</span><span class="special">,</span> <span class="identifier">y</span><span class="special">));</span>
+ <span class="special">}</span>
+<span class="special">}</span>
+
+<span class="keyword">struct</span> <span class="identifier">print_visitor</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">static_visitor</span><span class="special">&lt;&gt;</span>
+<span class="special">{</span>
+ <span class="keyword">void</span> <span class="keyword">operator</span><span class="special">()(</span><span class="identifier">polygon</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">g</span><span class="special">)</span> <span class="keyword">const</span> <span class="special">{</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">wkt</span><span class="special">&lt;</span><span class="identifier">polygon</span><span class="special">&gt;(</span><span class="identifier">g</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="special">}</span>
+ <span class="keyword">void</span> <span class="keyword">operator</span><span class="special">()(</span><span class="identifier">ring</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">g</span><span class="special">)</span> <span class="keyword">const</span> <span class="special">{</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">wkt</span><span class="special">&lt;</span><span class="identifier">ring</span><span class="special">&gt;(</span><span class="identifier">g</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="special">}</span>
+ <span class="keyword">void</span> <span class="keyword">operator</span><span class="special">()(</span><span class="identifier">linestring</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">g</span><span class="special">)</span> <span class="keyword">const</span> <span class="special">{</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">wkt</span><span class="special">&lt;</span><span class="identifier">linestring</span><span class="special">&gt;(</span><span class="identifier">g</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="special">}</span>
+<span class="special">};</span>
+
+<span class="keyword">struct</span> <span class="identifier">envelope_visitor</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">static_visitor</span><span class="special">&lt;</span><span class="identifier">box</span><span class="special">&gt;</span>
+<span class="special">{</span>
+ <span class="identifier">box</span> <span class="keyword">operator</span><span class="special">()(</span><span class="identifier">polygon</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">g</span><span class="special">)</span> <span class="keyword">const</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">return_envelope</span><span class="special">&lt;</span><span class="identifier">box</span><span class="special">&gt;(</span><span class="identifier">g</span><span class="special">);</span> <span class="special">}</span>
+ <span class="identifier">box</span> <span class="keyword">operator</span><span class="special">()(</span><span class="identifier">ring</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">g</span><span class="special">)</span> <span class="keyword">const</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">return_envelope</span><span class="special">&lt;</span><span class="identifier">box</span><span class="special">&gt;(</span><span class="identifier">g</span><span class="special">);</span> <span class="special">}</span>
+ <span class="identifier">box</span> <span class="keyword">operator</span><span class="special">()(</span><span class="identifier">linestring</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">g</span><span class="special">)</span> <span class="keyword">const</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">return_envelope</span><span class="special">&lt;</span><span class="identifier">box</span><span class="special">&gt;(</span><span class="identifier">g</span><span class="special">);</span> <span class="special">}</span>
+<span class="special">};</span>
+
+
+<span class="keyword">int</span> <span class="identifier">main</span><span class="special">(</span><span class="keyword">void</span><span class="special">)</span>
+<span class="special">{</span>
+ <span class="comment">// geometries container</span>
+ <span class="identifier">map</span> <span class="identifier">geometries</span><span class="special">;</span>
+
+ <span class="comment">// create some geometries</span>
+ <span class="keyword">for</span> <span class="special">(</span> <span class="keyword">unsigned</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span> <span class="special">;</span> <span class="identifier">i</span> <span class="special">&lt;</span> <span class="number">10</span> <span class="special">;</span> <span class="special">++</span><span class="identifier">i</span> <span class="special">)</span>
+ <span class="special">{</span>
+ <span class="keyword">unsigned</span> <span class="identifier">c</span> <span class="special">=</span> <span class="identifier">rand</span><span class="special">()</span> <span class="special">%</span> <span class="number">3</span><span class="special">;</span>
+
+ <span class="keyword">if</span> <span class="special">(</span> <span class="number">0</span> <span class="special">==</span> <span class="identifier">c</span> <span class="special">)</span>
+ <span class="special">{</span>
+ <span class="comment">// create polygon</span>
+ <span class="identifier">polygon</span> <span class="identifier">p</span><span class="special">;</span>
+ <span class="identifier">fill</span><span class="special">(</span><span class="identifier">i</span><span class="special">,</span> <span class="identifier">p</span><span class="special">.</span><span class="identifier">outer</span><span class="special">());</span>
+ <span class="identifier">geometries</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">make_pair</span><span class="special">(</span><span class="identifier">i</span><span class="special">,</span> <span class="identifier">geometry</span><span class="special">(</span><span class="identifier">p</span><span class="special">)));</span>
+ <span class="special">}</span>
+ <span class="keyword">else</span> <span class="keyword">if</span> <span class="special">(</span> <span class="number">1</span> <span class="special">==</span> <span class="identifier">c</span> <span class="special">)</span>
+ <span class="special">{</span>
+ <span class="comment">// create ring</span>
+ <span class="identifier">ring</span> <span class="identifier">r</span><span class="special">;</span>
+ <span class="identifier">fill</span><span class="special">(</span><span class="identifier">i</span><span class="special">,</span> <span class="identifier">r</span><span class="special">);</span>
+ <span class="identifier">geometries</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">make_pair</span><span class="special">(</span><span class="identifier">i</span><span class="special">,</span> <span class="identifier">geometry</span><span class="special">(</span><span class="identifier">r</span><span class="special">)));</span>
+ <span class="special">}</span>
+ <span class="keyword">else</span> <span class="keyword">if</span> <span class="special">(</span> <span class="number">2</span> <span class="special">==</span> <span class="identifier">c</span> <span class="special">)</span>
+ <span class="special">{</span>
+ <span class="comment">// create linestring</span>
+ <span class="identifier">linestring</span> <span class="identifier">l</span><span class="special">;</span>
+ <span class="identifier">fill</span><span class="special">(</span><span class="identifier">i</span><span class="special">,</span> <span class="identifier">l</span><span class="special">);</span>
+ <span class="identifier">geometries</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">make_pair</span><span class="special">(</span><span class="identifier">i</span><span class="special">,</span> <span class="identifier">geometry</span><span class="special">(</span><span class="identifier">l</span><span class="special">)));</span>
+ <span class="special">}</span>
+ <span class="special">}</span>
+
+ <span class="comment">// display geometries</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"generated geometries:"</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
+ <span class="identifier">BOOST_FOREACH</span><span class="special">(</span><span class="identifier">map</span><span class="special">::</span><span class="identifier">value_type</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">p</span><span class="special">,</span> <span class="identifier">geometries</span><span class="special">)</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">apply_visitor</span><span class="special">(</span><span class="identifier">print_visitor</span><span class="special">(),</span> <span class="identifier">p</span><span class="special">.</span><span class="identifier">second</span><span class="special">);</span>
+
+ <span class="comment">// create the rtree using default constructor</span>
+ <span class="identifier">bgi</span><span class="special">::</span><span class="identifier">rtree</span><span class="special">&lt;</span> <span class="identifier">value</span><span class="special">,</span> <span class="identifier">bgi</span><span class="special">::</span><span class="identifier">quadratic</span><span class="special">&lt;</span><span class="number">16</span><span class="special">,</span> <span class="number">4</span><span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">rtree</span><span class="special">;</span>
+
+ <span class="comment">// fill the spatial index</span>
+ <span class="keyword">for</span> <span class="special">(</span> <span class="identifier">map</span><span class="special">::</span><span class="identifier">iterator</span> <span class="identifier">it</span> <span class="special">=</span> <span class="identifier">geometries</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">;</span> <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">geometries</span><span class="special">.</span><span class="identifier">end</span><span class="special">()</span> <span class="special">;</span> <span class="special">++</span><span class="identifier">it</span> <span class="special">)</span>
+ <span class="special">{</span>
+ <span class="comment">// calculate polygon bounding box</span>
+ <span class="identifier">box</span> <span class="identifier">b</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">apply_visitor</span><span class="special">(</span><span class="identifier">envelope_visitor</span><span class="special">(),</span> <span class="identifier">it</span><span class="special">-&gt;</span><span class="identifier">second</span><span class="special">);</span>
+ <span class="comment">// insert new value</span>
+ <span class="identifier">rtree</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">make_pair</span><span class="special">(</span><span class="identifier">b</span><span class="special">,</span> <span class="identifier">it</span><span class="special">));</span>
+ <span class="special">}</span>
+
+ <span class="comment">// find values intersecting some area defined by a box</span>
+ <span class="identifier">box</span> <span class="identifier">query_box</span><span class="special">(</span><span class="identifier">point</span><span class="special">(</span><span class="number">0</span><span class="special">,</span> <span class="number">0</span><span class="special">),</span> <span class="identifier">point</span><span class="special">(</span><span class="number">5</span><span class="special">,</span> <span class="number">5</span><span class="special">));</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="identifier">value</span><span class="special">&gt;</span> <span class="identifier">result_s</span><span class="special">;</span>
+ <span class="identifier">rtree</span><span class="special">.</span><span class="identifier">query</span><span class="special">(</span><span class="identifier">query_box</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">back_inserter</span><span class="special">(</span><span class="identifier">result_s</span><span class="special">));</span>
+
+ <span class="comment">// find 5 nearest values to a point</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="identifier">value</span><span class="special">&gt;</span> <span class="identifier">result_n</span><span class="special">;</span>
+ <span class="identifier">rtree</span><span class="special">.</span><span class="identifier">query</span><span class="special">(</span><span class="identifier">bgi</span><span class="special">::</span><span class="identifier">nearest</span><span class="special">(</span><span class="identifier">point</span><span class="special">(</span><span class="number">0</span><span class="special">,</span> <span class="number">0</span><span class="special">),</span> <span class="number">5</span><span class="special">),</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">back_inserter</span><span class="special">(</span><span class="identifier">result_n</span><span class="special">));</span>
+
+ <span class="comment">// display results</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"spatial query box:"</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">wkt</span><span class="special">&lt;</span><span class="identifier">box</span><span class="special">&gt;(</span><span class="identifier">query_box</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"spatial query result:"</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
+ <span class="identifier">BOOST_FOREACH</span><span class="special">(</span><span class="identifier">value</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">v</span><span class="special">,</span> <span class="identifier">result_s</span><span class="special">)</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">apply_visitor</span><span class="special">(</span><span class="identifier">print_visitor</span><span class="special">(),</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">second</span><span class="special">-&gt;</span><span class="identifier">second</span><span class="special">);</span>
+
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"knn query point:"</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">wkt</span><span class="special">&lt;</span><span class="identifier">point</span><span class="special">&gt;(</span><span class="identifier">point</span><span class="special">(</span><span class="number">0</span><span class="special">,</span> <span class="number">0</span><span class="special">))</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"knn query result:"</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
+ <span class="identifier">BOOST_FOREACH</span><span class="special">(</span><span class="identifier">value</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">v</span><span class="special">,</span> <span class="identifier">result_n</span><span class="special">)</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">apply_visitor</span><span class="special">(</span><span class="identifier">print_visitor</span><span class="special">(),</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">second</span><span class="special">-&gt;</span><span class="identifier">second</span><span class="special">);</span>
+
+ <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
+<span class="special">}</span>
+</pre>
+<p>
+ </p>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="geometry_index.r_tree.rtree_examples.index_stored_in_shared_memory_using_boost_interprocess"></a><a class="link" href="rtree_examples.html#geometry_index.r_tree.rtree_examples.index_stored_in_shared_memory_using_boost_interprocess" title="Index stored in shared memory using Boost.Interprocess">Index
+ stored in shared memory using Boost.Interprocess</a>
 </h4></div></div></div>
 <p>
 </p>

Modified: sandbox-branches/geometry/index/doc/html/index.html
==============================================================================
--- sandbox-branches/geometry/index/doc/html/index.html (original)
+++ sandbox-branches/geometry/index/doc/html/index.html 2013-02-23 22:29:11 EST (Sat, 23 Feb 2013)
@@ -51,7 +51,7 @@
 </div>
 </div>
 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
-<td align="left"><p><small>Last revised: February 23, 2013 at 23:45:13 GMT</small></p></td>
+<td align="left"><p><small>Last revised: February 24, 2013 at 03:27:27 GMT</small></p></td>
 <td align="right"><div class="copyright-footer"></div></td>
 </tr></table>
 <hr>

Modified: sandbox-branches/geometry/index/doc/imports.qbk
==============================================================================
--- sandbox-branches/geometry/index/doc/imports.qbk (original)
+++ sandbox-branches/geometry/index/doc/imports.qbk 2013-02-23 22:29:11 EST (Sat, 23 Feb 2013)
@@ -11,4 +11,5 @@
 [import src/examples/rtree/quick_start.cpp]
 [import src/examples/rtree/polygons_vector.cpp]
 [import src/examples/rtree/polygons_shared_ptr.cpp]
+[import src/examples/rtree/variants_map.cpp]
 [import src/examples/rtree/interprocess.cpp]

Modified: sandbox-branches/geometry/index/doc/rtree/examples.qbk
==============================================================================
--- sandbox-branches/geometry/index/doc/rtree/examples.qbk (original)
+++ sandbox-branches/geometry/index/doc/rtree/examples.qbk 2013-02-23 22:29:11 EST (Sat, 23 Feb 2013)
@@ -22,7 +22,11 @@
 [rtree_polygons_shared_ptr]
 [endsect]
 
-[section Interprocess]
+[section Index of iterators of a map storing variant geometries]
+[rtree_variants_map]
+[endsect]
+
+[section Index stored in shared memory using Boost.Interprocess]
 [rtree_interprocess]
 [endsect]
 

Modified: sandbox-branches/geometry/index/doc/src/examples/rtree/Jamfile.v2
==============================================================================
--- sandbox-branches/geometry/index/doc/src/examples/rtree/Jamfile.v2 (original)
+++ sandbox-branches/geometry/index/doc/src/examples/rtree/Jamfile.v2 2013-02-23 22:29:11 EST (Sat, 23 Feb 2013)
@@ -12,6 +12,8 @@
     ;
 exe polygons_shared_ptr : polygons_shared_ptr.cpp
     ;
+exe variants_map : variants_map.cpp
+ ;
 
 exe interprocess : interprocess.cpp /boost/thread//boost_thread
         :

Added: sandbox-branches/geometry/index/doc/src/examples/rtree/variants_map.cpp
==============================================================================
--- (empty file)
+++ sandbox-branches/geometry/index/doc/src/examples/rtree/variants_map.cpp 2013-02-23 22:29:11 EST (Sat, 23 Feb 2013)
@@ -0,0 +1,143 @@
+// Boost.Geometry Index
+//
+// Quickbook Examples
+//
+// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
+//
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+//[rtree_variants_map
+
+#include <boost/geometry.hpp>
+#include <boost/geometry/geometries/point.hpp>
+#include <boost/geometry/geometries/box.hpp>
+#include <boost/geometry/geometries/polygon.hpp>
+#include <boost/geometry/geometries/ring.hpp>
+#include <boost/geometry/geometries/linestring.hpp>
+
+#include <boost/geometry/index/rtree.hpp>
+
+#include <cmath>
+#include <vector>
+#include <map>
+#include <iostream>
+#include <boost/foreach.hpp>
+#include <boost/variant.hpp>
+
+namespace bg = boost::geometry;
+namespace bgi = boost::geometry::index;
+
+typedef bg::model::point<float, 2, bg::cs::cartesian> point;
+typedef bg::model::box<point> box;
+typedef bg::model::polygon<point, false, false> polygon; // ccw, open polygon
+typedef bg::model::ring<point, false, false> ring; // ccw, open ring
+typedef bg::model::linestring<point> linestring;
+typedef boost::variant<polygon, ring, linestring> geometry;
+
+typedef std::map<unsigned, geometry> map;
+typedef std::pair<box, map::iterator> value;
+
+template <class Container>
+void fill(unsigned i, Container & container)
+{
+ for ( float a = 0 ; a < 6.28316f ; a += 1.04720f )
+ {
+ float x = i + int(10*::cos(a))*0.1f;
+ float y = i + int(10*::sin(a))*0.1f;
+ container.push_back(point(x, y));
+ }
+}
+
+struct print_visitor : public boost::static_visitor<>
+{
+ void operator()(polygon const& g) const { std::cout << bg::wkt<polygon>(g) << std::endl; }
+ void operator()(ring const& g) const { std::cout << bg::wkt<ring>(g) << std::endl; }
+ void operator()(linestring const& g) const { std::cout << bg::wkt<linestring>(g) << std::endl; }
+};
+
+struct envelope_visitor : public boost::static_visitor<box>
+{
+ box operator()(polygon const& g) const { return bg::return_envelope<box>(g); }
+ box operator()(ring const& g) const { return bg::return_envelope<box>(g); }
+ box operator()(linestring const& g) const { return bg::return_envelope<box>(g); }
+};
+
+
+int main(void)
+{
+ // geometries container
+ map geometries;
+
+ // create some geometries
+ for ( unsigned i = 0 ; i < 10 ; ++i )
+ {
+ unsigned c = rand() % 3;
+
+ if ( 0 == c )
+ {
+ // create polygon
+ polygon p;
+ fill(i, p.outer());
+ geometries.insert(std::make_pair(i, geometry(p)));
+ }
+ else if ( 1 == c )
+ {
+ // create ring
+ ring r;
+ fill(i, r);
+ geometries.insert(std::make_pair(i, geometry(r)));
+ }
+ else if ( 2 == c )
+ {
+ // create linestring
+ linestring l;
+ fill(i, l);
+ geometries.insert(std::make_pair(i, geometry(l)));
+ }
+ }
+
+ // display geometries
+ std::cout << "generated geometries:" << std::endl;
+ BOOST_FOREACH(map::value_type const& p, geometries)
+ boost::apply_visitor(print_visitor(), p.second);
+
+ // create the rtree using default constructor
+ bgi::rtree< value, bgi::quadratic<16, 4> > rtree;
+
+ // fill the spatial index
+ for ( map::iterator it = geometries.begin() ; it != geometries.end() ; ++it )
+ {
+ // calculate polygon bounding box
+ box b = boost::apply_visitor(envelope_visitor(), it->second);
+ // insert new value
+ rtree.insert(std::make_pair(b, it));
+ }
+
+ // find values intersecting some area defined by a box
+ box query_box(point(0, 0), point(5, 5));
+ std::vector<value> result_s;
+ rtree.query(query_box, std::back_inserter(result_s));
+
+ // find 5 nearest values to a point
+ std::vector<value> result_n;
+ rtree.query(bgi::nearest(point(0, 0), 5), std::back_inserter(result_n));
+
+ // display results
+ std::cout << "spatial query box:" << std::endl;
+ std::cout << bg::wkt<box>(query_box) << std::endl;
+ std::cout << "spatial query result:" << std::endl;
+ BOOST_FOREACH(value const& v, result_s)
+ boost::apply_visitor(print_visitor(), v.second->second);
+
+ std::cout << "knn query point:" << std::endl;
+ std::cout << bg::wkt<point>(point(0, 0)) << std::endl;
+ std::cout << "knn query result:" << std::endl;
+ BOOST_FOREACH(value const& v, result_n)
+ boost::apply_visitor(print_visitor(), v.second->second);
+
+ return 0;
+}
+
+//]
\ No newline at end of file


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk