Libosmium 2.22.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
6 This file is part of Osmium (https://osmcode.org/libosmium).
7
8 Copyright 2013-2025 Jochen Topf <jochen@topf.org> and others (see README).
9
10 Boost Software License - Version 1.0 - August 17th, 2003
11
12 Permission is hereby granted, free of charge, to any person or organization
13 obtaining a copy of the software and accompanying documentation covered by
14 this license (the "Software") to use, reproduce, display, distribute,
15 execute, and transmit the Software, and to prepare derivative works of the
16 Software, and to permit third-parties to whom the Software is furnished to
17 do so, all subject to the following:
18
19 The copyright notices in the Software and this entire statement, including
20 the above license grant, this restriction and the following disclaimer,
21 must be included in all copies of the Software, in whole or in part, and
22 all derivative works of the Software, unless such copies or derivative
23 works are solely in the form of machine-executable object code generated by
24 a source language processor.
25
26 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28 FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
29 SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
30 FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
31 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
32 DEALINGS IN THE SOFTWARE.
33
34*/
35
36#include <osmium/memory/collection.hpp>
37#include <osmium/memory/item.hpp>
38#include <osmium/osm/box.hpp>
39#include <osmium/osm/entity.hpp>
40#include <osmium/osm/item_type.hpp>
41#include <osmium/osm/node_ref.hpp>
42#include <osmium/osm/node_ref_list.hpp>
43#include <osmium/osm/object.hpp>
44
45 namespace 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
59 static constexpr osmium::item_type itemtype = osmium::item_type::way_node_list;
60
61 constexpr static bool is_compatible_to(osmium::item_type t) noexcept {
62 return t == itemtype;
63 }
64
65 WayNodeList() noexcept :
66 NodeRefList(itemtype) {
67 }
68
69 }; // class WayNodeList
70
71
72 class Way : public OSMObject {
73
74 template <typename TDerived, typename T>
75 friend class osmium::builder::OSMObjectBuilder;
76
77 Way() noexcept :
78 OSMObject(sizeof(Way), osmium::item_type::way) {
79 }
80
81 public:
82
83 static constexpr osmium::item_type itemtype = osmium::item_type::way;
84
85 constexpr static bool is_compatible_to(osmium::item_type t) noexcept {
86 return t == itemtype;
87 }
88
89 WayNodeList& nodes() {
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
142 bool ends_have_same_location() const {
143 return nodes().ends_have_same_location();
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
box.hpp
osmium::NodeRefList
Definition node_ref_list.hpp:52
osmium::NodeRefList::envelope
osmium::Box envelope() const noexcept
Definition node_ref_list.hpp:190
osmium::NodeRefList::is_closed
bool is_closed() const noexcept
Definition node_ref_list.hpp:151
osmium::NodeRefList::ends_have_same_location
bool ends_have_same_location() const
Definition node_ref_list.hpp:178
osmium::NodeRefList::ends_have_same_id
bool ends_have_same_id() const noexcept
Definition node_ref_list.hpp:164
osmium::NodeRef
Definition node_ref.hpp:50
osmium::NodeRef::ref
constexpr osmium::object_id_type ref() const noexcept
Definition node_ref.hpp:71
osmium::NodeRef::location
osmium::Location & location() noexcept
Definition node_ref.hpp:85
osmium::OSMObject
Definition object.hpp:64
osmium::OSMObject::cend
const_iterator cend() const
Definition object.hpp:397
osmium::OSMObject::end
iterator end()
Definition object.hpp:389
osmium::OSMObject::begin
iterator begin()
Definition object.hpp:385
osmium::OSMObject::cbegin
const_iterator cbegin() const
Definition object.hpp:393
osmium::WayNodeList
Definition way.hpp:55
osmium::WayNodeList::WayNodeList
WayNodeList() noexcept
Definition way.hpp:65
osmium::WayNodeList::is_compatible_to
static constexpr bool is_compatible_to(osmium::item_type t) noexcept
Definition way.hpp:61
osmium::WayNodeList::itemtype
static constexpr osmium::item_type itemtype
Definition way.hpp:59
osmium::Way
Definition way.hpp:72
osmium::Way::ends_have_same_location
bool ends_have_same_location() const
Definition way.hpp:142
osmium::Way::is_compatible_to
static constexpr bool is_compatible_to(osmium::item_type t) noexcept
Definition way.hpp:85
osmium::Way::ends_have_same_id
bool ends_have_same_id() const noexcept
Definition way.hpp:129
osmium::Way::envelope
osmium::Box envelope() const noexcept
Definition way.hpp:152
osmium::Way::nodes
const WayNodeList & nodes() const
Definition way.hpp:93
osmium::Way::is_closed
bool is_closed() const noexcept
Definition way.hpp:117
osmium::Way::nodes
WayNodeList & nodes()
Definition way.hpp:89
osmium::Way::update_node_location
void update_node_location(const NodeRef &new_node_ref)
Definition way.hpp:101
osmium::Way::itemtype
static constexpr osmium::item_type itemtype
Definition way.hpp:83
osmium::Way::Way
Way() noexcept
Definition way.hpp:77
osmium::builder::OSMObjectBuilder
Definition way.hpp:49
collection.hpp
entity.hpp
item.hpp
item_type.hpp
osmium
Namespace for everything in the Osmium library.
Definition assembler.hpp:53
osmium::item_type
item_type
Definition item_type.hpp:45
osmium::item_type::way_node_list
@ way_node_list
osmium::item_type::way
@ way
node_ref.hpp
node_ref_list.hpp
object.hpp