This file is indexed.

/usr/include/osmium/area/detail/proto_ring.hpp is in libosmium2-dev 2.11.4-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
#ifndef OSMIUM_AREA_DETAIL_PROTO_RING_HPP
#define OSMIUM_AREA_DETAIL_PROTO_RING_HPP

/*

This file is part of Osmium (http://osmcode.org/libosmium).

Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).

Boost Software License - Version 1.0 - August 17th, 2003

Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:

The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

*/

#include <algorithm>
#include <cassert>
#include <cstdint>
#include <iostream>
#include <set>
#include <vector>

#include <osmium/osm/location.hpp>
#include <osmium/osm/node_ref.hpp>
#include <osmium/area/detail/node_ref_segment.hpp>

namespace osmium {

    class Way;

    namespace area {

        namespace detail {

            /**
             * A ring in the process of being built by the Assembler object.
             */
            class ProtoRing {

            public:

                using segments_type = std::vector<NodeRefSegment*>;

            private:

                // Segments in this ring.
                segments_type m_segments;

                // If this is an outer ring, these point to it's inner rings
                // (if any).
                std::vector<ProtoRing*> m_inner;

                // The smallest segment. Will be kept current whenever a new
                // segment is added to the ring.
                NodeRefSegment* m_min_segment;

                // If this is an inner ring, points to the outer ring.
                ProtoRing* m_outer_ring;

                int64_t m_sum;

            public:

                explicit ProtoRing(NodeRefSegment* segment) noexcept :
                    m_segments(),
                    m_inner(),
                    m_min_segment(segment),
                    m_outer_ring(nullptr),
                    m_sum(0) {
                    add_segment_back(segment);
                }

                void add_segment_back(NodeRefSegment* segment) {
                    assert(segment);
                    if (*segment < *m_min_segment) {
                        m_min_segment = segment;
                    }
                    m_segments.push_back(segment);
                    segment->set_ring(this);
                    m_sum += segment->det();
                }

                NodeRefSegment* min_segment() const noexcept {
                    return m_min_segment;
                }

                ProtoRing* outer_ring() const noexcept {
                    return m_outer_ring;
                }

                void set_outer_ring(ProtoRing* outer_ring) noexcept {
                    assert(outer_ring);
                    assert(m_inner.empty());
                    m_outer_ring = outer_ring;
                }

                const std::vector<ProtoRing*>& inner_rings() const noexcept {
                    return m_inner;
                }

                void add_inner_ring(ProtoRing* ring) {
                    assert(ring);
                    assert(!m_outer_ring);
                    m_inner.push_back(ring);
                }

                bool is_outer() const noexcept {
                    return !m_outer_ring;
                }

                const segments_type& segments() const noexcept {
                    return m_segments;
                }

                const NodeRef& get_node_ref_start() const noexcept {
                    return m_segments.front()->start();
                }

                const NodeRef& get_node_ref_stop() const noexcept {
                    return m_segments.back()->stop();
                }

                bool closed() const noexcept {
                    return get_node_ref_start().location() == get_node_ref_stop().location();
                }

                void reverse() {
                    std::for_each(m_segments.begin(), m_segments.end(), [](NodeRefSegment* segment) {
                        segment->reverse();
                    });
                    std::reverse(m_segments.begin(), m_segments.end());
                    m_sum = -m_sum;
                }

                void mark_direction_done() {
                    std::for_each(m_segments.begin(), m_segments.end(), [](NodeRefSegment* segment) {
                        segment->mark_direction_done();
                    });
                }

                bool is_cw() const noexcept {
                    return m_sum <= 0;
                }

                int64_t sum() const noexcept {
                    return m_sum;
                }

                void fix_direction() noexcept {
                    if (is_cw() == is_outer()) {
                        reverse();
                    }
                }

                void reset() {
                    m_inner.clear();
                    m_outer_ring = nullptr;
                    std::for_each(m_segments.begin(), m_segments.end(), [](NodeRefSegment* segment) {
                        segment->mark_direction_not_done();
                    });
                }

                void get_ways(std::set<const osmium::Way*>& ways) const {
                    for (const auto& segment : m_segments) {
                        ways.insert(segment->way());
                    }
                }

                void join_forward(ProtoRing& other) {
                    for (NodeRefSegment* segment : other.m_segments) {
                        add_segment_back(segment);
                    }
                }

                void join_backward(ProtoRing& other) {
                    for (auto it = other.m_segments.rbegin(); it != other.m_segments.rend(); ++it) {
                        (*it)->reverse();
                        add_segment_back(*it);
                    }
                }

                void print(std::ostream& out) const {
                    out << "[";
                    if (!m_segments.empty()) {
                        out << m_segments.front()->start().ref();
                    }
                    for (const auto& segment : m_segments) {
                        out << ',' << segment->stop().ref();
                    }
                    out << "]-" << (is_outer() ? "OUTER" : "INNER");
                }

            }; // class ProtoRing

            template <typename TChar, typename TTraits>
            inline std::basic_ostream<TChar, TTraits>& operator<<(std::basic_ostream<TChar, TTraits>& out, const ProtoRing& ring) {
                ring.print(out);
                return out;
            }

        } // namespace detail

    } // namespace area

} // namespace osmium

#endif // OSMIUM_AREA_DETAIL_PROTO_RING_HPP