title: How to register a Boost.Geometry distance strategy for OGRPoint and OGRLineString?
body: <p>I am creating a wrapper that allows using OGR's classes with Boost.Geometry. So far, I've created that necessary iterator facade and registered OGR's geometry classes (<code>OGRPoint</code>, <code>OGRLineString</code>, <code>OGRLinearRing</code> and <code>OGRPolygon</code>) with Boost.Geometry.</p>
  
  <p>Now, I'd like to use the OGR classes predicates such as <code>OGRGeometry::Distance()</code> with boost instead of those employed by Boost.Geometry (because, for example, stock Boost.Geometry 1.57.0 does not have any notion of map projections). It worked for <code>boost::geometry::distance(OGRPoint, OGRPoint)</code>, but it does not for <code>bg::distance(OGRPoint, OGRLineString)</code> or any other collection of points. My guess that is because Boost.Geometry treats linestrings, rings and polygons as an ordered collection of points to iterate on, since the compiler tries to instanciate the following template:</p>
  
  <pre><code>struct boost::geometry::strategy::distance::services::default_strategy&lt;
          boost::geometry::point_tag,
          boost::geometry::segment_tag,
          OGRPoint,                           // NOTE: Twice OGRPoint!
          OGRPoint,
          MyCode::OGRCoordinateSystemTag,
          MyCode::OGRCoordinateSystemTag, void&gt;
  </code></pre>
  
  <p>The full error message is as follows:</p>
  
  <pre><code>In file included from /usr/include/boost/geometry/strategies/strategies.hpp:30:0,
                   from /usr/include/boost/geometry/geometry.hpp:43,
                   from /usr/include/boost/geometry.hpp:17,
                   from ../../../winzent/test/simulation/OGRLineStringAdapterTest.cpp:7:
  /usr/include/boost/geometry/strategies/distance.hpp: In instantiation of 'struct boost::geometry::strategy::distance::services::default_strategy&lt;boost::geometry::point_tag, boost::geometry::segment_tag, OGRPoint, OGRPoint, Winzent::Simulation::boost::OGRCoordinateSystemTag, Winzent::Simulation::boost::OGRCoordinateSystemTag, void&gt;':
  /usr/include/boost/geometry/algorithms/detail/distance/default_strategies.hpp:57:8:   required from 'struct boost::geometry::detail::distance::default_strategy&lt;OGRPoint, OGRLineString, boost::geometry::pointlike_tag, boost::geometry::linestring_tag, false&gt;'
  /usr/include/boost/geometry/algorithms/detail/distance/default_strategies.hpp:73:8:   required from 'struct boost::geometry::detail::distance::default_strategy&lt;OGRLineString, OGRPoint, boost::geometry::linestring_tag, boost::geometry::pointlike_tag, true&gt;'
  /usr/include/boost/geometry/strategies/distance_result.hpp:60:8:   required from 'struct boost::geometry::resolve_strategy::distance_result&lt;OGRLineString, OGRPoint, boost::geometry::default_strategy&gt;'
  /usr/include/boost/geometry/strategies/distance_result.hpp:79:8:   required from 'struct boost::geometry::resolve_variant::distance_result&lt;OGRLineString, OGRPoint, boost::geometry::default_strategy&gt;'
  /usr/include/boost/geometry/strategies/distance_result.hpp:199:8:   required from 'struct boost::geometry::distance_result&lt;OGRLineString, OGRPoint, boost::geometry::default_strategy&gt;'
  /usr/include/boost/geometry/strategies/distance_result.hpp:205:8:   required from 'struct boost::geometry::distance_result&lt;OGRLineString, OGRPoint, void&gt;'
  /usr/include/boost/geometry/strategies/default_distance_result.hpp:35:8:   required from 'struct boost::geometry::default_distance_result&lt;OGRLineString, OGRPoint&gt;'
  /usr/include/boost/geometry/algorithms/detail/distance/interface.hpp:392:1:   required by substitution of 'template&lt;class Geometry1, class Geometry2&gt; typename boost::geometry::default_distance_result&lt;Geometry1, Geometry2&gt;::type boost::geometry::distance(const Geometry1&amp;, const Geometry2&amp;) [with Geometry1 = OGRLineString; Geometry2 = OGRPoint]'
  ../../../winzent/test/simulation/OGRLineStringAdapterTest.cpp:71:62:   required from here
  /usr/include/boost/geometry/strategies/distance.hpp:97:456: error: no matching function for call to 'assertion_failed(mpl_::failed************ (boost::geometry::strategy::distance::services::default_strategy&lt;boost::geometry::point_tag, boost::geometry::segment_tag, OGRPoint, OGRPoint, Winzent::Simulation::boost::OGRCoordinateSystemTag, Winzent::Simulation::boost::OGRCoordinateSystemTag, void&gt;::NOT_IMPLEMENTED_FOR_THIS_POINT_TYPE_COMBINATION::************)(mpl_::assert_::types&lt;OGRPoint, OGRPoint, Winzent::Simulation::boost::OGRCoordinateSystemTag, Winzent::Simulation::boost::OGRCoordinateSystemTag&gt;))'
       BOOST_MPL_ASSERT_MSG
  </code></pre>
  
  <p>So I tried to provide a template specialization specifically for <code>struct boost::geometry::detail::distance::default_strategy&lt;OGRPoint, OGRLineString, boost::geometry::pointlike_tag, boost::geometry::linestring_tag, false&gt;</code>, but with no luck --- the same error message prevails.</p>
  
  <p>This is my code:</p>
  
  <pre><code>namespace boost {
      namespace geometry {
          namespace detail {
              namespace distance {
  
  
                  template &lt;&gt;
                  struct default_strategy&lt;
                          OGRPoint,
                          OGRLineString,
                          pointlike_tag,
                          linestring_tag,
                          false&gt;
                  {
                      typedef OGRPointToLineStringDistanceStrategy type;
                  };
              } // namespace distance
          } // namespace detail
      } // namespace geometry
  } // namespace boost
  </code></pre>
  
  <p>How can I "intercept" the template instanciation that leads to the usage of the iterator/range concept and use <code>OGRGeometry::Distance()</code> directly?</p>