summaryrefslogtreecommitdiff
path: root/boost/geometry/algorithms/detail/buffer/turn_in_input.hpp
blob: 2b1c33d291cc285ffaa28f4bf04f6ffee080b0cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// Boost.Geometry (aka GGL, Generic Geometry Library)

// Copyright (c) 2012-2014 Barend Gehrels, Amsterdam, the Netherlands.

// 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)

#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_TURN_IN_INPUT_HPP
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_TURN_IN_INPUT_HPP

#include <boost/geometry/core/tags.hpp>
#include <boost/geometry/algorithms/covered_by.hpp>


namespace boost { namespace geometry
{

#ifndef DOXYGEN_NO_DETAIL
namespace detail { namespace buffer
{

// Checks if an turn/intersection point is inside (or covered by) the input geometry

template <typename Tag>
struct turn_in_input
{
};

template <>
struct turn_in_input<polygon_tag>
{
    template <typename Point, typename Geometry>
    static inline int apply(Point const& point, Geometry const& geometry)
    {
        return geometry::covered_by(point, geometry) ? 1 : -1;
    }
};

template <>
struct turn_in_input<linestring_tag>
{
    template <typename Point, typename Geometry>
    static inline int apply(Point const& , Geometry const& )
    {
        return 0;
    }
};

template <>
struct turn_in_input<point_tag>
{
    template <typename Point, typename Geometry>
    static inline int apply(Point const& , Geometry const& )
    {
        return 0;
    }
};

template <>
struct turn_in_input<multi_polygon_tag>
{
    template <typename Point, typename Geometry>
    static inline int apply(Point const& point, Geometry const& geometry)
    {
        return geometry::covered_by(point, geometry) ? 1 : -1;
    }
};

template <>
struct turn_in_input<multi_linestring_tag>
{
    template <typename Point, typename Geometry>
    static inline int apply(Point const& , Geometry const& )
    {
        return 0;
    }
};

template <>
struct turn_in_input<multi_point_tag>
{
    template <typename Point, typename Geometry>
    static inline int apply(Point const& , Geometry const& )
    {
        return 0;
    }
};


}} // namespace detail::buffer
#endif // DOXYGEN_NO_DETAIL



}} // namespace boost::geometry

#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_TURN_IN_INPUT_HPP