Libosmium  2.15.2
Fast and flexible C++ library for working with OpenStreetMap data
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-2019 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 
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>
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 
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>
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 
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
WayNodeList & nodes()
Definition: way.hpp:89
Definition: osm_object_builder.hpp:402
bool ends_have_same_id() const noexcept
Definition: way.hpp:129
item_type
Definition: item_type.hpp:43
InputIterator< Reader > end(Reader &)
Definition: reader_iterator.hpp:47
Definition: way.hpp:72
static constexpr bool is_compatible_to(osmium::item_type t) noexcept
Definition: way.hpp:61
InputIterator< Reader > begin(Reader &reader)
Definition: reader_iterator.hpp:43
constexpr osmium::object_id_type ref() const noexcept
Definition: node_ref.hpp:71
Definition: way.hpp:55
Namespace for everything in the Osmium library.
Definition: assembler.hpp:53
Way() noexcept
Definition: way.hpp:77
void update_node_location(const NodeRef &new_node_ref)
Definition: way.hpp:101
bool is_closed() const noexcept
Definition: way.hpp:117
static constexpr bool is_compatible_to(osmium::item_type t) noexcept
Definition: way.hpp:85
osmium::Location & location() noexcept
Definition: node_ref.hpp:85
Definition: box.hpp:49
bool ends_have_same_location() const
Definition: way.hpp:142
osmium::Box envelope() const noexcept
Definition: way.hpp:152
WayNodeList() noexcept
Definition: way.hpp:65
const WayNodeList & nodes() const
Definition: way.hpp:93
Definition: node_ref_list.hpp:52
Definition: node_ref.hpp:50
Definition: object.hpp:64