Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to inherit from boost::geometry::model::point?
    primarykey
    data
    text
    <p>I'd like to inherit from <a href="http://www.boost.org/doc/libs/1_54_0/libs/geometry/doc/html/geometry/reference/models/model_point.html#geometry.reference.models.model_point.c0" rel="nofollow">bg::model::point</a> to extend it with own functionality. The *point*s shall be stored in an <a href="http://www.boost.org/doc/libs/1_54_0/libs/geometry/doc/html/geometry/spatial_indexes/rtree_examples/specializing_index__indexable_function_object___storing_shared_pointers_in_the_rtree.html" rel="nofollow">rtree</a>.</p> <p>The following minimal example fails to compile the usage of my derived point (boost 1.54, gcc 4.7.2):</p> <pre><code>#include &lt;boost/geometry.hpp&gt; #include &lt;boost/geometry/geometries/point.hpp&gt; #include &lt;boost/geometry/geometries/box.hpp&gt; #include &lt;boost/geometry/index/rtree.hpp&gt; #include &lt;iostream&gt; #include &lt;boost/shared_ptr.hpp&gt; namespace bg = boost::geometry; namespace bgi = boost::geometry::index; namespace boost { namespace geometry { namespace index { // apparently necessary: template &lt;typename Box&gt; struct indexable&lt; boost::shared_ptr&lt;Box&gt; &gt; { typedef boost::shared_ptr&lt;Box&gt; V; typedef Box const&amp; result_type; result_type operator()(V const&amp; v) const { return *v; } }; }}} // namespace boost::geometry::index namespace { // anonymous namespace // myPoint template&lt;typename CoordinateType, std::size_t DimensionCount, typename CoordinateSystem&gt; class myPoint : public bg::model::point&lt;CoordinateType, DimensionCount, CoordinateSystem&gt;{ public: void sayHello(void); }; template&lt;typename CoordinateType, std::size_t DimensionCount, typename CoordinateSystem&gt; void myPoint&lt; CoordinateType, DimensionCount, CoordinateSystem &gt;::sayHello() { std::cout&lt;&lt;"Hello!"&lt;&lt;std::endl; } } // end anonymous namespace int main(void) { typedef bg::model::point&lt;float, 2, bg::cs::cartesian&gt; point; // boost point version typedef myPoint&lt;float, 2, bg::cs::cartesian&gt; mypoint; // custom point version // create the rtree using default constructor bgi::rtree&lt; boost::shared_ptr&lt;point&gt;, bgi::rstar&lt;16, 4&gt; &gt; rtree; // that works bgi::rtree&lt; boost::shared_ptr&lt;mypoint&gt;, bgi::rstar&lt;16, 4&gt; &gt; myrtree; // that doesn't works return 0; } </code></pre> <p>how can i derive from bg::model::point? or, instead of inheriting, is there a better approach?</p> <p>thanks!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload