File: polygon.hpp

package info (click to toggle)
mapbox-geometry 2.0.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 304 kB
  • sloc: cpp: 1,563; sh: 150; makefile: 37
file content (45 lines) | stat: -rw-r--r-- 1,195 bytes parent folder | download | duplicates (6)
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
#pragma once

// mapbox
#include <mapbox/geometry/point.hpp>

// stl
#include <vector>

namespace mapbox {
namespace geometry {

template <typename T, template <typename...> class Cont = std::vector>
struct linear_ring : Cont<point<T>>
{
    using coordinate_type = T;
    using point_type = point<T>;
    using container_type = Cont<point_type>;
    using size_type = typename container_type::size_type;

    template <class... Args>
    linear_ring(Args&&... args) : container_type(std::forward<Args>(args)...)
    {
    }
    linear_ring(std::initializer_list<point_type> args)
        : container_type(std::move(args)) {}
};

template <typename T, template <typename...> class Cont = std::vector>
struct polygon : Cont<linear_ring<T>>
{
    using coordinate_type = T;
    using linear_ring_type = linear_ring<T>;
    using container_type = Cont<linear_ring_type>;
    using size_type = typename container_type::size_type;

    template <class... Args>
    polygon(Args&&... args) : container_type(std::forward<Args>(args)...)
    {
    }
    polygon(std::initializer_list<linear_ring_type> args)
        : container_type(std::move(args)) {}
};

} // namespace geometry
} // namespace mapbox