1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands.
4 // Copyright (c) 2008-2014 Bruno Lalande, Paris, France.
5 // Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
7 // This file was modified by Oracle on 2014.
8 // Modifications copyright (c) 2014, Oracle and/or its affiliates.
10 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
12 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
13 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
15 // Use, modification and distribution is subject to the Boost Software License,
16 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
17 // http://www.boost.org/LICENSE_1_0.txt)
19 #ifndef BOOST_GEOMETRY_STRATEGIES_CONCEPTS_DISTANCE_CONCEPT_HPP
20 #define BOOST_GEOMETRY_STRATEGIES_CONCEPTS_DISTANCE_CONCEPT_HPP
25 #include <boost/concept_check.hpp>
26 #include <boost/core/ignore_unused.hpp>
27 #include <boost/mpl/assert.hpp>
28 #include <boost/type_traits/is_same.hpp>
30 #include <boost/geometry/util/parameter_type_of.hpp>
32 #include <boost/geometry/geometries/concepts/point_concept.hpp>
33 #include <boost/geometry/geometries/segment.hpp>
34 #include <boost/geometry/geometries/point.hpp>
36 #include <boost/geometry/strategies/tags.hpp>
39 namespace boost { namespace geometry { namespace concepts
44 \brief Checks strategy for point-point or point-box or box-box distance
47 template <typename Strategy, typename Point1, typename Point2>
48 struct PointDistanceStrategy
50 #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
55 template <typename ApplyMethod>
56 static void apply(ApplyMethod)
58 // 1: inspect and define both arguments of apply
59 typedef typename parameter_type_of
64 typedef typename parameter_type_of
69 // 2) must define meta-function "return_type"
70 typedef typename strategy::distance::services::return_type
72 Strategy, ptype1, ptype2
75 // 3) must define meta-function "comparable_type"
76 typedef typename strategy::distance::services::comparable_type
81 // 4) must define meta-function "tag"
82 typedef typename strategy::distance::services::tag
87 static const bool is_correct_strategy_tag =
88 boost::is_same<tag, strategy_tag_distance_point_point>::value
89 || boost::is_same<tag, strategy_tag_distance_point_box>::value
90 || boost::is_same<tag, strategy_tag_distance_box_box>::value;
93 ((is_correct_strategy_tag),
94 INCORRECT_STRATEGY_TAG,
97 // 5) must implement apply with arguments
101 rtype r = str->apply(*p1, *p2);
103 // 6) must define (meta)struct "get_comparable" with apply
104 ctype c = strategy::distance::services::get_comparable
109 // 7) must define (meta)struct "result_from_distance" with apply
110 r = strategy::distance::services::result_from_distance
116 boost::ignore_unused<tag>();
117 boost::ignore_unused(str, c, r);
124 BOOST_CONCEPT_USAGE(PointDistanceStrategy)
126 checker::apply(&Strategy::template apply<Point1, Point2>);
133 \brief Checks strategy for point-segment distance
134 \ingroup strategy_concepts
136 template <typename Strategy, typename Point, typename PointOfSegment>
137 struct PointSegmentDistanceStrategy
139 #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
144 template <typename ApplyMethod>
145 static void apply(ApplyMethod)
147 // 1) inspect and define both arguments of apply
148 typedef typename parameter_type_of
153 typedef typename parameter_type_of
158 namespace services = strategy::distance::services;
159 // 2) must define meta-function "tag"
160 typedef typename services::tag<Strategy>::type tag;
165 tag, strategy_tag_distance_point_segment
167 INCORRECT_STRATEGY_TAG,
170 // 3) must define meta-function "return_type"
171 typedef typename services::return_type
173 Strategy, ptype, sptype
176 // 4) must define meta-function "comparable_type"
177 typedef typename services::comparable_type<Strategy>::type ctype;
179 // 5) must implement apply with arguments
185 rtype r = str->apply(*p, *sp1, *sp2);
187 // 6) must define (meta-)struct "get_comparable" with apply
188 ctype cstrategy = services::get_comparable<Strategy>::apply(*str);
190 // 7) must define (meta-)struct "result_from_distance" with apply
191 r = services::result_from_distance
193 Strategy, ptype, sptype
194 >::apply(*str, rtype(1.0));
196 boost::ignore_unused(str, r, cstrategy);
201 BOOST_CONCEPT_USAGE(PointSegmentDistanceStrategy)
203 checker::apply(&Strategy::template apply<Point, PointOfSegment>);
209 }}} // namespace boost::geometry::concepts
212 #endif // BOOST_GEOMETRY_STRATEGIES_CONCEPTS_DISTANCE_CONCEPT_HPP