1 #ifndef OSMIUM_HANDLER_NODE_LOCATIONS_FOR_WAYS_HPP 2 #define OSMIUM_HANDLER_NODE_LOCATIONS_FOR_WAYS_HPP 47 #include <type_traits> 63 template <
typename TStoragePosIDs,
typename TStorageNegIDs = dummy_type>
67 using based_on_map = std::is_base_of<osmium::index::map::Map<osmium::unsigned_object_id_type, osmium::Location>, T>;
99 TStorageNegIDs& storage_neg =
get_dummy()) noexcept :
100 m_storage_pos(storage_pos),
101 m_storage_neg(storage_neg) {
113 m_ignore_errors =
true;
125 const auto id = node.
id();
127 m_storage_pos.set(static_cast<osmium::unsigned_object_id_type>(
id), node.
location());
129 m_storage_neg.set(static_cast<osmium::unsigned_object_id_type>(-
id), node.
location());
138 return m_storage_pos.get_noexcept(static_cast<osmium::unsigned_object_id_type>(
id));
140 return m_storage_neg.get_noexcept(static_cast<osmium::unsigned_object_id_type>(-
id));
149 m_storage_pos.sort();
150 m_storage_neg.sort();
152 m_last_id = std::numeric_limits<osmium::unsigned_object_id_type>::max();
155 for (
auto& node_ref : way.
nodes()) {
157 if (!node_ref.location()) {
161 if (!m_ignore_errors && error) {
162 throw osmium::not_found{
"location for one or more nodes not found in node location index"};
172 m_storage_pos.clear();
173 m_storage_neg.clear();
182 #endif // OSMIUM_HANDLER_NODE_LOCATIONS_FOR_WAYS_HPP WayNodeList & nodes()
Definition: way.hpp:89
bool m_ignore_errors
Definition: node_locations_for_ways.hpp:85
void way(osmium::Way &way)
Definition: node_locations_for_ways.hpp:147
std::is_base_of< osmium::index::map::Map< osmium::unsigned_object_id_type, osmium::Location >, T > based_on_map
Definition: node_locations_for_ways.hpp:67
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
bool m_must_sort
Definition: node_locations_for_ways.hpp:87
void ignore_errors()
Definition: node_locations_for_ways.hpp:112
Definition: handler.hpp:71
~NodeLocationsForWays() noexcept=default
static dummy_type & get_dummy()
Definition: node_locations_for_ways.hpp:91
NodeLocationsForWays(TStoragePosIDs &storage_pos, TStorageNegIDs &storage_neg=get_dummy()) noexcept
Definition: node_locations_for_ways.hpp:98
Namespace for everything in the Osmium library.
Definition: assembler.hpp:53
osmium::unsigned_object_id_type m_last_id
Definition: node_locations_for_ways.hpp:83
TStoragePosIDs & m_storage_pos
Object that handles the actual storage of the node locations (with positive IDs). ...
Definition: node_locations_for_ways.hpp:78
int64_t object_id_type
Type for OSM object (node, way, or relation) IDs.
Definition: types.hpp:45
TStorageNegIDs index_neg_type
Definition: node_locations_for_ways.hpp:73
TStorageNegIDs & m_storage_neg
Object that handles the actual storage of the node locations (with negative IDs). ...
Definition: node_locations_for_ways.hpp:81
Definition: location.hpp:273
object_id_type id() const noexcept
Get ID of this object.
Definition: object.hpp:122
osmium::Location location() const noexcept
Definition: node.hpp:67
NodeLocationsForWays & operator=(const NodeLocationsForWays &)=delete
TStoragePosIDs index_pos_type
Definition: node_locations_for_ways.hpp:72
osmium::Location get_node_location(const osmium::object_id_type id) const
Definition: node_locations_for_ways.hpp:136
unsigned_object_id_type positive_id() const noexcept
Get absolute value of the ID of this object.
Definition: object.hpp:127
Definition: node_locations_for_ways.hpp:64
void node(const osmium::Node &node)
Definition: node_locations_for_ways.hpp:119
void clear()
Definition: node_locations_for_ways.hpp:171