~pavel-pimenov/dcplusplus/flylinkdc-mediainfo

« back to all changes in this revision

Viewing changes to boost/boost/geometry/algorithms/equals.hpp

  • Committer: pavel pimenov
  • Date: 2013-06-21 16:01:07 UTC
  • mfrom: (2636.1.678 trunk)
  • Revision ID: pavel.pimenov@gmail.com-20130621160107-icvvzptxavbbbhpx
* [merge]

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
#include <cstddef>
19
19
#include <vector>
20
20
 
21
 
#include <boost/mpl/if.hpp>
22
 
#include <boost/static_assert.hpp>
23
21
#include <boost/range.hpp>
24
22
 
25
23
#include <boost/geometry/core/access.hpp>
30
28
 
31
29
#include <boost/geometry/algorithms/detail/disjoint.hpp>
32
30
#include <boost/geometry/algorithms/detail/not.hpp>
 
31
#include <boost/geometry/algorithms/not_implemented.hpp>
33
32
 
34
33
// For trivial checks
35
34
#include <boost/geometry/algorithms/area.hpp>
51
50
 
52
51
template
53
52
<
54
 
    typename Box1,
55
 
    typename Box2,
56
53
    std::size_t Dimension,
57
54
    std::size_t DimensionCount
58
55
>
59
56
struct box_box
60
57
{
 
58
    template <typename Box1, typename Box2>
61
59
    static inline bool apply(Box1 const& box1, Box2 const& box2)
62
60
    {
63
61
        if (!geometry::math::equals(get<min_corner, Dimension>(box1), get<min_corner, Dimension>(box2))
65
63
        {
66
64
            return false;
67
65
        }
68
 
        return box_box<Box1, Box2, Dimension + 1, DimensionCount>::apply(box1, box2);
 
66
        return box_box<Dimension + 1, DimensionCount>::apply(box1, box2);
69
67
    }
70
68
};
71
69
 
72
 
template <typename Box1, typename Box2, std::size_t DimensionCount>
73
 
struct box_box<Box1, Box2, DimensionCount, DimensionCount>
 
70
template <std::size_t DimensionCount>
 
71
struct box_box<DimensionCount, DimensionCount>
74
72
{
 
73
    template <typename Box1, typename Box2>
75
74
    static inline bool apply(Box1 const& , Box2 const& )
76
75
    {
77
76
        return true;
103
102
};
104
103
 
105
104
 
106
 
template <typename Geometry1, typename Geometry2, typename TrivialCheck>
 
105
template <typename TrivialCheck>
107
106
struct equals_by_collection
108
107
{
 
108
    template <typename Geometry1, typename Geometry2>
109
109
    static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2)
110
110
    {
111
111
        if (! TrivialCheck::apply(geometry1, geometry2))
152
152
 
153
153
template
154
154
<
155
 
    typename Tag1, typename Tag2,
156
155
    typename Geometry1,
157
156
    typename Geometry2,
 
157
    typename Tag1 = typename tag<Geometry1>::type,
 
158
    typename Tag2 = typename tag<Geometry2>::type,
 
159
    std::size_t DimensionCount = dimension<Geometry1>::type::value,
 
160
    bool Reverse = reverse_dispatch<Geometry1, Geometry2>::type::value
 
161
>
 
162
struct equals: not_implemented<Tag1, Tag2>
 
163
{};
 
164
 
 
165
 
 
166
// If reversal is needed, perform it
 
167
template
 
168
<
 
169
    typename Geometry1, typename Geometry2,
 
170
    typename Tag1, typename Tag2,
158
171
    std::size_t DimensionCount
159
172
>
160
 
struct equals
161
 
{};
162
 
 
163
 
 
164
 
template <typename P1, typename P2, std::size_t DimensionCount>
165
 
struct equals<point_tag, point_tag, P1, P2, DimensionCount>
 
173
struct equals<Geometry1, Geometry2, Tag1, Tag2, DimensionCount, true>
 
174
    : equals<Geometry2, Geometry1, Tag2, Tag1, DimensionCount, false>
 
175
{
 
176
    static inline bool apply(Geometry1 const& g1, Geometry2 const& g2)
 
177
    {
 
178
        return equals
 
179
            <
 
180
                Geometry2, Geometry1,
 
181
                Tag2, Tag1,
 
182
                DimensionCount,
 
183
                false
 
184
            >::apply(g2, g1);
 
185
    }
 
186
};
 
187
 
 
188
 
 
189
template <typename P1, typename P2, std::size_t DimensionCount, bool Reverse>
 
190
struct equals<P1, P2, point_tag, point_tag, DimensionCount, Reverse>
166
191
    : geometry::detail::not_
167
192
        <
168
193
            P1,
172
197
{};
173
198
 
174
199
 
175
 
template <typename Box1, typename Box2, std::size_t DimensionCount>
176
 
struct equals<box_tag, box_tag, Box1, Box2, DimensionCount>
177
 
    : detail::equals::box_box<Box1, Box2, 0, DimensionCount>
178
 
{};
179
 
 
180
 
 
181
 
template <typename Ring1, typename Ring2>
182
 
struct equals<ring_tag, ring_tag, Ring1, Ring2, 2>
183
 
    : detail::equals::equals_by_collection
184
 
        <
185
 
            Ring1, Ring2,
186
 
            detail::equals::area_check
187
 
        >
188
 
{};
189
 
 
190
 
 
191
 
template <typename Polygon1, typename Polygon2>
192
 
struct equals<polygon_tag, polygon_tag, Polygon1, Polygon2, 2>
193
 
    : detail::equals::equals_by_collection
194
 
        <
195
 
            Polygon1, Polygon2,
196
 
            detail::equals::area_check
197
 
        >
198
 
{};
199
 
 
200
 
 
201
 
template <typename LineString1, typename LineString2>
202
 
struct equals<linestring_tag, linestring_tag, LineString1, LineString2, 2>
203
 
    : detail::equals::equals_by_collection
204
 
        <
205
 
            LineString1, LineString2,
206
 
            detail::equals::length_check
207
 
        >
208
 
{};
209
 
 
210
 
 
211
 
template <typename Polygon, typename Ring>
212
 
struct equals<polygon_tag, ring_tag, Polygon, Ring, 2>
213
 
    : detail::equals::equals_by_collection
214
 
        <
215
 
            Polygon, Ring,
216
 
            detail::equals::area_check
217
 
        >
218
 
{};
219
 
 
220
 
 
221
 
template <typename Ring, typename Box>
222
 
struct equals<ring_tag, box_tag, Ring, Box, 2>
223
 
    : detail::equals::equals_by_collection
224
 
        <
225
 
            Ring, Box,
226
 
            detail::equals::area_check
227
 
        >
228
 
{};
229
 
 
230
 
 
231
 
template <typename Polygon, typename Box>
232
 
struct equals<polygon_tag, box_tag, Polygon, Box, 2>
233
 
    : detail::equals::equals_by_collection
234
 
        <
235
 
            Polygon, Box,
236
 
            detail::equals::area_check
237
 
        >
238
 
{};
239
 
 
240
 
 
241
 
template
242
 
<
243
 
    typename Tag1, typename Tag2,
244
 
    typename Geometry1,
245
 
    typename Geometry2,
246
 
    std::size_t DimensionCount
247
 
>
248
 
struct equals_reversed
249
 
{
250
 
    static inline bool apply(Geometry1 const& g1, Geometry2 const& g2)
251
 
    {
252
 
        return equals
253
 
            <
254
 
                Tag2, Tag1,
255
 
                Geometry2, Geometry1,
256
 
                DimensionCount
257
 
            >::apply(g2, g1);
258
 
    }
259
 
};
 
200
template <typename Box1, typename Box2, std::size_t DimensionCount, bool Reverse>
 
201
struct equals<Box1, Box2, box_tag, box_tag, DimensionCount, Reverse>
 
202
    : detail::equals::box_box<0, DimensionCount>
 
203
{};
 
204
 
 
205
 
 
206
template <typename Ring1, typename Ring2, bool Reverse>
 
207
struct equals<Ring1, Ring2, ring_tag, ring_tag, 2, Reverse>
 
208
    : detail::equals::equals_by_collection<detail::equals::area_check>
 
209
{};
 
210
 
 
211
 
 
212
template <typename Polygon1, typename Polygon2, bool Reverse>
 
213
struct equals<Polygon1, Polygon2, polygon_tag, polygon_tag, 2, Reverse>
 
214
    : detail::equals::equals_by_collection<detail::equals::area_check>
 
215
{};
 
216
 
 
217
 
 
218
template <typename LineString1, typename LineString2, bool Reverse>
 
219
struct equals<LineString1, LineString2, linestring_tag, linestring_tag, 2, Reverse>
 
220
    : detail::equals::equals_by_collection<detail::equals::length_check>
 
221
{};
 
222
 
 
223
 
 
224
template <typename Polygon, typename Ring, bool Reverse>
 
225
struct equals<Polygon, Ring, polygon_tag, ring_tag, 2, Reverse>
 
226
    : detail::equals::equals_by_collection<detail::equals::area_check>
 
227
{};
 
228
 
 
229
 
 
230
template <typename Ring, typename Box, bool Reverse>
 
231
struct equals<Ring, Box, ring_tag, box_tag, 2, Reverse>
 
232
    : detail::equals::equals_by_collection<detail::equals::area_check>
 
233
{};
 
234
 
 
235
 
 
236
template <typename Polygon, typename Box, bool Reverse>
 
237
struct equals<Polygon, Box, polygon_tag, box_tag, 2, Reverse>
 
238
    : detail::equals::equals_by_collection<detail::equals::area_check>
 
239
{};
260
240
 
261
241
 
262
242
} // namespace dispatch
289
269
            Geometry2 const
290
270
        >();
291
271
 
292
 
    return boost::mpl::if_c
293
 
        <
294
 
            reverse_dispatch<Geometry1, Geometry2>::type::value,
295
 
            dispatch::equals_reversed
296
 
            <
297
 
                typename tag<Geometry1>::type,
298
 
                typename tag<Geometry2>::type,
299
 
                Geometry1,
300
 
                Geometry2,
301
 
                dimension<Geometry1>::type::value
302
 
            >,
303
 
            dispatch::equals
304
 
            <
305
 
                typename tag<Geometry1>::type,
306
 
                typename tag<Geometry2>::type,
307
 
                Geometry1,
308
 
                Geometry2,
309
 
                dimension<Geometry1>::type::value
310
 
            >
311
 
        >::type::apply(geometry1, geometry2);
 
272
    return dispatch::equals<Geometry1, Geometry2>::apply(geometry1, geometry2);
312
273
}
313
274
 
314
275