Libosmium: include/osmium/osm/way.hpp Source File

Libosmium 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-2026 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
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
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
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::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::NodeRefList
NodeRefList(osmium::item_type itemtype) noexcept
Definition node_ref_list.hpp:65
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::cend
const_iterator cend() const
Definition object.hpp:397
osmium::OSMObject::end
iterator end()
Definition object.hpp:389
osmium::OSMObject::OSMObject
OSMObject(osmium::memory::item_size_type size, osmium::item_type type)
Definition object.hpp:102
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::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 osm_object_builder.hpp:428
collection.hpp
entity.hpp
item.hpp
item_type.hpp
osmium::builder
Classes for building OSM objects and other items in buffers.
Definition attr.hpp:62
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
Definition item_type.hpp:54
osmium::item_type::way
@ way
Definition item_type.hpp:49
node_ref.hpp
node_ref_list.hpp
object.hpp