Loading...
Searching...
No Matches
node_ref.hpp
Go to the documentation of this file.
#ifndef OSMIUM_OSM_NODE_REF_HPP
#define OSMIUM_OSM_NODE_REF_HPP
/*
This file is part of Osmium (https://osmcode.org/libosmium).
Copyright 2013-2025 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 <osmium/memory/item.hpp>
#include <osmium/osm/location.hpp>
#include <osmium/osm/types.hpp>
#include <cstdint>
#include <cstdlib>
#include <iosfwd>
namespace osmium {
class NodeRef : public osmium::memory::detail::ItemHelper {
osmium::object_id_type m_ref;
osmium::Location m_location;
public:
constexpr NodeRef(const osmium::object_id_type ref = 0, const osmium::Location& location = Location{}) noexcept : // NOLINT(google-explicit-constructor, hicpp-explicit-conversions)
m_ref(ref),
m_location(location) {
}
constexpr osmium::object_id_type ref() const noexcept {
return m_ref;
}
osmium::unsigned_object_id_type positive_ref() const noexcept {
return static_cast<osmium::unsigned_object_id_type>(std::abs(m_ref));
}
osmium::Location& location() noexcept {
return m_location;
}
constexpr osmium::Location location() const noexcept {
return m_location;
}
double lon() const {
return m_location.lon();
}
double lat() const {
return m_location.lat();
}
constexpr int32_t x() const noexcept {
return m_location.x();
}
constexpr int32_t y() const noexcept {
return m_location.y();
}
NodeRef& set_ref(const osmium::object_id_type ref) noexcept {
m_ref = ref;
return *this;
}
NodeRef& set_location(const osmium::Location& location) noexcept {
m_location = location;
return *this;
}
}; // class NodeRef
constexpr bool operator==(const NodeRef& lhs, const NodeRef& rhs) noexcept {
return lhs.ref() == rhs.ref();
}
constexpr bool operator!=(const NodeRef& lhs, const NodeRef& rhs) noexcept {
return !(lhs == rhs);
}
constexpr bool operator<(const NodeRef& lhs, const NodeRef& rhs) noexcept {
return lhs.ref() < rhs.ref();
}
constexpr bool operator>(const NodeRef& lhs, const NodeRef& rhs) noexcept {
return rhs < lhs;
}
constexpr bool operator<=(const NodeRef& lhs, const NodeRef& rhs) noexcept {
return !(rhs < lhs);
}
constexpr bool operator>=(const NodeRef& lhs, const NodeRef& rhs) noexcept {
return !(lhs < rhs);
}
template <typename TChar, typename TTraits>
inline std::basic_ostream<TChar, TTraits>& operator<<(std::basic_ostream<TChar, TTraits>& out, const osmium::NodeRef& nr) {
return out << "<" << nr.ref() << " " << nr.location() << ">";
}
struct location_equal {
constexpr bool operator()(const NodeRef& lhs, const NodeRef& rhs) const noexcept {
return lhs.location() == rhs.location();
}
using first_argument_type = NodeRef;
using second_argument_type = NodeRef;
using result_type = bool;
}; // struct location_equal
struct location_less {
constexpr bool operator()(const NodeRef& lhs, const NodeRef& rhs) const noexcept {
return lhs.location() < rhs.location();
}
using first_argument_type = NodeRef;
using second_argument_type = NodeRef;
using result_type = bool;
}; // struct location_less
} // namespace osmium
#endif // OSMIUM_OSM_NODE_REF_HPP
osmium::Location
Definition location.hpp:271
osmium::Location::lon
double lon() const
Definition location.hpp:400
osmium::Location::x
constexpr int32_t x() const noexcept
Definition location.hpp:377
osmium::Location::lat
double lat() const
Definition location.hpp:419
osmium::Location::y
constexpr int32_t y() const noexcept
Definition location.hpp:381
osmium::NodeRef
Definition node_ref.hpp:50
osmium::NodeRef::set_ref
NodeRef & set_ref(const osmium::object_id_type ref) noexcept
Definition node_ref.hpp:133
osmium::NodeRef::positive_ref
osmium::unsigned_object_id_type positive_ref() const noexcept
Definition node_ref.hpp:78
osmium::NodeRef::x
constexpr int32_t x() const noexcept
Definition node_ref.hpp:117
osmium::NodeRef::NodeRef
constexpr NodeRef(const osmium::object_id_type ref=0, const osmium::Location &location=Location{}) noexcept
Definition node_ref.hpp:63
osmium::NodeRef::lon
double lon() const
Definition node_ref.hpp:101
osmium::NodeRef::set_location
NodeRef & set_location(const osmium::Location &location) noexcept
Definition node_ref.hpp:143
osmium::NodeRef::y
constexpr int32_t y() const noexcept
Definition node_ref.hpp:124
osmium::NodeRef::location
constexpr osmium::Location location() const noexcept
Definition node_ref.hpp:92
osmium::NodeRef::ref
constexpr osmium::object_id_type ref() const noexcept
Definition node_ref.hpp:71
osmium::NodeRef::lat
double lat() const
Definition node_ref.hpp:110
osmium::NodeRef::location
osmium::Location & location() noexcept
Definition node_ref.hpp:85
osmium::NodeRef::m_ref
osmium::object_id_type m_ref
Definition node_ref.hpp:52
osmium::NodeRef::m_location
osmium::Location m_location
Definition node_ref.hpp:53
item.hpp
location.hpp
osmium
Namespace for everything in the Osmium library.
Definition assembler.hpp:53
osmium::operator==
bool operator==(const Changeset &lhs, const Changeset &rhs)
Definition changeset.hpp:440
osmium::operator<=
bool operator<=(const Changeset &lhs, const Changeset &rhs)
Definition changeset.hpp:459
osmium::operator>
bool operator>(const Changeset &lhs, const Changeset &rhs)
Definition changeset.hpp:455
osmium::object_id_type
int64_t object_id_type
Type for OSM object (node, way, or relation) IDs.
Definition types.hpp:45
osmium::operator>=
bool operator>=(const Changeset &lhs, const Changeset &rhs)
Definition changeset.hpp:463
osmium::operator!=
bool operator!=(const Changeset &lhs, const Changeset &rhs)
Definition changeset.hpp:444
osmium::operator<<
std::basic_ostream< TChar, TTraits > & operator<<(std::basic_ostream< TChar, TTraits > &out, const item_type item_type)
Definition item_type.hpp:187
osmium::unsigned_object_id_type
uint64_t unsigned_object_id_type
Type for OSM object (node, way, or relation) IDs where we only allow positive IDs.
Definition types.hpp:46
osmium::operator<
bool operator<(const Changeset &lhs, const Changeset &rhs)
Definition changeset.hpp:451
osmium::location_equal
Definition node_ref.hpp:208
osmium::location_equal::result_type
bool result_type
Definition node_ref.hpp:216
osmium::location_equal::operator()
constexpr bool operator()(const NodeRef &lhs, const NodeRef &rhs) const noexcept
Definition node_ref.hpp:210
osmium::location_less
Definition node_ref.hpp:223
osmium::location_less::result_type
bool result_type
Definition node_ref.hpp:231
osmium::location_less::operator()
constexpr bool operator()(const NodeRef &lhs, const NodeRef &rhs) const noexcept
Definition node_ref.hpp:225
types.hpp