Libosmium  2.20.0
Fast and flexible C++ library for working with OpenStreetMap data
Loading...
Searching...
No Matches
way.hpp
Go to the documentation of this file.
1#ifndef OSMIUM_OSM_WAY_HPP
2#define OSMIUM_OSM_WAY_HPP
3
4/*
5
6This file is part of Osmium (https://osmcode.org/libosmium).
7
8Copyright 2013-2023 Jochen Topf <jochen@topf.org> and others (see README).
9
10Boost Software License - Version 1.0 - August 17th, 2003
11
12Permission is hereby granted, free of charge, to any person or organization
13obtaining a copy of the software and accompanying documentation covered by
14this license (the "Software") to use, reproduce, display, distribute,
15execute, and transmit the Software, and to prepare derivative works of the
16Software, and to permit third-parties to whom the Software is furnished to
17do so, all subject to the following:
18
19The copyright notices in the Software and this entire statement, including
20the above license grant, this restriction and the following disclaimer,
21must be included in all copies of the Software, in whole or in part, and
22all derivative works of the Software, unless such copies or derivative
23works are solely in the form of machine-executable object code generated by
24a source language processor.
25
26THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
29SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
30FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
31ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
32DEALINGS IN THE SOFTWARE.
33
34*/
35
38#include <osmium/osm/box.hpp>
39#include <osmium/osm/entity.hpp>
43#include <osmium/osm/object.hpp>
44
45namespace osmium {
46
47 namespace builder {
48 template <typename TDerived, typename T>
49 class OSMObjectBuilder;
50 } // namespace builder
51
55 class WayNodeList : public NodeRefList {
56
57 public:
58
60
61 constexpr static bool is_compatible_to(osmium::item_type t) noexcept {
62 return t == itemtype;
63 }
64
65 WayNodeList() noexcept :
67 }
68
69 }; // class WayNodeList
70
71
72 class Way : public OSMObject {
73
74 template <typename TDerived, typename T>
76
77 Way() noexcept :
78 OSMObject(sizeof(Way), osmium::item_type::way) {
79 }
80
81 public:
82
84
85 constexpr static bool is_compatible_to(osmium::item_type t) noexcept {
86 return t == itemtype;
87 }
88
90 return osmium::detail::subitem_of_type<WayNodeList>(begin(), end());
91 }
92
93 const WayNodeList& nodes() const {
94 return osmium::detail::subitem_of_type<const WayNodeList>(cbegin(), cend());
95 }
96
101 void update_node_location(const NodeRef& new_node_ref) {
102 for (auto& node_ref : nodes()) {
103 if (node_ref.ref() == new_node_ref.ref()) {
104 node_ref.set_location(new_node_ref.location());
105 }
106 }
107 }
108
117 bool is_closed() const noexcept {
118 return nodes().is_closed();
119 }
120
129 bool ends_have_same_id() const noexcept {
130 return nodes().ends_have_same_id();
131 }
132
144 }
145
152 osmium::Box envelope() const noexcept {
153 return nodes().envelope();
154 }
155
156 }; // class Way
157
158
159} // namespace osmium
160
161#endif // OSMIUM_OSM_WAY_HPP
Definition node_ref_list.hpp:52
osmium::Box envelope() const noexcept
Definition node_ref_list.hpp:190
bool is_closed() const noexcept
Definition node_ref_list.hpp:151
bool ends_have_same_location() const
Definition node_ref_list.hpp:178
bool ends_have_same_id() const noexcept
Definition node_ref_list.hpp:164
Definition node_ref.hpp:50
constexpr osmium::object_id_type ref() const noexcept
Definition node_ref.hpp:71
osmium::Location & location() noexcept
Definition node_ref.hpp:85
Definition object.hpp:64
const_iterator cend() const
Definition object.hpp:397
iterator end()
Definition object.hpp:389
iterator begin()
Definition object.hpp:385
const_iterator cbegin() const
Definition object.hpp:393
Definition way.hpp:55
WayNodeList() noexcept
Definition way.hpp:65
static constexpr bool is_compatible_to(osmium::item_type t) noexcept
Definition way.hpp:61
static constexpr osmium::item_type itemtype
Definition way.hpp:59
Definition way.hpp:72
bool ends_have_same_location() const
Definition way.hpp:142
static constexpr bool is_compatible_to(osmium::item_type t) noexcept
Definition way.hpp:85
bool ends_have_same_id() const noexcept
Definition way.hpp:129
osmium::Box envelope() const noexcept
Definition way.hpp:152
const WayNodeList & nodes() const
Definition way.hpp:93
bool is_closed() const noexcept
Definition way.hpp:117
WayNodeList & nodes()
Definition way.hpp:89
void update_node_location(const NodeRef &new_node_ref)
Definition way.hpp:101
static constexpr osmium::item_type itemtype
Definition way.hpp:83
Way() noexcept
Definition way.hpp:77
Definition osm_object_builder.hpp:401
Namespace for everything in the Osmium library.
Definition assembler.hpp:53
item_type
Definition item_type.hpp:45